1、python实现外卖信息管理系统python实现外卖信息管理系统本文为大家分享了python实现外卖信息管理系统的具体代码,供大家参考,具体内容如下一、需求分析需求分析包含如下:1、问题描述以外卖信息系统管理员身份登陆该系统,实现对店铺信息、派送员信息、客服人员信息、订单信息、配送信息等进行有条件查询以及信息的录入、修改、删除等功能。2、系统功能描述(1)信息录入:使用wxpython设计排版编写窗口界面,给出录入信息的接口,通过python语句实现与数据库的连接,从而向数据库中插入相应数据。(2)信息修改:使用wxpython设计排版编写窗口界面,给出修改信息的接口,通过python语句实现
2、与数据库的连接,从而修改数据库中相应数据。(3)信息查询:在窗口界面中,通过响应的按钮触发,实现与数据库的连接查询,得到所有在线店铺信息。(4)数据统计:在数据库中编写相应的存储过程,输入店铺名称即可select其所管理的派送员和客服人员。3、登录界面:源码:# coding:utf8# Python code generated with wxFormBuilder (version Jun 17 2015)# http:/www.wxformbuilder.org/# PLEASE DO NOT EDIT THIS FILE!#import wx #导入wxpyhton,pyhton自带的
3、GUI库#import wx.xrcimport pymysql #用于操作数据库import sysreload(sys)sys.setdefaultencoding(utf8)# Class MyFrame1#建一个窗口类MyFrame1继承wx.Frameclass MyFrame1(wx.Frame): def _init_(self, parent): #Wx.Frame (parent, id, title, pos, size, style, name) wx.Frame._init_(self, parent, id=wx.ID_ANY, title=u外卖信息管理系统, po
4、s=wx.DefaultPosition, size=wx.Size(610, 400), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.Center() #居中显示 # 小构件,如按钮,文本框等被放置在面板窗口。 wx.Panel类通常是被放在一个wxFrame对象中。这个类也继承自wxWindow类。 self.m_panel1 = wx.Panel(self) # 标签,一行或多行的只读文本,Wx.StaticText(parent, id, label, position, size, style) self.m_stati
5、cText1 = wx.StaticText(self.m_panel1, wx.ID_ANY, u关于店铺:, (20, 20) self.m_button1 = wx.Button(self.m_panel1, wx.ID_ANY, u店铺信息, (130, 20), wx.DefaultSize, style=wx.BORDER_MASK) self.m_button2 = wx.Button(self.m_panel1, wx.ID_ANY, u店铺上架, (250, 20), wx.DefaultSize, style=wx.BORDER_MASK) self.m_button3 =
6、 wx.Button(self.m_panel1, wx.ID_ANY, u店铺下架, (370, 20), wx.DefaultSize, style=wx.BORDER_MASK) self.m_staticText2 = wx.StaticText(self.m_panel1, wx.ID_ANY, u关于派送员:, (20, 90) self.m_button4 = wx.Button(self.m_panel1, wx.ID_ANY, u派送员信息, (130, 90), wx.DefaultSize, style=wx.BORDER_MASK) self.m_button5 = w
7、x.Button(self.m_panel1, wx.ID_ANY, u聘请派送员, (250, 90), wx.DefaultSize, style=wx.BORDER_MASK) self.m_button6 = wx.Button(self.m_panel1, wx.ID_ANY, u解雇派送员, (370, 90), wx.DefaultSize, style=wx.BORDER_MASK) self.m_staticText3 = wx.StaticText(self.m_panel1, wx.ID_ANY, u关于客服人员:, (20, 160) self.m_button7 =
8、wx.Button(self.m_panel1, wx.ID_ANY, u客服人员信息, (130, 160), wx.DefaultSize, style=wx.BORDER_MASK) self.m_button8 = wx.Button(self.m_panel1, wx.ID_ANY, u聘请客服人员, (250, 160), wx.DefaultSize, style=wx.BORDER_MASK) self.m_button9 = wx.Button(self.m_panel1, wx.ID_ANY, u解雇客服人员, (370, 160), wx.DefaultSize, sty
9、le=wx.BORDER_MASK) self.m_staticText4 = wx.StaticText(self.m_panel1, wx.ID_ANY, u关于订单:, (20, 230) self.m_button10 = wx.Button(self.m_panel1, wx.ID_ANY, u订单信息, (130, 230), wx.DefaultSize, style=wx.BORDER_MASK) self.m_button11 = wx.Button(self.m_panel1, wx.ID_ANY, u学生订餐, (250, 230), wx.DefaultSize, st
10、yle=wx.BORDER_MASK) self.m_button12 = wx.Button(self.m_panel1, wx.ID_ANY, u取消订单, (370, 230), wx.DefaultSize, style=wx.BORDER_MASK) self.m_button13 = wx.Button(self.m_panel1, wx.ID_ANY, u修改订单, (490, 230), wx.DefaultSize, style=wx.BORDER_MASK) self.m_staticText5 = wx.StaticText(self.m_panel1, wx.ID_AN
11、Y, u关于物流:, (20, 300) self.m_button14 = wx.Button(self.m_panel1, wx.ID_ANY, u配送信息, (130, 300), wx.DefaultSize, style=wx.BORDER_MASK) self.m_button15 = wx.Button(self.m_panel1, wx.ID_ANY, u安排配送, (250, 300), wx.DefaultSize, style=wx.BORDER_MASK) self.m_button16 = wx.Button(self.m_panel1, wx.ID_ANY, u取消
12、配送, (370, 300), wx.DefaultSize, style=wx.BORDER_MASK) #按钮绑定对话框的弹出 #在创建应用程序时,Bind函数可以将按钮的动作与特定的函数绑定,当按钮上有动作时,这个函数就会启动,从而处理响应的事件。 #个Button被单击发生了EVT_BUTTON事件 self.m_button1.Bind(wx.EVT_BUTTON, MyDialog11(None).OnClick) self.m_button2.Bind(wx.EVT_BUTTON, MyDialog12(None).OnClick) self.m_button3.Bind(wx.
13、EVT_BUTTON, MyDialog13(None).OnClick) self.m_button4.Bind(wx.EVT_BUTTON, MyDialog21(None).OnClick) self.m_button5.Bind(wx.EVT_BUTTON, MyDialog22(None).OnClick) self.m_button6.Bind(wx.EVT_BUTTON, MyDialog23(None).OnClick) self.m_button7.Bind(wx.EVT_BUTTON, MyDialog31(None).OnClick) self.m_button8.Bin
14、d(wx.EVT_BUTTON, MyDialog32(None).OnClick) self.m_button9.Bind(wx.EVT_BUTTON, MyDialog33(None).OnClick) self.m_button10.Bind(wx.EVT_BUTTON, MyDialog41(None).OnClick) self.m_button11.Bind(wx.EVT_BUTTON, MyDialog42(None).OnClick) self.m_button12.Bind(wx.EVT_BUTTON, MyDialog43(None).OnClick) self.m_but
15、ton13.Bind(wx.EVT_BUTTON, MyDialog44(None).OnClick) self.m_button14.Bind(wx.EVT_BUTTON, MyDialog51(None).OnClick) self.m_button15.Bind(wx.EVT_BUTTON, MyDialog52(None).OnClick) self.m_button16.Bind(wx.EVT_BUTTON, MyDialog53(None).OnClick) #设置按钮的背景颜色 self.m_button1.SetBackgroundColour(#0a74f7) self.m_
16、button1.SetForegroundColour(white) self.m_button2.SetBackgroundColour(#0a74f7) self.m_button2.SetForegroundColour(white) self.m_button3.SetBackgroundColour(#0a74f7) self.m_button3.SetForegroundColour(white) self.m_button4.SetBackgroundColour(#238E23) self.m_button4.SetForegroundColour(white) self.m_
17、button5.SetBackgroundColour(#238E23) self.m_button5.SetForegroundColour(white) self.m_button6.SetBackgroundColour(#238E23) self.m_button6.SetForegroundColour(white) self.m_button7.SetBackgroundColour(#6F4242) self.m_button7.SetForegroundColour(white) self.m_button8.SetBackgroundColour(#6F4242) self.
18、m_button8.SetForegroundColour(white) self.m_button9.SetBackgroundColour(#6F4242) self.m_button9.SetForegroundColour(white) self.m_button10.SetBackgroundColour(#8E6B23) self.m_button10.SetForegroundColour(white) self.m_button11.SetBackgroundColour(#8E6B23) self.m_button11.SetForegroundColour(white) s
19、elf.m_button12.SetBackgroundColour(#8E6B23) self.m_button12.SetForegroundColour(white) self.m_button13.SetBackgroundColour(#8E6B23) self.m_button13.SetForegroundColour(white) self.m_button14.SetBackgroundColour(#545454) self.m_button14.SetForegroundColour(white) self.m_button15.SetBackgroundColour(#
20、545454) self.m_button15.SetForegroundColour(white) self.m_button16.SetBackgroundColour(#545454) self.m_button16.SetForegroundColour(white) self.m_panel1.SetBackgroundColour(white) #设置面板的背景颜色# Class MyDialog11#一个对话框的类继承wx.Dialogclass MyDialog11(wx.Dialog): def _init_(self, parent): wx.Dialog._init_(s
21、elf, parent, id=wx.ID_ANY, title=u店铺信息, pos=wx.DefaultPosition, size=wx.Size(302, 362), style=wx.DEFAULT_DIALOG_STYLE) self.Center() self.panel = wx.Panel(self) self.panel.SetBackgroundColour(white) wx.StaticText(self.panel, -1, 店铺名称, (20, 20) wx.StaticText(self.panel, -1, 月销量, (80, 20) def OnClick(
22、self, event): conn = pymysql.connect(host=127.0.0.1, port=3306, user=root, passwd=123, db=project, charset=utf8) cursor = conn.cursor() try: sql = select * from foodshop cursor.execute(sql) rs = cursor.fetchall() h = 30 for row in rs: h = h + 20 shop_name = row0 salenum = row1 #注意数据库中的数据为数字 int 类型时的
23、读取方式 id = %d % i0 wx.StaticText(self.panel, -1, shop_name, (20, h) wx.StaticText(self.panel, -1, salenum, (80, h) except: conn.rollback() finally: cursor.close() conn.close() self.ShowModal()# Class MyDialog12#class MyDialog12(wx.Dialog): def _init_(self, parent): wx.Dialog._init_(self, parent, id=w
24、x.ID_ANY, title=u店铺上架, pos=wx.DefaultPosition, size=wx.Size(302, 250), style=wx.DEFAULT_DIALOG_STYLE) self.Center() self.panel = wx.Panel(self) self.panel.SetBackgroundColour(white) wx.StaticText(self.panel, -1, 请输入店铺名称:, (20, 20) # 可编辑文本框的创建使用wx.TextCtrl,默认情况下,文本框只能编辑一行文字(无论文字多长均不换行) self.t1 = wx.T
25、extCtrl(self.panel, pos=(130, 20), size=(120, 25) wx.StaticText(self.panel, -1, 请输入月销量:, (20, 80) self.t2 = wx.TextCtrl(self.panel, pos=(130, 80), size=(120, 25) def OnClick(self, e): dialog12 = MyDialog12(None) btn = wx.Button(parent=dialog12.panel, label=上架, pos=(20, 150), size=(100, 45), style=wx
26、.BORDER_MASK) btn.Bind(wx.EVT_BUTTON, dialog12.insert) dialog12.ShowModal() def insert(self, event): conn = pymysql.connect(host=127.0.0.1, port=3306, user=root, passwd=123, db=project, charset=utf8) cursor = conn.cursor() shop_name = self.t1.GetValue().encode(utf8) #注意GetValue()获取的是unicode编码, salen
27、um = self.t2.GetValue().encode(utf8) #你使用的#coding=utf8,那就对获取的数据.encode(utf8)重新编码 data = (shop_name, salenum) try: sql = insert into foodshop values (%s,%s) cursor.execute(sql, data) mit() #提交给后台数据库 dial = wx.MessageDialog(None, 成功上架!, 结果, wx.YES_NO) # 创建一个带按钮的消息框, 语法是(self, 框中内容, 框标题, ID) dial.ShowM
28、odal() # 显示对话框 except: conn.rollback() finally: cursor.close() conn.close()# Class MyDialog13#class MyDialog13(wx.Dialog): def _init_(self, parent): wx.Dialog._init_(self, parent, id=wx.ID_ANY, title=u店铺下架, pos=wx.DefaultPosition, size=wx.Size(200, 200), style=wx.DEFAULT_DIALOG_STYLE) self.Center() self.panel = wx.Panel(self) self.panel.SetBackgroundColour(white) wx.StaticText(self.panel, -1, 店铺名称:, (20, 20) self.t1 = wx.TextCtrl(self.panel, pos=(20, 50), size=(120, 25) de
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1