protected void grdBondingCompaniesCostsByClientProject_RowUpdating(object sender, GridViewUpdateEventArgs e) { Page.Validate("DataEditBondingCompaniesByClientProject"); if (Page.IsValid) { int companyId = Int32.Parse(hdfCompanyId.Value); int refId = Int32.Parse(((Label)grdBondingCompaniesCostsByClientProject.Rows[e.RowIndex].FindControl("lblRefIdEditBondingCompaniesByClientProject")).Text); DateTime date = (DateTime)((RadDatePicker)grdBondingCompaniesCostsByClientProject.Rows[e.RowIndex].FindControl("tkrdpDateEditBondingCompaniesByClientProject")).SelectedDate; int bondingCompanyId = Int32.Parse(((DropDownList)grdBondingCompaniesCostsByClientProject.Rows[e.RowIndex].FindControl("ddlBondingCompaniesEditBondingCompaniesByClientProject")).Text); string name = ((DropDownList)grdBondingCompaniesCostsByClientProject.Rows[e.RowIndex].FindControl("ddlBondingCompaniesEditBondingCompaniesByClientProject")).SelectedItem.Text; int projectId = Int32.Parse(((Label)grdBondingCompaniesCostsByClientProject.Rows[e.RowIndex].FindControl("lblProjectIdEditBondingCompaniesByClientProject")).Text); decimal rate = decimal.Round(decimal.Parse(((TextBox)grdBondingCompaniesCostsByClientProject.Rows[e.RowIndex].FindControl("tbxRateEditBondingCompaniesByClientProject")).Text), 2); decimal rateCad = 0; decimal rateUsd = 0; ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); if (projectGateway.GetCountryID(projectId) == 1) //Canada { rateCad = rate; } else { rateUsd = rate; } string comment = ((TextBox)grdBondingCompaniesCostsByClientProject.Rows[e.RowIndex].FindControl("tbxCommentEditBondingCompaniesByClientProject")).Text; bool deleted = false; // Update Data ActualCostsAddBondingCompaniesCosts actualCostsAddBondingCompaniesCosts = new ActualCostsAddBondingCompaniesCosts(actualCostsAddTDS); actualCostsAddBondingCompaniesCosts.Update(projectId, refId, bondingCompanyId, date, rateCad, rateUsd, comment, deleted, companyId, name); // Store dataset Session.Remove("subcontractorCostsBySubcontractorDummy"); Session.Remove("bondingCompaniesCostsByClientProjectDummy"); Session["actualCostsAddTDS"] = actualCostsAddTDS; Session["bondingCompaniesCosts"] = actualCostsAddTDS.BondingCompaniesCosts; bondingCompaniesCosts = actualCostsAddTDS.BondingCompaniesCosts; } else { e.Cancel = true; } }
protected void grdBondingCompaniesCostsByClientProject_RowDeleting(object sender, GridViewDeleteEventArgs e) { // BondingCompanies Gridview, if the gridview is edition mode if (grdBondingCompaniesCostsByClientProject.EditIndex >= 0) { grdBondingCompaniesCostsByClientProject.UpdateRow(grdBondingCompaniesCostsByClientProject.EditIndex, true); } // Delete BondingCompanies int projectId = (int)e.Keys["ProjectID"]; int refId = (int)e.Keys["RefID"]; // Delete costs details ActualCostsAddBondingCompaniesCosts actualCostsAddBondingCompaniesCosts = new ActualCostsAddBondingCompaniesCosts(actualCostsAddTDS); actualCostsAddBondingCompaniesCosts.Delete(projectId, refId); // Store dataset Session.Remove("subcontractorCostsBySubcontractorDummy"); Session.Remove("bondingCompaniesCostsByClientProjectDummy"); Session["actualCostsAddTDS"] = actualCostsAddTDS; Session["bondingCompaniesCosts"] = actualCostsAddTDS.BondingCompaniesCosts; bondingCompaniesCosts = actualCostsAddTDS.BondingCompaniesCosts; }
private void grdBondingCompaniesCostsByClientProjectDetailAdd() { if (FooterValidateBondingCompaniesByClientProject()) { Page.Validate("DataNewBondingCompaniesByClientProject"); if (Page.IsValid) { int companyId = Int32.Parse(hdfCompanyId.Value); DateTime date = (DateTime)((RadDatePicker)grdBondingCompaniesCostsByClientProject.FooterRow.FindControl("tkrdpDateFooterBondingCompaniesByClientProject")).SelectedDate; int bondingCompanyId = Int32.Parse(((DropDownList)grdBondingCompaniesCostsByClientProject.FooterRow.FindControl("ddlBondingCompaniesFooterBondingCompaniesByClientProject")).Text); string name = ((DropDownList)grdBondingCompaniesCostsByClientProject.FooterRow.FindControl("ddlBondingCompaniesFooterBondingCompaniesByClientProject")).SelectedItem.Text; int clientId = Int32.Parse(((DropDownList)grdBondingCompaniesCostsByClientProject.FooterRow.FindControl("ddlClientFooterBondingCompaniesByClientProject")).SelectedValue); string client = ((DropDownList)grdBondingCompaniesCostsByClientProject.FooterRow.FindControl("ddlClientFooterBondingCompaniesByClientProject")).SelectedItem.Text; int projectId = Int32.Parse(((DropDownList)grdBondingCompaniesCostsByClientProject.FooterRow.FindControl("ddlProjectFooterBondingCompaniesByClientProject")).SelectedValue); string project = ((DropDownList)grdBondingCompaniesCostsByClientProject.FooterRow.FindControl("ddlProjectFooterBondingCompaniesByClientProject")).SelectedItem.Text; decimal rate = decimal.Round(decimal.Parse(((TextBox)grdBondingCompaniesCostsByClientProject.FooterRow.FindControl("tbxRateFooterBondingCompaniesByClientProject")).Text), 2); string comment = ((TextBox)grdBondingCompaniesCostsByClientProject.FooterRow.FindControl("tbxCommentFooterBondingCompaniesByClientProject")).Text; bool deleted = false; bool inDatabase = false; decimal rateCad = 0; decimal rateUsd = 0; ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); if (projectGateway.GetCountryID(projectId) == 1) //Canada { rateCad = rate; rateUsd = rate; } else { rateCad = rate; rateUsd = rate; } // Insert Data ActualCostsAddBondingCompaniesCosts actualCostsAddBondingCompaniesCosts = new ActualCostsAddBondingCompaniesCosts(actualCostsAddTDS); actualCostsAddBondingCompaniesCosts.Insert(projectId, bondingCompanyId, date, rateCad, rateUsd, comment, deleted, companyId, inDatabase, name, client, project, clientId); // Store dataset Session.Remove("subcontractorCostsBySubcontractorDummy"); Session.Remove("bondingCompaniesCostsByClientProjectDummy"); Session["actualCostsAddTDS"] = actualCostsAddTDS; Session["bondingCompaniesCosts"] = actualCostsAddTDS.BondingCompaniesCosts; bondingCompaniesCosts = actualCostsAddTDS.BondingCompaniesCosts; grdBondingCompaniesCostsByClientProject.DataBind(); grdBondingCompaniesCostsByClientProject.PageIndex = grdBondingCompaniesCostsByClientProject.PageCount - 1; } } }
private void UpdateDatabase() { DB.Open(); DB.BeginTransaction(); try { int companyId = Int32.Parse(hdfCompanyId.Value); int loginId = Convert.ToInt32(Session["loginID"]); // Save costs information if (cbxSubcontractorCosts.Checked) { if (rbtnSubcontractorCostsBySubcontractor.Checked) { ActualCostsAddSubcontractorCosts actualCostsAddSubcontractorCosts = new ActualCostsAddSubcontractorCosts(actualCostsAddTDS); actualCostsAddSubcontractorCosts.Save(companyId); } else { if (rbtnSubcontractorCostsByProjectAndClient.Checked) { ActualCostsAddSubcontractorCosts actualCostsAddSubcontractorCosts = new ActualCostsAddSubcontractorCosts(actualCostsAddTDS); actualCostsAddSubcontractorCosts.Save(companyId); } } } if (cbxHotelCosts.Checked) { ActualCostsAddHotelCosts actualCostsAddHotelCosts = new ActualCostsAddHotelCosts(actualCostsAddTDS); actualCostsAddHotelCosts.Save(companyId); } if (cbxBondingCosts.Checked) { ActualCostsAddBondingCompaniesCosts actualCostsAddBondingCompaniesCosts = new ActualCostsAddBondingCompaniesCosts(actualCostsAddTDS); actualCostsAddBondingCompaniesCosts.Save(companyId); } if (cbxInsuranceCosts.Checked) { ActualCostsAddInsuranceCompaniesCosts actualCostsAddInsuranceCompaniesCosts = new ActualCostsAddInsuranceCompaniesCosts(actualCostsAddTDS); actualCostsAddInsuranceCompaniesCosts.Save(companyId); } if (cbxOtherCosts.Checked) { ActualCostsAddOtherCosts actualCostsAddOtherCosts = new ActualCostsAddOtherCosts(actualCostsAddTDS); actualCostsAddOtherCosts.Save(companyId); } DB.CommitTransaction(); // Store datasets actualCostsAddTDS.AcceptChanges(); Session["actualCostsAddTDS"] = actualCostsAddTDS; } catch (Exception ex) { DB.RollbackTransaction(); string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' ')); Response.Redirect(url); } }
private string GetSummary() { string summary = ""; int companyId = Int32.Parse(hdfCompanyId.Value); // Summary for Subcontractor costs if (cbxSubcontractorCosts.Checked) { if (rbtnSubcontractorCostsBySubcontractor.Checked) { summary += "NEW SUBCONTRACTORS COSTS \n"; summary += "SUBCONTRACTOR: " + ddlSubcontractor.SelectedItem.Text + "\n"; ActualCostsAddSubcontractorCosts actualCostsAddSubcontractorCosts = new ActualCostsAddSubcontractorCosts(actualCostsAddTDS); summary += actualCostsAddSubcontractorCosts.GetSummary(companyId, "\n", "BySubcontractor"); } else { if (rbtnSubcontractorCostsByProjectAndClient.Checked) { summary += "NEW SUBCONTRACTORS COSTS \n"; summary += "CLIENT: " + ddlClientByClientProject.SelectedItem.Text + "\n"; summary += "PROJECT: " + ddlProjectByClientProject.SelectedItem.Text + "\n"; ActualCostsAddSubcontractorCosts actualCostsAddSubcontractorCosts = new ActualCostsAddSubcontractorCosts(actualCostsAddTDS); summary += actualCostsAddSubcontractorCosts.GetSummary(companyId, "\n", "ByClientProject"); } } } if (cbxHotelCosts.Checked) { summary += "NEW HOTEL COSTS \n"; ActualCostsAddHotelCosts actualCostsAddHotelCosts = new ActualCostsAddHotelCosts(actualCostsAddTDS); summary += actualCostsAddHotelCosts.GetSummary(companyId, "\n"); } if (cbxBondingCosts.Checked) { summary += "NEW BONDING COMPANIES COSTS \n"; ActualCostsAddBondingCompaniesCosts actualCostsAddBondingCompaniesCosts = new ActualCostsAddBondingCompaniesCosts(actualCostsAddTDS); summary += actualCostsAddBondingCompaniesCosts.GetSummary(companyId, "\n"); } if (cbxInsuranceCosts.Checked) { summary += "NEW INSURANCE COMPANIES COSTS \n"; ActualCostsAddInsuranceCompaniesCosts actualCostsAddInsuranceCompaniesCosts = new ActualCostsAddInsuranceCompaniesCosts(actualCostsAddTDS); summary += actualCostsAddInsuranceCompaniesCosts.GetSummary(companyId, "\n"); } if (cbxOtherCosts.Checked) { summary += "NEW OTHER COSTS \n"; ActualCostsAddOtherCosts actualCostsAddOtherCosts = new ActualCostsAddOtherCosts(actualCostsAddTDS); summary += actualCostsAddOtherCosts.GetSummary(companyId, "\n"); } return summary; }