public WorkViewTDS.WorkViewConditionNewDataTable GetConditionsNew() { workViewConditionNew = (WorkViewTDS.WorkViewConditionNewDataTable)Session["workViewConditionNewDummy"]; if (workViewConditionNew == null) { workViewConditionNew = (WorkViewTDS.WorkViewConditionNewDataTable)Session["workViewConditionNew"]; } return workViewConditionNew; }
protected void AddConditionsNewEmptyFix(GridView grdView) { if (grdView.Rows.Count == 0) { WorkViewTDS.WorkViewConditionNewDataTable dt = new WorkViewTDS.WorkViewConditionNewDataTable(); dt.AddWorkViewConditionNewRow(-1, -1, "", -1, "", "", -1, "", false, false); Session["workViewConditionNewDummy"] = dt; grdView.DataBind(); } // normally executes at all postbacks if (grdView.Rows.Count == 1) { WorkViewTDS.WorkViewConditionNewDataTable dt = (WorkViewTDS.WorkViewConditionNewDataTable)Session["workViewConditionNewDummy"]; if (dt != null) { grdView.Rows[0].Visible = false; grdView.Rows[0].Controls.Clear(); } } }
private void GrdConditionsAdd() { if (ValidateFooterAdd()) { Page.Validate("Conditions"); if (Page.IsValid) { int conditionId = int.Parse(((DropDownList)grdConditions.FooterRow.FindControl("ddlName")).SelectedValue); string name = ((DropDownList)grdConditions.FooterRow.FindControl("ddlName")).SelectedItem.Text; string operator_ = ((DropDownList)grdConditions.FooterRow.FindControl("ddlOperator")).SelectedItem.Text; string sign = ((DropDownList)grdConditions.FooterRow.FindControl("ddlOperator")).SelectedValue; int conditionNumber = int.Parse(((DropDownList)grdConditions.FooterRow.FindControl("ddlConditionNumber")).SelectedValue); WorkTypeViewConditionGateway workTypeViewConditionGateway = new WorkTypeViewConditionGateway(); workTypeViewConditionGateway.LoadByWorkTypeConditionId(hdfWorkType.Value, conditionId, int.Parse(hdfCompanyId.Value)); string type = workTypeViewConditionGateway.GetType(hdfWorkType.Value, int.Parse(hdfCompanyId.Value), conditionId); string value = ""; if ((type == "String") || (type == "Date") || (type == "Int") || (type == "Decimal") || (type == "Distance")) { value = ((TextBox)grdConditions.FooterRow.FindControl("tbxValue")).Text; } if ((type == "FixedItems") || (type == "DynamicItems")) { value = ((DropDownList)grdConditions.FooterRow.FindControl("ddlValue")).SelectedItem.Text; } if (type == "Boolean") { if (((RadioButton)grdConditions.FooterRow.FindControl("rbtnYes")).Checked) value = "Yes"; if (((RadioButton)grdConditions.FooterRow.FindControl("rbtnNo")).Checked) value = "No"; } WorkViewTDS dataSet = new WorkViewTDS(); dataSet.WorkViewConditionNew.Merge(workViewConditionNew, true); WorkViewConditionNew model = new WorkViewConditionNew(dataSet); model.Insert(conditionId, name, operator_, sign, conditionNumber, value, false, false); Session.Remove("workViewConditionNewDummy"); workViewConditionNew = dataSet.WorkViewConditionNew; Session["workViewConditionNew"] = dataSet.WorkViewConditionNew; grdConditions.DataBind(); grdConditions.PageIndex = grdConditions.PageCount - 1; } } }
// //////////////////////////////////////////////////////////////////////// // 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["work_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["work_type"] == "Rehab Assessment") { if (!(Convert.ToBoolean(Session["sgLFS_CWP_REHABASSESSMENT_VIEW"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } if ((string)Request.QueryString["work_type"] == "Full Length Lining") { if (!(Convert.ToBoolean(Session["sgLFS_CWP_FULLLENGTHLINING_VIEW"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } if ((string)Request.QueryString["work_type"] == "Junction Lining") { if (!(Convert.ToBoolean(Session["sgLFS_CWP_JUNCTIONLINING_VIEW"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } if ((string)Request.QueryString["work_type"] == "Point Repairs") { if (!(Convert.ToBoolean(Session["sgLFS_CWP_POINTREPAIRS_VIEW"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } if ((string)Request.QueryString["work_type"] == "Manhole Rehabilitation") { if (!(Convert.ToBoolean(Session["sgLFS_CWP_MANHOLEREHABILITATION_VIEW"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } } // Tag page hdfWorkType.Value = (string)Request.QueryString["work_type"]; hdfProjectId.Value = (string)Request.QueryString["project_id"]; hdfCompanyId.Value = Session["companyID"].ToString(); hdfUpdate.Value = "no"; ViewState["columnsToDisplayPageIndex"] = 0; ViewState["sortPageIndex"] = 0; Session.Remove("workTypeViewDisplay"); Session.Remove("workTypeViewDisplayDummy"); Session.Remove("workTypeViewSort"); Session.Remove("workTypeViewSortDummy"); Session.Remove("workViewDisplayTemp"); Session.Remove("workViewSortTemp"); Session.Remove("workViewConditionNew"); Session.Remove("workViewConditionNewDummy"); WorkViewGateway workViewGateway = new WorkViewGateway(); hdfViewId.Value = (workViewGateway.GetLastViewId()+1).ToString().Trim(); // Prepare initial data // ... For view type WorkViewTypeList workViewTypeList = new WorkViewTypeList(new DataSet()); workViewTypeList.LoadAndAddItem("(Select a type)", Int32.Parse(hdfCompanyId.Value)); ddlType.DataSource = workViewTypeList.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 // ... ra_navigator.aspx, ra_navigator2.aspx, fl_navigator.aspx, fl_navigator2.aspx, jl_navigator.aspx, jl_navigator2.aspx, pr_navigator.aspx or pr_navigator2.aspx , mr_navigator.aspx, mr_navigator2.aspx if ((Request.QueryString["source_page"] == "ra_navigator.aspx") || (Request.QueryString["source_page"] == "ra_navigator2.aspx") || (Request.QueryString["source_page"] == "fl_navigator.aspx") || (Request.QueryString["source_page"] == "fl_navigator2.aspx") || (Request.QueryString["source_page"] == "jl_navigator.aspx") || (Request.QueryString["source_page"] == "jl_navigator2.aspx") || (Request.QueryString["source_page"] == "pr_navigator.aspx") || (Request.QueryString["source_page"] == "pr_navigator2.aspx") || (Request.QueryString["source_page"] == "mr_navigator.aspx") || (Request.QueryString["source_page"] == "mr_navigator2.aspx")) { // ... For Grids workViewTDS = new WorkViewTDS(); workTypeViewDisplay = new WorkViewTDS.LFS_WORK_TYPE_VIEW_DISPLAYDataTable(); workTypeViewSort = new WorkViewTDS.LFS_WORK_TYPE_VIEW_SORTDataTable(); workViewDisplayTemp = new WorkViewTDS.WorkViewDisplayTempDataTable(); workViewSortTemp = new WorkViewTDS.WorkViewSortTempDataTable(); workViewConditionNew = new WorkViewTDS.WorkViewConditionNewDataTable(); // ... Store datasets Session["workViewTDS"] = workViewTDS; Session["workTypeViewDisplay"] = workTypeViewDisplay; Session["workTypeViewSort"] = workTypeViewSort; Session["workViewDisplayTemp"] = workViewDisplayTemp; Session["workViewSortTemp"] = workViewSortTemp; Session["workViewConditionNew"] = workViewConditionNew; } // StepSection1In wzViews.ActiveStepIndex = 0; StepBeginIn(); } else { // Restore datasets workViewTDS = (WorkViewTDS)Session["workViewTDS"]; workTypeViewDisplay = (WorkViewTDS.LFS_WORK_TYPE_VIEW_DISPLAYDataTable)Session["workTypeViewDisplay"]; workTypeViewSort = (WorkViewTDS.LFS_WORK_TYPE_VIEW_SORTDataTable)Session["workTypeViewSort"]; workViewDisplayTemp = (WorkViewTDS.WorkViewDisplayTempDataTable)Session["workViewDisplayTemp"]; workViewSortTemp = (WorkViewTDS.WorkViewSortTempDataTable)Session["workViewSortTemp"]; workViewConditionNew = (WorkViewTDS.WorkViewConditionNewDataTable)Session["workViewConditionNew"]; } // control for postback hdfTag.Value = DateTime.Now.ToLongTimeString(); }
protected void grdConditions_RowUpdating(object sender, GridViewUpdateEventArgs e) { Page.Validate("ConditionsUpdate"); if (Page.IsValid) { int id = (int)e.Keys["ID"]; int conditionId = int.Parse(((DropDownList)grdConditions.Rows[e.RowIndex].Cells[3].FindControl("ddlName")).SelectedValue); string name = ((DropDownList)grdConditions.Rows[e.RowIndex].Cells[3].FindControl("ddlName")).SelectedItem.Text; DropDownList ddlOperator = ((DropDownList)grdConditions.Rows[grdConditions.EditIndex].FindControl("ddlOperator")); string operator_ = ddlOperator.SelectedItem.Text; string sign = ddlOperator.SelectedValue; int conditionNumber = int.Parse(((DropDownList)grdConditions.Rows[e.RowIndex].Cells[2].FindControl("ddlConditionNumber")).SelectedValue); WorkTypeViewConditionGateway workTypeViewConditionGateway = new WorkTypeViewConditionGateway(); workTypeViewConditionGateway.LoadByWorkTypeConditionId(hdfWorkType.Value, conditionId, int.Parse(hdfCompanyId.Value)); string type = workTypeViewConditionGateway.GetType(hdfWorkType.Value, int.Parse(hdfCompanyId.Value), conditionId); string value = ""; if ((type == "String") || (type == "Date") || (type == "Int") || (type == "Decimal") || (type == "Distance")) { value = ((TextBox)grdConditions.Rows[e.RowIndex].Cells[5].FindControl("tbxValue")).Text; } if ((type == "FixedItems") || (type == "DynamicItems")) { value = ((DropDownList)grdConditions.Rows[e.RowIndex].Cells[5].FindControl("ddlValue")).SelectedItem.Text; } if (type == "Boolean") { if (((RadioButton)grdConditions.Rows[e.RowIndex].Cells[5].FindControl("rbtnYes")).Checked) value = "Yes"; if (((RadioButton)grdConditions.Rows[e.RowIndex].Cells[5].FindControl("rbtnNo")).Checked) value = "No"; } WorkViewTDS dataSet = new WorkViewTDS(); dataSet.WorkViewConditionNew.Merge(workViewConditionNew, true); WorkViewConditionNew model = new WorkViewConditionNew(dataSet); model.Update(id, conditionId, name, operator_, sign, conditionNumber, value, false, false); Session["workViewConditionNew"] = dataSet.WorkViewConditionNew; workViewConditionNew = dataSet.WorkViewConditionNew; } else { e.Cancel = true; } }
private bool StepColumnsToDisplayNext() { ViewState["columnsToDisplayPageIndex"] = grdColumnsToDisplay.PageIndex; Page.Validate("ColumsToDisplay"); if (Page.IsValid) { hdfStep.Value = "StepColumnsToDisplay"; StepColumnsToDisplayProcessGrid(); workViewDisplayTemp.Rows.Clear(); // create dataset WorkViewTDS dataSet = new WorkViewTDS(); dataSet.LFS_WORK_TYPE_VIEW_DISPLAY.Merge(workTypeViewDisplay, true); dataSet.WorkViewDisplayTemp.Merge(workViewDisplayTemp, true); // process WorkViewDisplayTemp model = new WorkViewDisplayTemp(dataSet); model.ProcessForEdit(int.Parse(hdfViewId.Value), hdfWorkType.Value, int.Parse(hdfCompanyId.Value)); // get changes workViewDisplayTemp.Rows.Clear(); workViewDisplayTemp.Merge(model.Table); // store tables Session.Remove("workTypeViewDisplayDummy"); Session["workTypeViewDisplay"] = workTypeViewDisplay; Session["workViewDisplayTemp"] = workViewDisplayTemp; // load conditions for next step dataSet.WorkViewConditionNew.Merge(workViewConditionNew, true); dataSet.WorkViewConditionTemp.Merge(workViewConditionTemp, true); WorkViewConditionNew modelConditionNew = new WorkViewConditionNew(dataSet); modelConditionNew.LoadByViewIdCompanyIdWorkType(int.Parse(hdfViewId.Value), int.Parse(hdfCompanyId.Value), hdfWorkType.Value); // Store tables workViewConditionNew = (WorkViewTDS.WorkViewConditionNewDataTable)modelConditionNew.Table; Session["workViewConditionNew"] = workViewConditionNew; return true; } else { return false; } }