def index(): if session.get("username", None): sql = "select name,birthdate,address,email,phone,freelance,profile_title,profile_content from personal where name=?" name = session["username"][0][0] datas = DB.query_sql(sql, (name, ), single_strip=True) datas = list(datas) datas[1] = int(datetime.now().year) - int(datas[1][0:4]) return render_template("/reception/profile/index-2.html", datas=datas) else: return redirect(url_for("user.user_login"))
def sellData(): """ 修改产品售卖数量信息 """ if request.method=='POST': rowid=request.form["product_id"] productName=request.form["product_name"] sellNumber=request.form["sell_number"] productCategory=request.form["product_category"] productProfit=request.form["product_price"] operator="system" operatorTime=datetime.today().strftime("%Y-%m-%d %H:%M:%S") sql3="insert into product_history(productName, productCategory, productSaleNumber, productProfit, operator, operatorTime) values (?,?,?,?,?,?)" DB.execute_sql(sql3,(productName, productCategory, int(sellNumber), productProfit, operator, operatorTime)) sql="select productSaleNumber from product_list where rowid=?" productSaleNumber=DB.query_sql(sql,(rowid,),single_strip=True) productSaleNumber=int(productSaleNumber[0])+int(sellNumber) sql2="update product_list set productSaleNumber=? where rowid=?;" DB.execute_sql(sql2,(productSaleNumber,rowid)) return redirect(url_for("sell.sellList"))
def submit_profile(): header_png=None if "header_png" in request.files: header_png=request.files["header_png"] if allowed_file(header_png.filename): img_path=datetime.now().strftime("%Y%m%d%H%M%f")+os.path.splitext(header_png.filename)[1] header_png.save(os.path.join(UPLOAD_FOLDER,img_path)) username=request.form["username"] birthdate=datetime(int(request.form['year']),int(request.form['month']),int(request.form['days'])).date() address=request.form.get('address') email=request.form.get('email') phone=request.form.get('phone') freelance=request.form.get('freelance') profile_title=request.form.get('profile-title') profile_content=request.form.get('profile-text') sql="update personal set name=?,birthdate=?,address=?,email=?,phone=?,freelance=?,profile_title=?,profile_content=? ,head_portrait=? where rowid=2;" DB.execute_sql(sql,(username,birthdate,address,email,phone,freelance,profile_title,profile_content,img_path)) return redirect(url_for("index"))
def update_profile(): sql="select head_portrait,name,birthdate,address,email,phone,freelance,profile_title,profile_content from personal where name=?;" username=session["username"][0][0] datas=DB.query_sql(sql,(username,),single_strip=True) return render_template("reception/profile/update_profile.html",datas=datas)
def index(): sql = """SELECT ROWID,productName,productCategory,productNumber,productStandard, productPrice,productSaleNumber,productProfit,inputTime from product_list;""" products = DB.query_sql(sql) products = sumDollars(products) return render_template("product_list.html", products=products)
def sellListHistory(): sql="select rowid,productName,productCategory,productSaleNumber,productProfit,operator,operatorTime from product_history order by operatorTime desc ;" datas=DB.query_sql(sql) return render_template("sell_list_history.html",datas=datas)
def sellInformation(id,number): sql="select productName,productCategory,productStandard,productProfit,rowid from product_list where rowid=?;" datas=DB.query_sql(sql,(id,),single_strip=True) datas=datas+(number,) return render_template("sell_product_information.html",datas=datas)
def sellList(): sql="""select rowid,productName,productStandard,productNumber,productSaleNumber, inputTime,productCategory from product_list where productNumber-productSaleNumber != 0;""" sells=DB.query_sql(sql) sells=in_stock_number(sells) return render_template("sell_list.html",sells=sells)