def FN_VALIDATE_FIELDS(self): self.name = self.LE_name.text().strip() self.phone = self.lE_phone.text().strip() self.mobile = self.lE_mobile.text().strip() self.building = self.LE_building.text().strip() self.floor = self.LE_floor.text().strip() self.email = self.LE_email.text().strip() self.company = self.LE_company.text().strip() self.workPhone = self.LE_workPhone.text().strip() self.workAddress = self.LE_workAddress.text().strip() error = 0 if self.name == '' or self.mobile == '' or self.job == '' or self.address == '' or self.building == '' \ or self.floor == '' or self.email == '': QtWidgets.QMessageBox.warning(self, "خطأ", "برجاء إدخال جميع البيانات") error = 1 return error ret = CL_validation.FN_validation_int(self.phone) if ret == False: QtWidgets.QMessageBox.warning(self, "خطأ", "رقم التليفون غير صحيح") error = 1 ret = CL_validation.FN_validation_mobile(self.mobile) if ret == 3: QtWidgets.QMessageBox.warning(self, "خطأ", "رقم الموبايل يجب أن يكون 11 رقم") error = 1 elif ret == 2: QtWidgets.QMessageBox.warning(self, "خطأ", " رقم الموبايل يجب أن يبدأ ب 01") error = 1 ret = self.FN_CHECK_REPEATED_MOBILE(self.mobile) if ret == False: QtWidgets.QMessageBox.warning(self, "خطأ", "موبايل مكرر ") error = 1 ret = CL_validation.FN_validation_int(self.workPhone) if ret == False: QtWidgets.QMessageBox.warning(self, "خطأ", "رقم هاتف غير صحيح") error = 1 ret = CL_validation.FN_valedation_mail(self.email) if ret == False: QtWidgets.QMessageBox.warning(self, "خطأ", "إيميل غير صحسح") error = 1 return error
def FN_VALIDATE_FIELDS(self): no = self.LE_custNo.text().strip() name = self.LE_custName.text().strip() phone = self.LE_custPhone.text().strip() error = 0 if name == '' or phone == '': QtWidgets.QMessageBox.warning(self, "خطأ", "برجاء إدخال جميع البيانات") error = 1 else: ret = CL_validation.FN_validation_int(phone) if ret == False: QtWidgets.QMessageBox.warning(self, "خطأ", "رقم الموبايل غير صحيح") error = 1 ret = CL_validation.FN_validation_mobile(phone) if ret == 3: QtWidgets.QMessageBox.warning( self, "خطأ", "رقم الموبايل يجب أن يكون 11 رقم") error = 1 elif ret == 2: QtWidgets.QMessageBox.warning(self, "خطأ", "رقم الموبايل يجب أن يبدأ ب 01") error = 1 # ret = util.FN_VALIDATE_CUST(no) # if ret == False: # QtWidgets.QMessageBox.warning(self, "خطأ", "رقم العميل غير صحيح") # error = 1 return error
def FN_REPLACE_CLICKED(self): try: replacedPts=self.Qline_replace.text().strip() if (self.Qline_replace.text().strip() !='' and self.Qline_points.text().strip() !='') or (replacedPts == '-') : print(self.Qline_points.text().strip()) ret = CL_validation.FN_validation_int(self.Qline_replace.text().strip()) if ret == True: replacedPoints = float(self.Qline_replace.text().strip()) actualPoints = float(self.Qline_points.text().strip()) remainingPoints = actualPoints - replacedPoints self.Qline_remainder.setText(str(remainingPoints)) self.FN_GET_POINTS_VALUE(replacedPoints) else: QtWidgets.QMessageBox.warning(self, "خطأ", "replaced points is not integer ") except Exception as err: print(err)
def FN_SAVE_UPLOAD(self): if self.fileName != '': self.LE_fileName.setText(self.fileName) wb = xlrd.open_workbook(self.fileName) sheet = wb.sheet_by_index(0) conn = db1.connect() mycursor = conn.cursor() errorMsg = '' createdCust = 0 nonCreatedCust = 0 #print (sheet.nrows) error_message = '' for i in range(sheet.nrows): error = 0 try: self.name = sheet.cell_value(i, 0) error_message = error_message + " \n username " + self.name self.custGroup = int(sheet.cell_value(i, 1)) self.loyalityType = int(sheet.cell_value(i, 2)) self.phone = int(sheet.cell_value(i, 3)) self.mobile = sheet.cell_value(i, 4) self.job = sheet.cell_value(i, 5) self.address = sheet.cell_value(i, 6) self.city = int(sheet.cell_value(i, 7)) self.district = int(sheet.cell_value(i, 8)) self.building = int(sheet.cell_value(i, 9)) self.floor = int(sheet.cell_value(i, 10)) self.email = sheet.cell_value(i, 11) self.company = sheet.cell_value(i, 12) self.workPhone = int(sheet.cell_value(i, 13)) self.workAddress = sheet.cell_value(i, 14) self.status = int(sheet.cell_value(i, 15)) self.notes = sheet.cell_value(i, 16) nationalID = sheet.cell_value(i, 17) #QtWidgets.QMessageBox.warning(self, "خطأ", "Please select the row you want to modify ") if self.name == '' or self.mobile == '' or self.job == '' or self.address == '' or self.city == '' or self.district == '' or self.building == '' \ or self.email == '' or nationalID =='': error = 1 error_message = error_message + " user has an empty fields" ret = CL_validation.FN_validation_mobile(str(self.mobile)) if ret == 3: error_message = error_message + "رقم الموبايل يجب أن يكون 11 رقم" error = 1 elif ret == 2: error_message = error_message + " رقم الموبايل يجب أن يبدأ ب 01" error = 1 ret = CL_validation.FN_validation_int(str(self.phone)) if ret == False: error_message = error_message + " , صحيح غير الهاتف رقم " error = 1 ret = CL_validation.FN_validation_int(nationalID) if ret == False: QtWidgets.QMessageBox.warning(self, "خطأ", "رقم البطاقه غير صحيح") error = 1 ret = CL_validation.FN_valedation_mail(self.email) if ret == False: error_message = error_message + " إيميل غير صحسح" error = 1 if error != 1: sql0 = " LOCK TABLES Hyper1_Retail.POS_CUSTOMER WRITE " mycursor.execute(sql0) creationDate = str( datetime.today().strftime('%Y-%m-%d-%H:%M-%S')) sql = "INSERT INTO Hyper1_Retail.POS_CUSTOMER( LOYCT_TYPE_ID, CG_GROUP_ID, POSC_NAME, POSC_PHONE," \ " POSC_MOBILE, POSC_JOB, POSC_ADDRESS, POSC_CITY, POSC_DISTICT, POSC_BUILDING,POSC_FLOOR, POSC_EMAIL, " \ "POSC_CREATED_BY, POSC_CREATED_ON ,POSC_CHANGED_BY , POSC_COMPANY, " \ "POSC_WORK_PHONE, POSC_WORK_ADDRESS, POSC_NOTES, POSC_STATUS,`POSC_NATIONAL_ID`) " \ " VALUES (%s, %s, %s,%s,%s, %s, %s, %s, %s, " \ "%s,%s, %s, %s,%s, %s,%s, %s, %s, %s,%s,%s)" # sql = "INSERT INTO SYS_USER (USER_ID,USER_NAME) VALUES (%s, %s)" val = (self.loyalityType, self.custGroup, self.name, str(self.phone), self.mobile, self.job, self.address, str(self.city), str(self.district), str(self.building), self.floor, self.email, CL_userModule.user_name, creationDate, ' ', self.company, self.workPhone, self.workAddress, self.notes, self.status, nationalID) #print(val) mycursor.execute(sql, val) createdCust = createdCust + 1 sql00 = " UNLOCK tables " mycursor.execute(sql00) db1.connectionCommit(conn) else: nonCreatedCust = nonCreatedCust + 1 # self.msgBox1.setText(error_message) # self.msgBox1.show() except Exception as err: print(err) mycursor.close() self.msgBox = QMessageBox() # Set the various texts self.msgBox.setWindowTitle("Information") self.msgBox.setStandardButtons(QMessageBox.Ok) self.msgBox.setText(error_message + "\n No of created Cust '" + str(createdCust) + "' No of non created Cust '" + str(nonCreatedCust) + "'") self.msgBox.show() self.close() #Extracting number of rows else: QtWidgets.QMessageBox.warning(self, "خطأ", "برجاء اختيار الملف")
def FN_MODIFY_REDITEM(self): try: if len(self.Qtable_redeem.selectedIndexes()) > 0: branch = self.CMB_branch.currentText() comp = self.CMB_company.currentText() bar = self.Qline_barcode.text().strip() date_from = self.Qdate_from.date().toString('yyyy-MM-dd') date_to = self.Qdate_to.date().toString('yyyy-MM-dd') comp = util.FN_GET_COMP_ID(comp) branch = util.FN_GET_BRANCH_ID(branch, comp) points = self.Qline_points.text().strip() creationDate1 = str(datetime.today().strftime('%Y-%m-%d')) if self.Qradio_active.isChecked(): status = 1 else: status = 0 conn = db1.connect() mycursor = conn.cursor() if points == '': QtWidgets.QMessageBox.warning(self, "خطأ", "برجاء إدخال النقاط ") elif date_to < date_from: QtWidgets.QMessageBox.warning( self, "خطأ", "تاريخ الانتهاء يجب ان يكون اكبر من او يساوي تاريخ الانشاء" ) # elif date_from < creationDate1: # QtWidgets.QMessageBox.warning(self, "خطأ", "تاريخ التعديل يجب أن يكون أكبرمن أو يساوي تاريخ اليوم") else: self.CMB_branch.hide() self.CMB_company.hide() self.Qcombo_group3.show() self.Qcombo_group4.show() self.Qline_barcode.setEnabled(True) self.Qline_barcode.setText('') self.Qline_points.setText('') ret2 = CL_validation.FN_validation_int(points) if ret2 == True: sql = "update Hyper1_Retail.REDEEM_ITEM " \ "set REDEEM_POINTS_QTY =%s,REDEEM_VALID_FROM =%s , REDEEM_VALID_TO = %s , " \ "REDEEM_STATUS =%s where POS_GTIN = %s and COMPANY_ID = %s and BRANCH_NO = %s " val = (points, date_from, date_to, status, bar, comp, branch) mycursor.execute(sql, val) mycursor.close() print(mycursor.rowcount, "record updated.") QtWidgets.QMessageBox.information( self, "نجاح", "تم التعديل ") db1.connectionCommit(conn) self.FN_REFRESH_DATA_GRID() self.old_status = util.FN_GET_STATUS_id( str(self.old_status)) if str(status) != str(self.old_status): util.FN_INSERT_IN_LOG("REDEEM_ITEM", "status", status, self.old_status, bar, comp, branch) if str(points) != str(self.old_points): util.FN_INSERT_IN_LOG("REDEEM_ITEM", "points", points, self.old_points, bar, comp, branch) if str(date_from) != str(self.old_valid_from): util.FN_INSERT_IN_LOG("REDEEM_ITEM", "valid_from", date_from, self.old_valid_from, bar, comp, branch) if str(date_to) != str(self.old_valid_to): util.FN_INSERT_IN_LOG("REDEEM_ITEM", "valid_to", date_to, self.old_valid_to, bar, comp, branch) print("in modify red item") else: QtWidgets.QMessageBox.warning( self, "خطأ", "برجاء اختيار السطر المراد تعديله ") except Exception as err: print(err)
def FN_CREATE_REDITEM(self): try: branchs = self.Qcombo_group4.currentData() companies = self.Qcombo_group3.currentData() bar = self.Qline_barcode.text().strip() date_from = self.Qdate_from.date().toString('yyyy-MM-dd') date_to = self.Qdate_to.date().toString('yyyy-MM-dd') points = self.Qline_points.text().strip() if self.Qradio_active.isChecked(): status = 1 else: status = 0 # mycursor = self.conn.cursor(buffered=True) conn = db1.connect() mycursor = conn.cursor() creationDate = str(datetime.today().strftime('%Y-%m-%d-%H:%M-%S')) creationDate1 = str(datetime.today().strftime('%Y-%m-%d')) # get COMPANY company_list = companies # get branchs branch_list = branchs if len(self.Qcombo_group3.currentData()) == 0 or len( self.Qcombo_group4.currentData() ) == 0 or bar == '' or points == '' or date_from == '' or date_to == '': QtWidgets.QMessageBox.warning(self, "خطأ", "برجاء إدخال جميع البيانات") elif date_to < date_from: QtWidgets.QMessageBox.warning( self, "خطأ", "تاريخ الانتهاء يجب ان يكون اكبر من او يساوي تاريخ الانشاء" ) elif date_from < creationDate1: QtWidgets.QMessageBox.warning( self, "خطأ", "تاريخ الإنشاء يجب أن يكون أكبرمن أو يساوي تاريخ اليوم") else: ret1 = self.FN_CHECK_VALID_BARCCODE(bar) if ret1 == True: ret2 = CL_validation.FN_validation_int(points) if ret2 == True: for com in company_list: for br in branch_list: ret = self.FN_CHECK_EXIST(com, br, bar) if ret == False: mycursor1 = conn.cursor() #get BMC ID mycursor1.execute( "select BMC_ID from Hyper1_Retail.POS_ITEM where POS_GTIN ='" + bar + "'") myresult = mycursor1.fetchone() BMC_ID = myresult[0] sql = "INSERT INTO Hyper1_Retail.REDEEM_ITEM (POS_GTIN,COMPANY_ID," \ "BRANCH_NO,REDEEM_POINTS_QTY,REDEEM_CREATED_ON,REDEEM_CREATED_BY,REDEEM_VALID_FROM" \ ",REDEEM_VALID_TO,REDEEM_STATUS,BMC_ID)" \ "values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)" val = (bar, com, br, points, creationDate, CL_userModule.user_name, date_from, date_to, status, BMC_ID) mycursor1.execute(sql, val) db1.connectionCommit(conn) mycursor1.close() QtWidgets.QMessageBox.information( self, "تم", "تم الإنشاء") else: QtWidgets.QMessageBox.warning( self, "خطأ", "المدخلات موجوده بالفعل ") self.FN_REFRESH_DATA_GRID() else: QtWidgets.QMessageBox.warning( self, "خطأ", "النقاط يجب أن تكون أرقام") else: QtWidgets.QMessageBox.warning(self, "خطأ", "الباركود غير صحيح") except Exception as err: print(err)