// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!(Convert.ToBoolean(Session["sgLFS_PROJECTS_REVENUE_VIEW"]) && Convert.ToBoolean(Session["sgLFS_PROJECTS_REVENUE_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["project_id"] == null) || ((string)Request.QueryString["ref_id"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in revenue_summary.aspx"); } // Tag Page hdfCompanyId.Value = Session["companyID"].ToString(); hdfCurrentProjectId.Value = Request.QueryString["project_id"]; hdfCurrentRefId.Value = Request.QueryString["ref_id"]; // If coming from int companyId = Int32.Parse(hdfCompanyId.Value.Trim()); int projectId = Int32.Parse(hdfCurrentProjectId.Value); int refId = Int32.Parse(hdfCurrentRefId.Value); // ... revenue_navigator2.aspx, revenue_add.aspx if ((Request.QueryString["source_page"] == "revenue_navigator2.aspx") || (Request.QueryString["source_page"] == "revenue_add.aspx")) { StoreNavigatorState(); ViewState["update"] = "yes"; // ... ... Set initial tab revenueInformationTDS = new RevenueInformationTDS(); RevenueInformationBasicInformation revenueInformationBasicInformationForEdit = new RevenueInformationBasicInformation(revenueInformationTDS); revenueInformationBasicInformationForEdit.LoadByProjectIdRefId(projectId, refId, companyId); // Store dataset Session["revenueInformationTDS"] = revenueInformationTDS; } // ... revenue_delete.aspx or revenue_edit.aspx if ((Request.QueryString["source_page"] == "revenue_delete.aspx") || (Request.QueryString["source_page"] == "revenue_edit.aspx")) { StoreNavigatorState(); ViewState["update"] = Request.QueryString["update"]; // Restore dataset revenueInformationTDS = (RevenueInformationTDS)Session["revenueInformationTDS"]; } // ... Data for current revenue LoadData(); // Databind Page.DataBind(); } else { // Restore datasets revenueInformationTDS = (RevenueInformationTDS)Session["revenueInformationTDS"]; } }
// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!(Convert.ToBoolean(Session["sgLFS_PROJECTS_REVENUE_VIEW"]) && Convert.ToBoolean(Session["sgLFS_PROJECTS_REVENUE_DELETE"]))) { 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["project_id"] == null) || ((string)Request.QueryString["ref_id"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in revenue_delete.aspx"); } // Tag page hdfCompanyId.Value = Session["companyID"].ToString(); hdfCurrentProjectId.Value = Request.QueryString["project_id"]; hdfCurrentRefId.Value = Request.QueryString["ref_id"]; // ... for team member title int companyId = Int32.Parse(hdfCompanyId.Value.Trim()); int projectId = Int32.Parse(hdfCurrentProjectId.Value); int refId = Int32.Parse(hdfCurrentRefId.Value); RevenueInformationBasicInformationGateway revenueInformationBasicInformationGatewayForTitle = new RevenueInformationBasicInformationGateway(); revenueInformationBasicInformationGatewayForTitle.LoadByProjectIdRefId(projectId, refId, companyId); decimal revenue = decimal.Round(revenueInformationBasicInformationGatewayForTitle.GetRevenue(projectId, refId), 2); string money = ""; if (revenueInformationBasicInformationGatewayForTitle.GetCountryId(projectId, refId) == 1) // Canada { money = " (CAD)"; } else { money = " (USD)"; } lblTitleRevenue.Text = "Revenue: " + revenue + money + " (" + revenueInformationBasicInformationGatewayForTitle.GetDate(projectId, refId).ToShortDateString() + ")"; // If coming from // ... revenue_navigator2.aspx if (Request.QueryString["source_page"] == "revenue_navigator2.aspx") { revenueInformationTDS = new RevenueInformationTDS(); RevenueInformationBasicInformation revenueInformationBasicInformationForEdit = new RevenueInformationBasicInformation(revenueInformationTDS); revenueInformationBasicInformationForEdit.LoadByProjectIdRefId(projectId, refId, companyId); StoreNavigatorState(); ViewState["update"] = "no"; // Store dataset Session["revenueInformationTDS"] = revenueInformationTDS; } // ... revenue_summary.aspx if (Request.QueryString["source_page"] == "revenue_summary.aspx") { StoreNavigatorState(); ViewState["update"] = Request.QueryString["update"]; // Restore dataset revenueInformationTDS = (RevenueInformationTDS)Session["revenueInformationTDS"]; } } else { // Restore dataset revenueInformationTDS = (RevenueInformationTDS)Session["revenueInformationTDS"]; } }
private void Delete() { int projectId = int.Parse(hdfCurrentProjectId.Value); int refId = int.Parse(hdfCurrentRefId.Value); RevenueInformationBasicInformation revenueInformationBasicInformation = new RevenueInformationBasicInformation(revenueInformationTDS); revenueInformationBasicInformation.Delete(projectId, refId); // Store datasets Session["revenueInformationTDS"] = revenueInformationTDS; }
private void UpdateDatabase() { int companyId = Int32.Parse(hdfCompanyId.Value); DB.Open(); DB.BeginTransaction(); try { // Save revenue information RevenueInformationBasicInformation revenueInformationBasicInformation = new RevenueInformationBasicInformation(revenueInformationTDS); revenueInformationBasicInformation.Save(companyId); DB.CommitTransaction(); // Store datasets revenueInformationTDS.AcceptChanges(); Session["revenueInformationTDS"] = revenueInformationTDS; } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }
private void Save() { Page.Validate(); if (Page.IsValid) { // Save data int companyId = Int32.Parse(hdfCompanyId.Value); int projectId = Int32.Parse(hdfCurrentProjectId.Value); int refId = Int32.Parse(hdfCurrentRefId.Value); // ... Get basic revenue data DateTime newDate = (DateTime)tkrdpDate.SelectedDate; decimal newRevenue = decimal.Round(decimal.Parse(tbxRevenue.Text.Trim()),2); string newComment = tbxComments.Text.Trim(); // Update basic information data RevenueInformationBasicInformation revenueInformationBasicInformation = new RevenueInformationBasicInformation(revenueInformationTDS); revenueInformationBasicInformation.Update(projectId, refId, newDate, newRevenue, newComment); // Store datasets Session["revenueInformationTDS"] = revenueInformationTDS; // Update database UpdateDatabase(); ViewState["update"] = "yes"; // Redirect string url = ""; if (Request.QueryString["source_page"] == "revenue_navigator2.aspx" ) { url = "./revenue_navigator2.aspx?source_page=revenue_edit.aspx&project_id=" + "&ref_id=" + refId + hdfCurrentProjectId.Value + GetNavigatorState() + "&update=yes"; } if (Request.QueryString["source_page"] == "revenue_summary.aspx") { url = "./revenue_summary.aspx?source_page=revenue_edit.aspx&project_id=" + hdfCurrentProjectId.Value + "&ref_id=" + refId + GetNavigatorState() + "&update=yes"; } Response.Redirect(url); } }
private void Apply() { Page.Validate(); if (Page.IsValid) { // Save data int companyId = Int32.Parse(hdfCompanyId.Value); int projectId = Int32.Parse(hdfCurrentProjectId.Value); int refId = Int32.Parse(hdfCurrentRefId.Value); // ... Get basic revenue data DateTime newDate = (DateTime)tkrdpDate.SelectedDate; decimal newRevenue = decimal.Round(decimal.Parse(tbxRevenue.Text.Trim()), 2); string newComment = tbxComments.Text.Trim(); // Update service data RevenueInformationBasicInformation revenueInformationBasicInformation = new RevenueInformationBasicInformation(revenueInformationTDS); revenueInformationBasicInformation.Update(projectId, refId, newDate, newRevenue, newComment); // Store datasets Session["revenueInformationTDS"] = revenueInformationTDS; // Update database UpdateDatabase(); ViewState["update"] = "yes"; } }