Ejemplo n.º 1
0
    def searchCustomer(self):
        mob_num = self.searchled.text()
        if mob_num == '':
            self.statuslbl.setText('Must enter mobilephone to start search')
        elif select_customer_by_mob_num(mob_num):
            selectedCust = select_customer_by_mob_num(mob_num)
            self.renamelbl.setText(selectedCust.name)
            self.remobilenumlbl.setText(selectedCust.mobile_number)
            self.remobilenumlbl1.setText(selectedCust.mobile_number_1)
            self.remobilenumlbl2.setText(selectedCust.mobile_number_2)
            self.remobilenumlbl3.setText(selectedCust.mobile_number_3)
            self.remobilenumlbl4.setText(selectedCust.mobile_number_4)
            city_name = select_city_by_id(selectedCust.city_id).name
            self.recitylbl.setText(city_name)
            self.reagelbl.setText(str(selectedCust.age))
            self.regenderlbl.setText(selectedCust.gender.capitalize())
            self.statuslbl.setText('')
            self.detailsbtn.setEnabled(True)
            # role handel
            role = getLoginDataPKL()['role']
            if int(role) == 1 or int(role) == 2 or int(role) == 3:
                self.updatebtn.setEnabled(False)
            else:
                self.updatebtn.setEnabled(True)

            if select_maintenance_customer(selectedCust.id):
                self.statuslbl.setText(
                    "Can't delete, this customer have maintenance")
            else:
                return False
        else:
            self.statuslbl.setText("Can't found customer")
Ejemplo n.º 2
0
 def updateCustomer(self):
     if select_customer_by_mob_num(self.searchled.text()) and self.mobcustled.text() != '' or \
         self.remobilenumlbl.text() != '':
         selectedCust = select_customer_by_mob_num(self.searchled.text())
         custname = self.custnameled.text()
         custmobnum = self.mobcustled.text()
         custmobnum1 = self.mobcustled91.text()
         custmobnum2 = self.mobcustled92.text()
         custmobnum3 = self.mobcustled93.text()
         custmobnum4 = self.mobcustled94.text()
         custcity_id = self.citycmbx.currentIndex()
         custage = self.agespin.text()
         if self.malebtn.isChecked():
             gndr = 'male'
         elif self.femalerbtn.isChecked():
             gndr = 'female'
         if custname:
             custname = self.renamelbl.text()
         if not custmobnum:
             custmobnum = self.remobilenumlbl.text()
         if self.citycmbx.currentIndex() == 0:
             custcity_id = selectedCust.city_id
         if self.agespin.value() == 0:
             custage = self.reagelbl.text()
         if not self.malebtn.isChecked() | self.femalerbtn.isChecked():
             gndr = self.regenderlbl.text()
         update_customer(selectedCust.id, custname, custmobnum, custmobnum1,
                         custmobnum2, custmobnum3, custmobnum4, gndr,
                         custage, custcity_id)
         self.close()
     else:
         self.statuslbl.setText("No Customer To Update")
Ejemplo n.º 3
0
 def searchCustomer(self):
     mob_num = self.searchled.text()
     if mob_num == '':
         self.statuslbl.setText('Must enter mobilephone to start search')
     elif select_customer_by_mob_num(mob_num):
         selectedCust = select_customer_by_mob_num(mob_num)
         self.renamelbl.setText(selectedCust.name)
         self.custnameled.setText(selectedCust.name)
         self.remobilenumlbl.setText(selectedCust.mobile_number)
         self.remobilenumlbl91.setText(selectedCust.mobile_number_1)
         self.remobilenumlbl92.setText(selectedCust.mobile_number_2)
         self.remobilenumlbl93.setText(selectedCust.mobile_number_3)
         self.remobilenumlbl94.setText(selectedCust.mobile_number_4)
         self.mobcustled.setText(selectedCust.mobile_number)
         self.mobcustled91.setText(selectedCust.mobile_number_1)
         self.mobcustled92.setText(selectedCust.mobile_number_2)
         self.mobcustled93.setText(selectedCust.mobile_number_3)
         self.mobcustled94.setText(selectedCust.mobile_number_4)
         city = select_city_by_id(selectedCust.city_id)
         self.recitylbl.setText(city.name)
         self.citycmbx.setCurrentText(city.name)
         self.reagelbl.setText(str(selectedCust.age))
         self.agespin.setValue(selectedCust.age)
         self.regenderlbl.setText(selectedCust.gender.capitalize())
         if selectedCust.gender == 'male':
             self.malebtn.setChecked(True)
         else:
             self.femalerbtn.setChecked(True)
         self.statuslbl.setText('')
     else:
         self.statuslbl.setText("Can't found customer")
