def allpro(self): alx = Sql3() alo = alx.s_sql("select pro_name from allpro") box_menu = [] box_menu.append("請選擇") for aoa in alo: box_menu.append(aoa[0]) alx.del_con() return box_menu
def download_excel(self): er_box = self.stainput.get() er_word = self.box2.get() er_px = Sql3() er_pri = er_px.s_sql("select price from products where p_name='%s'" % (er_word)) for er in er_pri: er_price = er[0] ax = Y_sea(er_box, s_Help.Conver_ya(er_word), int(er_price)) ax.ssprint() er_px.del_con()
def del_p_info(self): dx = Sql3() del_name = self.delinput.get() d_mess = dx.d_sql("DELETE FROM products WHERE p_name=?", s_Help.check_str(del_name)) dx.del_con() if d_mess == True: self.delinput.delete(0, END) messagebox.showinfo("alert", "刪除成功") else: messagebox.showinfo("warning", "刪除錯誤")
def up_p_info(self): ux = Sql3() upn_name = self.uppninput.get() up_name = self.uppninput2.get() up_price = self.uppriinput.get() lock_p = self.lockpninput.get() ux.u_sql( "UPDATE products SET pn_name=?,price=?,p_name=? where p_name=?", s_Help.check_str(upn_name), s_Help.check_str(up_price), s_Help.check_str(up_name), s_Help.check_str(lock_p)) ux.del_con()
def change_box2(self): lock_name = self.lockpninput.get() lox = Sql3() clox = lox.s_sql( "select pn_name,p_name,price from products where p_name='%s'" % (s_Help.check_str(lock_name))) for cloa in clox: try: self.uppninput.insert(0, cloa[0]) self.uppninput2.insert(0, cloa[1]) self.uppriinput.insert(0, cloa[2]) except: messagebox.showinfo("warning", "未輸入空白") lox.del_con()
def justamethod(self): box2_menu = [] mes_box = self.box.get() mes_box = s_Help.check_str(mes_box) cbx = Sql3() coi = cbx.s_sql("select id from allpro where pro_name = '%s'" % (s_Help.check_str(mes_box))) for coq in coi: xcoi = coq[0] cbo = cbx.s_sql("select p_name from products where pn_name = '%s'" % (s_Help.check_str(str(xcoi)))) box2_menu.append("請選擇") for coa in cbo: box2_menu.append(coa[0]) cbx.del_con() self.box2['values'] = box2_menu
def add_p_info(self): x = Sql3() pn_name = self.pninput.get() p_name = self.pninput2.get() p_price = self.priinput.get() #print("INSERT INTO products (pn_name,p_name) VALUES(%s,%s);" %(pn_name,p_name)) #x.i_sql("INSERT INTO products ('pn_name','p_name') VALUES('%s','%s');" %(pn_name,p_name)) a_ok = x.i_sql( "INSERT INTO products ('pn_name','p_name','price') VALUES(?,?,?)", s_Help.check_str(pn_name), s_Help.check_str(p_name), s_Help.check_str(p_price)) x.del_con() if a_ok == True: self.pninput.delete(0, END) self.pninput2.delete(0, END) messagebox.showinfo("alert", "新增成功") else: messagebox.showinfo("warning", "錯誤的新增")
def w_excel(self): workbook = xlsxwriter.Workbook("C:\\Users\\%s\\Desktop\\%sprduct.xlsx" % (self.us,self.today_dt)) worksheet = workbook.add_worksheet() worksheet.set_column('A:D', 20) xa=Sql3() xa_all=xa.s_sql("select a.pro_name,p.p_name,p.price from allpro as a inner join products as p on a.id=p.pn_name") z=0 y=0 for row in xa_all: worksheet.write(z, y, row[0]) worksheet.write(z, y+1, row[1]) worksheet.write(z, y+2, row[2]) z+=1 workbook.close() xa.del_con