public List <IEmployeeBO> displayunitheadDB() { try { List <IEmployeeBO> list = new List <IEmployeeBO>(); string str = ConfigurationManager.ConnectionStrings["conn"].ConnectionString; SqlConnection conn = new SqlConnection(str); conn.Open(); SqlCommand command = new SqlCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "displayunithead"; command.Connection = conn; SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { int adminid = Convert.ToInt32(reader["AdministratorID"]); string bgcstatus = Convert.ToString(reader["bgcStatus"]); DateTime statuschangetime = Convert.ToDateTime(reader["StatusChangeTime"]); IEmployeeBO obj = EmployeeBOFactory.CreateEmployee(adminid, bgcstatus, statuschangetime); list.Add(obj); } return(list); } catch (Exception ex) { throw ex; } }
protected void BGCgrdview_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { GridViewRow row = BGCgrdview.Rows[e.RowIndex]; Label lbladminid2 = (Label)row.FindControl("lbladminid2"); DropDownList ddlstatus = (DropDownList)row.FindControl("ddlstatus"); Label lblStatusChangeTime2 = (Label)row.FindControl("lblStatusChangeTime2"); int adminid = Convert.ToInt32(lbladminid2.Text); string status = ddlstatus.SelectedValue; DateTime statuschangetime = DateTime.Now; IEmployeeBO objbo = EmployeeBOFactory.CreateEmployee(adminid, status, statuschangetime); IEmployeeBLL objbll = EmployeeFactoryBLL.createnew(); int check = objbll.displayapproved(objbo); if (check > 0) { BGCgrdview.EditIndex = -1; bgcdata(); } else { Response.Redirect("<script>alert('Employee details are not updated please update again')</script>"); } } catch (Exception ex) { Response.Write("<script>alert('Exception: " + ex.Message + "');</script>"); } }