private void UpdateDatabase() { DB.Open(); DB.BeginTransaction(); try { int companyId = Int32.Parse(hdfCompanyId.Value); int loginId = Convert.ToInt32(Session["loginID"]); if (cbxEndConfirm.Checked) { ProjectCostingSheetAddBasicInformation projectCostingSheetAddBasicInformation = new ProjectCostingSheetAddBasicInformation(projectCostingSheetAddTDS); int costingSheetId = projectCostingSheetAddBasicInformation.Save(companyId); hdfCostingSheetId.Value = costingSheetId.ToString(); // Save costs information ProjectCostingSheetAddLabourHoursInformation projectCostingSheetAddLabourHoursInformation = new ProjectCostingSheetAddLabourHoursInformation(projectCostingSheetAddTDS); projectCostingSheetAddLabourHoursInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddUnitsInformation projectCostingSheetAddUnitsInformation = new ProjectCostingSheetAddUnitsInformation(projectCostingSheetAddTDS); projectCostingSheetAddUnitsInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddMaterialsInformation projectCostingSheetAddMaterialsInformation = new ProjectCostingSheetAddMaterialsInformation(projectCostingSheetAddTDS); projectCostingSheetAddMaterialsInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddSubcontractorsInformation projectCostingSheetAddSubcontractorsInformation = new ProjectCostingSheetAddSubcontractorsInformation(projectCostingSheetAddTDS); projectCostingSheetAddSubcontractorsInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddOtherCostsInformation projectCostingSheetAddOtherCostsInformation = new ProjectCostingSheetAddOtherCostsInformation(projectCostingSheetAddTDS); projectCostingSheetAddOtherCostsInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddHotelsInformation projectCostingSheetAddHotelsInformation = new ProjectCostingSheetAddHotelsInformation(projectCostingSheetAddTDS); projectCostingSheetAddHotelsInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddBondingsInformation projectCostingSheetAddBondingsInformation = new ProjectCostingSheetAddBondingsInformation(projectCostingSheetAddTDS); projectCostingSheetAddBondingsInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddInsurancesInformation projectCostingSheetAddInsurancesInformation = new ProjectCostingSheetAddInsurancesInformation(projectCostingSheetAddTDS); projectCostingSheetAddInsurancesInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddOtherCategoryInformation projectCostingSheetAddOtherCategoryInformation = new ProjectCostingSheetAddOtherCategoryInformation(projectCostingSheetAddTDS); projectCostingSheetAddOtherCategoryInformation.Save(companyId, costingSheetId); ProjectCostingSheetAddRevenueInformation projectCostingSheetAddRevenueInformation = new ProjectCostingSheetAddRevenueInformation(projectCostingSheetAddTDS); projectCostingSheetAddRevenueInformation.Save(companyId, costingSheetId); if (rbtnBeginTemplate.Checked) { ProjectCostingSheetTemplateInformation projectCostingSheetTemplateInformation = new ProjectCostingSheetTemplateInformation(projectCostingSheetAddTDS); projectCostingSheetTemplateInformation.Save(companyId); } } else { if (cbxEndSave.Checked) { ProjectCostingSheetTemplateInformation projectCostingSheetTemplateInformation = new ProjectCostingSheetTemplateInformation(projectCostingSheetAddTDS); projectCostingSheetTemplateInformation.Save(companyId); } else { if (rbtnBeginTemplate.Checked) { ProjectCostingSheetTemplateInformation projectCostingSheetTemplateInformation = new ProjectCostingSheetTemplateInformation(projectCostingSheetAddTDS); projectCostingSheetTemplateInformation.Save(companyId); } } } DB.CommitTransaction(); // Store datasets projectCostingSheetAddTDS.AcceptChanges(); Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS; } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }
// //////////////////////////////////////////////////////////////////////// // STEP9 - REVENUE INFORMATION - METHODS // private void StepRevenueInformationIn() { // Set instruction Label instruction = (Label)this.Master.FindControl("lblInstruction"); instruction.Text = "Please verify Revenue information"; // Load ProjectCostingSheetAddRevenueInformation model = new ProjectCostingSheetAddRevenueInformation(projectCostingSheetAddTDS); if (projectCostingSheetAddTDS.RevenueInformation.Rows.Count <= 0) { model.Load(int.Parse(hdfProjectId.Value), tkrdpFrom.SelectedDate.Value, tkrdpTo.SelectedDate.Value, int.Parse(hdfCompanyId.Value)); } // Store tables Session.Remove("revenueInformationDummy"); revenueInformation = (ProjectCostingSheetAddTDS.RevenueInformationDataTable)model.Table; Session["revenueInformation"] = revenueInformation; Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS; // Validate grid columns //int projectId = Int32.Parse(hdfProjectId.Value); //ProjectGateway projectGateway = new ProjectGateway(); //projectGateway.LoadByProjectId(projectId); //if (projectGateway.GetCountryID(projectId) == 1) //Canada //{ // lblRevenueTotal.Text = "Total Revenue (CAD) : "; //} //else //{ // lblRevenueTotal.Text = "Total Revenue (USD) : "; //} grdRevenue.DataBind(); StepRevenueInformationProcessGrid(); GetRevenueSummary(); }
protected void grdRevenue_RowDeleting(object sender, GridViewDeleteEventArgs e) { // Revenue Gridview, if the gridview is edition mode if (grdRevenue.EditIndex >= 0) { grdRevenue.UpdateRow(grdRevenue.EditIndex, true); } // Delete revenue int costingSheetId = (int)e.Keys["CostingSheetID"]; int refIdRevenue = (int)e.Keys["RefIDRevenue"]; ProjectCostingSheetAddRevenueInformation model = new ProjectCostingSheetAddRevenueInformation(projectCostingSheetAddTDS); model.Delete(costingSheetId, refIdRevenue); // Store dataset revenueInformation = (ProjectCostingSheetAddTDS.RevenueInformationDataTable)model.Table; Session["revenueInformation"] = revenueInformation; Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS; StepRevenueInformationProcessGrid(); }
protected void grdRevenue_RowUpdating(object sender, GridViewUpdateEventArgs e) { // Validate general data Page.Validate("revenueEdit"); if (Page.IsValid) { int costingSheetId = (int)e.Keys["CostingSheetID"]; int refIdRevenue = (int)e.Keys["RefIDRevenue"]; int companyId = Int32.Parse(hdfCompanyId.Value); string comment = ((TextBox)grdRevenue.Rows[e.RowIndex].Cells[0].FindControl("tbxCommentEdit")).Text; decimal revenue = 0.0M; revenue = Decimal.Parse(((TextBox)grdRevenue.Rows[e.RowIndex].Cells[0].FindControl("tbxRevenueEdit")).Text.Trim()); revenue = Decimal.Round(revenue, 2); DateTime startDate = ((RadDatePicker)grdRevenue.Rows[e.RowIndex].Cells[0].FindControl("tkrdpStartDateEdit")).SelectedDate.Value; DateTime endDate = startDate; // Update data ProjectCostingSheetAddRevenueInformation model = new ProjectCostingSheetAddRevenueInformation(projectCostingSheetAddTDS); model.Update(costingSheetId, refIdRevenue, revenue, false, companyId, startDate, endDate, comment); // Store dataset revenueInformation = (ProjectCostingSheetAddTDS.RevenueInformationDataTable)model.Table; Session["revenueInformation"] = revenueInformation; Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS; StepRevenueInformationProcessGrid(); } else { e.Cancel = true; } }
// ///////////////////////////////////////////////////////////////////////////////////////////////////// // // STEP9 - REVENUE INFORMATION // // //////////////////////////////////////////////////////////////////////// // STEP9 - REVENUE INFORMATION - EVENTS // protected void grdRevenue_RowCommand(object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case "Add": // Revenue Gridview, if the gridview is edition mode if (grdRevenue.EditIndex >= 0) { grdRevenue.UpdateRow(grdRevenue.EditIndex, true); } // Validate general data Page.Validate("revenueNew"); if (Page.IsValid) { int companyId = Int32.Parse(hdfCompanyId.Value); string comment = ""; if (((TextBox)grdRevenue.FooterRow.FindControl("tbxCommentNew")).Text.Trim() != "") comment = ((TextBox)grdRevenue.FooterRow.FindControl("tbxCommentNew")).Text.Trim(); decimal revenue = 0.0M; revenue = Decimal.Parse(((TextBox)grdRevenue.FooterRow.FindControl("tbxRevenueNew")).Text.Trim()); revenue = Decimal.Round(revenue, 2); DateTime startDate = ((RadDatePicker)grdRevenue.FooterRow.FindControl("tkrdpStartDateNew")).SelectedDate.Value; DateTime endDate = startDate; ProjectCostingSheetAddRevenueInformation model = new ProjectCostingSheetAddRevenueInformation(projectCostingSheetAddTDS); model.Insert(0, revenue, false, companyId, startDate, endDate, comment); Session.Remove("revenueInformationDummy"); revenueInformation = (ProjectCostingSheetAddTDS.RevenueInformationDataTable)model.Table; Session["revenueInformation"] = revenueInformation; Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS; grdRevenue.DataBind(); StepRevenueInformationProcessGrid(); } break; } }