码迷,mamicode.com
首页 > 其他好文 > 详细

部分代码展示

时间:2020-05-23 11:24:49      阅读:38      评论:0      收藏:0      [点我收藏+]

标签:loop   删除   size   custom   init   none   登陆   ati   def   

(1)登陆选择

 1 class Choice(wx.Frame):
 2     def __init__(self, parent, id):
 3         wx.Frame.__init__(self, parent, id, title = "登录选择", pos = (700, 300), size =(400, 300))
 4         panel = wx.Panel(self)
 5         text = wx.StaticText(panel, label = "请选择登录的方式", pos = (140, 70))
 6         text.SetForegroundColour("Black")
 7         self.bt1 = wx.Button(panel, label = "管理员", pos = (105, 130))
 8         self.bt2 = wx.Button(panel, label = "普通用户", pos = (195, 130))
 9         self.bt1.Bind(wx.EVT_BUTTON, self.bt1_f)
10         self.bt2.Bind(wx.EVT_BUTTON, self.bt2_f)
11 
12     def bt1_f(self,event):
13         self.Destroy()
14         DBMmain()
15     def bt2_f(self, event):
16         self.Destroy()
17         Loginmain()
18 
19 if __name__ == "__main__":
20     app = wx.App()
21     frame = Choice(None, -1)
22     frame.Show()
23     frame.Centre()
24     app.MainLoop()

 

