protected void btnFind_Click(object sender, EventArgs e)
        {
            CsEmployee emp = new CsEmployee();

            //The program find the previous information about the employee enable the update button
            //once the employee has been found the program display his/her information then allow
            //the user to make an update
            #region "Find previous information about the employee"
            try
            {
                Int32 needeedCd = Convert.ToInt32(txtcode.Text);
                if (txtcode.Text.Length == 6)
                {
                    bool result = emp.validateEmpCode(needeedCd);
                    if (!result)
                    {
                        succes.Text                 = "Employee code not found! ";
                        btnUpdate.Enabled           = false;
                        errorDeptDuplicated.Visible = false;
                        succes.Visible              = true;
                    }
                    else
                    {
                        //call the the methode getEmployee with then class CsEmployee which retrieve information
                        //about the employee whose the code correspond to the one typed in the textbox employee code
                        errorDeptDuplicated.Visible = false;
                        succes.Visible = false;
                        emp.getEmployee(Convert.ToInt32(txtcode.Text));
                        txtname.Text      = emp._Name;
                        txtdesi.Text      = emp._Designation;
                        txtdept.Text      = emp._deptName;
                        btnUpdate.Enabled = true;
                        txtcode.Enabled   = false;
                    }
                }
                else
                {
                    //validate that the employee code typed by the user is 6 digits long
                    //otherwise it displays an appropriate error message to the user.
                    errorDeptDuplicated.Text = "Employee code should be 6 digits long without space and special characters.";
                    txtcode.Focus();
                    errorDeptDuplicated.Visible = true;
                    btnUpdate.Enabled           = false;
                    succes.Visible = false;
                }
            }
            catch
            {
                //verify that the user has typed only numeric values for thr employee code
                errorDeptDuplicated.Text = "Please Use only Numeric values without space and special characters for employee code";
                txtcode.Focus();
                errorDeptDuplicated.Visible = true;
                succes.Visible = false;
            }
            #endregion
        }
Esempio n. 2
0
        protected void btnFind_Click(object sender, EventArgs e)
        {
            
            txtdept.Text = "";
            txtname.Text = "";
            txtyears.Text = "";
            txtdesi.Text = "";
            CsEmployee objEmp = new CsEmployee();
            try
            {
                
                

                if (txtcode.Text.Length == 6)
                {
                    Int32 num = Convert.ToInt32(txtcode.Text.Trim());
                    bool result = objEmp.validateEmpCode(num);
                    if (!result)
                    {
                        notFound.Visible = true;
                        notFound.Text = "Employee code not found! ";
                    }
                    else
                    {
                        //After the Business logic has searched the datasource it retrieve information
                        //for the corresponded employee code.
                        notFound.Visible = false;
                        objEmp.getEmployee(num);

                        txtname.Text = objEmp._Name;
                        txtdesi.Text = objEmp._Designation;
                        txtdept.Text = objEmp._deptName;
                        txtyears.Text = objEmp._yearsOfService.ToString();
                        
                    }
                    
                }
                else
                {
                    //retrieves an error message when the user has typed an employee code less or greater than 
                    //6 digits long.
                    notFound.Text = "Employee code should be 6 digits long without space and special characters.";
                    notFound.Visible = true;
                }
            }
            catch
            {
                //retrieve an error message when a user has typed letter in the employee code textbox
                //while doing a search operation
                notFound.Text = "Incorrect Employee Code! Please Use only Numeric values without space and special characters for employee code";
                txtcode.Focus();
            }

        }
        protected void btnFind_Click(object sender, EventArgs e)
        {
            txtdept.Text  = "";
            txtname.Text  = "";
            txtyears.Text = "";
            txtdesi.Text  = "";
            CsEmployee objEmp = new CsEmployee();

            try
            {
                if (txtcode.Text.Length == 6)
                {
                    Int32 num    = Convert.ToInt32(txtcode.Text.Trim());
                    bool  result = objEmp.validateEmpCode(num);
                    if (!result)
                    {
                        notFound.Visible = true;
                        notFound.Text    = "Employee code not found! ";
                    }
                    else
                    {
                        //After the Business logic has searched the datasource it retrieve information
                        //for the corresponded employee code.
                        notFound.Visible = false;
                        objEmp.getEmployee(num);

                        txtname.Text  = objEmp._Name;
                        txtdesi.Text  = objEmp._Designation;
                        txtdept.Text  = objEmp._deptName;
                        txtyears.Text = objEmp._yearsOfService.ToString();
                    }
                }
                else
                {
                    //retrieves an error message when the user has typed an employee code less or greater than
                    //6 digits long.
                    notFound.Text    = "Employee code should be 6 digits long without space and special characters.";
                    notFound.Visible = true;
                }
            }
            catch
            {
                //retrieve an error message when a user has typed letter in the employee code textbox
                //while doing a search operation
                notFound.Text = "Incorrect Employee Code! Please Use only Numeric values without space and special characters for employee code";
                txtcode.Focus();
            }
        }
        protected void btnFind_Click(object sender, EventArgs e)
        {
            CsEmployee objEmp = new CsEmployee();
            bool flag;
            try
            {
                Int32 _codeofEmp=Convert.ToInt32(txtcode.Text.Trim());
                flag = objEmp.validateEmpCode(_codeofEmp);
                if (flag)
                {
                    btnDelete.Enabled = true;
                    txtcode.Enabled = false;
                    objEmp.getEmployee(_codeofEmp);
                    notFound.Visible = false;
                    txtdept.Text = objEmp._deptName;
                    txtdesi.Text = objEmp._Designation; 
                    txtname.Text = objEmp._Name;
                    txtyears.Text = objEmp._yearsOfService.ToString();
                    txtdept.Enabled = false;
                    txtdesi.Enabled = false;
                    txtname.Enabled = false;
                    txtyears.Enabled = false;
                }
                else
                {
                    notFound.Text = "Employee code not found!";
                    notFound.Visible = true;
                    txtcode.Focus();
                }
            }
            catch
            {
                notFound.Text = "Please Use only Numeric values without space and special characters for employee code";
                txtcode.Focus();
            }
            


        }
        protected void btnFind_Click(object sender, EventArgs e)
        {
            CsEmployee objEmp = new CsEmployee();
            bool       flag;

            try
            {
                Int32 _codeofEmp = Convert.ToInt32(txtcode.Text.Trim());
                flag = objEmp.validateEmpCode(_codeofEmp);
                if (flag)
                {
                    btnDelete.Enabled = true;
                    txtcode.Enabled   = false;
                    objEmp.getEmployee(_codeofEmp);
                    notFound.Visible = false;
                    txtdept.Text     = objEmp._deptName;
                    txtdesi.Text     = objEmp._Designation;
                    txtname.Text     = objEmp._Name;
                    txtyears.Text    = objEmp._yearsOfService.ToString();
                    txtdept.Enabled  = false;
                    txtdesi.Enabled  = false;
                    txtname.Enabled  = false;
                    txtyears.Enabled = false;
                }
                else
                {
                    notFound.Text    = "Employee code not found!";
                    notFound.Visible = true;
                    txtcode.Focus();
                }
            }
            catch
            {
                notFound.Text = "Please Use only Numeric values without space and special characters for employee code";
                txtcode.Focus();
            }
        }
