private void Page_Load(object sender, System.EventArgs e) { try { OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); if (Request.QueryString["id"] == null) { Session["lastpage"] = "admin_users.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { UserId = Convert.ToInt32(Request.QueryString["id"]); } catch (FormatException fex) { Session["lastpage"] = "admin_users.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } Header.AddBreadCrumb("Home", "/selectMode.aspx"); Header.AddBreadCrumb("Administration", "/admin.aspx"); Header.AddBreadCrumb("User Search", "/admin_users.aspx"); Header.AddBreadCrumb("User Detail", "/admin_user_detail.aspx?id=" + UserId.ToString()); Header.AddBreadCrumb("User Detail Edit", "/admin_user_detail_edit.aspx?id=" + UserId.ToString()); this.PageTitle = "User Detail Activate"; Header.LeftBarHtml = "User Activating/Deactivating"; SaveCancelControl.ParentPageURL = this.ParentPageURL; if (!IsPostBack) { user = new clsUsers(); user.cAction = "S"; user.iOrgId = OrgId; user.iId = UserId; if (user.UserDetails() == -1) { Session["lastpage"] = "admin_user_detail.aspx?id=" + UserId.ToString(); Session["error"] = _functions.ErrorMessage(134); Response.Redirect("error.aspx", false); return; } lblFirstName.Text = user.sFirstName.Value; lblLastName.Text = user.sLastName.Value; lblEmail.Text = user.sEmail.Value; lblType.Text = user.sTypeName.Value; lblCreatedDate.Text = user.daCreated.Value.ToLongDateString() + " " + user.daCreated.Value.ToLongTimeString(); if (user.bActiveStatus.Value) { ViewState["Active"] = false; lblUserActivateStatus.Text = "Activated"; SaveCancelControl.ButtonText = "Deactivate"; user.iTypeId = (int)UserTypes.Operator; dtOperators = user.GetUserListByType(); ViewState["Operators"] = dtOperators; user.iTypeId = (int)UserTypes.Technician; dtTechnicians = user.GetUserListByType(); ViewState["Technicians"] = dtTechnicians; equip = new clsEquipment(); equip.iOrgId = OrgId; equip.iUserId = UserId; DataTable dtEquipOrders = equip.GetEquipListByOperatorActivate(); if (dtEquipOrders.Rows.Count > 0) { repOperatorEquipments.DataSource = new DataView(dtEquipOrders); repOperatorEquipments.DataBind(); } else { tblMain.Rows[8].Visible = false; tblMain.Rows[9].Visible = false; tblMain.Rows[10].Visible = false; } DataTable dtTechOrders = equip.GetOrderListByTechnicianActivate(); if (dtTechOrders.Rows.Count > 0) { repWorkOrders.DataSource = new DataView(dtTechOrders); repWorkOrders.DataBind(); } else { tblMain.Rows[11].Visible = false; tblMain.Rows[12].Visible = false; tblMain.Rows[13].Visible = false; } } else { ViewState["Active"] = true; lblUserActivateStatus.Text = "Deactivated"; SaveCancelControl.ButtonText = "Activate"; tblMain.Rows[8].Visible = false; tblMain.Rows[9].Visible = false; tblMain.Rows[10].Visible = false; tblMain.Rows[11].Visible = false; tblMain.Rows[12].Visible = false; tblMain.Rows[13].Visible = false; } } } catch (Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = "admin_user_detail_edit.aspx?id=" + UserId.ToString(); Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if (user != null) { user.Dispose(); } if (equip != null) { equip.Dispose(); } } }