/// <summary> /// SaveForEdit /// </summary> /// <param name="viewId">viewId</param> /// <param name="loginId">loginId</param> /// <param name="name">name</param> /// <param name="type">type</param> /// <param name="logic">logic</param> /// <param name="sqlCommand">sqlCommand</param> /// <param name="workType">workType</param> /// <param name="companyId">companyId</param> public void SaveForEdit(int viewId, int loginId, string name, string type, string logic, string sqlCommand, string workType, int companyId, string newName, string newType) { WorkViewGateway workViewGateway = new WorkViewGateway(); workViewGateway.LoadByViewId(viewId, companyId); int originalViewId = viewId; int originalLoginId = workViewGateway.GetLoginId(viewId); string originalName = workViewGateway.GetName(viewId); string originalType = workViewGateway.GetType(viewId); string originalLogic = workViewGateway.GetLogic(viewId); string originalSqlCommand = workViewGateway.GetSqlCommand(viewId); string originalWorkType = workViewGateway.GetWorkType(viewId); bool originalDeleted = workViewGateway.GetDeleted(viewId); int originalCompanyId = workViewGateway.GetCompanyId(viewId); UpdateDirect(originalViewId, originalLoginId, originalName, originalType, originalLogic, originalSqlCommand, originalWorkType, originalDeleted, originalCompanyId, viewId, loginId, newName, newType, logic, sqlCommand, workType, false, companyId); }
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; } }