Ejemplo n.º 4
0
def valiedDeleteCustomer(mobNum):
    if customersModel.select_customer_by_mob_num(mobNum):
        selectedCust = customersModel.select_customer_by_mob_num(mobNum)
        if not maintenanceModel.select_maintenance_customer(
                selectedCust.customers_id):
            customersModel.delete_customer(selectedCust.id)
        else:
            return False
	def do_createNewCustomer(self):
		if not self.custnameled.text() or \
				not self.mobcustled.text() or \
						self.citycmbx.currentIndex() == 0 or \
						self.agespin.value() == 0 or \
						not self.malebtn.isChecked() and \
						not self.femalerbtn.isChecked():
			self.statuslbl.setText('All fields is required ')
		else:
			if not customersModel.select_customer_by_mob_num(self.mobcustled.text()):
				name = self.custnameled.text()
				mobileNumber = self.mobcustled.text()
				mobileNumber_1 = self.mobcustled_1.text()
				mobileNumber_2 = self.mobcustled_2.text()
				mobileNumber_3 = self.mobcustled_3.text()
				mobileNumber_4 = self.mobcustled_4.text()
				if self.malebtn.isChecked():
					gndr = 'male'
				elif self.femalerbtn.isChecked():
					gndr = 'female'
				age = self.agespin.text()
				city_id = self.citycmbx.currentIndex()
				mainte = creatMaintenanceWithNewCustomer(name, mobileNumber, mobileNumber_1, mobileNumber_2,
														 mobileNumber_3, mobileNumber_4, gndr, age, city_id)
				self.statuslbl.setText('A new customer added successfully ')
				# print(mainte)
				from uiview.ui_createBOM import Ui_createBOMDialog
				self.b = Ui_createBOMDialog(mainte)
				self.b.exec_()
				self.close()
			else:
				self.statuslbl.setText('This customer is already exists ')
Ejemplo n.º 6
0
    def tableDataShow(self):
        mylist = []
        if self.reqTypecomboBox.currentIndex() == 1:
            mylist = getOutbounEmployeeRow()
            self.tableData = OutboundTableModel()
            self.protableView.setModel(self.tableData)
        if self.reqTypecomboBox.currentIndex() == 2:
            cust = select_customer_by_mob_num(self.mobnumled.text())
            mylist = getOutbounOneCustomerRow(cust)
            self.tableData = OutboundTableModel()
            self.protableView.setModel(self.tableData)
        self.protableView.setColumnWidth(0, 100)
        self.protableView.setColumnWidth(1, 130)
        self.protableView.setColumnWidth(2, 132)
        self.protableView.setColumnWidth(3, 70)
        self.protableView.setColumnWidth(4, 40)

        for idx, val in enumerate(mylist):
            self.tableData.addItems(
                Outbound(
                    val.code,
                    None,
                    None,
                    val.customer_id,
                    val.employee_id,
                    val.raw_material_id,  # raw
                    val.spare_part_id,  # spare
                    val.tools_id,  # tools
                    val.product_id,  # product
                    val.req_qty,  # qty
                    None))
 def do_maint(self):
     indexes = self.tableView.selectionModel().selectedRows(1)
     for ind in sorted(indexes):
         cst = select_customer_by_mob_num(ind.data())
         maint = creatMaintenanceExtCustomer(cst)
         from uiview.ui_createBOM import Ui_createBOMDialog
         self.cbom = Ui_createBOMDialog(maint)
         self.cbom.exec_()
Ejemplo n.º 8
0
def validCustomer(name, mobNum, mobile_number_1, mobile_number_2,
                  mobile_number_3, mobile_number_4, gender, age, city_id):
    if not customersModel.select_customer_by_mob_num(mobNum):
        customersModel.add_customer(name, mobNum, mobile_number_1,
                                    mobile_number_2, mobile_number_3,
                                    mobile_number_4, gender, age, city_id)
        return True
    else:
        return False
 def Clicked(self, item):
     indexes = self.tableView.selectionModel().selectedRows(1)
     for ind in sorted(indexes):
         cst = select_customer_by_mob_num(ind.data())
         self.customerNamelbl.setText(cst.name)
         self.customerMobilelbl.setText(cst.mobile_number)
         self.customerAgelbl.setText(str(cst.age))
         cty = select_city_by_id(cst.city_id)
         self.customerCitylbl.setText(cty.name)
         self.createbtn.setEnabled(True)
Ejemplo n.º 10
0
 def deleteCustomer(self):
     mob_num = self.searchled.text()
     selectedCust = select_customer_by_mob_num(mob_num)
     if select_maintenance_customer(selectedCust.id):
         self.statuslbl.setText("Can't delete customer")
     else:
         reply = QMessageBox.question(
             QMessageBox(), 'Delete',
             "Are you sure to delete this customer ?\n"
             "This action you can't undo", QMessageBox.Yes | QMessageBox.No)
         if reply == QMessageBox.Yes:
             delete_customer(selectedCust.id)
             self.close()
Ejemplo n.º 11
0
 def openOutReport(self):
     if self.reqTypecomboBox.currentIndex() == 1:
         CreateOutboundReport().create_pdf()
         mylist = getOutbounEmployeeRow()
         for idx, val in enumerate(mylist):
             if val.tools:
                 if val.tools.back == 1:
                     increaseToolsInvQty(val.tools, val.req_qty)
             update_oubound_status(val.id, 0)
     if self.reqTypecomboBox.currentIndex() == 2:
         cust = select_customer_by_mob_num(self.mobnumled.text())
         CreateOutboundCustReport(cust).create_pdf()
         mylist = getOutbounOneCustomerRow(cust)
         for idx, val in enumerate(mylist):
             if val.tools:
                 if val.tools.back == 1:
                     increaseToolsInvQty(val.tools, val.req_qty)
             update_oubound_status(val.id, 0)
Ejemplo n.º 12
0
 def openHistory(self):
     from uiview.ui_customerHistory import Ui_historyDialog
     mob_num = self.searchled.text()
     selectedCust = select_customer_by_mob_num(mob_num)
     self.hd = Ui_historyDialog(selectedCust)
     self.hd.exec_()