Esempio n. 6
0
        protected void btnFind_Click(object sender, EventArgs e)
        {
            
            CsEmployee emp = new CsEmployee();
            //The program find the previous information about the employee enable the update button
            //once the employee has been found the program display his/her information then allow
            //the user to make an update 
            #region "Find previous information about the employee"
            try
            {
                Int32 needeedCd = Convert.ToInt32(txtcode.Text);
                if (txtcode.Text.Length == 6)
                {
                    bool result = emp.validateEmpCode(needeedCd);
                    if (!result)
                    {
                        succes.Text = "Employee code not found! ";
                        btnUpdate.Enabled = false;
                        errorDeptDuplicated.Visible = false;
                        succes.Visible = true;
                    }
                    else
                    {
                        //call the the methode getEmployee with then class CsEmployee which retrieve information
                        //about the employee whose the code correspond to the one typed in the textbox employee code
                        errorDeptDuplicated.Visible = false;
                        succes.Visible = false;
                        emp.getEmployee(Convert.ToInt32(txtcode.Text));
                        txtname.Text = emp._Name;
                        txtdesi.Text = emp._Designation;
                        txtdept.Text = emp._deptName;
                        btnUpdate.Enabled = true;
                        txtcode.Enabled = false;
                       
                    }
                    
                }
                else
                {
                    //validate that the employee code typed by the user is 6 digits long
                    //otherwise it displays an appropriate error message to the user.
                    errorDeptDuplicated.Text = "Employee code should be 6 digits long without space and special characters.";
                    txtcode.Focus();
                    errorDeptDuplicated.Visible = true;
                    btnUpdate.Enabled = false;
                    succes.Visible = false;
                   
                }
            }
            catch
            {
                //verify that the user has typed only numeric values for thr employee code
                errorDeptDuplicated.Text = "Please Use only Numeric values without space and special characters for employee code";
                txtcode.Focus();
                errorDeptDuplicated.Visible = true;
                succes.Visible = false;

            }
            #endregion

        }