(2)OrderRoom

  1 class OrderRoom(wx.Frame):
  2     def __init__(self, parent, id):
  3         wx.Frame.__init__(self, parent, id, title = "OrderRoom", size =(1000, 750))
  4         panel = wx.Panel(self)
  5         wx.StaticText(panel, label = "客户ID", pos = (100,25))
  6         wx.StaticText(panel, label = "名字", pos = (100,75))
  7         wx.StaticText(panel, label = "电话", pos = (100,125))
  8         wx.StaticText(panel, label = "房间ID", pos = (100,175))
  9         wx.StaticText(panel, label = "酒店ID", pos = (100,225))
 10         wx.StaticText(panel, label = "日期", pos = (100,275))
 11 
 12         wx.StaticText(panel, label = "房间ID", pos = (200,400))
 13         wx.StaticText(panel, label = "酒店ID", pos = (250,400))
 14         wx.StaticText(panel, label = "类型", pos = (315,400))
 15         wx.StaticText(panel, label = "等级", pos = (375,400))
 16         wx.StaticText(panel, label = "价格", pos = (425,400))
 17         wx.StaticText(panel, label = "状态", pos = (485,400))
 18 
 19         self.Cus_ID =  wx.TextCtrl(panel, pos = (200, 25), size = (235, 25),style =  wx.TE_LEFT)
 20         self.name =  wx.TextCtrl(panel, pos = (200, 75), size = (235, 25),style =  wx.TE_LEFT)
 21         self.Tel =  wx.TextCtrl(panel, pos = (200,125), size = (235, 25),style =  wx.TE_LEFT)
 22         self.Room_ID =  wx.TextCtrl(panel, pos = (200,175), size = (235, 25),style =  wx.TE_LEFT)
 23         self.Hotle_ID =  wx.TextCtrl(panel, pos = (200,225), size = (235, 25),style =  wx.TE_LEFT)
 24         self.State =  wx.TextCtrl(panel, pos = (200,275), size = (235, 25),style =  wx.TE_LEFT)
 25 
 26         self.bt1 = wx.Button(panel, label = "查询空闲房间", pos = (200,360))
 27         self.bt2 = wx.Button(panel, label = "预定房间", pos = (300,360))
 28         self.bt3 = wx.Button(panel, label = "返回主界面", pos = (400,360))
 29         self.bt1.Bind(wx.EVT_BUTTON, self.bt1_f)
 30         self.bt2.Bind(wx.EVT_BUTTON, self.bt2_f)
 31         self.bt3.Bind(wx.EVT_BUTTON, self.bt3_f)
 32 
 33         self.Text = wx.TextCtrl(panel, pos = (200,425), size = (550, 250),style =  wx.TE_MULTILINE)
 34 
 35     def bt1_f(self, event):
 36         con = sqlite3.connect(path)
 37         cur = con.cursor()
 38         cur.execute("SELECT * FROM Room WHERE 状态 = ?", ("空闲",))
 39         inf = cur.fetchall() 
 40         string = ""
 41         for i in inf:
 42             string = string+i[0] + "\t" + i[1] + "\t" + i[2] +"\t"+i[3]+"\t"+i[4]+"\t"+i[5]+"\t\n"
 43         self.Text.SetValue(string)
 44         cur.close()
 45         con.close()
 46 
 47     def bt2_f(self, event):
 48         con = sqlite3.connect(path)
 49         cur = con.cursor()
 50         Cus_ID = self.Cus_ID.GetValue()
 51         name = self.name.GetValue()
 52         Tel = self.Tel.GetValue()
 53         Room_ID = self.Room_ID.GetValue()
 54         Hotle_ID = self.Hotle_ID.GetValue()
 55         State = self.State.GetValue()
 56         if Cus_ID == "" or name == "" or Tel == "" or Room_ID == "" or Hotle_ID == "":
 57             message = "输入信息不全" + "\n"
 58             wx.MessageBox(message)
 59         else:
 60             cur.execute("SELECT * FROM Customer WHERE 客户ID = ?",(Cus_ID,))
 61             inf = cur.fetchall()
 62             cur.execute("SELECT * FROM Room WHERE (状态, 房间ID, 酒店ID) = (?, ? ,?)", ("空闲", Room_ID, Hotle_ID))
 63             inf2 = cur.fetchall()
 64             cur.execute("SELECT 住房订单ID FROM Order")
 65             inf3 = cur.fetchall()
 66             Sum = 0
 67             for i in inf3:
 68                 Sum = Sum+1
 69             Sum = Sum+1
 70             Sum = str(Sum) #sum为订单号
 71             if len(Sum) == 1:
 72                 Sum = "ho00"+Sum
 73             elif len(Sum) == 2:
 74                 Sum = "ho0" + Sum
 75             elif len(Sum) == 3:
 76                 Sum = "ho" + Sum
 77             
 78             if len(inf2) != 0:
 79                 if len(inf) == 0:
 80                     cur.execute("INSERT INTO CUSTOMER(客户ID, 名字, 电话) VALUES(?, ?, ?)", (Cus_ID, name, Tel))
 81                 cur.execute("INSERT INTO Order(住房订单ID, 房间ID, 酒店ID, 客户ID, 日期, 总消费) VALUES(?, ?, ?, ?, ?, ?)", (Sum, Room_ID, Hotle_ID, Cus_ID, State, random.randint(1000, 10000)))
 82                 cur.execute("UPDATE Room SET 状态 = ? WHERE (房间ID, 酒店ID) = (?, ?)", ("已满", Room_ID, Hotle_ID))
 83                 con.commit()
 84                 message = "预定成功"
 85                 wx.MessageBox(message)
 86             elif len(inf2) == 0:
 87                 message = "输入信息有误"
 88                 wx.MessageBox(message)
 89         cur.close()
 90         con.close()
 91     def bt3_f(self, event):
 92         self.Destroy()
 93 
 94 def orderRoom():
 95     app = wx.App()
 96     frame = OrderRoom(None, -1)
 97     frame.Centre()
 98     frame.Show()
 99     app.MainLoop()
100 
101 if __name__ == "__main__":
102     orderRoom()

