コード例 #1
0
    def save(self):
        valid = True
        if len(self.id.currentText()) == 0:
            QMessageBox(QMessageBox.Information,
                        "Error",
                        "Please select name and ID!",
                        parent=self).exec_()
            valid = False
        else:
            for i in range(len(self.inputs)):
                if not self.inputs[i].isValid():
                    valid = False
                    QtGui.QMessageBox(QtGui.QMessageBox.Information,
                                      "Error",
                                      self.inputs[i].getErrorMessage(),
                                      parent=self).exec_()
                    break

        if valid:
            emp = Employee(self.id.currentText(), self.nameEdit.text(),
                           self.designation.currentText(),
                           self.originalPay.text(),
                           self.originalPayGrade.text(), self.DOJ.getDate(),
                           self.pan.text())
            try:
                Database.getdb().editEmployee(emp)
            except mysql.connector.Error as e:
                ShowMysqlError(e, self)
                return

            QMessageBox(QMessageBox.NoIcon,
                        "Success",
                        "Employee edited successfully",
                        parent=self).exec_()
コード例 #2
0
    def add(self):
        """This method is automatically called on clicking 'Add Employee' button

        This first checks if all inputs are valid. If any of the inputs are invalid, error message
        is shown for the first invalid input, else a new Employee object is created from available info.
        This Employee object is then passed to addEmployee() function of DatabaseManager which adds
        a new employee record in the database.
        """

        valid = True
        for i in range(len(self.inputs)):
            if not self.inputs[i].isValid():
                valid = False
                QtGui.QMessageBox(QtGui.QMessageBox.Information, "Error", self.inputs[i].getErrorMessage(),
                                        parent=self).exec_()
                break

        if valid:
            emp = Employee(self.id.text(),
                           self.name.text(),
                           self.designation.currentText(),
                           self.originalPay.text(),
                           self.gradePay.text(),
                           self.DOJ.getDate(),
                           self.pan.text())
            try:
                Database.getdb().addEmployee(emp)
                QtGui.QMessageBox(QtGui.QMessageBox.NoIcon, "Success", "Employee added successfully",
                                  parent=self).exec_()
                self.goBack()
            except mysql.connector.Error as e:
                ShowMysqlError(e, self)
                return
コード例 #3
0
    def getEmployeeInfo(self, id):
        """Get all details about the employee with given ID stored in the database

        Args:
            id (str): ID for which employee details are required

        Returns:
            Employee: An Employee object with required details
        """
        command = "SELECT * FROM " + self.employeeTableName + " WHERE ID = %s"
        self.mycursor.execute(command, (id, ))
        res = self.mycursor.fetchone()
        if res is None:
            return None
        return Employee(*res)
コード例 #4
0
    def __init__(self, parent, salary):
        QWidget.__init__(self)
        self.title = "Salary Result"
        # self.setGeometry(50, 50, 800, 600)

        self.__parent = parent
        self.salary = salary

        self.month = str(self.salary.month)
        self.year = str(self.salary.year)
        self.id = QLineEdit()
        self.id.setReadOnly(True)
        self.id.setText(self.salary.id)
        self.name = QLineEdit()
        self.name.setReadOnly(True)
        self.name.setText(self.salary.name)
        self.designation = QLineEdit()
        self.designation.setReadOnly(True)
        self.designation.setText(self.salary.designation)
        self.originalPay = QLineEdit()
        self.originalPay.setReadOnly(True)
        self.originalPay.setText(str(self.salary.originalPay))
        self.originalPayGrade = QLineEdit()
        self.originalPayGrade.setReadOnly(True)
        self.originalPayGrade.setText(str(self.salary.originalPayGrade))
        self.DOJ = QLineEdit()
        self.DOJ.setReadOnly(True)
        self.DOJ.setText(Employee.dateToStr(salary.doj))
        self.pan = QLineEdit()
        self.pan.setReadOnly(True)
        self.pan.setText(self.salary.pan)

        self.presentPay = QLineEdit()
        self.presentPay.setReadOnly(True)
        self.presentPay.setText(str(self.salary.presentPay))
        self.da = QLineEdit()
        self.da.setReadOnly(True)
        self.da.setText(str(self.salary.da))
        self.hra = QLineEdit()
        self.hra.setReadOnly(True)
        self.hra.setText(str(self.salary.hra))
        self.ta = QLineEdit()
        self.ta.setReadOnly(True)
        self.ta.setText(str(self.salary.ta))
        self.it = QLineEdit()
        self.it.setReadOnly(True)
        self.it.setText(str(self.salary.it))
        self.pt = QLineEdit()
        self.pt.setReadOnly(True)
        self.pt.setText(str(self.salary.pt))

        self.grossAllowance = QLineEdit()
        self.grossAllowance.setReadOnly(True)
        self.grossAllowance.setText(str(self.salary.grossEarnings))
        self.grossDeduction = QLineEdit()
        self.grossDeduction.setReadOnly(True)
        self.grossDeduction.setText(str(self.salary.grossDeductions))

        self.netPay = QLineEdit()
        self.netPay.setReadOnly(True)
        self.netPay.setText(str(self.salary.netPay))

        self.setupUI()