示例#1
0
        private void populate_drp()
        {
            dropDept.Items.Clear();
            csDepartment obj = new csDepartment();

            dropDept.DataSource = obj.getDepartment();
            dropDept.DataBind();
        }
示例#2
0
 private void populate_drp()
 {
     dropDept.Items.Clear();
     csDepartment obj = new csDepartment();
     dropDept.DataSource = obj.getDepartment();
     dropDept.DataBind();
   
 }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            //This button is enabled only if the find button has been clicked and the employee code typed by the user
            //has been found in the database other wise it will remain disabled.
            CsEmployee emp = new CsEmployee();
            csDepartment test = new csDepartment();
            #region "verify that all textboxes have been completed"
            if (txtname.Text.Trim().Length < 1)
            {
                errorDeptDuplicated.Text = "Please Enter Correct name";
                errorDeptDuplicated.Visible = true;
                txtname.Focus();
                return; 
            }
            if (txtdesi.Text.Trim().Length < 1)
            {
                errorDeptDuplicated.Text = "Please Enter Correct designation";
                errorDeptDuplicated.Visible = true;
                txtdesi.Focus();
                return;
            }
            if (txtdept.Text.Trim().Length < 1)
            {
                errorDeptDuplicated.Text = "Please Enter Correct departement";
                errorDeptDuplicated.Visible = true;
                txtdept.Focus();
                return;
            }
            #endregion
            #region "Update employee information"
            //update information of the employee found when the button find was clicked
            try
            {
                Int32 emp_code = Convert.ToInt32(txtcode.Text);
                String xCodD = txtdept.Text.Trim().ToUpper();
                
                bool validated = test.validateDept(xCodD);
                if (!validated)
                {
                    errorDeptDuplicated.Visible = true;
                    errorDeptDuplicated.Text = "Invalid Department.Please eneter valid Department name \n[SALES, IT, FINANCE, MARKETING, PURCHASING] ";
                    succes.Visible = false;
                  
                }
                else
                {
                    String xName = txtname.Text.Trim();
                    String xDesi = txtdesi.Text.Trim();
                    
                    errorDeptDuplicated.Visible = false;
                    emp.Update(emp_code, xName, xDesi, xCodD);
                    succes.Text = "Information has been succesfully updated";
                    succes.Visible = true;
                    txtcode.Text = "";
                    txtdept.Text = "";
                    txtdesi.Text = "";
                    txtname.Text = "";
                    txtcode.Enabled = true;
                    txtcode.Focus();
                    btnUpdate.Enabled = false;
                    updateTimer();
                   
                }
            }
            catch
            {
                errorDeptDuplicated.Visible = true;
                errorDeptDuplicated.Text = "Incorrect Employee Number!";


            }
            #endregion

        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            //This button is enabled only if the find button has been clicked and the employee code typed by the user
            //has been found in the database other wise it will remain disabled.
            CsEmployee   emp  = new CsEmployee();
            csDepartment test = new csDepartment();

            #region "verify that all textboxes have been completed"
            if (txtname.Text.Trim().Length < 1)
            {
                errorDeptDuplicated.Text    = "Please Enter Correct name";
                errorDeptDuplicated.Visible = true;
                txtname.Focus();
                return;
            }
            if (txtdesi.Text.Trim().Length < 1)
            {
                errorDeptDuplicated.Text    = "Please Enter Correct designation";
                errorDeptDuplicated.Visible = true;
                txtdesi.Focus();
                return;
            }
            if (txtdept.Text.Trim().Length < 1)
            {
                errorDeptDuplicated.Text    = "Please Enter Correct departement";
                errorDeptDuplicated.Visible = true;
                txtdept.Focus();
                return;
            }
            #endregion
            #region "Update employee information"
            //update information of the employee found when the button find was clicked
            try
            {
                Int32  emp_code = Convert.ToInt32(txtcode.Text);
                String xCodD    = txtdept.Text.Trim().ToUpper();

                bool validated = test.validateDept(xCodD);
                if (!validated)
                {
                    errorDeptDuplicated.Visible = true;
                    errorDeptDuplicated.Text    = "Invalid Department.Please eneter valid Department name \n[SALES, IT, FINANCE, MARKETING, PURCHASING] ";
                    succes.Visible = false;
                }
                else
                {
                    String xName = txtname.Text.Trim();
                    String xDesi = txtdesi.Text.Trim();

                    errorDeptDuplicated.Visible = false;
                    emp.Update(emp_code, xName, xDesi, xCodD);
                    succes.Text     = "Information has been succesfully updated";
                    succes.Visible  = true;
                    txtcode.Text    = "";
                    txtdept.Text    = "";
                    txtdesi.Text    = "";
                    txtname.Text    = "";
                    txtcode.Enabled = true;
                    txtcode.Focus();
                    btnUpdate.Enabled = false;
                    updateTimer();
                }
            }
            catch
            {
                errorDeptDuplicated.Visible = true;
                errorDeptDuplicated.Text    = "Incorrect Employee Number!";
            }
            #endregion
        }