// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // public FlatSectionJlinerTDS.JuntionLiner2HistoryDataTable GetCommentsNew() { history = (FlatSectionJlinerTDS.JuntionLiner2HistoryDataTable)Session["historyDummy"]; if (history == null) { history = ((FlatSectionJlinerTDS.JuntionLiner2HistoryDataTable)Session["history"]); } return history; }
protected void AddHistoryNewEmptyFix(GridView grdComments) { if (grdHistory.Rows.Count == 0) { FlatSectionJlinerTDS.JuntionLiner2HistoryDataTable dt = new FlatSectionJlinerTDS.JuntionLiner2HistoryDataTable(); dt.AddJuntionLiner2HistoryRow(Guid.NewGuid(), -1, -1, -1, DateTime.Now, -1, "", false, false, false, ""); Session["historyDummy"] = dt; grdHistory.DataBind(); } // Normally executes at all postbacks if (grdHistory.Rows.Count == 1) { FlatSectionJlinerTDS.JuntionLiner2HistoryDataTable dt = (FlatSectionJlinerTDS.JuntionLiner2HistoryDataTable)Session["historyDummy"]; if (dt != null) { grdHistory.Rows[0].Visible = false; grdHistory.Rows[0].Controls.Clear(); } } }
// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!(Convert.ToBoolean(Session["sgLFS_APP_VIEW"]) && Convert.ToBoolean(Session["sgLFS_APP_EDIT"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } // Validate query string if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["client"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in flat_section_jliner_edit.aspx"); } // Tag page hdfCurrentClient.Value = (string)Request.QueryString["client"]; hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString(); hdfId.Value = Convert.ToString(Request.QueryString["rowId"]); hdfRefId.Value = Convert.ToString(Request.QueryString["rowRefId"]); hdfCompanyId.Value = Convert.ToString(Request.QueryString["rowCompanyId"]); hdfAdminPermission.Value = Convert.ToBoolean(Session["sgLFS_APP_ADMIN"]).ToString(); hdfUpdate.Value = "yes"; // Prepare initial data Session.Remove("historyDummy"); // ... Names for UserList int companyId = Int32.Parse(hdfCompanyId.Value); LoginGateway loginGateway = new LoginGateway(); loginGateway.LoadByLoginId(Convert.ToInt32(hdfLoginId.Value), companyId); hdfCreatedBy.Value = loginGateway.GetLastName(Convert.ToInt32(hdfLoginId.Value), companyId) + " " + loginGateway.GetFirstName(Convert.ToInt32(hdfLoginId.Value), companyId); hdfCreationDateTime.Value = DateTime.Now.ToString(); // If comming from // ... flat_section_jliner_summary.aspx if (Request.QueryString["source_page"] == "flat_section_jliner_summary.aspx" || Request.QueryString["source_page"] == "flat_section_jliner_edit.aspx") { StoreNavigatorState(); ViewState["update"] = Request.QueryString["update"]; Session["rowFocus"] = Convert.ToInt32(Request.QueryString["rowFocus"].ToString()); // ... Load history to edit sectionTDS = new SectionTDS(); flatSectionJlinerTDS = (FlatSectionJlinerTDS)Session["flatSectionJlinerTDS"]; SectionGateway sectionGateway = new SectionGateway(sectionTDS); sectionGateway.LoadById(new Guid(hdfId.Value), Convert.ToInt32(hdfCompanyId.Value)); JlinerGateway jlinerGateway = new JlinerGateway(sectionTDS); jlinerGateway.LoadByIdCompanyIdRefId(new Guid(hdfId.Value), Convert.ToInt32(hdfCompanyId.Value), Convert.ToInt32(hdfRefId.Value)); FlatSectionJlinerJuntionLiner2HistoryGateway flatSectionJlinerJuntionLiner2HistoryGateway = new FlatSectionJlinerJuntionLiner2HistoryGateway(flatSectionJlinerTDS); flatSectionJlinerJuntionLiner2HistoryGateway.LoadAllByIdRefId(new Guid(hdfId.Value), Convert.ToInt32(hdfRefId.Value), Convert.ToInt32(hdfCompanyId.Value)); FlatSectionJlinerJuntionLiner2History flatSectionJlinerJuntionLiner2History = new FlatSectionJlinerJuntionLiner2History(flatSectionJlinerJuntionLiner2HistoryGateway.Data); flatSectionJlinerJuntionLiner2History.UpdateForProcess(); // ... Load comments for transfers FlatSectionJlinerJuntionLiner2CommentGateway flatSectionJlinerJuntionLiner2CommentGateway = new FlatSectionJlinerJuntionLiner2CommentGateway(flatSectionJlinerTDS); flatSectionJlinerJuntionLiner2CommentGateway.LoadAllByIdRefId(new Guid(hdfId.Value), Convert.ToInt32(hdfRefId.Value), Convert.ToInt32(hdfCompanyId.Value)); // ... Store datasets Session["sectionTDS"] = sectionTDS; Session["flatSectionJlinerTDS"] = flatSectionJlinerTDS; history = flatSectionJlinerTDS.JuntionLiner2History; Session["history"] = history; } } else { // Restore datasets sectionTDS = (SectionTDS)Session["sectionTDS"]; flatSectionJlinerTDS = (FlatSectionJlinerTDS)Session["flatSectionJlinerTDS"]; Session["flatSectionJlinerTDS"] = flatSectionJlinerTDS; history = flatSectionJlinerTDS.JuntionLiner2History; Session["history"] = history; } }