Exemplo n.º 1
0
 public EmployeeManager(EmployeeRemark employeeRemark)
 {
     this.employeeRemark = employeeRemark;
 }
    private bool validateInputField()
    {
        bool trackAll = true;

        string remarkRefNo = null;
        string dateOfRemark = null;
        string remarkType = null;
        string penlityType = null;
        string penlityPer = null;
        string managerID = null;
        string remarkReason = null;
        string branch = null;

        if (txtRemarkRefNo.Text.Trim() != "")
        {
            lblRefNo.Visible = false;
            remarkRefNo = txtRemarkRefNo.Text.Trim();
        }
        else
        {
            lblRefNo.Visible = true;
            trackAll &= false;
        }

        if (txtDateOFRemark.Text.Trim() != "")
        {
            lblDateOfRemark.Visible = false;
            try
            {
                dateOfRemark = Convert.ToDateTime(txtDateOFRemark.Text.Trim()).ToShortDateString();
            }
            catch (FormatException)
            {
                msgPanel.Visible = true;
                ErroroDIV.Visible = true;
                lblErrorMsg.Text = "Please enter the date format in 'MM/dd/YYYY' and then try again.";
                trackAll &= false;
            }
        }
        else
        {
            lblDateOfRemark.Visible = true;
            trackAll &= false;
        }

        if (DropDRemarkType.SelectedValue != "-1")
        {
            lblremarkType.Visible = false;
            remarkType = DropDRemarkType.SelectedValue.Trim();
        }
        else
        {
            lblremarkType.Visible = true;
            trackAll &= false;
        }
        if (DropDRemarkType.SelectedValue != "-1")
        {
            lblPenality.Visible = false;
            penlityType = DropDRemarkType.SelectedValue.Trim();
        }
        else
        {
            lblPenality.Visible = true;
            trackAll &= false;
        }
        if (DropDRemarkType.SelectedValue == "Bad Remark")
        {
            if (RBPenality.SelectedValue != "")
            {
                lblPenality.Visible = false;
                penlityPer = RBPenality.SelectedValue.Trim();
            }
            else
            {
                lblPenality.Visible = true;
                trackAll &= false;
            }
        }
        else if (DropDRemarkType.SelectedValue == "Good Remark")
        {
            penlityPer = "";
        }

        if (DropDManagPosition.SelectedValue != "-1")
        {
            lblMangID.Visible = false;
            managerID = DropDManagPosition.SelectedValue;

            Employee getEmp = new Employee();
            getEmp.EmpID = managerID;

            EmployeeManager employeeManager = new EmployeeManager(getEmp);
            List<Employee> listOfEmployee = employeeManager.getEmployeeDetial();

            if (listOfEmployee != null && listOfEmployee.Count > 0)
            {
                foreach (Employee emply in listOfEmployee)
                {
                    string emp = emply.EmpID;
                    string profession = emply.MajorCategory.Trim();
                    currentMgtJTitle = emply.JobTitle.Trim();
                    currentEmpBranch = emply.Branch;
                }
            }
        }
        else
        {
            lblMangID.Visible = true;
            trackAll &= false;
        }

        if (txtRemarkReason.Text.Trim() != "")
        {
            lblRemarkReason.Visible = false;
            remarkReason = txtRemarkReason.Text.Trim();
        }
        else
        {
            lblRemarkReason.Visible = true;
            trackAll &= false;
        }

        employeeRemark = new EmployeeRemark();

        if (trackAll)
        {
            employeeRemark.EmployeeID = txtEmployeeID.Text.Trim();
            employeeRemark.RemarkReferanceNo = remarkRefNo;
            employeeRemark.DateOfRemark = dateOfRemark;
            employeeRemark.RemarkType = remarkType;
            employeeRemark.PenaltyPerc = penlityPer;
            employeeRemark.ManagerID = managerID;
            employeeRemark.ManagerPosition = currentMgtJTitle;
            employeeRemark.RemarkReason = remarkReason;
            employeeRemark.Branch = currentEmpBranch;
        }

        return trackAll;
    }