You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
207 lines
8.3 KiB
207 lines
8.3 KiB
from flask import Flask,render_template,request,redirect
|
|
import pymysql
|
|
from mysql操作 import *
|
|
app = Flask(__name__)
|
|
|
|
@app.route('/')
|
|
def login():
|
|
|
|
return (render_template('login.html'))
|
|
|
|
@app.route('/daohang1',methods=['GET','POST'])
|
|
def daohang1():
|
|
|
|
UserID=request.form['UserID']
|
|
password = request.form['password']
|
|
if (UserID=='adminer' and password=="123456"):
|
|
return (render_template('导航条.html'))
|
|
if (UserID=='nudt2020' and password=="654321"):
|
|
return (render_template('导航条1.html'))
|
|
else:
|
|
return ('密码错误')
|
|
|
|
|
|
@app.route('/没有权限')
|
|
def meiyouquanxian():
|
|
|
|
return (render_template('没有权限.html'))
|
|
|
|
@app.route('/daohang')
|
|
def daohang():
|
|
|
|
return (render_template('导航条.html'))
|
|
|
|
@app.route('/查询剩余物资')
|
|
def chaxunshengyuwuzi():
|
|
supplies = select('select * from supplies')
|
|
return render_template('查询剩余物资.html',supplies=supplies)
|
|
|
|
@app.route('/查询')
|
|
def chaxun():
|
|
|
|
return (render_template('查询.html'))
|
|
|
|
@app.route('/查询捐赠情况')
|
|
def chaxunjuanzeng():
|
|
donations = select('select * from donations')
|
|
|
|
return (render_template("查询捐赠情况.html", donations = donations))
|
|
|
|
@app.route('/查询分配情况')
|
|
def chaxunfenpei():
|
|
distributions = select('select * from distributions')
|
|
|
|
return (render_template("查询分配情况.html", distributions=distributions))
|
|
|
|
@app.route('/管理')
|
|
def guanli():
|
|
|
|
return (render_template('管理.html'))
|
|
|
|
|
|
@app.route('/管理捐赠情况')
|
|
def guanlijuanzeng():
|
|
donations = select('select * from donations')
|
|
return (render_template('管理捐赠情况.html',donations=donations))
|
|
|
|
@app.route('/删除捐赠记录',methods=['GET'])
|
|
def shanchujuanzeng():
|
|
id= request.args.get("id")
|
|
#展示语句是否正确的
|
|
#print('delete from donations where 捐赠编号={};'.format(id))
|
|
delete('delete from donations where 捐赠编号={};'.format(id))
|
|
return redirect('/管理捐赠情况')
|
|
|
|
@app.route("/修改捐赠记录",methods=['GET','POST'])
|
|
def xiugaijuanzeng():
|
|
if request.method == 'GET':
|
|
id = request.args.get("id")
|
|
donation = select('select * from donations where 捐赠编号={}'.format(id))[0]
|
|
return render_template("修改捐赠记录.html",donation = donation)
|
|
else:
|
|
#接收参数,修改数据
|
|
id = request.form["id"]
|
|
时间 = request.form['捐赠时间']
|
|
捐赠方单位 = request.form['捐赠方单位']
|
|
物资名称 = request.form['物资名称']
|
|
物资类别 = request.form['物资类别']
|
|
数量 = request.form['数量']
|
|
单位 = request.form['单位']
|
|
价值 = request.form['价值']
|
|
|
|
#print('update donations set 时间=STR_TO_DATE("{}","%Y-%m-%d") ,捐赠方单位="{}" ,物资名称="{}" ,类别="{}" ,数量={} ,计量单位="{}" ,价值={} where 捐赠编号={}'.format(时间,捐赠方单位,物资名称,物资类别,数量,单位,价值,id))
|
|
|
|
alter('update donations set 时间=STR_TO_DATE("{}","%Y-%m-%d") ,捐赠方单位="{}" ,物资名称="{}" ,类别="{}" ,数量={} ,计量单位="{}" ,价值={} where 捐赠编号={}'.format(时间,捐赠方单位,物资名称,物资类别,数量,单位,价值,id))
|
|
return redirect('/管理捐赠情况')
|
|
|
|
@app.route('/insert_page捐赠记录')
|
|
def insert_page1():
|
|
return render_template('insert_page捐赠记录.html')
|
|
|
|
@app.route('/添加捐赠记录',methods=['GET','POST'])
|
|
def tianjiajuanzeng():
|
|
#进行添加操作
|
|
时间 = request.form['捐赠时间']
|
|
捐赠方单位 = request.form['捐赠方单位']
|
|
物资名称 = request.form['物资名称']
|
|
物资类别 = request.form['物资类别']
|
|
数量 = request.form['数量']
|
|
单位 = request.form['单位']
|
|
价值 = request.form['价值']
|
|
insert('insert into donations (时间,捐赠方单位,物资名称,类别,数量,计量单位,价值) values(STR_TO_DATE("{}","%Y-%m-%d") ,"{}" ,"{}" ,"{}" ,{} ,"{}" ,{} );'.format(时间,捐赠方单位,物资名称,物资类别,数量,单位,价值))
|
|
return redirect('管理捐赠情况')
|
|
|
|
#/*----------------------------------------------------------------------------------------*/
|
|
|
|
@app.route('/管理分配情况')
|
|
def guanlifenpei():
|
|
distributions = select("select * from distributions")
|
|
return (render_template('管理分配情况.html',distributions=distributions))
|
|
|
|
@app.route('/删除分配记录',methods=['GET'])
|
|
def shanchufenpei():
|
|
id= request.args.get("id")
|
|
#展示语句是否正确的
|
|
print('delete from distributions where 发放编号={};'.format(id))
|
|
delete('delete from distributions where 发放编号={};'.format(id))
|
|
return redirect('/管理分配情况')
|
|
|
|
@app.route("/修改分配记录",methods=['GET','POST'])
|
|
def xiugaifenpei():
|
|
if request.method == 'GET':
|
|
id = request.args.get("id")
|
|
distribution = select('select * from distributions where 发放编号={}'.format(id))[0]
|
|
return render_template("修改分配记录.html",distribution = distribution)
|
|
else:
|
|
#接收参数,修改数据
|
|
id = request.form["id"]
|
|
时间 = request.form['发放时间']
|
|
物资名称 = request.form['物资名称']
|
|
物资类别 = request.form['物资类别']
|
|
数量 = request.form['数量']
|
|
单位 = request.form['单位']
|
|
价值 = request.form['价值']
|
|
接收方单位 = request.form['接收方单位']
|
|
发放用途= request.form['发放用途']
|
|
|
|
#print('update donations set 时间=STR_TO_DATE("{}","%Y-%m-%d") ,捐赠方单位="{}" ,物资名称="{}" ,类别="{}" ,数量={} ,计量单位="{}" ,价值={} where 捐赠编号={}'.format(时间,捐赠方单位,物资名称,物资类别,数量,单位,价值,id))
|
|
|
|
alter('update distributions set 时间=STR_TO_DATE("{}","%Y-%m-%d") ,物资名称="{}" ,类别="{}" ,数量={} ,计量单位="{}" ,价值={} ,接收方单位="{}",发放用途="{}" where 发放编号={}'.format(时间,物资名称,物资类别,数量,单位,价值, 接收方单位,发放用途,id))
|
|
return redirect('/管理分配情况')
|
|
|
|
@app.route('/insert_page分配记录')
|
|
def insert_page2():
|
|
return render_template('insert_page分配记录.html')
|
|
|
|
@app.route('/添加分配记录',methods=['GET','POST'])
|
|
def tianjiafenpei():
|
|
#进行添加操作
|
|
时间 = request.form['发放时间']
|
|
物资名称 = request.form['物资名称']
|
|
物资类别 = request.form['物资类别']
|
|
数量 = request.form['数量']
|
|
单位 = request.form['单位']
|
|
价值 = request.form['价值']
|
|
接收方单位 = request.form['接收方单位']
|
|
发放用途 = request.form['发放用途']
|
|
|
|
insert('insert into distributions (时间,物资名称,类别,数量,计量单位,价值,接收方单位,发放用途) values(STR_TO_DATE("{}","%Y-%m-%d") ,"{}" ,"{}" ,{} ,"{}" ,{} ,"{}" ,"{}" );'.format(时间,物资名称,物资类别,数量,单位,价值,接收方单位,发放用途))
|
|
return redirect('管理分配情况')
|
|
|
|
|
|
#/*----------------------------------------------------------------------------------------*/
|
|
|
|
@app.route('/名字查询')
|
|
def mingzichaxun():
|
|
|
|
return render_template('名字查询.html')
|
|
@app.route('/名字查询捐赠记录',methods=['GET','POST'])
|
|
def mingzichaxunjuanzeng():
|
|
donations = select('select * from donations')
|
|
return render_template('名字查询捐赠记录.html', donations=donations)
|
|
|
|
|
|
@app.route('/名字查询捐赠记录1',methods=['GET','POST'])
|
|
def mingzichaxunjuanzeng1():
|
|
名字 = request.form['名字']
|
|
donations = select('select * from donations where 捐赠方单位="{}"'.format(名字))
|
|
return render_template('名字查询捐赠记录.html',donations=donations)
|
|
|
|
@app.route('/名字查询受赠记录',methods=['GET','POST'])
|
|
def mingzichaxunshouzeng():
|
|
distributions = select('select * from distributions')
|
|
return render_template('名字查询受赠记录.html',distributions=distributions)
|
|
|
|
|
|
@app.route('/名字查询受赠记录1',methods=['GET','POST'])
|
|
def mingzichaxunshouzeng1():
|
|
名字 = request.form['名字']
|
|
distributions = select('select * from distributions where 接收方单位="{}"'.format(名字))
|
|
return render_template('名字查询受赠记录.html', distributions=distributions)
|
|
@app.route('/功能暂未开放')
|
|
def zanweikaifang():
|
|
|
|
return render_template('功能暂未开放.html')
|
|
if __name__ == '__main__':
|
|
app.run()
|