private void Save() { // Process view FmViewTDS dataset = new FmViewTDS(); dataset.FmViewDisplayTemp.Merge(fmViewDisplayTemp, true); dataset.FmViewConditionNew.Merge(fmViewConditionNew, true); dataset.FmViewSortTemp.Merge(fmViewSortTemp, true); FmViewDisplayTemp modelFmViewDisplayTemp = new FmViewDisplayTemp(dataset); FmViewConditionNew modelFmViewConditionNew = new FmViewConditionNew(dataset); FmViewSortTemp modelFmViewSortTemp = new FmViewSortTemp(dataset); // Get parameters int viewId = int.Parse(hdfViewId.Value); int companyId = int.Parse(hdfCompanyId.Value); int loginId = Convert.ToInt32(Session["loginID"]); string name = tbxName.Text; string type = ddlType.SelectedValue; string logic = tbxLogic.Text; string sqlCommand = GetSqlCommand(); string fmType = hdfFmType.Value; if (!(Convert.ToBoolean(Session["sgLFS_VIEWS_ADD"])) && ((string)Request.QueryString["fm_type"] == "Services")) { if ((Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_VIEW"])) && ((string)Request.QueryString["fm_type"] == "Services")) { type = "Personal"; } } if (!(Convert.ToBoolean(Session["sgLFS_VIEWS_ADD"])) && ((string)Request.QueryString["fm_type"] == "Units")) { if ((Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_UNITS_VIEW"])) && ((string)Request.QueryString["fm_type"] == "Units")) { type = "Personal"; } } // Save to database DB.Open(); DB.BeginTransaction(); try { FmView fmView = new FmView(null); fmView.InsertDirect(viewId, loginId, name, type, logic, sqlCommand, fmType, false, companyId); modelFmViewDisplayTemp.Save(); modelFmViewConditionNew.Save(viewId, companyId, fmType); modelFmViewSortTemp.Save(viewId, fmType, companyId); DB.CommitTransaction(); } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }
// ///////////////////////////////////////////////////////////////////////////////////////////////////// // // STEP6 - SUMMARY // // //////////////////////////////////////////////////////////////////////// // STEP6 - SUMMARY - METHODS // private void StepSummaryIn() { // Set instruction Label instruction = (Label)this.Master.FindControl("lblInstruction"); instruction.Text = "Summary"; // Tag Page hdfStep.Value = "StepSummary"; hdfUpdate.Value = "yes"; // Initialize summary FmView fmView = new FmView(fmViewTDS); // Process view FmViewTDS dataset = new FmViewTDS(); dataset.FmViewDisplayTemp.Merge(fmViewDisplayTemp, true); dataset.FmViewConditionNew.Merge(fmViewConditionNew, true); dataset.FmViewSortTemp.Merge(fmViewSortTemp, true); FmViewDisplayTemp modelFmViewDisplayTemp = new FmViewDisplayTemp(dataset); FmViewConditionNew modelFmViewConditionNew = new FmViewConditionNew(dataset); FmViewSortTemp modelFmViewSortTemp = new FmViewSortTemp(dataset); string summary = ""; summary = summary + "Name: " + tbxName.Text + "\n\n"; summary = summary + "Columns To Display; " + modelFmViewDisplayTemp.GetColumnsToDisplay() + "\n\n"; summary = summary + "Conditions: " + modelFmViewConditionNew.GetConditionsForSummary(hdfFmType.Value, int.Parse(hdfCompanyId.Value)) + "\n\n"; summary = summary + "Logical Expression: " + tbxLogic.Text + "\n\n"; summary = summary + "Order by: " + modelFmViewSortTemp.GetSortForSummary() + "\n\n"; tbxSummary.Text = summary; }
private void UpdateDatabaseForViews() { int viewId = Int32.Parse(ddlView.SelectedValue.Trim()); int companyId = Int32.Parse(hdfCompanyId.Value.Trim()); DB.Open(); DB.BeginTransaction(); try { FmView fmView = new FmView(null); fmView.DeleteDirect(viewId, companyId); DB.CommitTransaction(); } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }