protected void grdOtherCostsByClientProject_RowDeleting(object sender, GridViewDeleteEventArgs e) { // Other Gridview, if the gridview is edition mode if (grdOtherCostsByClientProject.EditIndex >= 0) { grdOtherCostsByClientProject.UpdateRow(grdOtherCostsByClientProject.EditIndex, true); } // Delete Other int projectId = (int)e.Keys["ProjectID"]; int refId = (int)e.Keys["RefID"]; // Delete costs details ActualCostsAddOtherCosts actualCostsAddOtherCosts = new ActualCostsAddOtherCosts(actualCostsAddTDS); actualCostsAddOtherCosts.Delete(projectId, refId); // Store dataset Session.Remove("otherCostsByClientProjectDummy"); Session["actualCostsAddTDS"] = actualCostsAddTDS; Session["otherCosts"] = actualCostsAddTDS.OtherCosts; otherCosts = actualCostsAddTDS.OtherCosts; }
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; }
private void grdOtherCostsByClientProjectDetailAdd() { if (FooterValidateOtherByClientProject()) { Page.Validate("DataNewOtherByClientProject"); if (Page.IsValid) { int companyId = Int32.Parse(hdfCompanyId.Value); DateTime date = (DateTime)((RadDatePicker)grdOtherCostsByClientProject.FooterRow.FindControl("tkrdpDateFooterOtherByClientProject")).SelectedDate; string category = ((DropDownList)grdOtherCostsByClientProject.FooterRow.FindControl("ddlCategoryFooterOtherByClientProject")).Text; string name = ((DropDownList)grdOtherCostsByClientProject.FooterRow.FindControl("ddlCategoryFooterOtherByClientProject")).SelectedItem.Text; int clientId = Int32.Parse(((DropDownList)grdOtherCostsByClientProject.FooterRow.FindControl("ddlClientFooterOtherByClientProject")).SelectedValue); string client = ((DropDownList)grdOtherCostsByClientProject.FooterRow.FindControl("ddlClientFooterOtherByClientProject")).SelectedItem.Text; int projectId = Int32.Parse(((DropDownList)grdOtherCostsByClientProject.FooterRow.FindControl("ddlProjectFooterOtherByClientProject")).SelectedValue); string project = ((DropDownList)grdOtherCostsByClientProject.FooterRow.FindControl("ddlProjectFooterOtherByClientProject")).SelectedItem.Text; decimal rate = decimal.Round(decimal.Parse(((TextBox)grdOtherCostsByClientProject.FooterRow.FindControl("tbxRateFooterOtherByClientProject")).Text), 2); string comment = ((TextBox)grdOtherCostsByClientProject.FooterRow.FindControl("tbxCommentFooterOtherByClientProject")).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 ActualCostsAddOtherCosts actualCostsAddOtherCosts = new ActualCostsAddOtherCosts(actualCostsAddTDS); actualCostsAddOtherCosts.Insert(projectId, category, date, rateCad, rateUsd, comment, deleted, companyId, inDatabase, name, client, project, clientId); // Store dataset Session.Remove("otherCostsByClientProjectDummy"); Session["actualCostsAddTDS"] = actualCostsAddTDS; Session["otherCosts"] = actualCostsAddTDS.OtherCosts; otherCosts = actualCostsAddTDS.OtherCosts; grdOtherCostsByClientProject.DataBind(); grdOtherCostsByClientProject.PageIndex = grdOtherCostsByClientProject.PageCount - 1; } } }
protected void grdOtherCostsByClientProject_RowUpdating(object sender, GridViewUpdateEventArgs e) { Page.Validate("DataEditOtherByClientProject"); if (Page.IsValid) { int companyId = Int32.Parse(hdfCompanyId.Value); int refId = Int32.Parse(((Label)grdOtherCostsByClientProject.Rows[e.RowIndex].FindControl("lblRefIdEditOtherByClientProject")).Text); DateTime date = (DateTime)((RadDatePicker)grdOtherCostsByClientProject.Rows[e.RowIndex].FindControl("tkrdpDateEditOtherByClientProject")).SelectedDate; string category = ((DropDownList)grdOtherCostsByClientProject.Rows[e.RowIndex].FindControl("ddlCategoryEditOtherByClientProject")).Text; string name = ((DropDownList)grdOtherCostsByClientProject.Rows[e.RowIndex].FindControl("ddlCategoryEditOtherByClientProject")).SelectedItem.Text; int projectId = Int32.Parse(((Label)grdOtherCostsByClientProject.Rows[e.RowIndex].FindControl("lblProjectIdEditOtherByClientProject")).Text); decimal rate = decimal.Round(decimal.Parse(((TextBox)grdOtherCostsByClientProject.Rows[e.RowIndex].FindControl("tbxRateEditOtherByClientProject")).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)grdOtherCostsByClientProject.Rows[e.RowIndex].FindControl("tbxCommentEditOtherByClientProject")).Text; bool deleted = false; // Update Data ActualCostsAddOtherCosts actualCostsAddOtherCosts = new ActualCostsAddOtherCosts(actualCostsAddTDS); actualCostsAddOtherCosts.Update(projectId, refId, category, date, rateCad, rateUsd, comment, deleted, companyId, name); // Store dataset Session.Remove("otherCostsByClientProjectDummy"); Session["actualCostsAddTDS"] = actualCostsAddTDS; Session["otherCosts"] = actualCostsAddTDS.OtherCosts; otherCosts = actualCostsAddTDS.OtherCosts; } else { e.Cancel = true; } }