protected void grdInsurances_RowUpdating(object sender, GridViewUpdateEventArgs e) { // Validate general data Page.Validate("insuranceEdit"); if (Page.IsValid) { int costingSheetId = (int)e.Keys["CostingSheetID"]; int insuranceCompanyId = (int)e.Keys["InsuranceCompanyID"]; int refId = (int)e.Keys["RefID"]; int companyId = Int32.Parse(hdfCompanyId.Value); decimal rate = Decimal.Parse(((TextBox)grdInsurances.Rows[e.RowIndex].Cells[0].FindControl("tbxRateEdit")).Text.Trim()); DateTime startDate = ((RadDatePicker)grdInsurances.Rows[e.RowIndex].Cells[0].FindControl("tkrdpStartDateEdit")).SelectedDate.Value; DateTime endDate = ((RadDatePicker)grdInsurances.Rows[e.RowIndex].Cells[0].FindControl("tkrdpEndDateEdit")).SelectedDate.Value; // Update data ProjectCostingSheetAddInsurancesInformation model = new ProjectCostingSheetAddInsurancesInformation(projectCostingSheetAddTDS); model.Update(costingSheetId, insuranceCompanyId, refId, rate, false, companyId, startDate, endDate); // Store dataset insurancesInformation = (ProjectCostingSheetAddTDS.InsurancesInformationDataTable)model.Table; Session["insurancesInformation"] = insurancesInformation; Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS; StepInsurancesInformationProcessGrid(); } else { e.Cancel = true; } }
protected void grdInsurances_RowDeleting(object sender, GridViewDeleteEventArgs e) { // Insurances Gridview, if the gridview is edition mode if (grdInsurances.EditIndex >= 0) { grdInsurances.UpdateRow(grdInsurances.EditIndex, true); } // Delete insurance int costingSheetId = (int)e.Keys["CostingSheetID"]; int insuranceCompanyId = (int)e.Keys["InsuranceCompanyID"]; int refId = (int)e.Keys["RefID"]; ProjectCostingSheetAddInsurancesInformation model = new ProjectCostingSheetAddInsurancesInformation(projectCostingSheetAddTDS); model.Delete(costingSheetId, insuranceCompanyId, refId); // Store dataset insurancesInformation = (ProjectCostingSheetAddTDS.InsurancesInformationDataTable)model.Table; Session["insurancesInformation"] = insurancesInformation; Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS; StepInsurancesInformationProcessGrid(); }
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); } }
// ///////////////////////////////////////////////////////////////////////////////////////////////////// // // STEP7 - INSURANCE INFORMATION // // //////////////////////////////////////////////////////////////////////// // STEP7 - INSURANCE INFORMATION - EVENTS // protected void grdInsurances_RowCommand(object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case "Add": // Insurances Gridview, if the gridview is edition mode if (grdInsurances.EditIndex >= 0) { grdInsurances.UpdateRow(grdInsurances.EditIndex, true); } // Validate general data Page.Validate("insuranceNew"); if (Page.IsValid) { int companyId = Int32.Parse(hdfCompanyId.Value); int insuranceCompanyId = Int32.Parse(((DropDownList)grdInsurances.FooterRow.FindControl("ddlInsuranceNew")).SelectedValue); string insurance = ((DropDownList)grdInsurances.FooterRow.FindControl("ddlInsuranceNew")).SelectedItem.Text; decimal rate = Decimal.Parse(((TextBox)grdInsurances.FooterRow.FindControl("tbxRateNew")).Text.Trim()); DateTime startDate = ((RadDatePicker)grdInsurances.FooterRow.FindControl("tkrdpStartDateNew")).SelectedDate.Value; DateTime endDate = ((RadDatePicker)grdInsurances.FooterRow.FindControl("tkrdpEndDateNew")).SelectedDate.Value; ProjectCostingSheetAddInsurancesInformation model = new ProjectCostingSheetAddInsurancesInformation(projectCostingSheetAddTDS); model.Insert(0, insuranceCompanyId, rate, false, companyId, startDate, endDate, insurance); Session.Remove("insurancesInformationDummy"); insurancesInformation = (ProjectCostingSheetAddTDS.InsurancesInformationDataTable)model.Table; Session["insurancesInformation"] = insurancesInformation; Session["projectCostingSheetAddTDS"] = projectCostingSheetAddTDS; grdInsurances.DataBind(); StepInsurancesInformationProcessGrid(); } break; } }
// //////////////////////////////////////////////////////////////////////// // STEP7 - INSURANCE INFORMATION - METHODS // private void StepInsurancesInformationIn() { // Set instruction Label instruction = (Label)this.Master.FindControl("lblInstruction"); instruction.Text = "Please verify Insurances information"; // Load ProjectCostingSheetAddInsurancesInformation model = new ProjectCostingSheetAddInsurancesInformation(projectCostingSheetAddTDS); if (projectCostingSheetAddTDS.InsurancesInformation.Rows.Count <= 0) { model.Load(int.Parse(hdfProjectId.Value), tkrdpFrom.SelectedDate.Value, tkrdpTo.SelectedDate.Value, int.Parse(hdfCompanyId.Value)); } // Store tables Session.Remove("insurancesInformationDummy"); insurancesInformation = (ProjectCostingSheetAddTDS.InsurancesInformationDataTable)model.Table; Session["insurancesInformation"] = insurancesInformation; 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 { // Insurances Grid lblInsurancesTotalCosts.Text = "Total Cost (CAD) : "; tbxInsurancesTotalCostsCAD.Visible = true; tbxInsurancesTotalCostsUSD.Visible = false; } else { // Insurances Grid lblInsurancesTotalCosts.Text = "Total Cost (USD) : "; tbxInsurancesTotalCostsCAD.Visible = false; tbxInsurancesTotalCostsUSD.Visible = true; } grdInsurances.DataBind(); StepInsurancesInformationProcessGrid(); }