protected void Page_Load(object sender, EventArgs e) { string office_id = Request.QueryString["office_id"]; if (!string.IsNullOrEmpty(office_id)) { OfficeID = Convert.ToInt32(office_id); } else if (OfficeID == 0) { Response.Redirect(Config.SIMSURL + "SIMSWSCHome.aspx"); } WSCID = Convert.ToInt32(db.Offices.FirstOrDefault(p => p.office_id == OfficeID).wsc_id); currWSC = db.WSCs.FirstOrDefault(p => p.wsc_id == WSCID); ph1.Title = "Initial Site Registration"; ph1.SubTitle = currWSC.wsc_nm + " Water Science Center"; ph1.ShowOfficeInfoPanel = true; //If the user belongs to this site's WSC (or has an exception to work in the WSC), or is a SuperUser, then allow them to edit the page if (user.WSCID.Contains(WSCID) && user.IsAdmin || user.IsSuperUser) { HasEditAccess = true; } if (!Page.IsPostBack) { InitialPageSetup(); } }
/// <summary> /// Set up our environment based on current session or query string info. /// </summary> /// <param name="context"></param> private void Setup(HttpContext context) { if (context.Request.QueryString[type_qs] != null) { type = context.Request.QueryString[type_qs]; } if (context.Request.QueryString[wsc_cd_qs] != null) { wsc_cd = context.Request.QueryString[wsc_cd_qs]; } if (context.Request.QueryString[office_id_qs] != null) { office_id = Convert.ToInt32(context.Request.QueryString[office_id_qs]); } if (context.Request.QueryString[office_cd_qs] != null) { office_cd = context.Request.QueryString[office_cd_qs]; } if (office_id > 0) { office = db.Offices.FirstOrDefault(p => p.office_id == office_id); } else if (!string.IsNullOrEmpty(office_cd)) { office = db.Offices.FirstOrDefault(p => p.office_cd == office_cd); } else if (!string.IsNullOrEmpty(wsc_cd)) { wsc = db.WSCs.FirstOrDefault(p => p.wsc_cd == wsc_cd); } }
protected void Page_Load(object sender, EventArgs e) { string office_id = Request.QueryString["office_id"]; if (!string.IsNullOrEmpty(office_id)) { OfficeID = Convert.ToInt32(office_id); } else if (OfficeID == 0) { Response.Redirect(Config.SIMSURL + "SIMSWSCHome.aspx"); } WSCID = Convert.ToInt32(db.Offices.FirstOrDefault(p => p.office_id == OfficeID).wsc_id); currWSC = db.WSCs.FirstOrDefault(p => p.wsc_id == WSCID); ph1.Title = "Manage Personnel"; ph1.SubTitle = currWSC.wsc_nm + " Water Science Center"; ph1.ShowOfficeInfoPanel = true; if (!Page.IsPostBack) { //If the user belongs to this site's WSC (or has an exception to work in the WSC), or is a SuperUser, then allow them to edit the page if (user.WSCID.Contains(WSCID) && user.IsAdmin || user.IsSuperUser) { HasEditAccess = true; } if (!HasEditAccess) { pnlNoAccess.Visible = true; pnlHasAccess.Visible = false; } else { pnlNoAccess.Visible = false; pnlHasAccess.Visible = true; if (!user.IsAdmin && !user.IsSuperUser) { Session["CanEdit"] = "false"; rgPersonnel.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None; } else { Session["CanEdit"] = "true"; } } Session["ShowActiveOnly"] = "True"; if (Session["ShowActiveOnly"].ToString() == "False") { Session["ShowActiveOnly"] = "False"; lbToggleActive.Text = "Click to view only active users"; lbToggleActive.CommandArgument = "ActiveOnly"; } else if (Session["ShowActiveOnly"].ToString() == "True") { Session["ShowActiveOnly"] = "True"; lbToggleActive.Text = "Click to view all users"; lbToggleActive.CommandArgument = "ShowAll"; } } }