// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Validate query string if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["fm_type"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in view_add.aspx"); } // Security check if (!(Convert.ToBoolean(Session["sgLFS_VIEWS_ADD"]))) { if ((string)Request.QueryString["fm_type"] == "Services") { if (!(Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_VIEW"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } if ((string)Request.QueryString["fm_type"] == "Units") { if (!(Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_UNITS_VIEW"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } } // Tag page hdfFmType.Value = (string)Request.QueryString["fm_type"]; hdfCompanyId.Value = Session["companyID"].ToString(); hdfUpdate.Value = "no"; ViewState["columnsToDisplayPageIndex"] = 0; ViewState["sortPageIndex"] = 0; Session.Remove("fmTypeViewDisplay"); Session.Remove("fmTypeViewDisplayDummy"); Session.Remove("fmTypeViewSort"); Session.Remove("fmTypeViewSortDummy"); Session.Remove("fmViewDisplayTemp"); Session.Remove("fmViewSortTemp"); Session.Remove("fmViewConditionNew"); Session.Remove("fmViewConditionNewDummy"); Session.Remove("categoriesTDSForAddView"); FmViewGateway fmViewGateway = new FmViewGateway(); hdfViewId.Value = (fmViewGateway.GetLastViewId() + 1).ToString().Trim(); // Prepare initial data // ... For view type FmViewTypeList fmViewTypeList = new FmViewTypeList(new DataSet()); fmViewTypeList.LoadAndAddItem("(Select a type)", Int32.Parse(hdfCompanyId.Value)); ddlType.DataSource = fmViewTypeList.Table; ddlType.DataValueField = "Type"; ddlType.DataTextField = "Type"; ddlType.DataBind(); ddlType.SelectedIndex = 0; // ... Global Views check if (!Convert.ToBoolean(Session["sgLFS_GLOBALVIEWS_ADD"])) { ddlType.Items.Remove("Global"); } // If coming from // ... services_navigator.aspx, services_navigator2.aspx, units_navigator.aspx or units_navigator2.aspx if ((Request.QueryString["source_page"] == "services_navigator.aspx") || (Request.QueryString["source_page"] == "services_navigator2.aspx") || (Request.QueryString["source_page"] == "units_navigator.aspx") || (Request.QueryString["source_page"] == "unit_navigator2.aspx")) { // ... For Grids fmViewTDS = new FmViewTDS(); fmTypeViewDisplay = new FmViewTDS.LFS_FM_TYPE_VIEW_DISPLAYDataTable(); fmTypeViewSort = new FmViewTDS.LFS_FM_TYPE_VIEW_SORTDataTable(); fmViewDisplayTemp = new FmViewTDS.FmViewDisplayTempDataTable(); fmViewSortTemp = new FmViewTDS.FmViewSortTempDataTable(); fmViewConditionNew = new FmViewTDS.FmViewConditionNewDataTable(); // ... for Categories categoriesTDS = new CategoriesTDS(); // ... Store datasets Session["fmViewTDS"] = fmViewTDS; Session["fmTypeViewDisplay"] = fmTypeViewDisplay; Session["fmTypeViewSort"] = fmTypeViewSort; Session["fmViewDisplayTemp"] = fmViewDisplayTemp; Session["fmViewSortTemp"] = fmViewSortTemp; Session["fmViewConditionNew"] = fmViewConditionNew; Session["categoriesTDSForAddView"] = categoriesTDS; } // StepSection1In wzViews.ActiveStepIndex = 0; StepBeginIn(); } else { // Restore datasets fmViewTDS = (FmViewTDS)Session["fmViewTDS"]; fmTypeViewDisplay = (FmViewTDS.LFS_FM_TYPE_VIEW_DISPLAYDataTable)Session["fmTypeViewDisplay"]; fmTypeViewSort = (FmViewTDS.LFS_FM_TYPE_VIEW_SORTDataTable)Session["fmTypeViewSort"]; fmViewDisplayTemp = (FmViewTDS.FmViewDisplayTempDataTable)Session["fmViewDisplayTemp"]; fmViewSortTemp = (FmViewTDS.FmViewSortTempDataTable)Session["fmViewSortTemp"]; fmViewConditionNew = (FmViewTDS.FmViewConditionNewDataTable)Session["fmViewConditionNew"]; categoriesTDS = (CategoriesTDS)Session["categoriesTDSForAddView"]; } // Control for postback hdfTag.Value = DateTime.Now.ToLongTimeString(); }