public bool Equals(StaffMaster other)
        {
            //Check whether the compared object is null.
            if (Object.ReferenceEquals(other, null))
            {
                return(false);
            }

            //Check whether the compared object references the same data.
            if (Object.ReferenceEquals(this, other))
            {
                return(true);
            }

            //Check whether the products' properties are equal.
            return(EmployeeName.Equals(other.EmployeeName));
        }
Esempio n. 2
0
        // Save/Add button.
        private void saveButton_Click(object sender, EventArgs e)
        {
            bool hasOnlyWhite = EmployeeName.Length > 0 &&
                                EmployeeName.Trim().Length == 0;

            if (hasOnlyWhite || EmployeeName.Equals(""))
            {
                labelName.ForeColor = Color.Red;
                MessageBox.Show(EmptyWarningMessage,
                                EmptyWarningTitle,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return;
            }
            labelName.ForeColor = Color.Black;
            if (editID != -1)
            {
                DialogResult result = MessageBox.Show(SaveConfirmMessage,
                                                      SaveConfirmTitle,
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    pEmployee.Save(editID);
                    EmployeeRefresh?.Invoke(this, new EventArgs());
                    MessageBox.Show(SaveConfirmOk);
                }
            }
            else
            {
                DialogResult result = MessageBox.Show(CreateConfirmMessage,
                                                      CreateConfirmTitle,
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    pEmployee.Save(editID);
                    EmployeeRefresh?.Invoke(this, new EventArgs());
                    MessageBox.Show(CreateConfirmOk);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Returns true if Employee instances are equal
        /// </summary>
        /// <param name="other">Instance of Employee to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Employee other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     EmployeeId == other.EmployeeId ||
                     EmployeeId != null &&
                     EmployeeId.Equals(other.EmployeeId)
                     ) &&
                 (
                     EmployeeCode == other.EmployeeCode ||
                     EmployeeCode != null &&
                     EmployeeCode.Equals(other.EmployeeCode)
                 ) &&
                 (
                     EmployeeName == other.EmployeeName ||
                     EmployeeName != null &&
                     EmployeeName.Equals(other.EmployeeName)
                 ) &&
                 (
                     Gender == other.Gender ||

                     Gender.Equals(other.Gender)
                 ) &&
                 (
                     DateOfBirth == other.DateOfBirth ||
                     DateOfBirth != null &&
                     DateOfBirth.Equals(other.DateOfBirth)
                 ) &&
                 (
                     PhoneNumber == other.PhoneNumber ||
                     PhoneNumber != null &&
                     PhoneNumber.Equals(other.PhoneNumber)
                 ) &&
                 (
                     DepartmentId == other.DepartmentId ||
                     DepartmentId != null &&
                     DepartmentId.Equals(other.DepartmentId)
                 ) &&
                 (
                     DepartmentName == other.DepartmentName ||
                     DepartmentName != null &&
                     DepartmentName.Equals(other.DepartmentName)
                 ) &&
                 (
                     Email == other.Email ||
                     Email != null &&
                     Email.Equals(other.Email)
                 ) &&
                 (
                     Salary == other.Salary ||

                     Salary.Equals(other.Salary)
                 ) &&
                 (
                     WorkStatus == other.WorkStatus ||

                     WorkStatus.Equals(other.WorkStatus)
                 ) &&
                 (
                     PositionId == other.PositionId ||
                     PositionId != null &&
                     PositionId.Equals(other.PositionId)
                 ) &&
                 (
                     PositionName == other.PositionName ||
                     PositionName != null &&
                     PositionName.Equals(other.PositionName)
                 ) &&
                 (
                     TaxCode == other.TaxCode ||
                     TaxCode != null &&
                     TaxCode.Equals(other.TaxCode)
                 ) &&
                 (
                     JoinDate == other.JoinDate ||
                     JoinDate != null &&
                     JoinDate.Equals(other.JoinDate)
                 ) &&
                 (
                     IdentityNumber == other.IdentityNumber ||
                     IdentityNumber != null &&
                     IdentityNumber.Equals(other.IdentityNumber)
                 ) &&
                 (
                     IdentityDate == other.IdentityDate ||
                     IdentityDate != null &&
                     IdentityDate.Equals(other.IdentityDate)
                 ) &&
                 (
                     IdentityPlace == other.IdentityPlace ||
                     IdentityPlace != null &&
                     IdentityPlace.Equals(other.IdentityPlace)
                 ));
        }