private void PostPageChanges() { ProjectGateway projectGateway = new ProjectGateway(projectTDS); int projectId = int.Parse(hdfProjectId.Value); // General Data Int64 countryId = projectGateway.GetCountryID(projectId); int officeId = projectGateway.GetOfficeID(projectId); Int64? provinceId = projectGateway.GetProvinceID(projectId); Int64? cityId = projectGateway.GetCityID(projectId); Int64? countyId = projectGateway.GetCountyID(projectId); int? projectLeadId = null; if ((ddlProjectLeadId.SelectedValue != "-1") && (ddlProjectLeadId.SelectedIndex > -1)) projectLeadId = int.Parse(ddlProjectLeadId.SelectedValue); int salesmanId = int.Parse(ddlSalesmanId.SelectedValue); string projectType = projectGateway.GetProjectType(projectId); string projectState = projectGateway.GetProjectState(projectId); string name = tbxName.Text.Trim(); string description = tbxDescription.Text.Trim(); DateTime? proposalDate = null; if (tkrdpProposalDate.SelectedDate.HasValue) proposalDate = tkrdpProposalDate.SelectedDate.Value; DateTime? startDate = null; if (tkrdpStartDate.SelectedDate.HasValue) startDate = tkrdpStartDate.SelectedDate.Value; DateTime? endDate = null; if (tkrdpEndDate.SelectedDate.HasValue) endDate = tkrdpEndDate.SelectedDate.Value; int clientId = projectGateway.GetClientID(projectId); string clientProjectNumber = tbxClientProjectNumber.Text.Trim(); int? clientPrimaryContactId = null; if ((ddlClientPrimaryContactId.SelectedValue != "-1") && (ddlClientPrimaryContactId.SelectedIndex > -1)) clientPrimaryContactId = int.Parse(ddlClientPrimaryContactId.SelectedValue); int? clientSecondaryContactId = null; if ((ddlClientSecondaryContactId.SelectedValue != "-1") && (ddlClientSecondaryContactId.SelectedIndex > -1)) clientSecondaryContactId = int.Parse(ddlClientSecondaryContactId.SelectedValue); bool deleted = projectGateway.GetDeleted(projectId); int? libraryCategoriesId = null; if (projectGateway.GetLibraryCategoriesId(projectId).HasValue) libraryCategoriesId = (int)projectGateway.GetLibraryCategoriesId(projectId); bool fairWageApplies = cbxFairWageApplies.Checked; // ... Update Project Number Project project = new Project(projectTDS); string projectNumber; if (projectGateway.GetOriginalProjectID(projectId) == null) { projectNumber = project.UpdateProjectNumber(projectId, salesmanId); } else { projectNumber = projectGateway.GetProjectNumber(projectId); } // ... Update Project project.Update(projectId, countryId, officeId, projectLeadId, salesmanId, projectNumber, projectType, projectState, name, description, proposalDate, startDate, endDate, clientId, clientProjectNumber, clientPrimaryContactId, clientSecondaryContactId, deleted, libraryCategoriesId, provinceId, cityId, Int32.Parse(hdfCompanyId.Value.Trim()), countyId, fairWageApplies); // ... If project type is Ballpark update Bill Price and Bill Money if (projectType == "Ballpark") { ProjectSaleBillingPricing projectSaleBillingPricingForGeneralData = new ProjectSaleBillingPricing(projectTDS); decimal? billPrice = null; if (tbxBillPrice.Text != "") billPrice = Convert.ToDecimal(tbxBillPrice.Text); string billMoney = ddlBillMoney.SelectedValue; projectSaleBillingPricingForGeneralData.UpdateBillPrice(projectId, billPrice, billMoney); } if ((projectType != "Ballpark") && (projectType != "Internal")) { // Sale/Billing/Pricing //bool saleBidProject = cbxSaleBidProject.Checked; //bool saleRFP = cbxSaleRFP.Checked; //bool saleSoleSource = cbxSaleSoleSource.Checked; //bool saleTermContract = cbxSaleTermContract.Checked; //string saleTermContractDetail = tbxSaleTermContractDetail.Text.Trim(); //bool saleOther = cbxSaleOther.Checked; //string saleOtherDetail = tbxSaleOtherDetail.Text.Trim(); //int? saleGettingJob = null; if (tbxSaleGettingJob.Text.Trim() != "") saleGettingJob = int.Parse(tbxSaleGettingJob.Text.Trim()); decimal? billPriceSaleBillingPricing = null; if (tbxBillPriceSaleBillingPricing.Text.Trim() != "") billPriceSaleBillingPricing = decimal.Parse(tbxBillPriceSaleBillingPricing.Text.Trim()); string billMoneySaleBillingPricing = ddlBillMoneySaleBillingPricing.SelectedValue; decimal? billSubcontractorAmount = null; if (tbxBillSubcontractorAmount.Text.Trim() != "") billSubcontractorAmount = decimal.Parse(tbxBillSubcontractorAmount.Text.Trim()); //string billBidHardDollar = tbxBillBidHardDollar.Text.Trim(); //bool billPerUnit = cbxBillPerUnit.Checked; //bool billHourly = cbxBillHourly.Checked; //string billExpectExtras = tbxBillExpectExtras.Text.Trim(); //bool chargesWater = cbxChargesWater.Checked; //decimal? chargesWaterAmount = null; if (tbxChargesWaterAmount.Text.Trim() != "") chargesWaterAmount = decimal.Parse(tbxChargesWaterAmount.Text.Trim()); //bool chargesDisposal = cbxChargesDisposal.Checked; //decimal? chargesDisposalAmount = null; if (tbxChargesDisposalAmount.Text.Trim() != "") chargesDisposalAmount = decimal.Parse(tbxChargesDisposalAmount.Text.Trim()); // ... Update Sale/Billing/Pricing ProjectSaleBillingPricing projectSaleBillingPricing = new ProjectSaleBillingPricing(projectTDS); //projectSaleBillingPricing.Update(projectId, saleBidProject, saleRFP, saleSoleSource, saleTermContract, saleTermContractDetail, saleOther, saleOtherDetail, saleGettingJob, billPriceSaleBillingPricing, billMoneySaleBillingPricing, billBidHardDollar, billPerUnit, billHourly, billExpectExtras, billSubcontractorAmount, chargesWater, chargesWaterAmount, chargesDisposal, chargesDisposalAmount, Int32.Parse(hdfCompanyId.Value.Trim())); projectSaleBillingPricing.Update(projectId, billPriceSaleBillingPricing, billMoneySaleBillingPricing, billSubcontractorAmount, Int32.Parse(hdfCompanyId.Value.Trim())); // ... Update job info bool typeOfWorkMhRehab = ckbxMhRehab.Checked; bool typeOfWorkJunctionLining = ckbxJunctionLining.Checked; bool typeOfWorkProjectManagement = ckbxProjectManagement.Checked; bool typeOfWorkFullLenghtLining = ckbxFullLengthLining.Checked; bool typeOfWorkPointRepairs = ckbxPointRepairs.Checked; bool typeOfWorkRehabAssessment = ckbxRehabAssessment.Checked; bool typeOfWorkGrout = ckbxGrout.Checked; bool typeOfWorkOther = ckbxOther.Checked; bool agreement = cbxSubcontractorAgreement.Checked; bool writtenQuote = cbxSubcontractorWrittenQuote.Checked; string role = tbxSubcontractorRole.Text; ProjectNavigatorProjectJobInfo projectNavigatorProjectJobInfo = new ProjectNavigatorProjectJobInfo(projectNavigatorTDS); projectNavigatorProjectJobInfo.Update(projectId, typeOfWorkMhRehab, typeOfWorkJunctionLining, typeOfWorkProjectManagement, typeOfWorkFullLenghtLining, typeOfWorkPointRepairs, typeOfWorkRehabAssessment, typeOfWorkGrout, typeOfWorkOther, agreement, writtenQuote, role); // Costing Updates //decimal? extrasToDate = null; if (tbxExtrasToDate.Text.Trim() != "") extrasToDate = decimal.Parse(tbxExtrasToDate.Text.Trim()); //decimal? costsIncurred = null; if (tbxCostsIncurred.Text.Trim() != "") costsIncurred = decimal.Parse(tbxCostsIncurred.Text.Trim()); //decimal? costToComplete = null; if (tbxCostToComplete.Text.Trim() != "") costToComplete = decimal.Parse(tbxCostToComplete.Text.Trim()); //decimal? originalProfitEstimated = null; if (tbxOriginalProfitEstimated.Text.Trim() != "") originalProfitEstimated = decimal.Parse(tbxOriginalProfitEstimated.Text.Trim()); //decimal? invoicedToDate = null; if (tbxInvoicedToDate.Text.Trim() != "") invoicedToDate = decimal.Parse(tbxInvoicedToDate.Text.Trim()); // ... Update Costing Updates //ProjectCostingUpdates projectCostingUpdates = new ProjectCostingUpdates(projectTDS); //projectCostingUpdates.Update(projectId, extrasToDate, costsIncurred, costToComplete, originalProfitEstimated, invoicedToDate, Int32.Parse(hdfCompanyId.Value.Trim())); // Terms/PO // ... Liquidated Damage //bool liquidateDamage = cbxLiquidatedDamages.Checked; //decimal? liquidatedRate = null; //if (tbxLiquidatedDamagesRate.Text.Trim() != "") { decimal damages = Decimal.Parse(tbxLiquidatedDamagesRate.Text.Trim()); liquidatedRate = Decimal.Round(damages, 2); } //string liquidatedUnit = null; if (tbxLiquidatedDamagesUnit.Text != "") liquidatedUnit = tbxLiquidatedDamagesUnit.Text.Trim(); //// ... Client LFS Relationship //bool clientWorkedBefore = cbxWorkedBefore.Checked; //string clientQuirks = null; if (tbxClientQuirks.Text.Trim() != "") clientQuirks = tbxClientQuirks.Text.Trim(); //bool clientPromises = cbxClientPromises.Checked; //string clientPromisesNotes = null; if (tbxClientPromises.Text.Trim() != "") clientPromisesNotes = tbxClientPromises.Text.Trim(); //string waterObtain = null; if (tbxWaterObtain.Text.Trim() != "") waterObtain = tbxWaterObtain.Text.Trim(); //string materialDispose = null; if (tbxMaterialDispose.Text.Trim() != "") materialDispose = tbxMaterialDispose.Text.Trim(); //bool requireRPZ = cbxRequireRPZ.Checked; //string standardHydrantFitting = null; if (tbxStandardHydrantFitting.Text.Trim() != "") standardHydrantFitting = tbxStandardHydrantFitting.Text.Trim(); //bool preconstructionMeeting = cbxPreConstructionMeetingNeed.Checked; //bool specificMeetingLocation = cbxSpecificMeetingLocation.Checked; //string specificMeetingLocationNotes = null; if (tbxSpecificMeetingLocation.Text.Trim() != "") specificMeetingLocationNotes = tbxSpecificMeetingLocation.Text.Trim(); //string vehicleAccess = null; if (ddlVehicleAccess.Text.Trim() != "") vehicleAccess = ddlVehicleAccess.Text.Trim(); //string vehicleAccessNotes = null; if (tbxVehicleAccess.Text.Trim() != "") vehicleAccessNotes = tbxVehicleAccess.Text.Trim(); string projectOutcome = null; if (tbxDesireOutcomeOfProject.Text.Trim() != "") projectOutcome = tbxDesireOutcomeOfProject.Text.Trim(); string specificReportingNeeds = null; if (tbxSpecificReportingNeeds.Text.Trim() != "") specificReportingNeeds = tbxSpecificReportingNeeds.Text.Trim(); bool vehicleAccessRoad = ckbxVehicleAccessRoad.Checked; bool vehicleAccessEasement = ckbxVehicleAccessEasement.Checked; bool vehicleAccessOther = ckbxVehicleAccessOther.Checked; //... Purchase Order //bool orderAttached = cbxPurchaseOrderAttach.Checked; string orderNumber = null; if (tbxPurchaseOrderNumber.Text.Trim() != "") orderNumber = tbxPurchaseOrderNumber.Text.Trim(); //string orderNotes = null; if (tbxPurchaseOrderWillNotProvided.Text.Trim() != "") orderNotes = tbxPurchaseOrderWillNotProvided.Text.Trim(); // ... Update Term/PO ProjectTermsPO projectTermsPO = new ProjectTermsPO(projectTDS); //projectTermsPO.Update(projectId, liquidateDamage, liquidatedRate, liquidatedUnit, clientWorkedBefore, clientQuirks, clientPromises, clientPromisesNotes, waterObtain, materialDispose, requireRPZ, standardHydrantFitting, preconstructionMeeting, specificMeetingLocation, specificMeetingLocationNotes, vehicleAccess, vehicleAccessNotes, projectOutcome, specificReportingNeeds, orderNumber, orderAttached, orderNotes, Int32.Parse(hdfCompanyId.Value.Trim())); projectTermsPO.Update(projectId, projectOutcome, specificReportingNeeds, orderNumber, Int32.Parse(hdfCompanyId.Value.Trim()), vehicleAccessRoad, vehicleAccessEasement, vehicleAccessOther); // Technical bool availableDrawings = cbxAvailableDrawings.Checked; bool availableVideo = cbxAvailableVideo.Checked; //bool groundConditions = cbxGroundConditions.Checked; //string groundConditionNotes = null; if (tbxGroundCondition.Text != "") groundConditionNotes = tbxGroundCondition.Text.Trim(); //bool reviewVideoInspections = cbxReviewVideoInspections.Checked; //bool strangeConfigurations = cbxStrangeConfigurations.Checked; //string strangeConfigurationsNotes = null; if (tbxStrangeConfigurations.Text != "") strangeConfigurationsNotes = tbxStrangeConfigurations.Text.Trim(); //string furtherObservations = null; if (tbxFurtherObservations.Text != "") furtherObservations = tbxFurtherObservations.Text.Trim(); //string restrictiveFactors = null; if (tbxRestrictiveFactors.Text != "") restrictiveFactors = tbxRestrictiveFactors.Text.Trim(); // ... Update Technical ProjectTechnical projectTechnical = new ProjectTechnical(projectTDS); //projectTechnical.Update(projectId, availableDrawings, availableVideo, groundConditions, groundConditionNotes, reviewVideoInspections, strangeConfigurations, strangeConfigurationsNotes, furtherObservations, restrictiveFactors, Int32.Parse(hdfCompanyId.Value.Trim())); projectTechnical.Update(projectId, availableDrawings, availableVideo, Int32.Parse(hdfCompanyId.Value.Trim())); // Engineer/Subcontractors bool generalContractor = cbxGeneralContractor.Checked; bool generalWSIB = cbxGeneralWSIB.Checked; bool generalInsuranceCertificate = cbxGeneralInsuranceCertificate.Checked; string generalBondingSupplied = ddlGeneralBondingSupplied.SelectedValue; //string generalMOLForm = ddlGeneralMOLForm.SelectedValue; //bool generalNoticeProject = rbtnGeneralNoticeProject.Checked; //bool generalForm1000 = rbtnGeneralForm1000.Checked; //int? engineeringFirmId = null; if (ddlEngineeringFirmId.SelectedValue != "") engineeringFirmId = int.Parse(ddlEngineeringFirmId.SelectedValue); //int? engineerId = null; if (ddlEngineerId.SelectedValue != "") engineerId = int.Parse(ddlEngineerId.SelectedValue); //string engineerNumber = tbxEngineerNumber.Text.Trim(); bool subcontractorUsed = cbxSubcontractorUsed.Checked; string bondNumber = tbxBondNumber.Text.Trim(); // ... Update Engineer/Subcontractors ProjectEngineerSubcontractors projectEngineerSubcontractors = new ProjectEngineerSubcontractors(projectTDS); //projectEngineerSubcontractors.Update(projectId, generalContractor, generalWSIB, generalInsuranceCertificate, generalBondingSupplied, generalMOLForm, generalNoticeProject, generalForm1000, engineeringFirmId, engineerId, engineerNumber, subcontractorUsed, Int32.Parse(hdfCompanyId.Value.Trim()), bondNumber); projectEngineerSubcontractors.Update(projectId, generalContractor, generalWSIB, generalInsuranceCertificate, generalBondingSupplied, subcontractorUsed, Int32.Parse(hdfCompanyId.Value.Trim()), bondNumber); // ... Update subcontractors //ProjectSubcontractor projectSubcontractor = new ProjectSubcontractor(projectTDS); //bool subcontractorWrittenQuote = ((CheckBox)row.FindControl("cbxSubcontractorWrittenQuote")).Checked; //bool subcontractorAgreement = ((CheckBox)row.FindControl("cbxSubcontractorAgreement")).Checked; ////foreach (GridViewRow row in grdvSubcontractors.Rows) //{ // int subcontractorRefId = int.Parse(((HiddenField)row.FindControl("hdfRefId")).Value); // int subcontractorId = int.Parse(((DropDownList)row.FindControl("ddlSubcontractorId")).SelectedValue); // bool subcontractorSurveyedSite = ((CheckBox)row.FindControl("cbxSubcontractorSurveyedSite")).Checked; // bool subcontractorWorkedBefore = ((CheckBox)row.FindControl("cbxSubcontractorWorkedBefore")).Checked; // string subcontractorRole = ((TextBox)row.FindControl("tbxSubcontractorRole")).Text.Trim(); // string subcontractorIssues = ((TextBox)row.FindControl("tbxSubcontractorIssues")).Text.Trim(); // bool subcontractorPurchaseOrder = ((CheckBox)row.FindControl("cbxSubcontractorPurchaseOrder")).Checked; // bool subcontractorInsuranceCertificate = ((CheckBox)row.FindControl("cbxSubcontractorInsuranceCertificate")).Checked; // bool subcontractorWSIB = ((CheckBox)row.FindControl("cbxSubcontractorWSIB")).Checked; // string subcontractorMOLForm1000 = ((DropDownList)row.FindControl("ddlSubcontractorMolForm1000")).SelectedValue; // int? royalties = null; // if (((TextBox)row.FindControl("tbxRoyalties")).Text != "") // { // royalties = Int32.Parse(((TextBox)row.FindControl("tbxRoyalties")).Text); // } //projectSubcontractor.Update(projectId, subcontractorRefId, subcontractorId, subcontractorWrittenQuote, subcontractorSurveyedSite, subcontractorWorkedBefore, subcontractorRole, subcontractorAgreement, subcontractorIssues, subcontractorPurchaseOrder, subcontractorInsuranceCertificate, subcontractorWSIB, subcontractorMOLForm1000, false, Int32.Parse(hdfCompanyId.Value.Trim()), royalties); //projectSubcontractor.Update(projectId, 1, subcontractorWrittenQuote, subcontractorAgreement, Int32.Parse(hdfCompanyId.Value.Trim())); //} decimal unitsBudget = 0M; if (tbxUnitsBudget.Text.Trim() != "") unitsBudget = decimal.Parse(tbxUnitsBudget.Text); decimal materialsBudget = 0M; if (tbxMaterialsBudget.Text.Trim() != "") materialsBudget = decimal.Parse(tbxMaterialsBudget.Text); decimal subcontractorsBudget = 0M; if (tbxSubcontractorsBudget.Text.Trim() != "") subcontractorsBudget = decimal.Parse(tbxSubcontractorsBudget.Text); decimal hotelsBudget = 0M; if (tbxHotelsBudget.Text.Trim() != "") hotelsBudget = decimal.Parse(tbxHotelsBudget.Text); decimal bondingsBudget = 0M; if (tbxBondingsBudget.Text.Trim() != "") bondingsBudget = decimal.Parse(tbxBondingsBudget.Text); decimal insurancesBudget = 0M; if (tbxInsurancesBudget.Text.Trim() != "") insurancesBudget = decimal.Parse(tbxInsurancesBudget.Text); ProjectNavigatorProjectUnitsBudget projectNavigatorProjectUnitsBudget = new ProjectNavigatorProjectUnitsBudget(projectNavigatorTDS); if (projectNavigatorProjectUnitsBudget.Table.Rows.Count > 0) { projectNavigatorProjectUnitsBudget.Update(projectId, unitsBudget); } else { projectNavigatorProjectUnitsBudget.Insert(projectId, unitsBudget, false, Int32.Parse(hdfCompanyId.Value), false); } ProjectNavigatorProjectMaterialsBudget projectNavigatorProjectMaterialsBudget = new ProjectNavigatorProjectMaterialsBudget(projectNavigatorTDS); if (projectNavigatorProjectMaterialsBudget.Table.Rows.Count > 0) { projectNavigatorProjectMaterialsBudget.Update(projectId, materialsBudget); } else { projectNavigatorProjectMaterialsBudget.Insert(projectId, materialsBudget, false, Int32.Parse(hdfCompanyId.Value), false); } ProjectNavigatorProjectSubcontractorsBudget projectNavigatorProjectSubcontractorsBudget = new ProjectNavigatorProjectSubcontractorsBudget(projectNavigatorTDS); if (projectNavigatorProjectSubcontractorsBudget.Table.Rows.Count > 0) { projectNavigatorProjectSubcontractorsBudget.Update(projectId, 1, 1, subcontractorsBudget, false, Int32.Parse(hdfCompanyId.Value)); } else { projectNavigatorProjectSubcontractorsBudget.Insert(projectId, 1, subcontractorsBudget, false, Int32.Parse(hdfCompanyId.Value), false, ""); } ProjectNavigatorProjectHotelsBudget projectNavigatorProjectHotelsBudget = new ProjectNavigatorProjectHotelsBudget(projectNavigatorTDS); if (projectNavigatorProjectHotelsBudget.Table.Rows.Count > 0) { projectNavigatorProjectHotelsBudget.Update(projectId, 1, 1, hotelsBudget, false, Int32.Parse(hdfCompanyId.Value)); } else { projectNavigatorProjectHotelsBudget.Insert(projectId, 1, hotelsBudget, false, Int32.Parse(hdfCompanyId.Value), false, ""); } ProjectNavigatorProjectBondingsBudget projectNavigatorProjectBondingsBudget = new ProjectNavigatorProjectBondingsBudget(projectNavigatorTDS); if (projectNavigatorProjectBondingsBudget.Table.Rows.Count > 0) { projectNavigatorProjectBondingsBudget.Update(projectId, 1, 1, bondingsBudget, false, Int32.Parse(hdfCompanyId.Value)); } else { projectNavigatorProjectBondingsBudget.Insert(projectId, 1, bondingsBudget, false, Int32.Parse(hdfCompanyId.Value), false, ""); } ProjectNavigatorProjectInsurancesBudget projectNavigatorProjectInsurancesBudget = new ProjectNavigatorProjectInsurancesBudget(projectNavigatorTDS); if (projectNavigatorProjectInsurancesBudget.Table.Rows.Count > 0) { projectNavigatorProjectInsurancesBudget.Update(projectId, 1, 1, insurancesBudget, false, Int32.Parse(hdfCompanyId.Value)); } else { projectNavigatorProjectInsurancesBudget.Insert(projectId, 1, insurancesBudget, false, Int32.Parse(hdfCompanyId.Value), false, ""); } } }