(3)HousingOrder

  1 class Function(wx.Frame):
  2     def __init__(self, parent, id):
  3         wx.Frame.__init__(self, parent, id, title = "Order", size =(1000, 750))
  4         panel = wx.Panel(self)
  5         wx.StaticText(panel, label = "*住房订单ID", pos = (100,40))
  6         wx.StaticText(panel, label = "日期", pos = (100,90))
  7         wx.StaticText(panel, label = "房间ID", pos = (100,140))
  8         wx.StaticText(panel, label = "酒店ID", pos = (100,190))
  9         wx.StaticText(panel, label = "客户ID", pos = (100,240))
 10         wx.StaticText(panel, label = "总消费", pos = (100,290))
 11 
 12         wx.StaticText(panel, label = "*住房订单ID", pos = (200,375))
 13         wx.StaticText(panel, label = "房间ID", pos = (315,375))
 14         wx.StaticText(panel, label = "酒店ID", pos = (370,375))
 15         wx.StaticText(panel, label = "客户ID", pos = (430,375))
 16         wx.StaticText(panel, label = "日期", pos = (500,375))
 17         wx.StaticText(panel, label = "总消费", pos = (590,375))
 18 
 19         self.Ord_ID =  wx.TextCtrl(panel, pos = (200, 40), size = (235, 25),style =  wx.TE_LEFT)
 20         self.Ord_date =  wx.TextCtrl(panel, pos = (200, 90), size = (235, 25),style =  wx.TE_LEFT)
 21         self.Ord_roomID =  wx.TextCtrl(panel, pos = (200,140), size = (235, 25),style =  wx.TE_LEFT)
 22         self.Ord_hotelID = wx.TextCtrl(panel, pos = (200,190), size = (235, 25),style =  wx.TE_LEFT)
 23         self.Ord_customerID =  wx.TextCtrl(panel, pos = (200,240), size = (235, 25),style =  wx.TE_LEFT)
 24         self.Ord_consume =  wx.TextCtrl(panel, pos = (200,290), size = (235, 25),style =  wx.TE_LEFT)
 25         self.bt1 = wx.Button(panel, label = "查询所有信息", pos = (200,325))
 26         self.bt2 = wx.Button(panel, label = "查询", pos = (300,325))
 27         self.bt3 = wx.Button(panel, label = "录入", pos = (400,325))
 28         self.bt4 = wx.Button(panel, label = "删除", pos = (500,325))
 29         self.bt5 = wx.Button(panel, label = "修改", pos = (600,325))
 30         self.bt1.Bind(wx.EVT_BUTTON, self.bt1_f)
 31         self.bt2.Bind(wx.EVT_BUTTON, self.bt2_f)
 32         self.bt3.Bind(wx.EVT_BUTTON, self.bt3_f)
 33         self.bt4.Bind(wx.EVT_BUTTON, self.bt4_f)
 34         self.bt5.Bind(wx.EVT_BUTTON, self.bt5_f)
 35         self.Text = wx.TextCtrl(panel, pos = (200,400), size = (550, 250),style =  wx.TE_MULTILINE)
 36 
 37     def bt1_f(self, event):
 38         con = sqlite3.connect(path)
 39         cur = con.cursor()
 40         cur.execute("SELECT * FROM HOrder")
 41         inf = cur.fetchall() 
 42         string = ""
 43         for i in inf:
 44             string = string+ i[0] +"\t" + i[1] +"\t"+ i[2] +"\t" +i[3]+"\t"+i[4]+"\t"+str(i[5])+"\t\n"
 45         self.Text.SetValue(string)
 46         cur.close()
 47 
 48     def bt2_f(self, event):
 49         con = sqlite3.connect(path)
 50         cur = con.cursor()
 51         ID = self.Ord_ID.GetValue()
 52         Date = self.Ord_date.GetValue()
 53         RoomID = self.Ord_roomID.GetValue()
 54         HotelID = self.Ord_hotelID.GetValue()
 55         CustomerID = self.Ord_customerID.GetValue()
 56         Consume = self.Ord_consume.GetValue()
 57         if ID == "":
 58             message = "请输入包间订单ID"
 59             wx.MessageBox(message)
 60         else:
 61             cur.execute("SELECT * FROM HOrder WHERE 住房订单ID = ?",(ID,))
 62             inf = cur.fetchall()
 63             if inf == []:
 64                 message = "信息不存在"
 65                 wx.MessageBox(message)
 66             else :
 67                 string = ""
 68                 string =inf[0][0] +"\t"+ inf[0][1] +"\t"+ inf[0][2] +"\t" +inf[0][3] +"\t"+inf[0][4]+"\t"+str(inf[0][5])+"\t"
 69                 self.Text.SetValue(string)
 70         cur.close()
 71 
 72     def bt3_f(self, event):
 73         con = sqlite3.connect(path)
 74         cur = con.cursor()
 75         ID = self.Ord_ID.GetValue()
 76         Date = self.Ord_date.GetValue()
 77         RoomID = self.Ord_roomID.GetValue()
 78         HotelID = self.Ord_hotelID.GetValue()
 79         CustomerID = self.Ord_customerID.GetValue()
 80         Consume = self.Ord_consume.GetValue()
 81         if ID == "" or Date == "" or RoomID == "" or CustomerID == "" or Consume == "" or HotelID == "":
 82             message = "信息不完整"
 83             wx.MessageBox(message)
 84         else:
 85             message = "信息录入成功"
 86             cur.execute("INSERT INTO HOrder(住房订单ID,房间ID,酒店ID,客户ID,日期,总消费) VALUES(?,?,?,?,?,?)",(ID,RoomID,HotelID,CustomerID,Date,int(Consume)))
 87             wx.MessageBox(message)
 88         con.commit()
 89         cur.close()
 90 
 91     def bt4_f(self, event):
 92         con = sqlite3.connect(path)
 93         cur = con.cursor()
 94         ID = self.Ord_ID.GetValue()
 95         Date = self.Ord_date.GetValue()
 96         RoomID = self.Ord_roomID.GetValue()
 97         HotelID = self.Ord_hotelID.GetValue()
 98         CustomerID = self.Ord_customerID.GetValue()
 99         Consume = self.Ord_consume.GetValue()
