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_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
Exemple #3
0
    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, "خطأ", "برجاء اختيار الملف")