Exemplo n.º 1
0
        /// <summary>
        /// Function will update the new role allocated to the selected employee id in the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUP_Click(object sender, EventArgs e)
        {
            //IEmployee objEmployee = EmployeeBOFactory.CreateEmployeeObject();
            IAdminBLL        objBLL   = AdminBLLFactory.CreateAdminBLLObject();
            ILogin           objLogin = LoginBOFactory.CreateLoginObject();
            List <IEmployee> lstEmp   = new List <IEmployee>();

            try
            {
                bool isNotSelected = false;
                for (int i = 0; i < gvshowItems.Rows.Count; i++)
                {
                    GridViewRow gvEmployeeRow = gvshowItems.Rows[i];

                    IEmployee objEmployee = EmployeeBOFactory.CreateEmployeeObject();
                    objEmployee.EmployeeId = Convert.ToInt32(gvEmployeeRow.Cells[0].Text);
                    //objEmployee.FirstName = (gvEmployeeRow.Cells[2].Text);
                    //objEmployee.LastName = (gvEmployeeRow.Cells[3].Text);

                    objEmployee.RoleId = Convert.ToInt32(((DropDownList)gvEmployeeRow.FindControl("ddlNewRole")).SelectedItem.Value);
                    //objEmployee.MobileNumber = Convert.ToInt64(gvEmployeeRow.Cells[5].Text);
                    if (objEmployee.RoleId == 10 || objEmployee.RoleId == 11 || objEmployee.RoleId == 12 || objEmployee.RoleId == 13)
                    {
                        lstEmp.Add(objEmployee);
                    }
                }
                //objEmployee.RoleId =Convert.ToInt32(ddlNewRole.SelectedValue);

                bool IsUpdated = false;
                if (!isNotSelected)
                {
                    IsUpdated = objBLL.UpdateEmployeeDetails(lstEmp);
                }
                if (IsUpdated)
                {
                    lblMessage.Text = "Employee details Updated successfully.";
                }
                else
                {
                    lblMessage.Text = "An error occurred while updating Employee details";
                }
            }
            catch (Exception ex)
            {
                lblMessage.Text = "An error occurred while updating Employee details";
            }
            finally
            {
                objBLL = null;
            }
        }