100         if ID == "":
101             message = "所需删除的数据不明确"
102             wx.MessageBox(message)
103         else:
104             cur.execute("SELECT * FROM HOrder WHERE 住房订单ID = ?",(ID,))
105             inf = cur.fetchall()
106             if inf == []:
107                 message = "信息不存在"
108                 wx.MessageBox(message)
109             else:
110                 message = "信息删除成功"
111                 cur.execute("DELETE FROM HOrder WHERE 住房订单ID = ?",(ID,))
112                 wx.MessageBox(message)
113             con.commit()
114         cur.close()
115 
116     def bt5_f(self, event):
117         con = sqlite3.connect(path)
118         cur = con.cursor()
119         ID = self.Ord_ID.GetValue()
120         Date = self.Ord_date.GetValue()
121         RoomID = self.Ord_roomID.GetValue()
122         HotelID = self.Ord_hotelID.GetValue()
123         CustomerID = self.Ord_customerID.GetValue()
124         Consume = self.Ord_consume.GetValue()
125         if ID == "":
126             message = "所需更改的数据不明确"
127             wx.MessageBox(message)
128         else:
129             cur.execute("SELECT * FROM HOrder WHERE 住房订单ID = ?",(ID,))
130             inf = cur.fetchall()
131             if inf == []:
132                 message = "信息不存在"
133                 wx.MessageBox(message)
134             else:
135                 message = "请输入需要修改的信息"
136                 if Date != "":
137                     message = "信息修改成功"
138                     cur.execute("UPDATE HOrder SET 日期 = ? WHERE 住房订单ID = ?",(Date,ID))
139                 if RoomID != "":
140                     message = "信息修改成功"
141                     cur.execute("UPDATE HOrder SET 房间ID = ? WHERE 住房订单ID = ?",(RoomID,ID))
142                 if CustomerID != "":
143                     message = "信息修改成功"
144                     cur.execute("UPDATE HOrder SET 客户ID = ? WHERE 住房订单ID = ?",(CustomerID,ID))
145                 if Consume != "":
146                     message = "信息修改成功"
147                     cur.execute("UPDATE HOrder SET 总消费 = ? WHERE 住房订单ID = ?",(int(Consume),ID))
148                 if HotelID != "":
149                     message = "信息修改成功"
150                     cur.execute("UPDATE HOrder SET 酒店ID = ? WHERE 住房订单ID = ?",(HotelID,ID))
151                 wx.MessageBox(message)
152             con.commit()
153         cur.close()

 

部分代码展示

标签:loop   删除   size   custom   init   none   登陆   ati   def   

原文地址:https://www.cnblogs.com/AdolfHitler/p/12941522.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!