private bool StepConditionsNext() { // Validate data bool validData = true; // Edit if there is data to save Page.Validate("ConditionsUpdate"); if (!Page.IsValid) validData = false; if (validData) { // Conditions Gridview, if the gridview is edition mode if (grdConditions.EditIndex >= 0) { grdConditions.UpdateRow(grdConditions.EditIndex, true); grdConditions.DataBind(); } } Page.Validate("ConditionsNext"); if (!Page.IsValid) validData = false; if (validData) { // Add conditions if exists at footer if (ValidateFooterNext()) { GrdConditionsAdd(); } // create dataset WorkViewTDS dataSet = new WorkViewTDS(); dataSet.WorkViewConditionNew.Merge(workViewConditionNew, true); // process new conditions WorkViewConditionNew model = new WorkViewConditionNew(dataSet); tbxLogic.Text = model.GetConditionsByDefault(); // get changes workViewConditionNew.Rows.Clear(); workViewConditionNew.Merge(model.Table); // store tables Session.Remove("workViewConditionNewDummy"); Session["workViewConditionNew"] = workViewConditionNew; hdfStep.Value = "StepConditions"; return true; } else { return false; } }
private bool StepConditionsNext() { // Validate data bool validData = true; // Edit if there is data to save Page.Validate("ConditionsUpdate"); if (!Page.IsValid) validData = false; if (validData) { // Conditions Gridview, if the gridview is edition mode if (grdConditions.EditIndex >= 0) { grdConditions.UpdateRow(grdConditions.EditIndex, true); grdConditions.DataBind(); } } Page.Validate("ConditionsNext"); if (!Page.IsValid) validData = false; if (validData) { // Add conditions if exists at footer if (ValidateFooterNext()) { GrdConditionsAdd(); } WorkViewGateway workViewGateway = new WorkViewGateway(); workViewGateway.LoadByViewId(int.Parse(hdfViewId.Value), int.Parse(hdfCompanyId.Value)); workViewConditionTemp.Rows.Clear(); // create dataset WorkViewTDS dataSet = new WorkViewTDS(); dataSet.WorkViewConditionNew.Merge(workViewConditionNew, true); dataSet.WorkViewConditionTemp.Merge(workViewConditionTemp, true); // process conditions WorkViewConditionTemp model = new WorkViewConditionTemp(dataSet); WorkViewConditionNew modelLogic = new WorkViewConditionNew(dataSet); string originalLogic = workViewGateway.GetLogic(int.Parse(hdfViewId.Value)); string newLogic = modelLogic.GetConditionsByDefault(); ArrayList aConditions = new ArrayList(); aConditions = modelLogic.GetConditions(); bool isConditionsUpdate = false; if (originalLogic.Trim() != newLogic.Trim()) { foreach (string conditionNumber in aConditions) { if (!originalLogic.Contains(conditionNumber)) { isConditionsUpdate = true; } } if (!isConditionsUpdate) { if (Session["conditionsUpdate"] != null) { if (Session["conditionsUpdate"].ToString() == "true") { isConditionsUpdate = true; } } } } else { tbxLogic.Text = originalLogic.Trim(); } if (isConditionsUpdate) { tbxLogic.Text = newLogic.Trim(); } else { tbxLogic.Text = originalLogic.Trim(); } // get changes workViewConditionNew.Rows.Clear(); workViewConditionNew.Merge(modelLogic.Table); workViewConditionTemp.Rows.Clear(); workViewConditionTemp.Merge(model.Table); //// store tables Session.Remove("workViewConditionNewDummy"); Session.Remove("workViewConditionTempDummy"); Session["workViewConditionNew"] = workViewConditionNew; Session["workViewConditionTemp"] = workViewConditionTemp; Session["conditionsUpdate"] = null; return true; } else { return false; } }