def Delete(self): loan_id = self.ui.loan_id.text() #贷款号为空 if loan_id == "": self.ui.ts.setText("! 不能为空") return cursor = self.db.cursor() sql = """select amount, amount_payed from loans where loan_id = %s""" cursor.execute(sql, [loan_id]) ret = cursor.fetchone() #print(ret) #贷款号错误 if ret is None: self.ui.ts.setText("! 贷款号错误") return self.ui.ts.setText("") amount, amount_payed = ret #贷款未发放 if 0 == amount_payed: try: sql = """delete from apply where loan_id = %s""" cursor.execute(sql, [loan_id]) sql = """delete from loans where loan_id = %s""" cursor.execute(sql, [loan_id]) alarmMessageBox(self, "贷款未发放,删除成功") except: alarmMessageBox(self, "失败") self.db.commit()
def delete(self): id = self.ui.id.text() if id is "": alarmMessageBox(self, "id不能为空") return cursor = self.db.cursor() sql = """select * FROM own WHERE id_number = %s and account_number = %s""" cursor.execute(sql, [id, self.account_id]) ret = cursor.fetchone() #print(ret,ret is None) if ret is None: alarmMessageBox(self, "该客户不是此账户的户主!") return try: cursor = self.db.cursor() sql = """DELETE FROM own WHERE id_number = %s and account_number = %s""" cursor.execute(sql, [id, self.account_id]) alarmMessageBox(self, "删除成功!") except: alarmMessageBox(self, "删除失败!") self.db.commit() self.parent.closeClient() self.parent.showTable() self.close()
def add(self): id = self.ui.id.text() if id is "": alarmMessageBox(self, "id不能为空") return #查询客户是否存在 cursor = self.db.cursor() sql = """ select * from client where id_number = %s""" cursor.execute(sql, [id]) ret = cursor.fetchall() if ret is None: alarmMessageBox(self, "该客户不存在!") return # 每个客户只能有一个储蓄账户和一个支票账户 sql = """select account_type from own,account where own.account_number = account.account_number and id_number = %s""" cursor.execute(sql, [id]) ret = cursor.fetchall() # print(ret) if len(ret) >= 2 or len(ret) >= 1 and ret[0][0] == int( self.account_type): alarmMessageBox(self, "每个客户只能有一个储蓄账户和一个支票账户 或者你已经是该账户的户主") return #加入 try: sql = """insert into own value (%s,%s,%s)""" cursor.execute(sql, [id, self.account_id, datetime.date.today()]) alarmMessageBox(self, "加入成功!") except: alarmMessageBox(self, "加入失败!") self.db.commit() self.parent.closeClient() self.parent.showTable() self.close()
def delete(self): alarmMessageBox(self, "若是支票账户,需要先付清透支额!") w = account_delete(self)
def Create(self): loan_id = self.ui.loan_id.text() amount = self.ui.amount.text() id1 = self.ui.id1.text() id2 = self.ui.id2.text() id3 = self.ui.id3.text() ready = True #输入基本要求 if loan_id == "": self.ui.ts1.setText("! id不能为空") ready = False else: self.ui.ts1.setText("") if amount == "": self.ui.ts2.setText("! 金额不能为空") ready = False elif not amount.isdigit(): self.ui.ts2.setText("! 请填写数字") ready = False else: self.ui.ts2.setText("") if id1 == "": ready = False self.ui.ts3.setText("!申请人1不能为空") else: ready = True self.ui.ts3.setText("") if ready == False: alarmMessageBox(self, "失败") return #判断Loan_id是否重复 cursor = self.db.cursor() sql = """select * from loans where loan_id = %s""" cursor.execute(sql, [loan_id]) ret = cursor.fetchone() if ret is not None: self.ui.ts1.setText("! id重复") #alarmMessageBox(self,"失败") ready = False #判断id1是否存在 sql = """select * from client where id_number = %s""" cursor.execute(sql, [id1]) ret = cursor.fetchone() #print(ret) if ret is None: #print("f**k") #self.ui.ts3.setText("!申请人1不能为空") self.ui.ts3.setText("id不存在") #alarmMessageBox(self,"失败") ready = False # 判断id2是否存在 if id2 != "": sql = """select * from client where id_number = %s""" cursor.execute(sql, [id2]) ret = cursor.fetchone() if ret is None: self.ui.ts4.setText("id不存在") #alarmMessageBox(self,"失败") ready = False # 判断id3是否存在 if id3 != "": sql = """select * from client where id_number = %s""" cursor.execute(sql, [id3]) ret = cursor.fetchone() if ret is None: self.ui.ts5.setText("id不存在") #alarmMessageBox(self,"失败") ready = False if ready == False: alarmMessageBox(self, "失败") return try: sql = """select department.name from staff ,department where staff.dep_department_id = department.department_id and staff.id_number = %s""" cursor.execute(sql, [self.id_number]) name = cursor.fetchone() sql = """select asset from sub_branch where name = %s""" # print(name) cursor.execute(sql, [name]) asset = cursor.fetchone() # print(asset) if asset[0] / 2 < float(amount): self.ui.ts2.setText("!金额过大,不能申请") return sql = """insert into loans value (%s,%s,%s,%s, %s)""" cursor.execute(sql, [loan_id, name, amount, "0", datetime.date.today()]) sql = """insert into apply value (%s,%s)""" cursor.execute(sql, [loan_id, id1]) if id2 != "": cursor.execute(sql, [loan_id, id2]) if id3 != "": cursor.execute(sql, [loan_id, id3]) alarmMessageBox(self, "成功") except: alarmMessageBox(self, "失败") self.db.commit() self.close()