// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // /// <summary> /// Delete /// </summary> /// <param name="workId">workId</param> /// <param name="companyId">companyId</param> public void Delete(int workId, int companyId) { WorkFullLengthLiningM1LateralGateway workFullLengthLiningM1LateralGateway = new WorkFullLengthLiningM1LateralGateway(); workFullLengthLiningM1LateralGateway.LoadByWorkId(workId, companyId); foreach (WorkTDS.LFS_WORK_FULLLENGTHLINING_M1_LATERALRow row in (WorkTDS.LFS_WORK_FULLLENGTHLINING_M1_LATERALDataTable)workFullLengthLiningM1LateralGateway.Table) { // delete lfs lateral client WorkGateway workGateway = new WorkGateway(); workGateway.LoadByWorkId(workId, companyId); int currentProjectId = workGateway.GetProjectId(workId); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(currentProjectId); int clientId = projectGateway.GetClientID(currentProjectId); LfsAssetSewerLateralClientGateway lfsAssetSewerLateralClientGateway = new LfsAssetSewerLateralClientGateway(); lfsAssetSewerLateralClientGateway.LoadByAssetIdClientId(row.Lateral, clientId, companyId); if (lfsAssetSewerLateralClientGateway.Table.Rows.Count > 0) { LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); lfsAssetSewerLateralClient.DeleteDirect(row.Lateral, clientId, companyId); } // Delete work lateral workFullLengthLiningM1LateralGateway.Delete(workId, row.Lateral, companyId); // Delete section LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null); lfsAssetSewerLateral.DeleteDirect(row.Lateral, companyId); } }
// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // /// <summary> /// Load /// </summary> /// <param name="projectId">projectId</param> /// <param name="companyId">companyId</param> /// <para>Load Original table to process data for Project Costing report without filters </para> public void Load(int projectId, int companyId) { // Initialization of Gateways ProjectGateway projectGateway = new ProjectGateway(Data); projectGateway.LoadByProjectId(projectId); int companiesId = (int)projectGateway.GetClientID(projectId); ProjectJobInfoGateway projectJobInfoGateway = new ProjectJobInfoGateway(Data); projectJobInfoGateway.LoadAllByProjectId(projectId); ProjectSaleBillingPricingGateway projectSaleBillingPricingGateway = new ProjectSaleBillingPricingGateway(Data); projectSaleBillingPricingGateway.LoadAllByProjectId(projectId); ProjectTechnicalGateway projectTechnicalGateway = new ProjectTechnicalGateway(Data); projectTechnicalGateway.LoadByProjectId(projectId); ProjectTermsPOGateway projectTermsPOGateway = new ProjectTermsPOGateway(Data); projectTermsPOGateway.LoadByProjectId(projectId); ProjectSubcontractorGateway projectSubcontractorGateway = new ProjectSubcontractorGateway(Data); projectSubcontractorGateway.LoadByProjectId(projectId); ProjectEngineerSubcontractorsGateway projectEngineerSubcontractorsGateway = new ProjectEngineerSubcontractorsGateway(Data); projectEngineerSubcontractorsGateway.LoadAllByProjectId(projectId); ProjectHistoryGateway projectHistoryGateway = new ProjectHistoryGateway(Data); projectHistoryGateway.LoadFirstRow(projectId); ProjectNotesGateway projectNoteGateway = new ProjectNotesGateway(Data); projectNoteGateway.LoadByProjectId(projectId); ProjectServiceGateway projectServiceGateway = new ProjectServiceGateway(Data); projectServiceGateway.LoadByProjectId(projectId); // For Updates // ...Get the loginId for submitted field at report // ...Update LFS_PROJECT this.UpdateForReport(projectId, companiesId, projectGateway.GetSalesmanID(projectId), (projectGateway.GetProjectLeadID(projectId)).GetValueOrDefault(), companyId); // ...Update LFS_PROJECT_ENGINEER_SUBCONTRACTOR ProjectSynopsisEngineerSubcontractors projectSynopsisEngineerSubcontractors = new ProjectSynopsisEngineerSubcontractors(Data); if (projectSynopsisEngineerSubcontractors.Table.Rows.Count > 0) { projectSynopsisEngineerSubcontractors.UpdateForReport(projectId, companiesId, companyId); } // ...Update LFS_PROJECT_SUBCONTRACTOR ProjectSynopsisSubcontractor projectSynopsisSubcontractor = new ProjectSynopsisSubcontractor(Data); if (projectSynopsisSubcontractor.Table.Rows.Count > 0) { projectSynopsisSubcontractor.UpdateForReport(projectId, companiesId, companyId); } // ...Update LFS_PROJECT_NOTE ProjectSynopsisNote projectSynopsisNote = new ProjectSynopsisNote(Data); if (projectSynopsisNote.Table.Rows.Count > 0) { projectSynopsisNote.UpdateForReport(projectId, companyId); } // ...Update LFS_PROJECT_SERVICE and Total Average Price ProjectSynopsisService projectSynopsisService = new ProjectSynopsisService(Data); if (projectSynopsisService.Table.Rows.Count > 0) { ProjectSynopsisReportTDS.LFS_PROJECTRow rowTotalAveragePrice = ((ProjectSynopsisReportTDS.LFS_PROJECTDataTable)Table).FindByProjectID(projectId); rowTotalAveragePrice.TotalAveragePrice = projectSynopsisService.UpdateForReport(projectId, companyId); } }
// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!Convert.ToBoolean(Session["sgLFS_PROJECTS_VIEW"])) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } // Validate query string if ((string)Request.QueryString["source_page"] == null) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in project_sections_navigator.aspx"); } // If coming from // ... Left Menu or Out if ((Request.QueryString["source_page"] == "lm") || (Request.QueryString["source_page"] == "out")) { // Store Navigator State and Update control StoreNavigatorState(); ViewState["update"] = Request.QueryString["update"]; projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; tNoResults.Visible = false; } // ... project_sections_navigator2.aspx if (Request.QueryString["source_page"] == "project_sections_navigator2.aspx") { RestoreNavigatorState(); if ((string)Request.QueryString["no_results"] == "yes") { tNoResults.Visible = true; } else { tNoResults.Visible = false; } } // Tag page hdfCompanyId.Value = Session["companyID"].ToString(); hdfProjectId.Value = Request.QueryString["project_id"]; ViewState["origin"] = Request.QueryString["origin"]; ViewState["state"] = Request.QueryString["state"]; ViewState["active_tab"] = Request.QueryString["active_tab"]; hdfDataChanged.Value = Request.QueryString["data_changed"]; hdfDataChangedMessage.Value = "Changes made to this project will not be saved."; projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; // ... for project int currentProjectId = Int32.Parse(hdfProjectId.Value.ToString()); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(currentProjectId); string name = projectGateway.GetName(currentProjectId); if (name.Length > 23) name = name.Substring(0, 20) + "..."; lblTitleProjectName.Text = name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")"; // ... for client int currentCompanyId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString())); int companyId = Int32.Parse(hdfCompanyId.Value); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(currentCompanyId, companyId); lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentCompanyId); hdfClientId.Value = projectGateway.GetClientID(int.Parse(hdfProjectId.Value)).ToString(); } else { // Restore dataset projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; // ... for project int currentProjectId = Int32.Parse(hdfProjectId.Value.ToString()); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(currentProjectId); string name = projectGateway.GetName(currentProjectId); if (name.Length > 23) name = name.Substring(0, 20) + "..."; lblTitleProjectName.Text = name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")"; // ... for client int currentCompanyId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString())); int companyId = Int32.Parse(hdfCompanyId.Value); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(currentCompanyId, companyId); lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentCompanyId); } }
/// <summary> /// LoadFairWageProject /// </summary> /// <param name="works">works</param> /// <param name="jobClassType">jobClassType</param> /// <param name="projectId">projectId</param> /// <param name="startDate">startDate</param> /// <param name="endDate">endDate</param> /// <param name="companyId">companyId</param> public void LoadFairWageProject(ArrayList works, ArrayList jobClassType, int projectId, DateTime startDate, DateTime endDate, int companyId, string month) { ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); string projectName = projectGateway.GetName(projectId); int clientId = projectGateway.GetClientID(projectId); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(clientId, companyId); string clientName = companiesGateway.GetName(clientId); // General vars int overtimeByCountry = 40; //Default for USA Projects int refId = GetNewRefId(); int countryId = 1; //Default Canada if (projectGateway.GetCountryID(projectId) == 2) { countryId = 2;//USA } // Foreach of Works (FLL, RA, JL, PR, MH Rehab, MOB, Other) foreach (string work_ in works) { // Load Functions by Work ProjectCostingSheetAddFunctionListGateway projectCostingSheetAddFunctionListGateway = new ProjectCostingSheetAddFunctionListGateway(); projectCostingSheetAddFunctionListGateway.LoadByWork_(work_); // Foreach of Functions foreach (ProjectCostingSheetAddTDS.FunctionListRow functionListRow in (ProjectCostingSheetAddTDS.FunctionListDataTable)projectCostingSheetAddFunctionListGateway.Table) { // Foreach of Job Class (Laborer Group 2, Laborer Group 6, Operator Group 1, Operator Group 2, Regular Rate) foreach (string jobClassType_ in jobClassType) { // Get Fringe Rate by Job Class decimal fringeRate = projectGateway.GetOperatorGroupFringeRate(projectId, jobClassType_); // Load Employees with Timesheet by ProjectId, StartDate, EndDate, Work, Function and Job Class ProjectCostingSheetAddEmployeeListGateway projectCostingSheetAddEmployeeListGateway = new ProjectCostingSheetAddEmployeeListGateway(Data); projectCostingSheetAddEmployeeListGateway.LoadByProjectIdStartDateEndDateWorkFunctionJobClass(projectId, startDate, endDate, work_, functionListRow.Function_, jobClassType_, companyId); // Foreach of Employees with Timesheet foreach (ProjectCostingSheetAddTDS.EmployeeListRow employeeListRow in (ProjectCostingSheetAddTDS.EmployeeListDataTable)projectCostingSheetAddEmployeeListGateway.Table) { DateTime newStartDate = new DateTime(); newStartDate = startDate; DateTime newEndDate = new DateTime(); newEndDate = endDate; // If Project is from Canada we get overtime if (projectGateway.GetCountryID(projectId) == 1) { // Get Category of Employee EmployeeGateway employeeGateway = new EmployeeGateway(); employeeGateway.LoadByEmployeeId(employeeListRow.EmployeeID); switch (employeeGateway.GetCategory(employeeListRow.EmployeeID)) { case "Special Forces": overtimeByCountry = 50; break; case "Field": overtimeByCountry = 50; break; case "Field 44": overtimeByCountry = 44; break; case "Office/Admin": overtimeByCountry = 44; break; case "Mechanic/Manufactoring": overtimeByCountry = 44; break; } } // Load Cost Pay Periods of Employee by StartDate and EndDate ProjectCostingSheetAddEmployeePayPeriodGateway projectCostingSheetAddEmployeePayPeriodGateway = new ProjectCostingSheetAddEmployeePayPeriodGateway(Data); projectCostingSheetAddEmployeePayPeriodGateway.LoadByStartDateEndDateEmployeeId(startDate, endDate, employeeListRow.EmployeeID); // If Employee has Cost Pay Periods between StartDate and EndDate if (projectCostingSheetAddEmployeePayPeriodGateway.Table.Rows.Count > 0) { // Foreach of Cost Pay Periods foreach (ProjectCostingSheetAddTDS.EmployeePayPeriodRow employeePayPeriodRow in (ProjectCostingSheetAddTDS.EmployeePayPeriodDataTable)projectCostingSheetAddEmployeePayPeriodGateway.Table) { // Update newEndDate with Date of Cost Pay Period newEndDate = employeePayPeriodRow.Date_.AddDays(-1); // Load Project Times of Employee by ProjectId, StartDate, EndDate, Work, Function, Job Class ProjectCostingSheetAddOriginalLabourHourGateway projectCostingSheetAddOriginalLabourHourGateway = new ProjectCostingSheetAddOriginalLabourHourGateway(Data); projectCostingSheetAddOriginalLabourHourGateway.LoadByProjectStartDateEndDateWorkFunctionJobClassTypeEmployeeId(projectId, newStartDate, newEndDate, work_, functionListRow.Function_, jobClassType_, employeeListRow.EmployeeID); // If Employee has ProjectTime if (projectCostingSheetAddOriginalLabourHourGateway.Table.Rows.Count > 0) { double lhQuantity = 0; double overtime = 0; decimal mealsQuantity = 0; decimal motelQuantity = 0; string employeeName = ""; refId++; // Foreach original ProjectTime foreach (ProjectCostingSheetAddTDS.OriginalLabourHourRow originalRow in (ProjectCostingSheetAddTDS.OriginalLabourHourDataTable)projectCostingSheetAddOriginalLabourHourGateway.Table) { employeeName = originalRow.EmployeeName; // Meal hours quantity if (!originalRow.IsMealsCountryNull()) { if (originalRow.MealsAllowance > 0) { mealsQuantity++; } } double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID); if (acumPeriod > overtimeByCountry) { overtime = overtime + originalRow.ProjectTime; } else { double newAcumPeriod = acumPeriod + originalRow.ProjectTime; if (newAcumPeriod > overtimeByCountry) { overtime = overtime + (newAcumPeriod - overtimeByCountry); lhQuantity = lhQuantity + (originalRow.ProjectTime - (newAcumPeriod - overtimeByCountry)); } else { lhQuantity = lhQuantity + originalRow.ProjectTime; } } } if (lhQuantity > 0) { ProjectCostingSheetAddTDS.LabourHoursInformationRow newRow = ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).NewLabourHoursInformationRow(); if (projectGateway.IsFairWageProjectWorkFunction(projectId, work_, functionListRow.Function_)) { if (jobClassType_ != "Regular Rate") { decimal fairWageRate = projectGateway.GetOperatorGroupRate(projectId, jobClassType_); GetEmployeeDataFairWage(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRow, countryId, fringeRate, fairWageRate); } else { GetEmployeeData(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRow); // Is same to non fair wage project } } else { GetEmployeeData(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRow); // Is same to non fair wage project } newRow.CostingSheetID = 0; newRow.Work_ = work_; newRow.EmployeeID = employeeListRow.EmployeeID; newRow.RefID = refId; newRow.LHQuantity = lhQuantity; newRow.MealsQuantity = Convert.ToInt32(mealsQuantity); if (mealsQuantity > 0) newRow.MealsUnitOfMeasurement = "Day"; else newRow.MealsUnitOfMeasurement = ""; if (motelQuantity > 0) newRow.MotelUnitOfMeasurement = "Day"; else newRow.MotelUnitOfMeasurement = ""; newRow.MealsCostCad = MealsAllowance.GetMealsAllowance(1, true, "Full Day"); newRow.MotelCostCad = 0; newRow.TotalCostCad = (Convert.ToDecimal(lhQuantity) * decimal.Round(newRow.LHCostCad,2)) + (mealsQuantity * newRow.MealsCostCad) + (motelQuantity * newRow.MotelCostCad); newRow.MealsCostUsd = MealsAllowance.GetMealsAllowance(2, true, "Full Day"); newRow.MotelCostUsd = 0; newRow.TotalCostUsd = (Convert.ToDecimal(lhQuantity) * decimal.Round(newRow.LHCostUsd,2)) + (mealsQuantity * newRow.MealsCostUsd) + (motelQuantity * newRow.MotelCostUsd); newRow.Deleted = false; newRow.InDatabase = false; newRow.COMPANY_ID = companyId; newRow.Name = employeeName; newRow.StartDate = newStartDate; newRow.EndDate = newEndDate; newRow.FromDatabase = true; newRow.Function_ = functionListRow.Function_; newRow.WorkFunction = work_ + " . " + functionListRow.Function_; newRow.Month = month; newRow.ClientName = clientName; newRow.ProjectName = projectName; ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).AddLabourHoursInformationRow(newRow); } if (overtime > 0) { refId++; ProjectCostingSheetAddTDS.LabourHoursInformationRow newRowOt = ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).NewLabourHoursInformationRow(); if (projectGateway.IsFairWageProjectWorkFunction(projectId, work_, functionListRow.Function_)) { if (jobClassType_ != "Regular Rate") { decimal fairWageRate = projectGateway.GetOperatorGroupRate(projectId, jobClassType_); GetEmployeeDataFairWageOvertime(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRowOt, countryId, fringeRate, fairWageRate); } else { GetEmployeeDataOvertime(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRowOt); // Is same to non fair wage project } } else { GetEmployeeDataOvertime(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRowOt); // Is same to non fair wage project } newRowOt.CostingSheetID = 0; newRowOt.Work_ = work_; newRowOt.EmployeeID = employeeListRow.EmployeeID; newRowOt.RefID = refId; newRowOt.LHQuantity = overtime; newRowOt.MealsQuantity = 0; newRowOt.MealsUnitOfMeasurement = ""; newRowOt.MotelUnitOfMeasurement = ""; newRowOt.MealsCostCad = MealsAllowance.GetMealsAllowance(1, true, "Full Day"); newRowOt.MotelCostCad = 0; newRowOt.TotalCostCad = (Convert.ToDecimal(overtime) * decimal.Round(newRowOt.LHCostCad,2)); newRowOt.MealsCostUsd = MealsAllowance.GetMealsAllowance(2, true, "Full Day"); newRowOt.MotelCostUsd = 0; newRowOt.TotalCostUsd = (Convert.ToDecimal(overtime) * decimal.Round(newRowOt.LHCostUsd,2)); newRowOt.Deleted = false; newRowOt.InDatabase = false; newRowOt.COMPANY_ID = companyId; newRowOt.Name = employeeName + " - Overtime"; newRowOt.StartDate = newStartDate; newRowOt.EndDate = newEndDate; newRowOt.FromDatabase = true; newRowOt.Function_ = functionListRow.Function_; newRowOt.WorkFunction = work_ + " . " + functionListRow.Function_; newRowOt.Month = month; newRowOt.ClientName = clientName; newRowOt.ProjectName = projectName; ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).AddLabourHoursInformationRow(newRowOt); } } newStartDate = newEndDate.AddDays(1); } if (newEndDate <= endDate) { ProjectCostingSheetAddOriginalLabourHourGateway projectCostingSheetAddOriginalLabourHourGateway = new ProjectCostingSheetAddOriginalLabourHourGateway(Data); projectCostingSheetAddOriginalLabourHourGateway.LoadByProjectStartDateEndDateWorkFunctionJobClassTypeEmployeeId(projectId, newStartDate, endDate, work_, functionListRow.Function_, jobClassType_, employeeListRow.EmployeeID); if (projectCostingSheetAddOriginalLabourHourGateway.Table.Rows.Count > 0) { double lhQuantity = 0; double overtime = 0; decimal mealsQuantity = 0; decimal motelQuantity = 0; string employeeName = ""; refId++; foreach (ProjectCostingSheetAddTDS.OriginalLabourHourRow originalRow in (ProjectCostingSheetAddTDS.OriginalLabourHourDataTable)projectCostingSheetAddOriginalLabourHourGateway.Table) { employeeName = originalRow.EmployeeName; // Meal hours quantity if (!originalRow.IsMealsCountryNull()) { if (originalRow.MealsAllowance > 0) { mealsQuantity++; } } double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID); if (acumPeriod > overtimeByCountry) { overtime = overtime + originalRow.ProjectTime; } else { double newAcumPeriod = acumPeriod + originalRow.ProjectTime; if (newAcumPeriod > overtimeByCountry) { overtime = overtime + (newAcumPeriod - overtimeByCountry); lhQuantity = lhQuantity + (originalRow.ProjectTime - (newAcumPeriod - overtimeByCountry)); } else { lhQuantity = lhQuantity + originalRow.ProjectTime; } } } if (lhQuantity > 0) { ProjectCostingSheetAddTDS.LabourHoursInformationRow newRow = ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).NewLabourHoursInformationRow(); if (projectGateway.IsFairWageProjectWorkFunction(projectId, work_, functionListRow.Function_)) { if (jobClassType_ != "Regular Rate") { decimal fairWageRate = projectGateway.GetOperatorGroupRate(projectId, jobClassType_); GetEmployeeDataFairWage(newStartDate, endDate, employeeListRow.EmployeeID, work_, newRow, countryId, fringeRate, fairWageRate); } else { GetEmployeeData(newStartDate, endDate, employeeListRow.EmployeeID, work_, newRow); } } else { GetEmployeeData(newStartDate, endDate, employeeListRow.EmployeeID, work_, newRow); } newRow.CostingSheetID = 0; newRow.Work_ = work_; newRow.EmployeeID = employeeListRow.EmployeeID; newRow.RefID = refId; newRow.LHQuantity = lhQuantity; newRow.MealsQuantity = Convert.ToInt32(mealsQuantity); if (mealsQuantity > 0) newRow.MealsUnitOfMeasurement = "Day"; else newRow.MealsUnitOfMeasurement = ""; if (motelQuantity > 0) newRow.MotelUnitOfMeasurement = "Day"; else newRow.MotelUnitOfMeasurement = ""; newRow.MealsCostCad = MealsAllowance.GetMealsAllowance(1, true, "Full Day"); newRow.MotelCostCad = 0; newRow.TotalCostCad = (Convert.ToDecimal(lhQuantity) * decimal.Round(newRow.LHCostCad,2)) + (mealsQuantity * newRow.MealsCostCad) + (motelQuantity * newRow.MotelCostCad); newRow.MealsCostUsd = MealsAllowance.GetMealsAllowance(2, true, "Full Day"); newRow.MotelCostUsd = 0; newRow.TotalCostUsd = (Convert.ToDecimal(lhQuantity) * decimal.Round(newRow.LHCostUsd,2)) + (mealsQuantity * newRow.MealsCostUsd) + (motelQuantity * newRow.MotelCostUsd); newRow.Deleted = false; newRow.InDatabase = false; newRow.COMPANY_ID = companyId; newRow.Name = employeeName; newRow.StartDate = newStartDate; newRow.EndDate = endDate; newRow.FromDatabase = true; newRow.Function_ = functionListRow.Function_; newRow.WorkFunction = work_ + " . " + functionListRow.Function_; newRow.Month = month; newRow.ClientName = clientName; newRow.ProjectName = projectName; ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).AddLabourHoursInformationRow(newRow); } if (overtime > 0) { refId++; ProjectCostingSheetAddTDS.LabourHoursInformationRow newRowOt = ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).NewLabourHoursInformationRow(); if (projectGateway.IsFairWageProjectWorkFunction(projectId, work_, functionListRow.Function_)) { if (jobClassType_ != "Regular Rate") { decimal fairWageRate = projectGateway.GetOperatorGroupRate(projectId, jobClassType_); GetEmployeeDataFairWageOvertime(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRowOt, countryId, fringeRate, fairWageRate); } else { GetEmployeeDataOvertime(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRowOt); // Is same to non fair wage project } } else { GetEmployeeDataOvertime(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRowOt); // Is same to non fair wage project } newRowOt.CostingSheetID = 0; newRowOt.Work_ = work_; newRowOt.EmployeeID = employeeListRow.EmployeeID; newRowOt.RefID = refId; newRowOt.LHQuantity = overtime; newRowOt.MealsQuantity = 0; newRowOt.MealsUnitOfMeasurement = ""; newRowOt.MotelUnitOfMeasurement = ""; newRowOt.MealsCostCad = MealsAllowance.GetMealsAllowance(1, true, "Full Day"); newRowOt.MotelCostCad = 0; newRowOt.TotalCostCad = (Convert.ToDecimal(overtime) * decimal.Round(newRowOt.LHCostCad,2)); newRowOt.MealsCostUsd = MealsAllowance.GetMealsAllowance(2, true, "Full Day"); newRowOt.MotelCostUsd = 0; newRowOt.TotalCostUsd = (Convert.ToDecimal(overtime) * decimal.Round(newRowOt.LHCostUsd,2)); newRowOt.Deleted = false; newRowOt.InDatabase = false; newRowOt.COMPANY_ID = companyId; newRowOt.Name = employeeName + " - Overtime"; newRowOt.StartDate = newStartDate; newRowOt.EndDate = endDate; newRowOt.FromDatabase = true; newRowOt.Function_ = functionListRow.Function_; newRowOt.WorkFunction = work_ + " . " + functionListRow.Function_; newRowOt.Month = month; newRowOt.ClientName = clientName; newRowOt.ProjectName = projectName; ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).AddLabourHoursInformationRow(newRowOt); } } } } else { ProjectCostingSheetAddOriginalLabourHourGateway projectCostingSheetAddOriginalLabourHourGateway = new ProjectCostingSheetAddOriginalLabourHourGateway(Data); projectCostingSheetAddOriginalLabourHourGateway.LoadByProjectStartDateEndDateWorkFunctionJobClassTypeEmployeeId(projectId, startDate, endDate, work_, functionListRow.Function_, jobClassType_, employeeListRow.EmployeeID); if (projectCostingSheetAddOriginalLabourHourGateway.Table.Rows.Count > 0) { double lhQuantity = 0; double overtime = 0; decimal mealsQuantity = 0; decimal motelQuantity = 0; string employeeName = ""; refId++; foreach (ProjectCostingSheetAddTDS.OriginalLabourHourRow originalRow in (ProjectCostingSheetAddTDS.OriginalLabourHourDataTable)projectCostingSheetAddOriginalLabourHourGateway.Table) { employeeName = originalRow.EmployeeName; // Meal hours quantity if (!originalRow.IsMealsCountryNull()) { if (originalRow.MealsAllowance > 0) { mealsQuantity++; } } double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID); if (acumPeriod > overtimeByCountry) { overtime = overtime + originalRow.ProjectTime; } else { double newAcumPeriod = acumPeriod + originalRow.ProjectTime; if (newAcumPeriod > overtimeByCountry) { overtime = overtime + (newAcumPeriod - overtimeByCountry); lhQuantity = lhQuantity + (originalRow.ProjectTime - (newAcumPeriod - overtimeByCountry)); } else { lhQuantity = lhQuantity + originalRow.ProjectTime; } } } if (lhQuantity > 0) { ProjectCostingSheetAddTDS.LabourHoursInformationRow newRow = ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).NewLabourHoursInformationRow(); if (projectGateway.IsFairWageProjectWorkFunction(projectId, work_, functionListRow.Function_)) { if (jobClassType_ != "Regular Rate") { decimal fairWageRate = projectGateway.GetOperatorGroupRate(projectId, jobClassType_); GetEmployeeDataFairWage(startDate, endDate, employeeListRow.EmployeeID, work_, newRow, countryId, fringeRate, fairWageRate); } else { GetEmployeeData(startDate, endDate, employeeListRow.EmployeeID, work_, newRow); } } else { GetEmployeeData(startDate, endDate, employeeListRow.EmployeeID, work_, newRow); } newRow.CostingSheetID = 0; newRow.Work_ = work_; newRow.EmployeeID = employeeListRow.EmployeeID; newRow.RefID = refId; newRow.LHQuantity = lhQuantity; newRow.MealsQuantity = Convert.ToInt32(mealsQuantity); if (mealsQuantity > 0) newRow.MealsUnitOfMeasurement = "Day"; else newRow.MealsUnitOfMeasurement = ""; if (motelQuantity > 0) newRow.MotelUnitOfMeasurement = "Day"; else newRow.MotelUnitOfMeasurement = ""; newRow.MealsCostCad = MealsAllowance.GetMealsAllowance(1, true, "Full Day"); newRow.MotelCostCad = 0; newRow.TotalCostCad = (Convert.ToDecimal(lhQuantity) * decimal.Round(newRow.LHCostCad,2)) + (mealsQuantity * newRow.MealsCostCad) + (motelQuantity * newRow.MotelCostCad); newRow.MealsCostUsd = MealsAllowance.GetMealsAllowance(2, true, "Full Day"); newRow.MotelCostUsd = 0; newRow.TotalCostUsd = (Convert.ToDecimal(lhQuantity) * decimal.Round(newRow.LHCostUsd,2)) + (mealsQuantity * newRow.MealsCostUsd) + (motelQuantity * newRow.MotelCostUsd); newRow.Deleted = false; newRow.InDatabase = false; newRow.COMPANY_ID = companyId; newRow.Name = employeeName; newRow.StartDate = startDate; newRow.EndDate = endDate; newRow.FromDatabase = true; newRow.Function_ = functionListRow.Function_; newRow.WorkFunction = work_ + " . " + functionListRow.Function_; newRow.Month = month; newRow.ClientName = clientName; newRow.ProjectName = projectName; ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).AddLabourHoursInformationRow(newRow); } if (overtime > 0) { refId++; ProjectCostingSheetAddTDS.LabourHoursInformationRow newRowOt = ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).NewLabourHoursInformationRow(); if (projectGateway.IsFairWageProjectWorkFunction(projectId, work_, functionListRow.Function_)) { if (jobClassType_ != "Regular Rate") { decimal fairWageRate = projectGateway.GetOperatorGroupRate(projectId, jobClassType_); GetEmployeeDataFairWageOvertime(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRowOt, countryId, fringeRate, fairWageRate); } else { GetEmployeeDataOvertime(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRowOt); // Is same to non fair wage project } } else { GetEmployeeDataOvertime(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRowOt); // Is same to non fair wage project } newRowOt.CostingSheetID = 0; newRowOt.Work_ = work_; newRowOt.EmployeeID = employeeListRow.EmployeeID; newRowOt.RefID = refId; newRowOt.LHQuantity = overtime; newRowOt.MealsQuantity = 0; newRowOt.MealsUnitOfMeasurement = ""; newRowOt.MotelUnitOfMeasurement = ""; newRowOt.MealsCostCad = MealsAllowance.GetMealsAllowance(1, true, "Full Day"); newRowOt.MotelCostCad = 0; newRowOt.TotalCostCad = (Convert.ToDecimal(overtime) * decimal.Round(newRowOt.LHCostCad,2)); newRowOt.MealsCostUsd = MealsAllowance.GetMealsAllowance(2, true, "Full Day"); newRowOt.MotelCostUsd = 0; newRowOt.TotalCostUsd = (Convert.ToDecimal(overtime) * decimal.Round(newRowOt.LHCostUsd,2)); newRowOt.Deleted = false; newRowOt.InDatabase = false; newRowOt.COMPANY_ID = companyId; newRowOt.Name = employeeName + " - Overtime"; newRowOt.StartDate = startDate; newRowOt.EndDate = endDate; newRowOt.FromDatabase = true; newRowOt.Function_ = functionListRow.Function_; newRowOt.WorkFunction = work_ + " . " + functionListRow.Function_; newRowOt.Month = month; newRowOt.ClientName = clientName; newRowOt.ProjectName = projectName; ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).AddLabourHoursInformationRow(newRowOt); } } } } } } } }
private void Generate() { mReport1 master = (mReport1)this.Master; int companyId = Convert.ToInt32(Session["companyID"]); string type = Request.QueryString["type"].ToString(); int costingSheetId = 0; int projectId = 0; ProjectCostingSheetInformationBasicInformation projectCostingSheetInformationBasicInformation = new ProjectCostingSheetInformationBasicInformation(); if (ddlCostingSheets.SelectedValue != "-1") { // Get Data costingSheetId = Convert.ToInt32(ddlCostingSheets.SelectedValue); projectCostingSheetInformationBasicInformation.LoadByCostingSheetIdForPreviewReport(costingSheetId, companyId); ProjectCostingSheetInformationBasicInformationGateway projectCostingSheetInformationBasicInformationGateway = new ProjectCostingSheetInformationBasicInformationGateway(projectCostingSheetInformationBasicInformation.Data); projectId = projectCostingSheetInformationBasicInformationGateway.GetProjectID(costingSheetId); // ... set properties to master page master.Data = projectCostingSheetInformationBasicInformation.Data; master.Table = projectCostingSheetInformationBasicInformation.TableName; master.Report = new ProjectCostingSheetsPreview(); // Get report if (projectCostingSheetInformationBasicInformation.Table.Rows.Count > 0) { ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); int clientId = projectGateway.GetClientID(projectId); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadByCompaniesId(clientId, companyId); master.SetParameter("Client", companiesGateway.GetName(clientId)); string name = projectGateway.GetName(projectId); master.SetParameter("Project", name); int loginId = Convert.ToInt32(Session["loginID"]); LoginGateway loginGateway = new LoginGateway(); loginGateway.LoadByLoginId(loginId, companyId); string user = loginGateway.GetLastName(loginId, companyId) + " " + loginGateway.GetFirstName(loginId, companyId); master.SetParameter("User", user.Trim()); master.SetParameter("CostingSheet", projectCostingSheetInformationBasicInformationGateway.GetName(costingSheetId)); if (type == "resume") { ((Section)master.Report.ReportDefinition.Sections["detailsLabourHours"]).SectionFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["detailsLabourHours2"]).SectionFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["detailsUnits"]).SectionFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["detailsUnits2"]).SectionFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["detailsMaterials"]).SectionFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["detailsMaterials2"]).SectionFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["detailsOtherCosts"]).SectionFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["detailsOtherCosts2"]).SectionFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["detailsSubcontractors"]).SectionFormat.EnableSuppress = true; //((Section)master.Report.ReportDefinition.Sections["detailsSubcontractors2"]).SectionFormat.EnableSuppress = true; } else { ((Section)master.Report.ReportDefinition.Sections["detailsLabourHours"]).SectionFormat.EnableSuppress = false; ((Section)master.Report.ReportDefinition.Sections["detailsLabourHours2"]).SectionFormat.EnableSuppress = false; ((Section)master.Report.ReportDefinition.Sections["detailsUnits"]).SectionFormat.EnableSuppress = false; ((Section)master.Report.ReportDefinition.Sections["detailsUnits2"]).SectionFormat.EnableSuppress = false; ((Section)master.Report.ReportDefinition.Sections["detailsMaterials"]).SectionFormat.EnableSuppress = false; ((Section)master.Report.ReportDefinition.Sections["detailsMaterials2"]).SectionFormat.EnableSuppress = false; ((Section)master.Report.ReportDefinition.Sections["detailsOtherCosts"]).SectionFormat.EnableSuppress = false; ((Section)master.Report.ReportDefinition.Sections["detailsOtherCosts2"]).SectionFormat.EnableSuppress = false; ((Section)master.Report.ReportDefinition.Sections["detailsSubcontractors"]).SectionFormat.EnableSuppress = false; //((Section)master.Report.ReportDefinition.Sections["detailsSubcontractors2"]).SectionFormat.EnableSuppress = false; } if (projectGateway.GetCountryID(projectId) == 1)//Canada { // General ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text32"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text34"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text36"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text38"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text2"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["headerTotalSubcontractorsUsd"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalLabourHoursUsd1"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalUnitsUsd1"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalMaterialsUsd1"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalOtherCostsUsd1"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["GrandTotalUsd1"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalSubcontractorsUsd1"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["Text5"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["GrandTotalUsd2"].ObjectFormat.EnableSuppress = true; // Labour Hours ReportDocument rpLabourHoursDetails = master.Report.OpenSubreport("LabourHoursDetails"); ReportDocument rpLabourHoursResume = master.Report.OpenSubreport("LabourHoursResume"); ((Section)rpLabourHoursDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text5"].ObjectFormat.EnableSuppress = true; ((Section)rpLabourHoursDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text2"].ObjectFormat.EnableSuppress = true; ((Section)rpLabourHoursDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["LHCostUsd1"].ObjectFormat.EnableSuppress = true; ((Section)rpLabourHoursDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostUsd1"].ObjectFormat.EnableSuppress = true; ((Section)rpLabourHoursDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true; // ((Section)rpLabourHoursResume.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text2"].ObjectFormat.EnableSuppress = true; ((Section)rpLabourHoursResume.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostUsd1"].ObjectFormat.EnableSuppress = true; ((Section)rpLabourHoursResume.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true; // Units ReportDocument rpUnitsDetails = master.Report.OpenSubreport("UnitsDetails"); ReportDocument rpUnitsResume = master.Report.OpenSubreport("UnitsResume"); ((Section)rpUnitsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text3"].ObjectFormat.EnableSuppress = true; ((Section)rpUnitsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text2"].ObjectFormat.EnableSuppress = true; ((Section)rpUnitsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostUsd1"].ObjectFormat.EnableSuppress = true; ((Section)rpUnitsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostUsd1"].ObjectFormat.EnableSuppress = true; ((Section)rpUnitsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true; // ((Section)rpUnitsResume.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text6"].ObjectFormat.EnableSuppress = true; ((Section)rpUnitsResume.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostUsd1"].ObjectFormat.EnableSuppress = true; ((Section)rpUnitsResume.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true; // Materials ReportDocument rpMaterialsDetails = master.Report.OpenSubreport("MaterialsDetails"); ReportDocument rpMaterialsResune = master.Report.OpenSubreport("MaterialsResume"); ((Section)rpMaterialsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text3"].ObjectFormat.EnableSuppress = true; ((Section)rpMaterialsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text2"].ObjectFormat.EnableSuppress = true; ((Section)rpMaterialsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostUsd1"].ObjectFormat.EnableSuppress = true; ((Section)rpMaterialsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostUsd1"].ObjectFormat.EnableSuppress = true; ((Section)rpMaterialsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true; /// ((Section)rpMaterialsResune.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text6"].ObjectFormat.EnableSuppress = true; ((Section)rpMaterialsResune.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostUsd1"].ObjectFormat.EnableSuppress = true; ((Section)rpMaterialsResune.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true; // Subcontractors ReportDocument rpSubcontractorsDetails = master.Report.OpenSubreport("SubcontractorsDetails"); //ReportDocument rpSubcontractorsResune = master.Report.OpenSubreport("SubcontractorsResume"); ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text3"].ObjectFormat.EnableSuppress = true; ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text2"].ObjectFormat.EnableSuppress = true; ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostUsd1"].ObjectFormat.EnableSuppress = true; ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostUsd1"].ObjectFormat.EnableSuppress = true; ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd1"].ObjectFormat.EnableSuppress = true; /// //((Section)rpSubcontractorsResune.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text6"].ObjectFormat.EnableSuppress = true; //((Section)rpSubcontractorsResune.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostUsd1"].ObjectFormat.EnableSuppress = true; //((Section)rpSubcontractorsResune.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true; // Other Costs ReportDocument rpOtherCostsDetails = master.Report.OpenSubreport("OtherCostsDetails"); ReportDocument rpOtherCostsResume = master.Report.OpenSubreport("OtherCostsResume"); ((Section)rpOtherCostsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text3"].ObjectFormat.EnableSuppress = true; ((Section)rpOtherCostsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text2"].ObjectFormat.EnableSuppress = true; ((Section)rpOtherCostsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostUsd1"].ObjectFormat.EnableSuppress = true; ((Section)rpOtherCostsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostUsd1"].ObjectFormat.EnableSuppress = true; ((Section)rpOtherCostsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true; /// ((Section)rpOtherCostsResume.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text6"].ObjectFormat.EnableSuppress = true; ((Section)rpOtherCostsResume.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostUsd1"].ObjectFormat.EnableSuppress = true; ((Section)rpOtherCostsResume.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostUsd2"].ObjectFormat.EnableSuppress = true; } else//USA { // General ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text31"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text33"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text35"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text37"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["Text1"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["GroupHeaderSection1"]).ReportObjects["headerTotalSubcontractorsCad"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalLabourHoursCad1"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalUnitsCad1"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalMaterialsCad1"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalOtherCostsCad1"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["GrandTotalCad1"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["Section3"]).ReportObjects["TotalSubcontractorsCad1"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true; ((Section)master.Report.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["GrandTotalCad2"].ObjectFormat.EnableSuppress = true; // Labour Hours ReportDocument rpLabourHoursDetails = master.Report.OpenSubreport("LabourHoursDetails"); ReportDocument rpLabourHoursResume = master.Report.OpenSubreport("LabourHoursResume"); ((Section)rpLabourHoursDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text9"].ObjectFormat.EnableSuppress = true; ((Section)rpLabourHoursDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text6"].ObjectFormat.EnableSuppress = true; ((Section)rpLabourHoursDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["LHCostCad1"].ObjectFormat.EnableSuppress = true; ((Section)rpLabourHoursDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostCad1"].ObjectFormat.EnableSuppress = true; ((Section)rpLabourHoursDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true; // ((Section)rpLabourHoursResume.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true; ((Section)rpLabourHoursResume.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostCad1"].ObjectFormat.EnableSuppress = true; ((Section)rpLabourHoursResume.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true; // Units ReportDocument rpUnitsDetails = master.Report.OpenSubreport("UnitsDetails"); ReportDocument rpUnitsResume = master.Report.OpenSubreport("UnitsResume"); ((Section)rpUnitsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text5"].ObjectFormat.EnableSuppress = true; ((Section)rpUnitsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true; ((Section)rpUnitsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostCad1"].ObjectFormat.EnableSuppress = true; ((Section)rpUnitsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostCad1"].ObjectFormat.EnableSuppress = true; ((Section)rpUnitsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true; // ((Section)rpUnitsResume.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true; ((Section)rpUnitsResume.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostCad1"].ObjectFormat.EnableSuppress = true; ((Section)rpUnitsResume.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true; // Materials ReportDocument rpMaterialsDetails = master.Report.OpenSubreport("MaterialsDetails"); ReportDocument rpMaterialsResune = master.Report.OpenSubreport("MaterialsResume"); ((Section)rpMaterialsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text5"].ObjectFormat.EnableSuppress = true; ((Section)rpMaterialsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true; ((Section)rpMaterialsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostCad1"].ObjectFormat.EnableSuppress = true; ((Section)rpMaterialsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostCad1"].ObjectFormat.EnableSuppress = true; ((Section)rpMaterialsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true; /// ((Section)rpMaterialsResune.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true; ((Section)rpMaterialsResune.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostCad1"].ObjectFormat.EnableSuppress = true; ((Section)rpMaterialsResune.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true; // Subcontractors ReportDocument rpSubcontractorsDetails = master.Report.OpenSubreport("SubcontractorsDetails"); ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text5"].ObjectFormat.EnableSuppress = true; ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true; ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostCad1"].ObjectFormat.EnableSuppress = true; ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostCad1"].ObjectFormat.EnableSuppress = true; ((Section)rpSubcontractorsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad1"].ObjectFormat.EnableSuppress = true; // Other Costs ReportDocument rpOtherCostsDetails = master.Report.OpenSubreport("OtherCostsDetails"); ReportDocument rpOtherCostsResume = master.Report.OpenSubreport("OtherCostsResume"); ((Section)rpOtherCostsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text5"].ObjectFormat.EnableSuppress = true; ((Section)rpOtherCostsDetails.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true; ((Section)rpOtherCostsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["CostCad1"].ObjectFormat.EnableSuppress = true; ((Section)rpOtherCostsDetails.ReportDefinition.Sections["DetailSection1"]).ReportObjects["TotalCostCad1"].ObjectFormat.EnableSuppress = true; ((Section)rpOtherCostsDetails.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true; /// ((Section)rpOtherCostsResume.ReportDefinition.Sections["ReportHeaderSection2"]).ReportObjects["Text4"].ObjectFormat.EnableSuppress = true; ((Section)rpOtherCostsResume.ReportDefinition.Sections["GroupFooterSection1"]).ReportObjects["SumofTotalCostCad1"].ObjectFormat.EnableSuppress = true; ((Section)rpOtherCostsResume.ReportDefinition.Sections["ReportFooterSection1"]).ReportObjects["SumofTotalCostCad2"].ObjectFormat.EnableSuppress = true; } } } }
private void LoadGeneralData() { // ... for geographical location hdfCountryId.DataBind(); if (hdfCountryId.Value != "") { CountryGateway countryGateway = new CountryGateway(); countryGateway.LoadByCountryId(Int64.Parse(hdfCountryId.Value)); tbxCountry.Text = countryGateway.GetName(Int64.Parse(hdfCountryId.Value)); } else { tbxCountry.Text = ""; } hdfProvinceStateId.DataBind(); if (hdfProvinceStateId.Value != "") { ProvinceGateway provinceGateway = new ProvinceGateway(); provinceGateway.LoadByProvinceId(Int64.Parse(hdfProvinceStateId.Value)); tbxProvinceState.Text = provinceGateway.GetName(Int64.Parse(hdfProvinceStateId.Value)); } else { tbxProvinceState.Text = ""; } hdfCountyId.DataBind(); if (hdfCountyId.Value != "") { CountyGateway countyGateway = new CountyGateway(); countyGateway.LoadByCountyId(Int64.Parse(hdfCountyId.Value)); tbxCounty.Text = countyGateway.GetName(Int64.Parse(hdfCountyId.Value)); } else { tbxCounty.Text = ""; } hdfCityId.DataBind(); if (hdfCityId.Value != "") { CityGateway cityGateway = new CityGateway(); cityGateway.LoadByCityId(Int64.Parse(hdfCityId.Value)); tbxCity.Text = cityGateway.GetName(Int64.Parse(hdfCityId.Value)); } else { tbxCity.Text = ""; } // ... for project ProjectGateway projectGateway = new ProjectGateway(projectTDS); int currentCompanyId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString())); hdfClientId.Value = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value)).ToString(); // ... for client int companyId = Int32.Parse(hdfCompanyId.Value); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(currentCompanyId, companyId); if (projectTDS.LFS_PROJECT.Rows.Count > 0) { tkrdpStartDate.DataBind(); tkrdpEndDate.DataBind(); tkrdpProposalDate.DataBind(); tbxProjectNumber.DataBind(); tbxName.DataBind(); tbxDescription.DataBind(); tbxClientName.Text = companiesGateway.GetName(projectGateway.GetClientID(int.Parse(hdfProjectId.Value))); tbxClientProjectNumber.DataBind(); // ... ... for primary contact ContactsList contactList = new ContactsList(); contactList.LoadAllAndAddItemByCompaniesId(-1, " ", projectGateway.GetClientID(int.Parse(hdfProjectId.Value)), companyId); ddlClientPrimaryContactId.DataSource = contactList.Table; ddlClientPrimaryContactId.DataValueField = "CONTACTS_ID"; ddlClientPrimaryContactId.DataTextField = "Name"; if (projectGateway.GetClientPrimaryContactID(int.Parse(hdfProjectId.Value)).HasValue) { ddlClientPrimaryContactId.SelectedValue = projectGateway.GetClientPrimaryContactID(int.Parse(hdfProjectId.Value)).ToString(); } else { ddlClientPrimaryContactId.SelectedValue = "-1"; } ddlClientPrimaryContactId.DataBind(); // ... ... for secondary contact ddlClientSecondaryContactId.DataSource = contactList.Table; ddlClientSecondaryContactId.DataValueField = "CONTACTS_ID"; ddlClientSecondaryContactId.DataTextField = "Name"; if (projectGateway.GetClientSecondaryContactID(int.Parse(hdfProjectId.Value)).HasValue) { ddlClientSecondaryContactId.SelectedValue = projectGateway.GetClientSecondaryContactID(int.Parse(hdfProjectId.Value)).ToString(); } else { ddlClientSecondaryContactId.SelectedValue = "-1"; } ddlClientSecondaryContactId.DataBind(); // ... for resources // ... ... for project lead EmployeeList employeeList = new EmployeeList(); employeeList.LoadAndAddItem(-1, " "); ddlProjectLeadId.DataSource = employeeList.Table; ddlProjectLeadId.DataValueField = "EmployeeID"; ddlProjectLeadId.DataTextField = "FullName"; ddlProjectLeadId.SelectedValue = (projectGateway.GetProjectLeadID(int.Parse(hdfProjectId.Value)).HasValue) ? ((int)projectGateway.GetProjectLeadID(int.Parse(hdfProjectId.Value))).ToString() : "-1"; ddlProjectLeadId.DataBind(); // ... ... for salesman SalesmanListGateway salesmanListGateway = new SalesmanListGateway(new DataSet()); salesmanListGateway.Load(); ddlSalesmanId.DataSource = salesmanListGateway.Table; ddlSalesmanId.DataValueField = "SalesmanID"; ddlSalesmanId.DataTextField = "FullName"; ddlSalesmanId.SelectedValue = ((int)projectGateway.GetSalesmanID(int.Parse(hdfProjectId.Value))).ToString(); ddlSalesmanId.DataBind(); // ... ... for Pricing if (projectGateway.GetProjectType(int.Parse(hdfProjectId.Value)) == "Ballpark") { ProjectSaleBillingPricingGateway projectSaleBillingPricingGateway = new ProjectSaleBillingPricingGateway(projectTDS); if (projectSaleBillingPricingGateway.Table.Rows.Count > 0) { tbxBillPrice.DataBind(); ddlBillMoney.DataBind(); } else { if (projectGateway.GetCountryID(int.Parse(hdfProjectId.Value)) == 1) { ddlBillMoney.SelectedValue = "CAD"; } else { ddlBillMoney.SelectedValue = "USD"; } } } } cbxFairWageApplies.DataBind(); // Data for unit budget tab ProjectNavigatorProjectUnitsBudgetGateway projectNavigatorProjectUnitsBudgetGateway = new ProjectNavigatorProjectUnitsBudgetGateway(projectNavigatorTDS); if (projectNavigatorProjectUnitsBudgetGateway.Table.Rows.Count > 0) { tbxUnitsBudget.Text = projectNavigatorProjectUnitsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value)).ToString("n2"); } // Data for materials budget tab ProjectNavigatorProjectMaterialsBudgetGateway projectNavigatorProjectMaterialsBudgetGateway = new ProjectNavigatorProjectMaterialsBudgetGateway(projectNavigatorTDS); if (projectNavigatorProjectMaterialsBudgetGateway.Table.Rows.Count > 0) { tbxMaterialsBudget.Text = projectNavigatorProjectMaterialsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value)).ToString("n2"); } // Data for subcontractors budget tab ProjectNavigatorProjectSubcontractorsBudgetGateway projectNavigatorProjectSubcontractorsBudgetGateway = new ProjectNavigatorProjectSubcontractorsBudgetGateway(projectNavigatorTDS); if (projectNavigatorProjectSubcontractorsBudgetGateway.Table.Rows.Count > 0) { tbxSubcontractorsBudget.Text = projectNavigatorProjectSubcontractorsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2"); } // Data for hotels budget tab ProjectNavigatorProjectHotelsBudgetGateway projectNavigatorProjectHotelsBudgetGateway = new ProjectNavigatorProjectHotelsBudgetGateway(projectNavigatorTDS); if (projectNavigatorProjectHotelsBudgetGateway.Table.Rows.Count > 0) { tbxHotelsBudget.Text = projectNavigatorProjectHotelsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2"); } // Data for bondings budget tab ProjectNavigatorProjectBondingsBudgetGateway projectNavigatorProjectBondingsBudgetGateway = new ProjectNavigatorProjectBondingsBudgetGateway(projectNavigatorTDS); if (projectNavigatorProjectBondingsBudgetGateway.Table.Rows.Count > 0) { tbxBondingsBudget.Text = projectNavigatorProjectBondingsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2"); } // Data for insurances budget tab ProjectNavigatorProjectInsurancesBudgetGateway projectNavigatorProjectInsurancesBudgetGateway = new ProjectNavigatorProjectInsurancesBudgetGateway(projectNavigatorTDS); if (projectNavigatorProjectInsurancesBudgetGateway.Table.Rows.Count > 0) { tbxInsurancesBudget.Text = projectNavigatorProjectInsurancesBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2"); } CalculateTotalBudget(); }
/// <summary> /// Save all sections & works to database (direct) /// </summary> /// <param name="workId">workId</param> /// <param name="projectId">projectId</param> /// <param name="sectionAssetId">sectionAssetId</param> /// <param name="countryId">countryId</param> /// <param name="provinceId">provinceId</param> /// <param name="countyId">countyId</param> /// <param name="cityId">cityId</param> /// <param name="videoLength">videoLength</param> /// <param name="companyId">companyId</param> /// <param name="isNewMeasuredFromDsmh">isNewMeasuredFromDsmh</param> public void Save(int workId, int projectId, int sectionAssetId, Int64 countryId, Int64? provinceId, Int64? countyId, Int64? cityId, string videoLength, int companyId, bool isNewMeasuredFromDsmh, bool prepDataRoboticPrep, DateTime? prepDataRoboticPrepCompleted) { FullLengthLiningTDS fullLengthLiningChanges = (FullLengthLiningTDS)Data.GetChanges(); if (fullLengthLiningChanges.LateralDetails.Rows.Count > 0) { FullLengthLiningLateralDetailsGateway fullLengthLiningLateralDetailsGateway = new FullLengthLiningLateralDetailsGateway(fullLengthLiningChanges); foreach (FullLengthLiningTDS.LateralDetailsRow row in (FullLengthLiningTDS.LateralDetailsDataTable)fullLengthLiningChanges.LateralDetails) { // Process modified rows if (row.ToProcess) { // Insert new laterals if ((!row.Deleted) && (row.InProject) && (!row.InProjectDatabase)) { // Insert asset int lateral_assetId = SaveLateral(row, projectId, sectionAssetId, countryId, provinceId, countyId, cityId, companyId, isNewMeasuredFromDsmh); int lateral = row.Lateral; // Insert work string videoDistance = fullLengthLiningLateralDetailsGateway.GetVideoDistance(lateral); string clockPosition = fullLengthLiningLateralDetailsGateway.GetClockPosition(lateral); string distanceToCentre = fullLengthLiningLateralDetailsGateway.GetDistanceToCentre(lateral); string timeOpened = fullLengthLiningLateralDetailsGateway.GetTimeOpened(lateral); string reverseSetup = fullLengthLiningLateralDetailsGateway.GetReverseSetup(lateral); DateTime? reinstate = fullLengthLiningLateralDetailsGateway.GetReinstate(lateral); string comments = fullLengthLiningLateralDetailsGateway.GetComments(lateral); string clientInspectionNo = fullLengthLiningLateralDetailsGateway.GetClientInspectionNo(lateral); DateTime? v1Inspection = null; bool requiresRoboticPrep = fullLengthLiningLateralDetailsGateway.GetRequiresRoboticPrep(lateral); DateTime? requiresRoboticPrepDate = null; bool holdClientIssue = fullLengthLiningLateralDetailsGateway.GetHoldClientIssue(lateral); bool holdLFSIssue = fullLengthLiningLateralDetailsGateway.GetHoldLFSIssue(lateral); bool lineLateral = fullLengthLiningLateralDetailsGateway.GetLineLateral(lateral); string flange = fullLengthLiningLateralDetailsGateway.GetFlange(lateral); bool dyeTestReq = fullLengthLiningLateralDetailsGateway.GetDyeTestReq(lateral); DateTime? dyeTestComplete = null; if (fullLengthLiningLateralDetailsGateway.GetDyeTestComplete(lateral).HasValue) dyeTestComplete = fullLengthLiningLateralDetailsGateway.GetDyeTestComplete(lateral); string contractYear = fullLengthLiningLateralDetailsGateway.GetContractYear(lateral); WorkFullLengthLiningM1LateralGateway workFullLengthLiningM1LateralGateay = new WorkFullLengthLiningM1LateralGateway(); workFullLengthLiningM1LateralGateay.LoadAllByWorkIdLateral(workId, lateral_assetId, companyId); if (workFullLengthLiningM1LateralGateay.Table.Rows.Count == 0) { InsertFLLLateral(workId, lateral_assetId, videoDistance, clockPosition, distanceToCentre, timeOpened, reverseSetup, reinstate, comments, row.Deleted, companyId, clientInspectionNo, v1Inspection, requiresRoboticPrep, requiresRoboticPrepDate, holdClientIssue, holdLFSIssue, lineLateral, dyeTestReq, dyeTestComplete, contractYear); } // ... ... If lateral will be in Junction Lining if ((row.LineLateral) && (!row.InJlDatabase)) { if (((!prepDataRoboticPrep) && (!prepDataRoboticPrepCompleted.HasValue)) || ((prepDataRoboticPrep) && (prepDataRoboticPrepCompleted.HasValue))) { // ... ... Load work id int sectionWorkId = 0; WorkJunctionLiningSection workJunctionLiningSection = new WorkJunctionLiningSection(null); sectionWorkId = workJunctionLiningSection.InsertDirect(projectId, sectionAssetId, null, 0, 0, false, "No", 0, 0, false, companyId, "", "", "", "", false, "", 0); WorkJunctionLiningLateralGateway workJunctionLiningLateralGateway = new WorkJunctionLiningLateralGateway(); WorkJunctionLiningLateral workJunctionLiningLateral = new WorkJunctionLiningLateral(workJunctionLiningLateralGateway.Data); workJunctionLiningLateral.InsertDirect(projectId, lateral_assetId, sectionWorkId, null, null, null, null, null, null, null, null, null, "", null, null, null, 0, null, null, null, 0, null, true, false, "", false, null, null, false, companyId, "", "", "", false, null, "", flange, "", "", false, null, false, null, false, holdClientIssue, null, holdLFSIssue, null, requiresRoboticPrep, requiresRoboticPrepDate, "", "", dyeTestReq, dyeTestComplete, contractYear); } } //... Insert material for m1 lateral string material = fullLengthLiningLateralDetailsGateway.GetMaterialType(lateral); if (material != "") { InsertMaterial(lateral_assetId, material, companyId); } //... Insert client lateral id string clientLateralId = fullLengthLiningLateralDetailsGateway.GetClientLateralId(lateral); if (clientLateralId.Trim() != "") { ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); int clientId = projectGateway.GetClientID(projectId); LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); lfsAssetSewerLateralClient.InsertDirect(lateral_assetId, clientId, clientLateralId, false, companyId); } // Change row process state NotProcess(lateral); } // Update laterals if ((!row.Deleted) && (row.InProject) && (row.InProjectDatabase)) { int lateral = row.Lateral; // original values string originalVideoDistance = fullLengthLiningLateralDetailsGateway.GetVideoDistanceOriginal(lateral); string originalClockPosition = fullLengthLiningLateralDetailsGateway.GetClockPositionOriginal(lateral); string originalDistanceToCentre = fullLengthLiningLateralDetailsGateway.GetDistanceToCentreOriginal(lateral); string originalTimeOpened = fullLengthLiningLateralDetailsGateway.GetTimeOpenedOriginal(lateral); string originalReverseSetup = fullLengthLiningLateralDetailsGateway.GetReverseSetupOriginal(lateral); DateTime? originalReinstate = fullLengthLiningLateralDetailsGateway.GetReinstateOriginal(lateral); string originalComments = fullLengthLiningLateralDetailsGateway.GetCommentsOriginal(lateral); string originalClientFullLateralId = fullLengthLiningLateralDetailsGateway.GetClientLateralIdOriginal(lateral); string originalClientLateralId = ""; if (originalClientFullLateralId != "") originalClientLateralId = originalClientFullLateralId; string originalClientInspectionNo = fullLengthLiningLateralDetailsGateway.GetClientInspectionNoOriginal(lateral); DateTime? originalV1Inspection = fullLengthLiningLateralDetailsGateway.GetV1InspectionOriginal(lateral); bool originalRequiresRoboticPrep = fullLengthLiningLateralDetailsGateway.GetRequiresRoboticPrepOriginal(lateral); DateTime? originalRequiresRoboticPrepDate = fullLengthLiningLateralDetailsGateway.GetRequiresRoboticPrepDateOriginal(lateral); bool originalHoldClientIssue = fullLengthLiningLateralDetailsGateway.GetHoldClientIssueOriginal(lateral); bool originalHoldLFSIssue = fullLengthLiningLateralDetailsGateway.GetHoldLFSIssueOriginal(lateral); bool originalLineLateral = fullLengthLiningLateralDetailsGateway.GetLineLateralOriginal(lateral); bool originalDyeTestReq = fullLengthLiningLateralDetailsGateway.GetDyeTestReqOriginal(lateral); DateTime? originalDyeTestComplete = null; if (fullLengthLiningLateralDetailsGateway.GetDyeTestCompleteOriginal(lateral).HasValue) originalDyeTestComplete = fullLengthLiningLateralDetailsGateway.GetDyeTestCompleteOriginal(lateral); string originalContractYear = fullLengthLiningLateralDetailsGateway.GetContractYearOriginal(lateral); // new values string newVideoDistance = fullLengthLiningLateralDetailsGateway.GetVideoDistance(lateral); string newClockPosition = fullLengthLiningLateralDetailsGateway.GetClockPosition(lateral); string newDistanceToCentre = fullLengthLiningLateralDetailsGateway.GetDistanceToCentre(lateral); string newTimeOpened = fullLengthLiningLateralDetailsGateway.GetTimeOpened(lateral); string newReverseSetup = fullLengthLiningLateralDetailsGateway.GetReverseSetup(lateral); DateTime? newReinstate = fullLengthLiningLateralDetailsGateway.GetReinstate(lateral); string newComments = fullLengthLiningLateralDetailsGateway.GetComments(lateral); string newClientFullLateralId = fullLengthLiningLateralDetailsGateway.GetClientLateralId(lateral); string newClientLateralId = ""; if (newClientFullLateralId != "") newClientLateralId = newClientFullLateralId; string newClientInspectionNo = fullLengthLiningLateralDetailsGateway.GetClientInspectionNo(lateral); bool newRequiresRoboticPrep = fullLengthLiningLateralDetailsGateway.GetRequiresRoboticPrep(lateral); DateTime? newRequiresRoboticPrepDate = fullLengthLiningLateralDetailsGateway.GetRequiresRoboticPrepDate(lateral); bool newHoldClientIssue = fullLengthLiningLateralDetailsGateway.GetHoldClientIssue(lateral); bool newHoldLFSIssue = fullLengthLiningLateralDetailsGateway.GetHoldLFSIssue(lateral); bool newLineLateral = fullLengthLiningLateralDetailsGateway.GetLineLateral(lateral); string newFlange = fullLengthLiningLateralDetailsGateway.GetFlange(lateral); bool newDyeTestReq = fullLengthLiningLateralDetailsGateway.GetDyeTestReq(lateral); DateTime? newDyeTestComplete = null; if (fullLengthLiningLateralDetailsGateway.GetDyeTestComplete(lateral).HasValue) newDyeTestComplete = fullLengthLiningLateralDetailsGateway.GetDyeTestComplete(lateral); string newContractYear = fullLengthLiningLateralDetailsGateway.GetContractYear(lateral); // ... Update fll laterals int lateral_assetId = SaveLateral(row, projectId, sectionAssetId, countryId, provinceId, countyId, cityId, companyId, isNewMeasuredFromDsmh); UpdateLateral(row, projectId, sectionAssetId, countryId, provinceId, countyId, cityId, videoLength, companyId); UpdateFLLLateral(workId, lateral_assetId, originalVideoDistance, originalClockPosition, originalDistanceToCentre, originalTimeOpened, originalReverseSetup, originalReinstate, originalComments, false, companyId, originalClientInspectionNo, originalV1Inspection, originalRequiresRoboticPrep, originalRequiresRoboticPrepDate, originalHoldClientIssue, originalHoldLFSIssue, originalLineLateral, originalDyeTestReq, originalDyeTestComplete, originalContractYear, workId, lateral_assetId, newVideoDistance, newClockPosition, newDistanceToCentre, newTimeOpened, newReverseSetup, newReinstate, newComments, false, companyId, newClientInspectionNo, originalV1Inspection, newRequiresRoboticPrep, newRequiresRoboticPrepDate, newHoldClientIssue, newHoldLFSIssue, newLineLateral, newDyeTestReq, newDyeTestComplete, newContractYear); // ... Update if lateral is in Junction Lining if (row.InJlDatabase) { if (originalLineLateral == newLineLateral) { // ... ... Update jl lateral (clientInspectionNo, v1Inspection, requiredRoboticPrep, requiredRoboticPrepDate, holdClientIssue, holdLFSIssue, flange) UpdateJLLaterals(projectId, lateral_assetId, companyId, newClientInspectionNo, newRequiresRoboticPrep, newRequiresRoboticPrepDate, newHoldClientIssue, newHoldLFSIssue, newFlange, newDyeTestReq, newDyeTestComplete, newContractYear); } else { int sectionWorkId = 0; WorkJunctionLiningSection workJunctionLiningSection = new WorkJunctionLiningSection(null); sectionWorkId = workJunctionLiningSection.InsertDirect(projectId, sectionAssetId, null, 0, 0, false, "No", 0, 0, false, companyId, "", "", "", "", false, "", 0); // Delete empty lateral form jl. DeleteJLLaterals(projectId, lateral_assetId, companyId, sectionWorkId); } } else { // ... ... Insert if should be in junction Lining if (row.LineLateral) { if (((!prepDataRoboticPrep) && (!prepDataRoboticPrepCompleted.HasValue)) || ((prepDataRoboticPrep) && (prepDataRoboticPrepCompleted.HasValue))) { int sectionWorkId = 0; // Insert to jl laterals WorkJunctionLiningSection workJunctionLiningSection = new WorkJunctionLiningSection(null); sectionWorkId = workJunctionLiningSection.InsertDirect(projectId, sectionAssetId, null, 0, 0, false, "No", 0, 0, false, companyId, "", "", "", "", false, "", 0); WorkJunctionLiningLateralGateway workJunctionLiningLateralGateway = new WorkJunctionLiningLateralGateway(); WorkJunctionLiningLateral workJunctionLiningLateral = new WorkJunctionLiningLateral(workJunctionLiningLateralGateway.Data); workJunctionLiningLateral.InsertDirect(projectId, lateral_assetId, sectionWorkId, null, null, null, null, null, null, null, null, null, "", null, null, null, 0, null, null, null, 0, null, false, false, "", false, null, null, false, companyId, "", "", "", false, null, newClientInspectionNo, newFlange, "", "", false, null, false, null, false, newHoldClientIssue, null, newHoldLFSIssue, null, newRequiresRoboticPrep, newRequiresRoboticPrepDate, "", "", newDyeTestReq, newDyeTestComplete, newContractYear); } } } //... Insert material for m1 lateral string material = fullLengthLiningLateralDetailsGateway.GetMaterialType(lateral); if (material != "") { InsertMaterial(lateral_assetId, material, companyId); } ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); int clientId = projectGateway.GetClientID(projectId); LfsAssetSewerLateralClientGateway lfsAssetSewerLateralClientGateway = new LfsAssetSewerLateralClientGateway(); lfsAssetSewerLateralClientGateway.LoadAllByAssetIdClientId(lateral_assetId, clientId, companyId); if (lfsAssetSewerLateralClientGateway.Table.Rows.Count == 0) { LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); lfsAssetSewerLateralClient.InsertDirect(lateral_assetId, clientId, originalClientLateralId, false, companyId); } else { LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); string originalFullClientLateralId = lfsAssetSewerLateralClientGateway.GetClientLateralId(lateral_assetId, clientId); lfsAssetSewerLateralClient.UpdateDirect(lateral_assetId, clientId, originalClientLateralId, false, companyId, lateral_assetId, clientId, newClientLateralId, false, companyId); } // Change row process state NotProcess(lateral); } // Deleted laterals or exclude them from fulllength lining work if (((row.Deleted) && (row.InProject) && (row.InProjectDatabase)) || ((!row.Deleted) && (!row.InProject) && (row.InProjectDatabase))) { DeleteFLLLateral(workId, row.Lateral, companyId, projectId); // Change row process state NotProcess(row.Lateral); } } } } }
/// <summary> /// Save a JL Work /// </summary> /// <param name="originalId">originalId</param> /// <param name="projectId">projectId</param> /// <param name="section_assetId">section_assetId</param> /// <param name="numLats">numLats</param> /// <param name="notLinedYet">notLinedYet</param> /// <param name="allMeasured">allMeasured</param> /// <param name="issueWithLaterals">issueWithLaterals</param> /// <param name="notMeasuredYet">notMeasuredYet</param> /// <param name="notDeliveredYet">notDeliveredYet</param> /// <param name="countryId">countryId</param> /// <param name="provinceId">provinceId</param> /// <param name="countyId">countyId</param> /// <param name="cityId">cityId</param> /// <param name="companyId">companyId</param> private void SaveJLWork(Guid originalId, int section_assetId, int numLats, int notLinedYet, bool allMeasured, string issueWithLaterals, int notMeasuredYet, int notDeliveredYet, int projectId, Int64? countryId, Int64? provinceId, Int64? countyId, Int64? cityId, int companyId) { // Insert Junction Lining Section WorkJunctionLiningSection workJunctionLiningSection = new WorkJunctionLiningSection(null); int sectionWorkId = workJunctionLiningSection.InsertDirect(projectId, section_assetId, null, numLats, notLinedYet, allMeasured, issueWithLaterals, notMeasuredYet, notDeliveredYet, false, companyId, "", "", "", "", false, "", 0); // Insert Junction Lining Laterals SectionTDS sectionTDS = new SectionTDS(); SectionGateway sectionGateway = new SectionGateway(sectionTDS); sectionGateway.LoadById(originalId, companyId); JlinerGateway jlinerGateway = new JlinerGateway(sectionTDS); jlinerGateway.LoadByIdCompanyId(originalId, companyId); foreach (SectionTDS.LFS_JUNCTION_LINER2Row row in (SectionTDS.LFS_JUNCTION_LINER2DataTable)jlinerGateway.Table) { string lateralID = ""; if (!row.IsDetailIDNull()) lateralID = row.DetailID; string address = ""; if (!row.IsAddressNull()) address = row.Address; string distanceFromUSMH = ""; if (!row.IsDistanceFromUSMHNull()) distanceFromUSMH = row.DistanceFromUSMH.ToString(); string distanceFromDSMH = ""; if (!row.IsDistanceFromDSMHNull()) distanceFromDSMH = row.DistanceFromDSMH.ToString(); DateTime? pipeLocated = null; if (!row.IsPipeLocatedNull()) pipeLocated = row.PipeLocated; DateTime? servicesLocated = null; if (!row.IsServicesLocatedNull()) servicesLocated = row.ServicesLocated; DateTime? coInstalled = null; if (!row.IsCoInstalledNull()) coInstalled = row.CoInstalled; DateTime? backfilledConcrete = null; if (!row.IsBackfilledConcreteNull()) backfilledConcrete = row.BackfilledConcrete; DateTime? backfilledSoil = null; if (!row.IsBackfilledSoilNull()) backfilledSoil = row.BackfilledSoil; DateTime? grouted = null; if (!row.IsGroutedNull()) grouted = row.Grouted; DateTime? cored = null; if (!row.IsCoredNull()) cored = row.Cored; DateTime? prepped = null; if (!row.IsPreppedNull()) prepped = row.Prepped; DateTime? measured = null; if (!row.IsMeasuredNull()) measured = row.Measured; string linerSize = ""; if (!row.IsLinerSizeNull()) linerSize = row.LinerSize; DateTime? inProcess = null; if (!row.IsInProcessNull()) inProcess = row.InProcess; DateTime? inStock = null; if (!row.IsInStockNull()) inStock = row.InStock; DateTime? delivered = null; if (!row.IsDeliveredNull()) delivered = row.Delivered; int? buildRebuid = null; if (!row.IsBuildRebuildNull()) buildRebuid = row.BuildRebuild; DateTime? preVideo = null; if (!row.IsPreVideoNull()) preVideo = row.PreVideo; DateTime? linerInstalled = null; if (!row.IsLinerInstalledNull()) linerInstalled = row.LinerInstalled; DateTime? finalVideo = null; if (!row.IsFinalVideoNull()) finalVideo = row.FinalVideo; string map = ""; if (!row.IsMapNull()) map = row.Map; decimal? cost = null; if (!row.IsCostNull()) cost = row.Cost; DateTime? videoInspection = null; if (!row.IsVideoInspectionNull()) videoInspection = row.VideoInspection; bool coRequired = row.CoRequired; bool pitRequired = row.PitRequired; string coPitLocation = ""; if (!row.IsCoPitLocationNull()) coPitLocation = row.CoPitLocation; bool postContractDigRequired = row.PostContractDigRequired; string comments = ""; if (!row.IsCommentsNull()) comments = row.Comments; string history = ""; if (!row.IsHistoryNull()) history = row.History; DateTime? coCutDown = null; if (!row.IsCoCutDownNull()) coCutDown = row.CoCutDown; DateTime? finalRestoration = null; if (!row.IsFinalRestorationNull()) finalRestoration = row.FinalRestoration; string clientLateralId = ""; if (!row.IsClientLateralIDNull()) clientLateralId = row.ClientLateralID; string videoLengthToPropertyLine = ""; if (!row.IsVideoLengthToPropertyLineNull()) videoLengthToPropertyLine = row.VideoLengthToPropertyLine; bool liningThruCo = row.LiningThruCo; DateTime? noticeDelivered = null; if (!row.IsNoticeDeliveredNull()) noticeDelivered = row.NoticeDelivered; string hamiltonInspectionNumber = ""; if (!row.IsHamiltonInspectionNumberNull()) hamiltonInspectionNumber = row.HamiltonInspectionNumber; bool dyeTestReq = row.DyeTestReq; DateTime? dyeTestComplete = null; if (!row.IsDyeTestCompleteNull()) dyeTestComplete = row.DyeTestComplete; // Fields only presents in new Junction lining string flange = ""; string gasket = ""; string connectionType = ""; string depthOfLocated = ""; bool digRequiredPriorToLining = false; DateTime? digRequiredPriorToLiningCompleted = null; bool digRequiredAfterLining = false; DateTime? digRequiredAfterLiningCompleted = null; bool outOfScope = false; bool holdClientIssue = false; DateTime? holdClientIssueResolved = null; bool holdLFSIssue = false; DateTime? holdLFSIssueResolved = null; bool requiresRoboticPrep = false; DateTime? requiresRoboticPrepCompleted = null; ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); int clientId = projectGateway.GetClientID(projectId); // Insert into LFS Asset Lateral LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null); int lateralAssetId = lfsAssetSewerLateral.InsertDirect(countryId, provinceId, countyId, cityId, section_assetId, address, lateralID, "", "", "", "", "Live", "", distanceFromUSMH, distanceFromDSMH, "", false, companyId, connectionType); // Insert into LFS Asset Lateral Client LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); lfsAssetSewerLateralClient.InsertDirect(lateralAssetId, clientId, clientLateralId, false, companyId); // Insert into Work Junction Lining Lateral WorkJunctionLiningLateral workJunctionLiningLateral = new WorkJunctionLiningLateral(null); int workLateral = workJunctionLiningLateral.InsertDirect(projectId, lateralAssetId, sectionWorkId, pipeLocated, servicesLocated, coInstalled, backfilledConcrete, backfilledSoil, grouted, cored, prepped, measured, linerSize, inProcess, inStock, delivered, buildRebuid, preVideo, linerInstalled, finalVideo, cost, videoInspection, coRequired, pitRequired, coPitLocation, postContractDigRequired, coCutDown, finalRestoration, false, companyId, comments, history, videoLengthToPropertyLine, liningThruCo, noticeDelivered, hamiltonInspectionNumber, flange, gasket, depthOfLocated, digRequiredPriorToLining, digRequiredPriorToLiningCompleted, digRequiredAfterLining, digRequiredAfterLiningCompleted, outOfScope, holdClientIssue, holdClientIssueResolved, holdLFSIssue, holdLFSIssueResolved, requiresRoboticPrep, requiresRoboticPrepCompleted, "", "", dyeTestReq, dyeTestComplete, ""); // Insert into Work Comments JlinerCommentGateway jlinerCommentGateway = new JlinerCommentGateway(sectionTDS); jlinerCommentGateway.LoadByIdRefId(originalId, row.RefID, companyId); foreach (SectionTDS.LFS_JUNCTION_LINER2_COMMENTRow rowComment in (SectionTDS.LFS_JUNCTION_LINER2_COMMENTDataTable)jlinerCommentGateway.Table) { int loginId = rowComment.LoginID; DateTime dateTime_ = rowComment.DateTime_; string comment = rowComment.Comment; WorkCommentsGateway workCommentsGateway = new WorkCommentsGateway(); workCommentsGateway.LoadByWorkIdWorkType(workLateral, companyId, "Junction Lining Lateral"); WorkComments workComments = new WorkComments(workCommentsGateway.Data); workComments.Insert(workLateral, 0, "Junction Lining Lateral", "Bulk Upload Comments", loginId, dateTime_, comment, null, false, companyId, false, "Junction Lining"); // Update Comments workCommentsGateway.Update(); } // Insert into Work History JlinerHistoryGateway jlinerHistoryGateway = new JlinerHistoryGateway(sectionTDS); jlinerHistoryGateway.LoadByIdRefId(originalId, row.RefID, companyId); foreach (SectionTDS.LFS_JUNCTION_LINER2_HISTORYRow rowHistory in (SectionTDS.LFS_JUNCTION_LINER2_HISTORYDataTable)jlinerHistoryGateway.Table) { int loginId = rowHistory.LoginID; DateTime dateTime_H = rowHistory.DateTime_; string history_ = rowHistory.History; WorkHistoryGateway workHistoryGateway = new WorkHistoryGateway(); workHistoryGateway.LoadByWorkIdWorkType(workLateral, companyId, "Junction Lining Lateral"); WorkHistory workHistory = new WorkHistory(workHistoryGateway.Data); workHistory.Insert(workLateral, 0, "Junction Lining Lateral", "Bulk Upload History", loginId, dateTime_H, history_, null, false, companyId, false, "Junction Lining"); // Update History workHistoryGateway.Update(); } } }
/// <summary> /// Delete /// </summary> /// <param name="workId">workId</param> /// <param name="assetIdLateral">assetIdLateral</param> /// <param name="sectionWorkId">sectionWorkId</param> /// <param name="companyId">companyId</param> private void Delete(int workId, int assetIdLateral, int sectionWorkId, int companyId) { WorkGateway workGateway = new WorkGateway(); workGateway.LoadByWorkId(workId, companyId); int currentProjectId = workGateway.GetProjectId(workId); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(currentProjectId); int clientId = projectGateway.GetClientID(currentProjectId); // delete lateral work WorkJunctionLiningLateral workJunctionLiningLateral = new WorkJunctionLiningLateral(null); workJunctionLiningLateral.DeleteDirect(workId, sectionWorkId, companyId); // delete lfs lateral LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null); bool isDeleted = lfsAssetSewerLateral.DeleteDirect(assetIdLateral, companyId); if (isDeleted) { // delete lfs lateral client LfsAssetSewerLateralClientGateway lfsAssetSewerLateralClientGateway = new LfsAssetSewerLateralClientGateway(); lfsAssetSewerLateralClientGateway.LoadByAssetIdClientId(assetIdLateral, clientId, companyId); if (lfsAssetSewerLateralClientGateway.Table.Rows.Count > 0) { LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); lfsAssetSewerLateralClient.DeleteDirect(assetIdLateral, clientId, companyId); } } }
/// <summary> /// LateralUpdate /// </summary> /// <param name="currentProjectId">currentProjectId</param> /// <param name="assetId">assetId</param> /// <param name="distanceFromDsmh">distanceFromDsmh</param> /// <param name="distanceFromUsmh">distanceFromUsmh</param> /// <param name="mapSize">mapSize</param> /// <param name="companyId">companyId</param> /// <param name="clientLateralId">clientLateralId</param> /// <param name="address">address</param> /// <param name="connectionType">connectionType</param> private void LateralUpdate(int currentProjectId, int assetId, string distanceFromDsmh, string distanceFromUsmh, string mapSize, int companyId, string clientLateralId, string address, string connectionType) { AssetSewerLateralGateway assetSewerLateralGateway = new AssetSewerLateralGateway(); assetSewerLateralGateway.LoadByAssetId(assetId, companyId); // original values int originalSection_ = assetSewerLateralGateway.GetSection(assetId); string originalAddress = assetSewerLateralGateway.GetAddress(assetId); string originalLateralId = assetSewerLateralGateway.GetLateralId(assetId); string originalLatitudeAtSection = assetSewerLateralGateway.GetLatitudeAtSection(assetId); string originalLongitudeAtSection = assetSewerLateralGateway.GetLongitudeAtSection(assetId); string originalLatitudeAtPropertyLine = assetSewerLateralGateway.GetLatitudeAtPropertyLine(assetId); string originalLongitudeAtPropertyLine = assetSewerLateralGateway.GetLongitudeAtPropertyLine(assetId); string originalState = assetSewerLateralGateway.GetState(assetId); string originalSize_ = assetSewerLateralGateway.GetSize(assetId); string originalDistanceFromUsmh = assetSewerLateralGateway.GetDistanceFromUSMH(assetId); string originalDistanceFromDsmh = assetSewerLateralGateway.GetDistanceFromDSMH(assetId); string originalMapSize = assetSewerLateralGateway.GetMapSize(assetId); bool originalDelete = assetSewerLateralGateway.GetDeleted(assetId); int originalCompanyId = assetSewerLateralGateway.GetCompanyId(assetId); string originalConnectionType = assetSewerLateralGateway.GetConnectionType(assetId); // new values string newAddress = address; string newDistanceFromUsmh = originalDistanceFromUsmh; string newDistanceFromDsmh = originalDistanceFromDsmh; string newMapSize = mapSize; string newConnectionType = connectionType; // Update Sewer lateral AssetSewerLateral assetSewerLateral = new AssetSewerLateral(null); assetSewerLateral.UpdateDirect(assetId, originalSection_, originalAddress, originalLateralId, originalLatitudeAtSection, originalLongitudeAtSection, originalLatitudeAtPropertyLine, originalLongitudeAtPropertyLine, originalState, originalSize_, originalDistanceFromUsmh, originalDistanceFromDsmh, originalMapSize, originalDelete, originalCompanyId, originalConnectionType, assetId, originalSection_, newAddress, originalLateralId, originalLatitudeAtSection, originalLongitudeAtSection, originalLatitudeAtPropertyLine, originalLongitudeAtPropertyLine, originalState, originalSize_, newDistanceFromUsmh, newDistanceFromDsmh, newMapSize, originalDelete, originalCompanyId, newConnectionType); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(currentProjectId); int clientId = projectGateway.GetClientID(currentProjectId); LfsAssetSewerLateralClientGateway lfsAssetSewerLateralClientGateway = new LfsAssetSewerLateralClientGateway(); lfsAssetSewerLateralClientGateway.LoadAllByAssetIdClientId(assetId, clientId, companyId); if (lfsAssetSewerLateralClientGateway.Table.Rows.Count == 0) { LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); lfsAssetSewerLateralClient.InsertDirect(assetId, clientId, clientLateralId, false, companyId); } else { LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); string originalClientLateralId = lfsAssetSewerLateralClientGateway.GetClientLateralId(assetId, clientId); string newClientLateralId = clientLateralId; lfsAssetSewerLateralClient.UpdateDirect(assetId, clientId, originalClientLateralId, false, companyId, assetId, clientId, newClientLateralId, false, companyId); } }
// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!Convert.ToBoolean(Session["sgLFS_PROJECTS_COSTINGSHEETS_ADMIN"])) { if (!Convert.ToBoolean(Session["sgLFS_PROJECTS_COSTINGSHEETS_VIEW"])) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } // Validate query string if (Request.QueryString["source_page"] == null) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in project_costing_sheets_navigator.aspx"); } // Tag page hdfCompanyId.Value = Session["companyID"].ToString(); hdfProjectId.Value = Request.QueryString["project_id"]; hdfDataChanged.Value = Request.QueryString["data_changed"]; hdfDataChangedMessage.Value = "Changes made to this project will not be saved."; ViewState["state"] = Request.QueryString["state"]; ViewState["active_tab"] = Request.QueryString["active_tab"]; ViewState["origin"] = Request.QueryString["origin"]; ViewState["update"] = Request.QueryString["update"]; projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; // Prepare initial data //lblResults.Visible = false; // ... for project int currentProjectId = Int32.Parse(hdfProjectId.Value.ToString()); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(currentProjectId); string name = projectGateway.GetName(currentProjectId); if (name.Length > 23) name = name.Substring(0, 20) + "..."; lblTitleProjectName.Text = name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")"; // ... for client int companyId = Int32.Parse(hdfCompanyId.Value); int currentCompanyId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString())); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(currentCompanyId, companyId); lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentCompanyId); hdfClientId.Value = projectGateway.GetClientID(int.Parse(hdfProjectId.Value)).ToString(); // Store navigator state at projects navigator StoreNavigatorState(); // If coming from // ... project_summary.aspx, project_edit.aspx, project_sections_navigator.aspx or project_sections_navigator2.aspx if ((Request.QueryString["source_page"] == "project_summary.aspx") || (Request.QueryString["source_page"] == "project_edit.aspx") || (Request.QueryString["source_page"] == "project_sections_navigator.aspx") || (Request.QueryString["source_page"] == "project_sections_navigator2.aspx")) { projectCostingSheetsNavigatorTDS = new ProjectCostingSheetsNavigatorTDS(); // ... Search data with updates projectCostingSheetsNavigatorTDS = SubmitSearch(); // ... Store datasets Session["projectCostingSheetsNavigatorTDS"] = projectCostingSheetsNavigatorTDS; } // ... project_costing_sheets_edit.aspx, project_costing_sheets_summary.aspx or project_costing_sheets_delete.aspx if ((Request.QueryString["source_page"] == "project_costing_sheets_edit.aspx") || (Request.QueryString["source_page"] == "project_costing_sheets_summary.aspx") || (Request.QueryString["source_page"] == "project_costing_sheets_delete.aspx") || (Request.QueryString["source_page"] == "project_combined_costing_sheets_edit.aspx") || (Request.QueryString["source_page"] == "project_combined_costing_sheets_summary.aspx") || (Request.QueryString["source_page"] == "project_combined_costing_sheets_delete.aspx")) { if (Request.QueryString["update"] == "no") { projectCostingSheetsNavigatorTDS = (ProjectCostingSheetsNavigatorTDS)Session["projectCostingSheetsNavigatorTDS"]; } else { // ... Delete store data Session.Contents.Remove("projectCostingSheetsNavigatorTDS"); projectCostingSheetsNavigatorTDS = SubmitSearch(); // ... store datasets Session["projectCostingSheetsNavigatorTDS"] = projectCostingSheetsNavigatorTDS; } } // For the grid grdCostingSheetsNavigator.DataSource = projectCostingSheetsNavigatorTDS.ProjectCostingSheetsNavigator; grdCostingSheetsNavigator.DataBind(); grdCombinedCostingSheetsNavigator.DataSource = projectCostingSheetsNavigatorTDS.ProjectCombinedCostingSheetsNavigator; grdCombinedCostingSheetsNavigator.DataBind(); //lblResults.Visible = false; // ... For the total rows if (projectCostingSheetsNavigatorTDS.ProjectCostingSheetsNavigator.Rows.Count > 0) { lblTotalRows.Text = "Total Rows: " + projectCostingSheetsNavigatorTDS.ProjectCostingSheetsNavigator.Rows.Count; lblTotalRows.Visible = true; //lblResults.Visible = true; btnOpen.Visible = true; btnEdit.Visible = true; btnDelete.Visible = true; ddlAction.Visible = true; pnlHorizontalRule.Visible = true; lblCostingSheetsTitle.Visible = true; } else { lblTotalRows.Visible = false; btnOpen.Visible = false; btnEdit.Visible = false; btnDelete.Visible = false; ddlAction.Visible = false; pnlHorizontalRule.Visible = false; lblCostingSheetsTitle.Visible = false; } // ... For the total rows if (projectCostingSheetsNavigatorTDS.ProjectCombinedCostingSheetsNavigator.Rows.Count > 0) { //lblResults.Visible = true; lblCombinedCostingSheetsTotalRows.Text = "Total Rows: " + projectCostingSheetsNavigatorTDS.ProjectCombinedCostingSheetsNavigator.Rows.Count; lblCombinedCostingSheetsTotalRows.Visible = true; lblCombinedCostingSheetsTitle.Visible = true; lblCombinedCostingSheetsTotalRows.Visible = true; btnOpenCombinedCostingSheet.Visible = true; btnEditCombinedCostingSheet.Visible = true; btnDeleteCombinedCostingSheet.Visible = true; pnlHorizontalRuleCombinedCostingSheet.Visible = true; ddlActionCombinedCostingSheet.Visible = true; } else { lblCombinedCostingSheetsTotalRows.Visible = false; lblCombinedCostingSheetsTitle.Visible = false; lblCombinedCostingSheetsTotalRows.Visible = false; btnOpenCombinedCostingSheet.Visible = false; btnEditCombinedCostingSheet.Visible = false; btnDeleteCombinedCostingSheet.Visible = false; pnlHorizontalRuleCombinedCostingSheet.Visible = false; ddlActionCombinedCostingSheet.Visible = false; } } else { // Restore TDS projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; projectCostingSheetsNavigatorTDS = (ProjectCostingSheetsNavigatorTDS)Session["projectCostingSheetsNavigatorTDS"]; // ... for project int currentProjectId = Int32.Parse(hdfProjectId.Value.ToString()); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(currentProjectId); string name = projectGateway.GetName(currentProjectId); if (name.Length > 23) name = name.Substring(0, 20) + "..."; lblTitleProjectName.Text = name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")"; // ... for client int companyId = Int32.Parse(hdfCompanyId.Value); int currentClientId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString())); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(currentClientId, companyId); lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId); // ... For the total rows if (projectCostingSheetsNavigatorTDS.ProjectCostingSheetsNavigator.Rows.Count > 0) { lblTotalRows.Text = "Total Rows: " + projectCostingSheetsNavigatorTDS.ProjectCostingSheetsNavigator.Rows.Count; lblTotalRows.Visible = true; //lblResults.Visible = true; btnOpen.Visible = true; btnEdit.Visible = true; btnDelete.Visible = true; ddlAction.Visible = true; pnlHorizontalRule.Visible = true; lblCostingSheetsTitle.Visible = true; } else { lblTotalRows.Visible = false; btnOpen.Visible = false; btnEdit.Visible = false; btnDelete.Visible = false; ddlAction.Visible = false; pnlHorizontalRule.Visible = false; lblCostingSheetsTitle.Visible = false; } // ... For the total rows if (projectCostingSheetsNavigatorTDS.ProjectCombinedCostingSheetsNavigator.Rows.Count > 0) { //lblResults.Visible = true; lblCombinedCostingSheetsTotalRows.Text = "Total Rows: " + projectCostingSheetsNavigatorTDS.ProjectCombinedCostingSheetsNavigator.Rows.Count; lblCombinedCostingSheetsTotalRows.Visible = true; lblCombinedCostingSheetsTitle.Visible = true; lblCombinedCostingSheetsTotalRows.Visible = true; btnOpenCombinedCostingSheet.Visible = true; btnEditCombinedCostingSheet.Visible = true; btnDeleteCombinedCostingSheet.Visible = true; pnlHorizontalRuleCombinedCostingSheet.Visible = true; ddlActionCombinedCostingSheet.Visible = true; } else { lblCombinedCostingSheetsTotalRows.Visible = false; lblCombinedCostingSheetsTitle.Visible = false; lblCombinedCostingSheetsTotalRows.Visible = false; btnOpenCombinedCostingSheet.Visible = false; btnEditCombinedCostingSheet.Visible = false; btnDeleteCombinedCostingSheet.Visible = false; pnlHorizontalRuleCombinedCostingSheet.Visible = false; ddlActionCombinedCostingSheet.Visible = false; } } }
// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!(Convert.ToBoolean(Session["sgLFS_PROJECTS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_PROJECTS_DELETE"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } // Validate query string if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["project_id"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in project_delete.aspx"); } // Tag page hdfCompanyId.Value = Session["companyID"].ToString(); hdfProjectId.Value = Request.QueryString["project_id"]; // If coming from project_summary.aspx or projects2.aspx if (((string)Request.QueryString["source_page"] == "project_summary.aspx") || ((string)Request.QueryString["source_page"] == "projects2.aspx")) { // Store Navigator State and Update control StoreNavigatorState(); ViewState["update"] = Request.QueryString["update"]; // Get project record projectTDS = new ProjectTDS(); ProjectGateway projectGatewayForLoad = new ProjectGateway(projectTDS); projectGatewayForLoad.LoadByProjectId(int.Parse(hdfProjectId.Value)); // Store datasets Session["lfsProjectTDS"] = projectTDS; } // Restore dataset projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; // Prepare initial data // ... for project int currentProjectId = Int32.Parse(hdfProjectId.Value.ToString()); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(currentProjectId); string name = projectGateway.GetName(currentProjectId); if (name.Length > 23) name = name.Substring(0, 20) + "..."; lblTitleProjectName.Text = name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")"; // ... for client int currentClientId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString())); int companyId = Int32.Parse(hdfCompanyId.Value); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(currentClientId, companyId); lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId); } else { // Restore dataset projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; } }
/// <summary> /// Save all sections & works to database (direct) /// </summary> /// <param name="workId">workId</param> /// <param name="projectId">projectId</param> /// <param name="sectionAssetId">sectionAssetId</param> /// <param name="countryId">countryId</param> /// <param name="provinceId">provinceId</param> /// <param name="countyId">countyId</param> /// <param name="cityId">cityId</param> /// <param name="length">length</param> /// <param name="companyId">companyId</param> /// <param name="isNewMeasuredFromDsmh">isNewMeasuredFromDsmh</param> /// <param name="prepDataRoboticPrep">prepDataRoboticPrep</param> /// <param name="prepDataRoboticPrepCompleted">prepDataRoboticPrepCompleted</param> public void Save(int workId, int projectId, int sectionAssetId, Int64 countryId, Int64? provinceId, Int64? countyId, Int64? cityId, string length, int companyId, bool isNewMeasuredFromDsmh, bool prepDataRoboticPrep, DateTime? prepDataRoboticPrepCompleted) { // Update Laterals RehabAssessmentLateralDetailsGateway rehabAssessmentLateralDetailsGateway = new RehabAssessmentLateralDetailsGateway(Data); if (rehabAssessmentLateralDetailsGateway.Table.Rows.Count > 0) { // Get WorkId if (workId == 0) { WorkFullLengthLining workFullLengthLining = new WorkFullLengthLining(null); workId = workFullLengthLining.InsertDirectEmptyWorks(projectId, sectionAssetId, null, "", null, null, null, null, null, null, null, false, false, false, false, false, false, false, companyId, false, "", ""); } foreach (RehabAssessmentTDS.LateralDetailsRow row in (RehabAssessmentTDS.LateralDetailsDataTable)Table) { int lateral = row.Lateral; ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); int clientId = projectGateway.GetClientID(projectId); // ... Insert lateral if ((!row.InDatabase) && (!row.Deleted)) { string videoDistance = rehabAssessmentLateralDetailsGateway.GetVideoDistance(lateral); string clockPosition = rehabAssessmentLateralDetailsGateway.GetClockPosition(lateral); string distanceToCentre = rehabAssessmentLateralDetailsGateway.GetDistanceToCentre(lateral); string timeOpened = rehabAssessmentLateralDetailsGateway.GetTimeOpened(lateral); string reverseSetup = rehabAssessmentLateralDetailsGateway.GetReverseSetup(lateral); DateTime? reinstate = rehabAssessmentLateralDetailsGateway.GetReinstate(lateral); string comments = rehabAssessmentLateralDetailsGateway.GetComments(lateral); string clientLateralId = rehabAssessmentLateralDetailsGateway.GetClientLateralId(lateral); string clientInspectionNo = rehabAssessmentLateralDetailsGateway.GetClientInspectionNo(lateral); DateTime? v1Inspection = rehabAssessmentLateralDetailsGateway.GetV1Inspection(lateral); bool requiredRoboticPrep = rehabAssessmentLateralDetailsGateway.GetRequiresRoboticPrep(lateral); DateTime? requiredRoboticPrepDate = rehabAssessmentLateralDetailsGateway.GetRequiresRoboticPrepDate(lateral); bool holdClientIssue = rehabAssessmentLateralDetailsGateway.GetHoldClientIssue(lateral); bool holdLFSIssue = rehabAssessmentLateralDetailsGateway.GetHoldLFSIssue(lateral); bool lineLateral = rehabAssessmentLateralDetailsGateway.GetLineLateral(lateral); string flange = rehabAssessmentLateralDetailsGateway.GetFlange(lateral); bool dyeTestReq = rehabAssessmentLateralDetailsGateway.GetDyeTestReq(lateral); DateTime? dyeTestComplete = null; if (rehabAssessmentLateralDetailsGateway.GetDyeTestComplete(lateral).HasValue) dyeTestComplete = rehabAssessmentLateralDetailsGateway.GetDyeTestComplete(lateral); string contractYear = rehabAssessmentLateralDetailsGateway.GetContractYear(lateral); // ... ... Insert asset int lateral_assetId = SaveLateral(row, projectId, sectionAssetId, countryId, provinceId, countyId, cityId, companyId, isNewMeasuredFromDsmh); // ... ... Insert lateral to FulllengthLining InsertFLLLateral(workId, lateral_assetId, videoDistance, clockPosition, distanceToCentre, timeOpened, reverseSetup, reinstate, comments, false, companyId, clientInspectionNo, v1Inspection, requiredRoboticPrep, requiredRoboticPrepDate, holdClientIssue, holdLFSIssue, lineLateral, dyeTestReq, dyeTestComplete, contractYear); // ... ... If lateral will be in Junction Lining if ((row.LineLateral) && (!row.InJlDatabase)) { if (((!prepDataRoboticPrep) && (!prepDataRoboticPrepCompleted.HasValue)) || ((prepDataRoboticPrep) && (prepDataRoboticPrepCompleted.HasValue))) { // ... ... Load work id int sectionWorkId = 0; WorkJunctionLiningSection workJunctionLiningSection = new WorkJunctionLiningSection(null); sectionWorkId = workJunctionLiningSection.InsertDirect(projectId, sectionAssetId, null, 0, 0, false, "No", 0, 0, false, companyId, "", "", "", "", false, "", 0); WorkJunctionLiningLateralGateway workJunctionLiningLateralGateway = new WorkJunctionLiningLateralGateway(); WorkJunctionLiningLateral workJunctionLiningLateral = new WorkJunctionLiningLateral(workJunctionLiningLateralGateway.Data); workJunctionLiningLateral.InsertDirect(projectId, lateral_assetId, sectionWorkId, null, null, null, null, null, null, null, null, null, "", null, null, null, 0, null, null, null, 0, v1Inspection, true, false, "", false, null, null, false, companyId, "", "", "", false, null, "", flange, "", "", false, null, false, null, false, holdClientIssue, null, holdLFSIssue, null, requiredRoboticPrep, requiredRoboticPrepDate, "", "", dyeTestReq, dyeTestComplete, contractYear); } } // ... Insert material for M1 lateral try { string material = rehabAssessmentLateralDetailsGateway.GetMaterialType(lateral); if (material != "") { InsertMaterial(lateral_assetId, material, companyId); } } catch { } //... Insert client lateral id try { if (clientLateralId.Trim() != "") { LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); lfsAssetSewerLateralClient.InsertDirect(lateral_assetId, clientId, clientLateralId, false, companyId); } } catch { } } // ... Edit laterals if ((row.InDatabase) && (!row.Deleted)) { // original values string originalVideoDistance = rehabAssessmentLateralDetailsGateway.GetVideoDistanceOriginal(lateral); string originalClockPosition = rehabAssessmentLateralDetailsGateway.GetClockPositionOriginal(lateral); string originalDistanceToCentre = rehabAssessmentLateralDetailsGateway.GetDistanceToCentreOriginal(lateral); string originalTimeOpened = rehabAssessmentLateralDetailsGateway.GetTimeOpenedOriginal(lateral); string originalReverseSetup = rehabAssessmentLateralDetailsGateway.GetReverseSetupOriginal(lateral); DateTime? originalReinstate = rehabAssessmentLateralDetailsGateway.GetReinstateOriginal(lateral); string originalComments = rehabAssessmentLateralDetailsGateway.GetCommentsOriginal(lateral); string originalClientLateralId = rehabAssessmentLateralDetailsGateway.GetClientLateralIdOriginal(lateral); string originalClientInspectionNo = rehabAssessmentLateralDetailsGateway.GetClientInspectionNoOriginal(lateral); DateTime? originalV1Inspection = rehabAssessmentLateralDetailsGateway.GetV1InspectionOriginal(lateral); bool originalRequiresRoboticPrep = rehabAssessmentLateralDetailsGateway.GetRequiresRoboticPrepOriginal(lateral); DateTime? originalRequiresRoboticPrepDate = rehabAssessmentLateralDetailsGateway.GetRequiresRoboticPrepDateOriginal(lateral); bool originalHoldClientIssue = rehabAssessmentLateralDetailsGateway.GetHoldClientIssueOriginal(lateral); bool originalHoldLFSIssue = rehabAssessmentLateralDetailsGateway.GetHoldLFSIssueOriginal(lateral); bool originalLineLateral = rehabAssessmentLateralDetailsGateway.GetLineLateralOriginal(lateral); bool originalDyeTestReq = rehabAssessmentLateralDetailsGateway.GetDyeTestReqOriginal(lateral); DateTime? originalDyeTestComplete = null; if (rehabAssessmentLateralDetailsGateway.GetDyeTestCompleteOriginal(lateral).HasValue) originalDyeTestComplete = rehabAssessmentLateralDetailsGateway.GetDyeTestCompleteOriginal(lateral); string originalContractYear = rehabAssessmentLateralDetailsGateway.GetContractYearOriginal(lateral); // new values string newVideoDistance = rehabAssessmentLateralDetailsGateway.GetVideoDistance(lateral); string newClockPosition = rehabAssessmentLateralDetailsGateway.GetClockPosition(lateral); string newDistanceToCentre = rehabAssessmentLateralDetailsGateway.GetDistanceToCentre(lateral); string newTimeOpened = rehabAssessmentLateralDetailsGateway.GetTimeOpened(lateral); string newReverseSetup = rehabAssessmentLateralDetailsGateway.GetReverseSetup(lateral); DateTime? newReinstate = rehabAssessmentLateralDetailsGateway.GetReinstate(lateral); string newComments = rehabAssessmentLateralDetailsGateway.GetComments(lateral); string newClientLateralId = rehabAssessmentLateralDetailsGateway.GetClientLateralId(lateral); string newClientInspectionNo = rehabAssessmentLateralDetailsGateway.GetClientInspectionNo(lateral); DateTime? newV1Inspection = rehabAssessmentLateralDetailsGateway.GetV1Inspection(lateral); bool newRequiresRoboticPrep = rehabAssessmentLateralDetailsGateway.GetRequiresRoboticPrep(lateral); DateTime? newRequiresRoboticPrepDate = rehabAssessmentLateralDetailsGateway.GetRequiresRoboticPrepDate(lateral); bool newHoldClientIssue = rehabAssessmentLateralDetailsGateway.GetHoldClientIssue(lateral); bool newHoldLFSIssue = rehabAssessmentLateralDetailsGateway.GetHoldLFSIssue(lateral); bool newLineLateral = rehabAssessmentLateralDetailsGateway.GetLineLateral(lateral); string newFlange = rehabAssessmentLateralDetailsGateway.GetFlange(lateral); bool newDyeTestReq = rehabAssessmentLateralDetailsGateway.GetDyeTestReq(lateral); DateTime? newDyeTestComplete = null; if (rehabAssessmentLateralDetailsGateway.GetDyeTestComplete(lateral).HasValue) newDyeTestComplete = rehabAssessmentLateralDetailsGateway.GetDyeTestComplete(lateral); string newContractYear = rehabAssessmentLateralDetailsGateway.GetContractYear(lateral); // ... Update laterals int lateral_assetId = SaveLateral(row, projectId, sectionAssetId, countryId, provinceId, countyId, cityId, companyId, isNewMeasuredFromDsmh); UpdateLateral(row, projectId, sectionAssetId, countryId, provinceId, countyId, cityId, length, companyId); // ... Update if lateral is in FulllenghtLining if (!row.InFllDatabase) { WorkFullLengthLiningM1LateralGateway workFullLengthLiningM1LateralGateay = new WorkFullLengthLiningM1LateralGateway(); workFullLengthLiningM1LateralGateay.LoadAllByWorkIdLateral(workId, lateral_assetId, companyId); if (workFullLengthLiningM1LateralGateay.Table.Rows.Count == 0) { InsertFLLLateral(workId, lateral_assetId, newVideoDistance, newClockPosition, newDistanceToCentre, newTimeOpened, newReverseSetup, newReinstate, newComments, false, companyId, newClientInspectionNo, newV1Inspection, newRequiresRoboticPrep, newRequiresRoboticPrepDate, newHoldClientIssue, newHoldLFSIssue, newLineLateral, newDyeTestReq, newDyeTestComplete, newContractYear); } else { UpdateFLLLateral(workId, lateral_assetId, originalVideoDistance, originalClockPosition, originalDistanceToCentre, originalTimeOpened, originalReverseSetup, originalReinstate, originalComments, true, companyId, originalClientInspectionNo, originalV1Inspection, originalRequiresRoboticPrep, originalRequiresRoboticPrepDate, originalHoldClientIssue, originalHoldLFSIssue, originalLineLateral, originalDyeTestReq, originalDyeTestComplete, originalContractYear, workId, lateral_assetId, newVideoDistance, newClockPosition, newDistanceToCentre, newTimeOpened, newReverseSetup, newReinstate, newComments, false, companyId, newClientInspectionNo, newV1Inspection, newRequiresRoboticPrep, newRequiresRoboticPrepDate, newHoldClientIssue, newHoldLFSIssue, newLineLateral, newDyeTestReq, newDyeTestComplete, newContractYear); } } else { UpdateFLLLateral(workId, lateral_assetId, originalVideoDistance, originalClockPosition, originalDistanceToCentre, originalTimeOpened, originalReverseSetup, originalReinstate, originalComments, false, companyId, originalClientInspectionNo, originalV1Inspection, originalRequiresRoboticPrep, originalRequiresRoboticPrepDate, originalHoldClientIssue, originalHoldLFSIssue, originalLineLateral, originalDyeTestReq, originalDyeTestComplete, originalContractYear,workId, lateral_assetId, newVideoDistance, newClockPosition, newDistanceToCentre, newTimeOpened, newReverseSetup, newReinstate, newComments, false, companyId, newClientInspectionNo, newV1Inspection, newRequiresRoboticPrep, newRequiresRoboticPrepDate, newHoldClientIssue, newHoldLFSIssue, newLineLateral, newDyeTestReq, newDyeTestComplete, newContractYear); } // ... Update if lateral is in Junction Lining if (row.InJlDatabase) { if (originalLineLateral == newLineLateral) { // ... ... Update jl lateral (clientInspectionNo, v1Inspection, requiredRoboticPrep, requiredRoboticPrepDate, holdClientIssue, holdLFSIssue, flange) UpdateJLLaterals(projectId, lateral_assetId, companyId, newV1Inspection, newClientInspectionNo, newRequiresRoboticPrep, newRequiresRoboticPrepDate, newHoldClientIssue, newHoldLFSIssue, newFlange, newDyeTestReq, newDyeTestComplete, newContractYear); } else { int sectionWorkId = 0; WorkJunctionLiningSection workJunctionLiningSection = new WorkJunctionLiningSection(null); sectionWorkId = workJunctionLiningSection.InsertDirect(projectId, sectionAssetId, null, 0, 0, false, "No", 0, 0, false, companyId, "", "", "", "", false, "", 0); // Delete empty lateral form jl. DeleteJLLaterals(projectId, lateral_assetId, companyId, sectionWorkId); } } else { // ... ... Insert if should be in junction Lining if (row.LineLateral) { if (((!prepDataRoboticPrep) && (!prepDataRoboticPrepCompleted.HasValue)) || ((prepDataRoboticPrep) && (prepDataRoboticPrepCompleted.HasValue))) { int sectionWorkId = 0; // Insert to jl laterals WorkJunctionLiningSection workJunctionLiningSection = new WorkJunctionLiningSection(null); sectionWorkId = workJunctionLiningSection.InsertDirect(projectId, sectionAssetId, null, 0, 0, false, "No", 0, 0, false, companyId, "", "", "", "", false, "", 0); WorkJunctionLiningLateralGateway workJunctionLiningLateralGateway = new WorkJunctionLiningLateralGateway(); WorkJunctionLiningLateral workJunctionLiningLateral = new WorkJunctionLiningLateral(workJunctionLiningLateralGateway.Data); workJunctionLiningLateral.InsertDirect(projectId, lateral_assetId, sectionWorkId, null, null, null, null, null, null, null, null, null, "", null, null, null, 0, null, null, null, 0, newV1Inspection, false, false, "", false, null, null, false, companyId, "", "", "", false, null, newClientInspectionNo, newFlange, "", "", false, null, false, null, false, newHoldClientIssue, null, newHoldLFSIssue, null, newRequiresRoboticPrep, newRequiresRoboticPrepDate, "", "", newDyeTestReq, newDyeTestComplete, newContractYear); } } } string material = rehabAssessmentLateralDetailsGateway.GetMaterialType(lateral); if (material != "") { InsertMaterial(lateral_assetId, material, companyId); } try { LfsAssetSewerLateralClientGateway lfsAssetSewerLateralClientGateway = new LfsAssetSewerLateralClientGateway(); lfsAssetSewerLateralClientGateway.LoadAllByAssetIdClientId(lateral_assetId, clientId, companyId); if (lfsAssetSewerLateralClientGateway.Table.Rows.Count == 0) { LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); lfsAssetSewerLateralClient.InsertDirect(lateral_assetId, clientId, originalClientLateralId, false, companyId); } else { LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); string originalClientLateralId2 = lfsAssetSewerLateralClientGateway.GetClientLateralId(lateral_assetId, clientId); lfsAssetSewerLateralClient.UpdateDirect(lateral_assetId, clientId, originalClientLateralId, false, companyId, lateral_assetId, clientId, newClientLateralId, false, companyId); } } catch { } } // ... Delete laterals if ((row.InDatabase) && (row.Deleted)) { DeleteFLLLateral(workId, row.Lateral, companyId, clientId); } } } }
private void InsertProject(int projectId) { // ... Data for current project ProjectGateway projectGateway = new ProjectGateway(projectTDS); projectGateway.LoadByProjectId(projectId); // ... Definition of general variables 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 (projectGateway.GetProjectLeadID(projectId).HasValue) projectLeadId = (int)projectGateway.GetProjectLeadID(projectId); int salesmanId = projectGateway.GetSalesmanID(projectId); bool deleted = false; int? clientPrimaryContactID = null; if (projectGateway.GetClientPrimaryContactID(projectId).HasValue) clientPrimaryContactID = (int)projectGateway.GetClientPrimaryContactID(projectId); int? clientSecondaryContactID = null; if (projectGateway.GetClientSecondaryContactID(projectId).HasValue) clientSecondaryContactID = (int)projectGateway.GetClientSecondaryContactID(projectId); int? OriginalProjectID = projectId; int? projectNumberCopy = null; if (projectGateway.GetLastProjectNumberCopy(projectId).HasValue) projectNumberCopy = (int)projectGateway.GetLastProjectNumberCopy(projectId) + 1; else projectNumberCopy = 1; string projectNumber = projectGateway.GetProjectNumber(projectId) + "-" + projectNumberCopy.ToString(); string projectType = "Proposal"; string projectState = projectGateway.GetProjectState(projectId); string name = projectGateway.GetName(projectId); string description = projectGateway.GetDescription(projectId); DateTime? proposalDate = null; if (projectGateway.GetProposalDate(projectId).HasValue) proposalDate = projectGateway.GetProposalDate(projectId); DateTime? startDate = null; if (projectGateway.GetStartDate(projectId).HasValue) startDate = projectGateway.GetStartDate(projectId); DateTime? endDate = null; if (projectGateway.GetEndDate(projectId).HasValue) endDate = projectGateway.GetEndDate(projectId); int clientId = projectGateway.GetClientID(projectId); string clientProjectNumber = projectGateway.GetClientProjectNumber(projectId); int? libraryCategoriesId = null; if (projectGateway.GetLibraryCategoriesId(projectId).HasValue) libraryCategoriesId = (int)projectGateway.GetLibraryCategoriesId(projectId); bool fairWageApplies = projectGateway.GetFairWageApplies(projectId); // ... Insert Project Project project = new Project(projectTDS); project.Insert(countryId, officeId, projectLeadId, salesmanId, projectNumber, projectType, projectState, name, description, proposalDate, startDate, endDate, clientId, clientPrimaryContactID, clientSecondaryContactID, clientProjectNumber, deleted, OriginalProjectID, projectNumberCopy, libraryCategoriesId, provinceId, cityId, Int32.Parse(hdfCompanyId.Value.Trim()), countyId, fairWageApplies); // ... Insert History ProjectHistory projectHistory = new ProjectHistory(projectTDS); projectHistory.Insert(0, 1, projectState, DateTime.Now, Convert.ToInt32(Session["loginID"]), Int32.Parse(hdfCompanyId.Value.Trim())); }
/// <summary> /// Delete lateral work /// </summary> /// <param name="workId">workId</param> /// <param name="lateral">lateral</param> /// <param name="companyId">companyId</param> /// <param name="projectId">projectId</param> private void DeleteFLLLateral(int workId, int lateral, int companyId, int projectId) { // Delete work lateral WorkFullLengthLiningM1Lateral workFullLengthLiningM1Lateral = new WorkFullLengthLiningM1Lateral(null); workFullLengthLiningM1Lateral.DeleteDirect(workId, lateral, companyId); // Delete section LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null); bool isDeleted = lfsAssetSewerLateral.DeleteDirect(lateral, companyId); if (isDeleted) { ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); int clientId = projectGateway.GetClientID(projectId); LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null); lfsAssetSewerLateralClient.DeleteDirect(lateral, clientId, companyId); } }
// //////////////////////////////////////////////////////////////////////// // INITIAL EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!Convert.ToBoolean(Session["sgLFS_PROJECTS_COSTINGSHEETS_ADMIN"])) { if (!(Convert.ToBoolean(Session["sgLFS_PROJECTS_COSTINGSHEETS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_PROJECTS_COSTINGSHEETS_EDIT"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } } // Validate query string if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["costing_sheet_id"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in project_combined_costing_sheets_edit.aspx"); } // Tag Page hdfCostingSheetId.Value = Request.QueryString["costing_sheet_id"].ToString(); hdfCompanyId.Value = Session["companyID"].ToString(); hdfProjectId.Value = Request.QueryString["project_id"]; hdfDataChanged.Value = Request.QueryString["data_changed"]; hdfDataChangedMessage.Value = "Changes made to this project will not be saved."; ViewState["state"] = Request.QueryString["state"]; ViewState["active_tab"] = Request.QueryString["active_tab"]; ViewState["origin"] = Request.QueryString["origin"]; ViewState["update"] = Request.QueryString["update"]; projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; Session.Remove("labourHoursInformationDummy"); Session.Remove("unitsInformationDummy"); Session.Remove("subcontractorsInformationDummy"); Session.Remove("materialsInformationDummy"); Session.Remove("otherCostsInformationDummy"); Session.Remove("revenueInformationDummy"); // If coming from project_combined_costing_sheets_navigator.aspx or project_combined_costing_sheets_add.aspx int companyId = Int32.Parse(hdfCompanyId.Value); if (Request.QueryString["source_page"] == "project_costing_sheets_navigator.aspx" || Request.QueryString["source_page"] == "project_combined_costing_sheets_add.aspx") { // Store Navigator State and Update control StoreNavigatorState(); ViewState["update"] = "no"; // Get Costing sheet ID int costingSheetId = Int32.Parse(hdfCostingSheetId.Value.Trim()); // Get dataset projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; projectCostingSheetInformationTDS = new ProjectCostingSheetInformationTDS(); labourHoursInformation = new ProjectCostingSheetInformationTDS.CombinedLabourHoursInformationDataTable(); unitsInformation = new ProjectCostingSheetInformationTDS.CombinedUnitsInformationDataTable(); subcontractorsInformation = new ProjectCostingSheetInformationTDS.CombinedSubcontractorsInformationDataTable(); materialsInformation = new ProjectCostingSheetInformationTDS.CombinedMaterialsInformationDataTable(); otherCostsInformation = new ProjectCostingSheetInformationTDS.CombinedOtherCostsInformationDataTable(); revenueInformation = new ProjectCostingSheetInformationTDS.CombinedRevenueInformationDataTable(); // Get General Data ProjectCombinedCostingSheetInformationBasicInformation projectCostingSheetInformationBasicInformation = new ProjectCombinedCostingSheetInformationBasicInformation(projectCostingSheetInformationTDS); projectCostingSheetInformationBasicInformation.LoadByCostingSheetId(costingSheetId, companyId); ProjectCombinedCostingSheetInformationLabourHoursInformationGateway projectCostingSheetInformationLabourHoursInformationGateway = new ProjectCombinedCostingSheetInformationLabourHoursInformationGateway(projectCostingSheetInformationTDS); projectCostingSheetInformationLabourHoursInformationGateway.LoadByCostingSheetId(costingSheetId, companyId); ProjectCombinedCostingSheetInformationUnitsInformationGateway projectCostingSheetInformationUnitsInformationGateway = new ProjectCombinedCostingSheetInformationUnitsInformationGateway(projectCostingSheetInformationTDS); projectCostingSheetInformationUnitsInformationGateway.LoadByCostingSheetId(costingSheetId, companyId); ProjectCombinedCostingSheetInformationSubcontractorsInformationGateway projectCostingSheetInformationSubcontractorsInformationGateway = new ProjectCombinedCostingSheetInformationSubcontractorsInformationGateway(projectCostingSheetInformationTDS); projectCostingSheetInformationSubcontractorsInformationGateway.LoadByCostingSheetId(costingSheetId, companyId); ProjectCombinedCostingSheetInformationMaterialsInformationGateway projectCostingSheetInformationMaterialsInformationGateway = new ProjectCombinedCostingSheetInformationMaterialsInformationGateway(projectCostingSheetInformationTDS); projectCostingSheetInformationMaterialsInformationGateway.LoadByCostingSheetId(costingSheetId, companyId); ProjectCombinedCostingSheetInformationOtherCostsInformationGateway projectCostingSheetInformationOtherCostsInformationGateway = new ProjectCombinedCostingSheetInformationOtherCostsInformationGateway(projectCostingSheetInformationTDS); projectCostingSheetInformationOtherCostsInformationGateway.LoadByCostingSheetId(costingSheetId, companyId); projectCombinedCostingSheetInformationRevenueInformationGateway projectCombinedCostingSheetInformationRevenueInformationGateway = new projectCombinedCostingSheetInformationRevenueInformationGateway(projectCostingSheetInformationTDS); projectCombinedCostingSheetInformationRevenueInformationGateway.LoadByCostingSheetId(costingSheetId, companyId); Session["lfsProjectTDS"] = projectTDS; Session["projectCostingSheetInformationTDS"] = projectCostingSheetInformationTDS; Session["labourHoursInformation"] = projectCostingSheetInformationTDS.CombinedLabourHoursInformation; Session["unitsInformation"] = projectCostingSheetInformationTDS.CombinedUnitsInformation; Session["subcontractorsInformation"] = projectCostingSheetInformationTDS.CombinedSubcontractorsInformation; Session["materialsInformation"] = projectCostingSheetInformationTDS.CombinedMaterialsInformation; Session["otherCostsInformation"] = projectCostingSheetInformationTDS.CombinedOtherCostsInformation; Session["revenueInformation"] = projectCostingSheetInformationTDS.CombinedRevenueInformation; labourHoursInformation = projectCostingSheetInformationTDS.CombinedLabourHoursInformation; unitsInformation = projectCostingSheetInformationTDS.CombinedUnitsInformation; subcontractorsInformation = projectCostingSheetInformationTDS.CombinedSubcontractorsInformation; materialsInformation = projectCostingSheetInformationTDS.CombinedMaterialsInformation; otherCostsInformation = projectCostingSheetInformationTDS.CombinedOtherCostsInformation; revenueInformation = projectCostingSheetInformationTDS.CombinedRevenueInformation; } // ... project_combined_costing_sheets_add.aspx if (Request.QueryString["source_page"] == "project_combined_costing_sheets_add.aspx") { ViewState["update"] = "yes"; } // ... left menu, project_combined_costing_sheets_edit.aspx, project_combined_costing_sheets_delete.aspx or project_combined_costing_sheets_state.aspx if ((Request.QueryString["source_page"] == "lm") || (Request.QueryString["source_page"] == "project_combined_costing_sheets_summary.aspx") || (Request.QueryString["source_page"] == "project_combined_costing_sheets_delete.aspx") || (Request.QueryString["source_page"] == "project_combined_costing_sheets_state.aspx")) { // Store Navigator State and Update control StoreNavigatorState(); ViewState["update"] = Request.QueryString["update"]; } // Restore dataset projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; projectCostingSheetInformationTDS = (ProjectCostingSheetInformationTDS)Session["projectCostingSheetInformationTDS"]; labourHoursInformation = (ProjectCostingSheetInformationTDS.CombinedLabourHoursInformationDataTable)Session["labourHoursInformation"]; unitsInformation = (ProjectCostingSheetInformationTDS.CombinedUnitsInformationDataTable)Session["unitsInformation"]; subcontractorsInformation = (ProjectCostingSheetInformationTDS.CombinedSubcontractorsInformationDataTable)Session["subcontractorsInformation"]; materialsInformation = (ProjectCostingSheetInformationTDS.CombinedMaterialsInformationDataTable)Session["materialsInformation"]; otherCostsInformation = (ProjectCostingSheetInformationTDS.CombinedOtherCostsInformationDataTable)Session["otherCostsInformation"]; revenueInformation = (ProjectCostingSheetInformationTDS.CombinedRevenueInformationDataTable)Session["revenueInformation"]; if (!Convert.ToBoolean(Session["sgLFS_PROJECTS_COSTINGSHEETS_ADMIN"])) { // Costing Sheet state check ProjectCombinedCostingSheetInformationBasicInformationGateway projectCostingSheetInformationBasicInformationGatewayForValidate = new ProjectCombinedCostingSheetInformationBasicInformationGateway(projectCostingSheetInformationTDS); string state = projectCostingSheetInformationBasicInformationGatewayForValidate.GetState(Int32.Parse(hdfCostingSheetId.Value)); if (state == "Approved") { Response.Redirect("./../../error_page.aspx?error=" + "This costing sheet is approved, you can not edit it."); } } ProjectGateway projectGateway = new ProjectGateway(projectTDS); hdfClientId.Value = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString())).ToString(); // ... for project int currentProjectId = Int32.Parse(hdfProjectId.Value.ToString()); string name = projectGateway.GetName(currentProjectId); if (name.Length > 23) name = name.Substring(0, 20) + "..."; lblTitleProjectName.Text = name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")"; // ... for client int currentClientId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString())); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(currentClientId, companyId); lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId); LoadBasicData(); } else { // Restore dataset projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; projectCostingSheetInformationTDS = (ProjectCostingSheetInformationTDS)Session["projectCostingSheetInformationTDS"]; labourHoursInformation = (ProjectCostingSheetInformationTDS.CombinedLabourHoursInformationDataTable)Session["labourHoursInformation"]; unitsInformation = (ProjectCostingSheetInformationTDS.CombinedUnitsInformationDataTable)Session["unitsInformation"]; subcontractorsInformation = (ProjectCostingSheetInformationTDS.CombinedSubcontractorsInformationDataTable)Session["subcontractorsInformation"]; materialsInformation = (ProjectCostingSheetInformationTDS.CombinedMaterialsInformationDataTable)Session["materialsInformation"]; otherCostsInformation = (ProjectCostingSheetInformationTDS.CombinedOtherCostsInformationDataTable)Session["otherCostsInformation"]; revenueInformation = (ProjectCostingSheetInformationTDS.CombinedRevenueInformationDataTable)Session["revenueInformation"]; } }
// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // /// <summary> /// Insert /// </summary> /// <param name="projectId">projectId</param> /// <param name="name">name</param> /// <param name="startDate">startDate</param> /// <param name="endDate">endDate</param> /// <param name="totalLabourHoursCad">totalLabourHoursCad</param> /// <param name="totalLabourHoursUsd">totalLabourHoursUsd</param> /// <param name="totalMaterialsCad">totalMaterialsCad</param> /// <param name="totalMaterialsUsd">totalMaterialsUsd</param> /// <param name="totalUnitsCad">totalUnitsCad</param> /// <param name="totalUnitsUsd">totalUnitsUsd</param> /// <param name="totalOtherCostsCad">totalOtherCostsCad</param> /// <param name="totalOtherCostsUsd">totalOtherCostsUsd</param> /// <param name="grandTotalCad">grandTotalCad</param> /// <param name="grandTotalUsd">grandTotalUsd</param> /// <param name="state">state</param> /// <param name="deleted">deleted</param> /// <param name="companyId">companyId</param> /// <param name="totalSubcontractorsCad">totalSubcontractorsCad</param> /// <param name="totalSubcontractorsUsd">totalSubcontractorsUsd</param> public void Insert(int projectId, string name, DateTime startDate, DateTime endDate, decimal totalLabourHoursCad, decimal totalLabourHoursUsd, decimal totalMaterialsCad, decimal totalMaterialsUsd, decimal totalUnitsCad, decimal totalUnitsUsd, decimal totalOtherCostsCad, decimal totalOtherCostsUsd, decimal grandTotalCad, decimal grandTotalUsd, string state, bool deleted, int companyId, decimal totalSubcontractorsCad, decimal totalSubcontractorsUsd, decimal grandRevenue, decimal grandProfit, decimal grandGrossMargin, decimal totalHotels, decimal totalBondings, decimal totalInsurances, decimal totalOtherCategory, string month) { ProjectCostingSheetAddTDS.BasicInformationRow row = ((ProjectCostingSheetAddTDS.BasicInformationDataTable)Table).NewBasicInformationRow(); row.CostingSheetID = 0; row.ProjectID = projectId; row.Name = name; row.StartDate = startDate; row.EndDate = endDate; row.TotalLabourHoursCad = totalLabourHoursCad; row.TotalLabourHoursUsd = totalLabourHoursUsd; row.TotalMaterialsCad = totalMaterialsCad; row.TotalMaterialsUsd = totalMaterialsUsd; row.TotalUnitsCad = totalUnitsCad; row.TotalUnitsUsd = totalUnitsUsd; row.TotalOtherCostsCad = totalOtherCostsCad; row.TotalOtherCostsUsd = totalOtherCostsUsd; row.GrantTotalCostCad = grandTotalCad; row.GrantTotalCostUsd = grandTotalUsd; row.Deleted = deleted; row.COMPANY_ID = companyId; row.TotalSubcontractorsCad = totalSubcontractorsCad; row.TotalSubcontractorsUsd = totalSubcontractorsUsd; row.TotalHotelCosts = totalHotels; row.TotalBondingCosts = totalBondings; row.TotalInsuranceCosts = totalInsurances; row.TotalOtherCategoryCosts = totalOtherCategory; row.GrantTotalCostCad = totalLabourHoursCad + totalUnitsCad + totalMaterialsCad + totalOtherCostsCad + totalSubcontractorsCad + totalHotels + totalBondings + totalInsurances + totalOtherCategory; row.GrantTotalCostUsd = totalLabourHoursUsd + totalUnitsUsd + totalMaterialsUsd + totalOtherCostsUsd + totalSubcontractorsUsd + totalHotels + totalBondings + totalInsurances + totalOtherCategory; row.State = "In Progress"; row.GrandRevenue = grandRevenue; row.GrandProfit = grandProfit; row.GrandGrossMargin = grandGrossMargin; row.Month = month; ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); row.ProjectName = projectGateway.GetName(projectId); int clientId = projectGateway.GetClientID(projectId); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(clientId, companyId); row.ClientName = companiesGateway.GetName(clientId); ((ProjectCostingSheetAddTDS.BasicInformationDataTable)Table).AddBasicInformationRow(row); }
// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!Convert.ToBoolean(Session["sgLFS_PROJECTS_VIEW"])) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } // Validate query string if (Request.QueryString["source_page"] == null) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in project_sections_navigator2.aspx"); } projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; assetsTDS = new AssetsTDS(); lfsAssetsTDS = new LfsAssetsTDS(); workTDS = new WorkTDS(); // Tag page hdfCompanyId.Value = Session["companyID"].ToString(); hdfProjectId.Value = Request.QueryString["project_id"]; hdfDataChanged.Value = Request.QueryString["data_changed"]; hdfDataChangedMessage.Value = "Changes made to this project will not be saved."; ViewState["state"] = Request.QueryString["state"]; ViewState["active_tab"] = Request.QueryString["active_tab"]; ViewState["origin"] = Request.QueryString["origin"]; ViewState["update"] = Request.QueryString["update"]; Session.Remove("projectSectionsNavigatorNewDummy"); Session.Remove("projectSectionsNavigator"); // Prepare initial data lblError.Visible = false; // ... for project int currentProjectId = Int32.Parse(hdfProjectId.Value.ToString()); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(currentProjectId); string name = projectGateway.GetName(currentProjectId); if (name.Length > 23) name = name.Substring(0, 20) + "..."; lblTitleProjectName.Text = name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")"; // ... for client int companyId = Int32.Parse(hdfCompanyId.Value.Trim()); int currentClientId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString())); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(currentClientId, companyId); lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId); hdfClientId.Value = projectGateway.GetClientID(int.Parse(hdfProjectId.Value)).ToString(); // Store navigator state at projects navigator StoreNavigatorState(); // ... project_sections_navigator.aspx or project_sections_navigator2.aspx if ((Request.QueryString["source_page"] == "project_sections_navigator.aspx") || (Request.QueryString["source_page"] == "project_sections_navigator2.aspx")) { // Restore navigator state RestoreNavigatorState(); // Restore data projectSectionsNavigatorTDS = (ProjectSectionsNavigatorTDS)Session["lfsProjectSectionsNavigatorTDS"]; projectSectionsNavigator = projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR; // Store data Session["projectSectionsNavigator"] = projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR; if (Request.QueryString["update_section"] == "no") { // Restore data projectSectionsNavigatorTDS = (ProjectSectionsNavigatorTDS)Session["lfsProjectSectionsNavigatorTDS"]; projectSectionsNavigator = projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR; // Store data Session["projectSectionsNavigator"] = projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR; } else { // ... Delete store data Session.Contents.Remove("lfsProjectSectionsNavigatorTDS"); // ... Search data with updates projectSectionsNavigatorTDS = SubmitSearch(); // ... store datasets Session["lfsProjectSectionsNavigatorTDS"] = projectSectionsNavigatorTDS; Session["projectSectionsNavigator"] = projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR; } //... for the total rows if (projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR.Rows.Count > 0) { lblTotalRows.Text = "Total Rows: " + projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR.Rows.Count; lblTotalRows.Visible = true; } else { lblTotalRows.Visible = false; } } } else { // Restore dataset projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; projectSectionsNavigatorTDS = (ProjectSectionsNavigatorTDS)Session["lfsProjectSectionsNavigatorTDS"]; assetsTDS = (AssetsTDS)Session["assetsTDS"]; lfsAssetsTDS = (LfsAssetsTDS)Session["lfsAssetsTDS"]; workTDS = (WorkTDS)Session["workTDS"]; // ... for project int currentProjectId = Int32.Parse(hdfProjectId.Value.ToString()); ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(currentProjectId); string name = projectGateway.GetName(currentProjectId); if (name.Length > 23) name = name.Substring(0, 20) + "..."; lblTitleProjectName.Text = name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")"; // ... for client int companyId = Int32.Parse(hdfCompanyId.Value); int currentClientId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString())); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(currentClientId, companyId); lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId); // Restore searched data (if any) projectSectionsNavigatorTDS = (ProjectSectionsNavigatorTDS)Session["lfsProjectSectionsNavigatorTDS"]; projectSectionsNavigator = projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR; //... for the total rows if (projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR.Rows.Count > 0) { lblTotalRows.Text = "Total Rows: " + projectSectionsNavigatorTDS.LFS_PROJECT_SECTIONS_NAVIGATOR.Rows.Count; } else { lblTotalRows.Visible = false; } } }
private void LoadGeneralData() { // Data for General Data tbxProjectNumber.DataBind(); tbxName.DataBind(); tbxProposalDate.DataBind(); tbxStartDate.DataBind(); tbxEndDate.DataBind(); tbxDescription.DataBind(); cbxFairWageApplies.DataBind(); // ... for geographical location hdfCountryId.DataBind(); if (hdfCountryId.Value != "") { CountryGateway countryGateway = new CountryGateway(); countryGateway.LoadByCountryId(Int64.Parse(hdfCountryId.Value)); tbxCountry.Text = countryGateway.GetName(Int64.Parse(hdfCountryId.Value)); } else { tbxCountry.Text = ""; } hdfProvinceStateId.DataBind(); if (hdfProvinceStateId.Value != "") { ProvinceGateway provinceGateway = new ProvinceGateway(); provinceGateway.LoadByProvinceId(Int64.Parse(hdfProvinceStateId.Value)); tbxProvinceState.Text = provinceGateway.GetName(Int64.Parse(hdfProvinceStateId.Value)); } else { tbxProvinceState.Text = ""; } hdfCountyId.DataBind(); if (hdfCountyId.Value != "") { CountyGateway countyGateway = new CountyGateway(); countyGateway.LoadByCountyId(Int64.Parse(hdfCountyId.Value)); tbxCounty.Text = countyGateway.GetName(Int64.Parse(hdfCountyId.Value)); } else { tbxCounty.Text = ""; } hdfCityId.DataBind(); if (hdfCityId.Value != "") { CityGateway cityGateway = new CityGateway(); cityGateway.LoadByCityId(Int64.Parse(hdfCityId.Value)); tbxCity.Text = cityGateway.GetName(Int64.Parse(hdfCityId.Value)); } else { tbxCity.Text = ""; } // ... for project ProjectGateway projectGateway = new ProjectGateway(projectTDS); int currentCompanyId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString())); // ... for client int companyId = Int32.Parse(hdfCompanyId.Value); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(currentCompanyId, companyId); tbxClientName.Text = companiesGateway.GetName(currentCompanyId); hdfClientId.Value = projectGateway.GetClientID(int.Parse(hdfProjectId.Value)).ToString(); tbxClientProjectNumber.DataBind(); // ... ... for primary contact if (projectGateway.GetClientPrimaryContactID(int.Parse(hdfProjectId.Value)).HasValue) { hdfClientPrimaryContactID.Value = ((int)projectGateway.GetClientPrimaryContactID(int.Parse(hdfProjectId.Value))).ToString(); ContactsGateway contactsGatewayForPrimaryContact = new ContactsGateway(); contactsGatewayForPrimaryContact.LoadAllByContactId(int.Parse(hdfClientPrimaryContactID.Value), companyId); tbxClientPrimaryContact.Text = contactsGatewayForPrimaryContact.GetCompleteName(int.Parse(hdfClientPrimaryContactID.Value)); } // ... ... for secondary contact if (projectGateway.GetClientSecondaryContactID(int.Parse(hdfProjectId.Value)).HasValue) { hdfClientSecondaryContactID.Value = ((int)projectGateway.GetClientSecondaryContactID(int.Parse(hdfProjectId.Value))).ToString(); ContactsGateway contactsGatewayForSecondaryContact = new ContactsGateway(); contactsGatewayForSecondaryContact.LoadAllByContactId(int.Parse(hdfClientSecondaryContactID.Value), companyId); tbxClientSecondaryContact.Text = contactsGatewayForSecondaryContact.GetCompleteName(int.Parse(hdfClientSecondaryContactID.Value)); } // ... for resources // ... ... for project lead if (projectGateway.GetProjectLeadID(int.Parse(hdfProjectId.Value)).HasValue) { EmployeeGateway employeeGateway = new EmployeeGateway(); employeeGateway.LoadByEmployeeId((int)projectGateway.GetProjectLeadID(int.Parse(hdfProjectId.Value))); tbxProjectLead.Text = employeeGateway.GetFullName((int)projectGateway.GetProjectLeadID(int.Parse(hdfProjectId.Value))); } // ... ... for salesman SalesmanGateway salesmanGateway = new SalesmanGateway(); salesmanGateway.LoadExpandedBySalesmanId(projectGateway.GetSalesmanID(int.Parse(hdfProjectId.Value))); tbxSalesman.Text = salesmanGateway.GetFullName(projectGateway.GetSalesmanID(int.Parse(hdfProjectId.Value))); // ... ... for Pricing if (projectGateway.GetProjectType(int.Parse(hdfProjectId.Value)) == "Ballpark") { ProjectSaleBillingPricingGateway projectSaleBillingPricingGateway = new ProjectSaleBillingPricingGateway(projectTDS); if (projectSaleBillingPricingGateway.Table.Rows.Count > 0) { if (projectSaleBillingPricingGateway.GetBillPrice(int.Parse(hdfProjectId.Value)).HasValue) tbxBillPrice.Text = ((decimal)projectSaleBillingPricingGateway.GetBillPrice(int.Parse(hdfProjectId.Value))).ToString("n2"); tbxBillMoney.Text = projectSaleBillingPricingGateway.GetBillMoney(int.Parse(hdfProjectId.Value)); } else { if (projectGateway.GetCountryID(int.Parse(hdfProjectId.Value)) == 1) { tbxBillMoney.Text = "CAD"; } else { tbxBillMoney.Text = "USD"; } } } // Data for unit budget tab ProjectNavigatorProjectUnitsBudgetGateway projectNavigatorProjectUnitsBudgetGateway = new ProjectNavigatorProjectUnitsBudgetGateway(projectNavigatorTDS); if (projectNavigatorProjectUnitsBudgetGateway.Table.Rows.Count > 0) { tbxUnitsBudget.Text = projectNavigatorProjectUnitsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value)).ToString("n2"); } // Data for materials budget tab ProjectNavigatorProjectMaterialsBudgetGateway projectNavigatorProjectMaterialsBudgetGateway = new ProjectNavigatorProjectMaterialsBudgetGateway(projectNavigatorTDS); if (projectNavigatorProjectMaterialsBudgetGateway.Table.Rows.Count > 0) { tbxMaterialsBudget.Text = projectNavigatorProjectMaterialsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value)).ToString("n2"); } // Data for subcontractors budget tab ProjectNavigatorProjectSubcontractorsBudgetGateway projectNavigatorProjectSubcontractorsBudgetGateway = new ProjectNavigatorProjectSubcontractorsBudgetGateway(projectNavigatorTDS); if (projectNavigatorProjectSubcontractorsBudgetGateway.Table.Rows.Count > 0) { tbxSubcontractorsBudget.Text = projectNavigatorProjectSubcontractorsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2"); } // Data for hotels budget tab ProjectNavigatorProjectHotelsBudgetGateway projectNavigatorProjectHotelsBudgetGateway = new ProjectNavigatorProjectHotelsBudgetGateway(projectNavigatorTDS); if (projectNavigatorProjectHotelsBudgetGateway.Table.Rows.Count > 0) { tbxHotelsBudget.Text = projectNavigatorProjectHotelsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2"); } // Data for bondings budget tab ProjectNavigatorProjectBondingsBudgetGateway projectNavigatorProjectBondingsBudgetGateway = new ProjectNavigatorProjectBondingsBudgetGateway(projectNavigatorTDS); if (projectNavigatorProjectBondingsBudgetGateway.Table.Rows.Count > 0) { tbxBondingsBudget.Text = projectNavigatorProjectBondingsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2"); } // Data for insurances budget tab ProjectNavigatorProjectInsurancesBudgetGateway projectNavigatorProjectInsurancesBudgetGateway = new ProjectNavigatorProjectInsurancesBudgetGateway(projectNavigatorTDS); if (projectNavigatorProjectInsurancesBudgetGateway.Table.Rows.Count > 0) { tbxInsurancesBudget.Text = projectNavigatorProjectInsurancesBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2"); } CalculateTotalBudget(); }
// //////////////////////////////////////////////////////////////////////// // EVENTS // protected void Page_Load(object sender, EventArgs e) { // Register client scripts this.RegisterClientScripts(); if (!IsPostBack) { // Security check if (!(Convert.ToBoolean(Session["sgLFS_PROJECTS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_PROJECTS_EDIT"]))) { Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator."); } // Validate query string if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["project_id"] == null)) { Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in project_edit.aspx"); } // Tag page hdfCompanyId.Value = Session["companyID"].ToString(); hdfProjectId.Value = Request.QueryString["project_id"]; hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString(); hdfDataChanged.Value = Request.QueryString["data_changed"]; hdfDataChangedMessage.Value = "Changes made to this project will not be saved."; // Prepare initial data Session.Remove("projectNotesDummy"); Session.Remove("projectServicesDummy"); Session.Remove("projectTypeOfWorkFunctionClassificationDummy"); Session.Remove("projectJobClassClassificationDummy"); Session.Remove("projectBudgetDummy"); Session.Remove("subcontractorsBudgetDummy"); Session.Remove("hotelsBudgetDummy"); Session.Remove("bondingsBudgetDummy"); Session.Remove("insurancesBudgetDummy"); Session.Remove("otherCostsBudgetDummy"); Session["fairWage"] = "None"; // ... Set initial tab if ((string)Session["dialogOpenedProjects"] != "1") { hdfActiveTab.Value = Request.QueryString["active_tab"]; } else { hdfActiveTab.Value = (string)Session["activeTabProjects"]; } // ... For Library if (Session["lfsLibraryTDS"] != null) { libraryTDS = (LibraryTDS)Session["lfsLibraryTDS"]; } else { libraryTDS = new LibraryTDS(); } // If coming from // ... projects2.aspx or project_add.aspx if (Request.QueryString["source_page"] == "projects2.aspx" || Request.QueryString["source_page"] == "project_add.aspx") { // Store Navigator State, Update control and Origin StoreNavigatorState(); ViewState["update"] = "no"; ViewState["origin"] = "navigator"; // Get Project Id int projectId = int.Parse(hdfProjectId.Value); // ... Attachment control if (Session["fromAttachment"] != null) { if (Session["fromAttachment"].ToString() == "yes") { // Restore dataset projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; projectNavigatorTDS = (ProjectNavigatorTDS)Session["projectNavigatorTDS"]; projectNotes = (ProjectNavigatorTDS.ProjectNotesDataTable)Session["projectNotes"]; projectServices = (ProjectNavigatorTDS.ProjectServiceDataTable)Session["projectServices"]; projectJobClassClassification = (ProjectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATEDataTable)Session["projectJobClassClassification"]; projectTypeOfWorkFunctionClassification = (ProjectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGEDataTable)Session["projectTypeOfWorkFunctionClassification"]; projectBudget = (ProjectNavigatorTDS.ProjectWorkFunctionBudgetDataTable)Session["projectBudget"]; unitsBudget = (ProjectNavigatorTDS.ProjectUnitsBudgetDataTable)Session["unitsBudget"]; materialsBudget = (ProjectNavigatorTDS.ProjectMaterialsBudgetDataTable)Session["materialsBudget"]; subcontractorsBudget = (ProjectNavigatorTDS.ProjectSubcontractorsBudgetDataTable)Session["subcontractorsBudget"]; hotelsBudget = (ProjectNavigatorTDS.ProjectHotelsBudgetDataTable)Session["hotelsBudget"]; bondingsBudget = (ProjectNavigatorTDS.ProjectBondingsBudgetDataTable)Session["bondingsBudget"]; insurancesBudget = (ProjectNavigatorTDS.ProjectInsurancesBudgetDataTable)Session["insurancesBudget"]; otherCostsBudget = (ProjectNavigatorTDS.ProjectOtherCostsBudgetDataTable)Session["otherCostsBudget"]; } Session.Remove("fromAttachment"); } else { // Get dataset projectTDS = new ProjectTDS(); projectNavigatorTDS = new ProjectNavigatorTDS(); projectNotes = new ProjectNavigatorTDS.ProjectNotesDataTable(); projectServices = new ProjectNavigatorTDS.ProjectServiceDataTable(); projectTypeOfWorkFunctionClassification = new ProjectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGEDataTable(); projectJobClassClassification = new ProjectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATEDataTable(); projectBudget = new ProjectNavigatorTDS.ProjectWorkFunctionBudgetDataTable(); unitsBudget = new ProjectNavigatorTDS.ProjectUnitsBudgetDataTable(); materialsBudget = new ProjectNavigatorTDS.ProjectMaterialsBudgetDataTable(); subcontractorsBudget = new ProjectNavigatorTDS.ProjectSubcontractorsBudgetDataTable(); hotelsBudget = new ProjectNavigatorTDS.ProjectHotelsBudgetDataTable(); bondingsBudget = new ProjectNavigatorTDS.ProjectBondingsBudgetDataTable(); insurancesBudget = new ProjectNavigatorTDS.ProjectInsurancesBudgetDataTable(); otherCostsBudget = new ProjectNavigatorTDS.ProjectOtherCostsBudgetDataTable(); // Get General Data ProjectGateway projectGatewayForLoad = new ProjectGateway(projectTDS); projectGatewayForLoad.LoadByProjectId(projectId); // Get job info ProjectJobInfoGateway projectJobInfoGateway = new ProjectJobInfoGateway(projectNavigatorTDS); projectJobInfoGateway.LoadAllByProjectId(projectId); // Get Sale/Billing/Pricing ProjectSaleBillingPricingGateway projectSaleBillingPricingGatewayForLoad = new ProjectSaleBillingPricingGateway(projectTDS); projectSaleBillingPricingGatewayForLoad.LoadAllByProjectId(projectId); // ... Get Sale/Billing/Pricing - Services ProjectNavigatorProjectService projectNavigatorProjectService = new ProjectNavigatorProjectService(projectNavigatorTDS); projectNavigatorProjectService.LoadAllByProjectId(projectId); projectNavigatorProjectService.UpdateForLoad(); // Get Costing Updates ProjectCostingUpdatesGateway projectCostingUpdatesGatewayForLoad = new ProjectCostingUpdatesGateway(projectTDS); projectCostingUpdatesGatewayForLoad.LoadByProjectId(projectId); // Get Project Terms ProjectTermsPOGateway projectTermsPOGatewayForLoad = new ProjectTermsPOGateway(projectTDS); projectTermsPOGatewayForLoad.LoadByProjectId(projectId); // Get Technical ProjectTechnicalGateway projectTechnicalGatewayForLoad = new ProjectTechnicalGateway(projectTDS); projectTechnicalGatewayForLoad.LoadByProjectId(projectId); // Get Engineer Subcontractors ProjectEngineerSubcontractorsGateway projectEngineerSubcontractorsGatewayForLoad = new ProjectEngineerSubcontractorsGateway(projectTDS); projectEngineerSubcontractorsGatewayForLoad.LoadAllByProjectId(projectId); // ... Get Subcontractors ProjectSubcontractorGateway projectSubcontractorGatewayForLoad = new ProjectSubcontractorGateway(projectTDS); projectSubcontractorGatewayForLoad.LoadAllByProjectId(projectId); // Cost Exceptions // ... Get Type Of Work & Function Classification ProjectNavigatorProjectWorkFunctionFairWage projectNavigatorProjectWorkFunctionFairWage = new ProjectNavigatorProjectWorkFunctionFairWage(projectNavigatorTDS); projectNavigatorProjectWorkFunctionFairWage.LoadAllByProjectId(projectId); // ... Get Job Class Classification ProjectNavigatorProjectJobClassTypeRate projectNavigatorProjectJobClassTypeRate = new ProjectNavigatorProjectJobClassTypeRate(projectNavigatorTDS); projectNavigatorProjectJobClassTypeRate.LoadAllByProjectId(projectId); // Get Budget ProjectNavigatorProjectWorkFunctionBudget projectNavigatorProjectWorkFunctionBudget = new ProjectNavigatorProjectWorkFunctionBudget(projectNavigatorTDS); projectNavigatorProjectWorkFunctionBudget.LoadAllByProjectId(projectId); // Get Units Budget ProjectNavigatorProjectUnitsBudget projectNavigatorProjectUnitsBudget = new ProjectNavigatorProjectUnitsBudget(projectNavigatorTDS); projectNavigatorProjectUnitsBudget.LoadAllByProjectId(projectId); // Get Materials Budget ProjectNavigatorProjectMaterialsBudget projectNavigatorProjectMaterialsBudget = new ProjectNavigatorProjectMaterialsBudget(projectNavigatorTDS); projectNavigatorProjectMaterialsBudget.LoadAllByProjectId(projectId); // Get Subcontractors Budget ProjectNavigatorProjectSubcontractorsBudget projectNavigatorProjectSubcontractorsBudget = new ProjectNavigatorProjectSubcontractorsBudget(projectNavigatorTDS); projectNavigatorProjectSubcontractorsBudget.LoadAllByProjectId(projectId); // Get Hotels Budget ProjectNavigatorProjectHotelsBudget projectNavigatorProjectHotelsBudget = new ProjectNavigatorProjectHotelsBudget(projectNavigatorTDS); projectNavigatorProjectHotelsBudget.LoadAllByProjectId(projectId); // Get Bondings Budget ProjectNavigatorProjectBondingsBudget projectNavigatorProjectBondingsBudget = new ProjectNavigatorProjectBondingsBudget(projectNavigatorTDS); projectNavigatorProjectBondingsBudget.LoadAllByProjectId(projectId); // Get Insurances Budget ProjectNavigatorProjectInsurancesBudget projectNavigatorProjectInsurancesBudget = new ProjectNavigatorProjectInsurancesBudget(projectNavigatorTDS); projectNavigatorProjectInsurancesBudget.LoadAllByProjectId(projectId); // Get Other Costs Budget ProjectNavigatorProjectOtherCostsBudget projectNavigatorProjectOtherCostsBudget = new ProjectNavigatorProjectOtherCostsBudget(projectNavigatorTDS); projectNavigatorProjectOtherCostsBudget.LoadAllByProjectId(projectId); // Get Notes ProjectNavigatorProjectNotes projectNavigatorProjectNotes = new ProjectNavigatorProjectNotes(projectNavigatorTDS); projectNavigatorProjectNotes.LoadAllByProjectId(projectId); // Store dataset Session["lfsProjectTDS"] = projectTDS; Session["projectNavigatorTDS"] = projectNavigatorTDS; Session["projectNotes"] = projectNavigatorTDS.ProjectNotes; Session["projectServices"] = projectNavigatorTDS.ProjectService; Session["projectTypeOfWorkFunctionClassification"] = projectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGE; Session["projectJobClassClassification"] = projectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATE; Session["projectBudget"] = projectNavigatorTDS.ProjectWorkFunctionBudget; Session["unitsBudget"] = projectNavigatorTDS.ProjectUnitsBudget; Session["materialsBudget"] = projectNavigatorTDS.ProjectMaterialsBudget; Session["subcontractorsBudget"] = projectNavigatorTDS.ProjectSubcontractorsBudget; Session["hotelsBudget"] = projectNavigatorTDS.ProjectHotelsBudget; Session["bondingsBudget"] = projectNavigatorTDS.ProjectBondingsBudget; Session["insurancesBudget"] = projectNavigatorTDS.ProjectInsurancesBudget; Session["otherCostsBudget"] = projectNavigatorTDS.ProjectOtherCostsBudget; } //grdNotes.DataBind(); //grdServices.DataBind(); grdTypeOfWorkFunctionClassification.DataBind(); grdJobClassClassification.DataBind(); grdBudget.DataBind(); /*grdSubcontractorsBudget.DataBind(); grdHotelsBudget.DataBind(); grdBondingsBudget.DataBind(); grdInsurancesBudget.DataBind();*/ grdOtherCostsBudget.DataBind(); } // ... project_summary.aspx or project_edit.aspx if ((Request.QueryString["source_page"] == "project_summary.aspx") || (Request.QueryString["source_page"] == "project_edit.aspx") || (Request.QueryString["source_page"] == "lm")) { // Store Navigator State, update control and origin StoreNavigatorState(); ViewState["update"] = Request.QueryString["update"]; ViewState["origin"] = Request.QueryString["origin"]; //summary // Restore dataset projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; projectNavigatorTDS = (ProjectNavigatorTDS)Session["projectNavigatorTDS"]; projectNotes = (ProjectNavigatorTDS.ProjectNotesDataTable)Session["projectNotes"]; projectServices = (ProjectNavigatorTDS.ProjectServiceDataTable)Session["projectServices"]; projectJobClassClassification = (ProjectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATEDataTable)Session["projectJobClassClassification"]; projectTypeOfWorkFunctionClassification = (ProjectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGEDataTable)Session["projectTypeOfWorkFunctionClassification"]; projectBudget = (ProjectNavigatorTDS.ProjectWorkFunctionBudgetDataTable)Session["projectBudget"]; unitsBudget = (ProjectNavigatorTDS.ProjectUnitsBudgetDataTable)Session["unitsBudget"]; materialsBudget = (ProjectNavigatorTDS.ProjectMaterialsBudgetDataTable)Session["materialsBudget"]; subcontractorsBudget = (ProjectNavigatorTDS.ProjectSubcontractorsBudgetDataTable)Session["subcontractorsBudget"]; hotelsBudget = (ProjectNavigatorTDS.ProjectHotelsBudgetDataTable)Session["hotelsBudget"]; bondingsBudget = (ProjectNavigatorTDS.ProjectBondingsBudgetDataTable)Session["bondingsBudget"]; insurancesBudget = (ProjectNavigatorTDS.ProjectInsurancesBudgetDataTable)Session["insurancesBudget"]; otherCostsBudget = (ProjectNavigatorTDS.ProjectOtherCostsBudgetDataTable)Session["otherCostsBudget"]; // Get Project Id int projectId = int.Parse(hdfProjectId.Value); if (ViewState["update"].ToString().Trim() == "yes") { // Get General Data ProjectGateway projectGatewayForLoad = new ProjectGateway(projectTDS); projectGatewayForLoad.LoadByProjectId(projectId); // Get job info ProjectJobInfoGateway projectJobInfoGateway = new ProjectJobInfoGateway(projectNavigatorTDS); projectJobInfoGateway.LoadAllByProjectId(projectId); // Get Sale/Billing/Pricing ProjectSaleBillingPricingGateway projectSaleBillingPricingGatewayForLoad = new ProjectSaleBillingPricingGateway(projectTDS); projectSaleBillingPricingGatewayForLoad.LoadAllByProjectId(projectId); // ... Get Sale/Billing/Pricing - Services ProjectNavigatorProjectService projectNavigatorProjectService = new ProjectNavigatorProjectService(projectNavigatorTDS); projectNavigatorProjectService.LoadAllByProjectId(projectId); projectNavigatorProjectService.UpdateForLoad(); // Get Costing Updates ProjectCostingUpdatesGateway projectCostingUpdatesGatewayForLoad = new ProjectCostingUpdatesGateway(projectTDS); projectCostingUpdatesGatewayForLoad.LoadByProjectId(projectId); // Get Project Terms ProjectTermsPOGateway projectTermsPOGatewayForLoad = new ProjectTermsPOGateway(projectTDS); projectTermsPOGatewayForLoad.LoadByProjectId(projectId); // Get Technical ProjectTechnicalGateway projectTechnicalGatewayForLoad = new ProjectTechnicalGateway(projectTDS); projectTechnicalGatewayForLoad.LoadByProjectId(projectId); // Get Engineer Subcontractors ProjectEngineerSubcontractorsGateway projectEngineerSubcontractorsGatewayForLoad = new ProjectEngineerSubcontractorsGateway(projectTDS); projectEngineerSubcontractorsGatewayForLoad.LoadAllByProjectId(projectId); // ... Get Subcontractors ProjectSubcontractorGateway projectSubcontractorGatewayForLoad = new ProjectSubcontractorGateway(projectTDS); projectSubcontractorGatewayForLoad.LoadAllByProjectId(projectId); // Cost Exceptions // ... Get Type Of Work & Function Classification ProjectNavigatorProjectWorkFunctionFairWage projectNavigatorProjectWorkFunctionFairWage = new ProjectNavigatorProjectWorkFunctionFairWage(projectNavigatorTDS); projectNavigatorProjectWorkFunctionFairWage.LoadAllByProjectId(projectId); // ... Get Job Class Classification ProjectNavigatorProjectJobClassTypeRate projectNavigatorProjectJobClassTypeRate = new ProjectNavigatorProjectJobClassTypeRate(projectNavigatorTDS); projectNavigatorProjectJobClassTypeRate.LoadAllByProjectId(projectId); // Get Budget ProjectNavigatorProjectWorkFunctionBudget projectNavigatorProjectWorkFunctionBudget = new ProjectNavigatorProjectWorkFunctionBudget(projectNavigatorTDS); projectNavigatorProjectWorkFunctionBudget.LoadAllByProjectId(projectId); // Get Units Budget ProjectNavigatorProjectUnitsBudget projectNavigatorProjectUnitsBudget = new ProjectNavigatorProjectUnitsBudget(projectNavigatorTDS); projectNavigatorProjectUnitsBudget.LoadAllByProjectId(projectId); // Get Materials Budget ProjectNavigatorProjectMaterialsBudget projectNavigatorProjectMaterialsBudget = new ProjectNavigatorProjectMaterialsBudget(projectNavigatorTDS); projectNavigatorProjectMaterialsBudget.LoadAllByProjectId(projectId); // Get Subcontractors Budget ProjectNavigatorProjectSubcontractorsBudget projectNavigatorProjectSubcontractorsBudget = new ProjectNavigatorProjectSubcontractorsBudget(projectNavigatorTDS); projectNavigatorProjectSubcontractorsBudget.LoadAllByProjectId(projectId); // Get Hotels Budget ProjectNavigatorProjectHotelsBudget projectNavigatorProjectHotelsBudget = new ProjectNavigatorProjectHotelsBudget(projectNavigatorTDS); projectNavigatorProjectHotelsBudget.LoadAllByProjectId(projectId); // Get Bondings Budget ProjectNavigatorProjectBondingsBudget projectNavigatorProjectBondingsBudget = new ProjectNavigatorProjectBondingsBudget(projectNavigatorTDS); projectNavigatorProjectBondingsBudget.LoadAllByProjectId(projectId); // Get Insurances Budget ProjectNavigatorProjectInsurancesBudget projectNavigatorProjectInsurancesBudget = new ProjectNavigatorProjectInsurancesBudget(projectNavigatorTDS); projectNavigatorProjectInsurancesBudget.LoadAllByProjectId(projectId); // Get Other Costs Budget ProjectNavigatorProjectOtherCostsBudget projectNavigatorProjectOtherCostsBudget = new ProjectNavigatorProjectOtherCostsBudget(projectNavigatorTDS); projectNavigatorProjectOtherCostsBudget.LoadAllByProjectId(projectId); // Get Notes ProjectNavigatorProjectNotes projectNavigatorProjectNotes = new ProjectNavigatorProjectNotes(projectNavigatorTDS); projectNavigatorProjectNotes.LoadAllByProjectId(projectId); //grdNotes.DataBind(); //grdServices.DataBind(); grdTypeOfWorkFunctionClassification.DataBind(); grdJobClassClassification.DataBind(); grdBudget.DataBind(); /*grdSubcontractorsBudget.DataBind(); grdHotelsBudget.DataBind(); grdBondingsBudget.DataBind(); grdInsurancesBudget.DataBind();*/ grdOtherCostsBudget.DataBind(); // Store dataset Session["lfsProjectTDS"] = projectTDS; Session["projectNavigatorTDS"] = projectNavigatorTDS; Session["projectNotes"] = projectNavigatorTDS.ProjectNotes; Session["projectServices"] = projectNavigatorTDS.ProjectService; Session["projectTypeOfWorkFunctionClassification"] = projectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGE; Session["projectJobClassClassification"] = projectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATE; Session["projectBudget"] = projectNavigatorTDS.ProjectWorkFunctionBudget; Session["unitsBudget"] = projectNavigatorTDS.ProjectUnitsBudget; Session["materialsBudget"] = projectNavigatorTDS.ProjectMaterialsBudget; Session["subcontractorsBudget"] = projectNavigatorTDS.ProjectSubcontractorsBudget; Session["hotelsBudget"] = projectNavigatorTDS.ProjectHotelsBudget; Session["bondingsBudget"] = projectNavigatorTDS.ProjectBondingsBudget; Session["insurancesBudget"] = projectNavigatorTDS.ProjectInsurancesBudget; Session["otherCostsBudget"] = projectNavigatorTDS.ProjectOtherCostsBudget; } } // Data for current project ProjectGateway projectGateway = new ProjectGateway(projectTDS); // ... for project int currentProjectId = Int32.Parse(hdfProjectId.Value.ToString()); string name = projectGateway.GetName(currentProjectId); if (name.Length > 23) name = name.Substring(0, 20) + "..."; lblTitleProjectName.Text = name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")"; // ... for client int companyId = Int32.Parse(hdfCompanyId.Value); int currentClientId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString())); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(currentClientId, companyId); lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId); // Load Data LoadData(); // Store Dataset Session["lfsProjectTDS"] = projectTDS; //// ... For total cost at services //ProjectNavigatorProjectService projectNavigatorProjectServiceForCost = new ProjectNavigatorProjectService(projectNavigatorTDS); //tbxTotalCost.Text = Decimal.Round(projectNavigatorProjectServiceForCost.GetTotalCost(), 2).ToString(); } else { // Restore dataset projectTDS = (ProjectTDS)Session["lfsProjectTDS"]; projectNavigatorTDS = (ProjectNavigatorTDS)Session["projectNavigatorTDS"]; projectNotes = (ProjectNavigatorTDS.ProjectNotesDataTable)Session["projectNotes"]; projectServices = (ProjectNavigatorTDS.ProjectServiceDataTable)Session["projectServices"]; projectJobClassClassification = (ProjectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATEDataTable)Session["projectJobClassClassification"]; projectTypeOfWorkFunctionClassification = (ProjectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGEDataTable)Session["projectTypeOfWorkFunctionClassification"]; projectBudget = (ProjectNavigatorTDS.ProjectWorkFunctionBudgetDataTable)Session["projectBudget"]; unitsBudget = (ProjectNavigatorTDS.ProjectUnitsBudgetDataTable)Session["unitsBudget"]; materialsBudget = (ProjectNavigatorTDS.ProjectMaterialsBudgetDataTable)Session["materialsBudget"]; subcontractorsBudget = (ProjectNavigatorTDS.ProjectSubcontractorsBudgetDataTable)Session["subcontractorsBudget"]; hotelsBudget = (ProjectNavigatorTDS.ProjectHotelsBudgetDataTable)Session["hotelsBudget"]; bondingsBudget = (ProjectNavigatorTDS.ProjectBondingsBudgetDataTable)Session["bondingsBudget"]; insurancesBudget = (ProjectNavigatorTDS.ProjectInsurancesBudgetDataTable)Session["insurancesBudget"]; otherCostsBudget = (ProjectNavigatorTDS.ProjectOtherCostsBudgetDataTable)Session["otherCostsBudget"]; tbxProjectNumber.DataBind(); if (Session["lfsLibraryTDS"] != null) { libraryTDS = (LibraryTDS)Session["lfsLibraryTDS"]; } else { libraryTDS = new LibraryTDS(); } } }
// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // /// <summary> /// Load /// </summary> /// <param name="works">works</param> /// <param name="projectId">projectId</param> /// <param name="startDate">startDate</param> /// <param name="endDate">endDate</param> /// <param name="companyId">companyId</param> public void Load(ArrayList works, int projectId, DateTime startDate, DateTime endDate, int companyId, string month) { ProjectGateway projectGateway = new ProjectGateway(); projectGateway.LoadByProjectId(projectId); string projectName = projectGateway.GetName(projectId); int clientId = projectGateway.GetClientID(projectId); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadAllByCompaniesId(clientId, companyId); string clientName = companiesGateway.GetName(clientId); // General vars int overtimeByCountry = 40; //Default for USA Projects int refId = GetNewRefId(); // Foreach of Works (FLL, RA, JL, PR, MH Rehab, MOB, Other) foreach (string work_ in works) { // Load Functions by Work ProjectCostingSheetAddFunctionListGateway projectCostingSheetAddFunctionListGateway = new ProjectCostingSheetAddFunctionListGateway(); projectCostingSheetAddFunctionListGateway.LoadByWork_(work_); // Foreach of Functions foreach (ProjectCostingSheetAddTDS.FunctionListRow functionListRow in (ProjectCostingSheetAddTDS.FunctionListDataTable)projectCostingSheetAddFunctionListGateway.Table) { // Load Employees by ProjectId, StartDate, EndDate, Work ProjectCostingSheetAddEmployeeListGateway projectCostingSheetAddEmployeeListGateway = new ProjectCostingSheetAddEmployeeListGateway(Data); projectCostingSheetAddEmployeeListGateway.LoadByProjectIdStartDateEndDateWorkFunction(projectId, startDate, endDate, work_, functionListRow.Function_, companyId); foreach (ProjectCostingSheetAddTDS.EmployeeListRow employeeListRow in (ProjectCostingSheetAddTDS.EmployeeListDataTable)projectCostingSheetAddEmployeeListGateway.Table) { DateTime newStartDate = new DateTime(); newStartDate = startDate; DateTime newEndDate = new DateTime(); newEndDate = endDate; //If Project is from Canada we get overtime if (projectGateway.GetCountryID(projectId) == 1) { //Get Category of Employee EmployeeGateway employeeGateway = new EmployeeGateway(); employeeGateway.LoadByEmployeeId(employeeListRow.EmployeeID); switch (employeeGateway.GetCategory(employeeListRow.EmployeeID)) { case "Special Forces": overtimeByCountry = 50; break; case "Field": overtimeByCountry = 50; break; case "Field 44": overtimeByCountry = 44; break; case "Office/Admin": overtimeByCountry = 44; break; case "Mechanic/Manufactoring": overtimeByCountry = 44; break; } } ProjectCostingSheetAddEmployeePayPeriodGateway projectCostingSheetAddEmployeePayPeriodGateway = new ProjectCostingSheetAddEmployeePayPeriodGateway(Data); projectCostingSheetAddEmployeePayPeriodGateway.LoadByStartDateEndDateEmployeeId(startDate, endDate, employeeListRow.EmployeeID); if (projectCostingSheetAddEmployeePayPeriodGateway.Table.Rows.Count > 0) { foreach (ProjectCostingSheetAddTDS.EmployeePayPeriodRow employeePayPeriodRow in (ProjectCostingSheetAddTDS.EmployeePayPeriodDataTable)projectCostingSheetAddEmployeePayPeriodGateway.Table) { newEndDate = employeePayPeriodRow.Date_.AddDays(-1); ProjectCostingSheetAddOriginalLabourHourGateway projectCostingSheetAddOriginalLabourHourGateway = new ProjectCostingSheetAddOriginalLabourHourGateway(Data); projectCostingSheetAddOriginalLabourHourGateway.LoadByProjectStartDateEndDateWorkFunctionEmployeeId(projectId, newStartDate, newEndDate, work_, functionListRow.Function_, employeeListRow.EmployeeID); if (projectCostingSheetAddOriginalLabourHourGateway.Table.Rows.Count > 0) { double lhQuantity = 0; double overtime = 0; decimal mealsQuantity = 0; decimal motelQuantity = 0; string employeeName = ""; refId++; foreach (ProjectCostingSheetAddTDS.OriginalLabourHourRow originalRow in (ProjectCostingSheetAddTDS.OriginalLabourHourDataTable)projectCostingSheetAddOriginalLabourHourGateway.Table) { employeeName = originalRow.EmployeeName; // Meal hours quantity if (!originalRow.IsMealsCountryNull()) { if (originalRow.MealsAllowance > 0) { mealsQuantity++; } } double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID); if (acumPeriod > overtimeByCountry) { overtime = overtime + originalRow.ProjectTime; } else { double newAcumPeriod = acumPeriod + originalRow.ProjectTime; if (newAcumPeriod > overtimeByCountry) { overtime = overtime + (newAcumPeriod - overtimeByCountry); lhQuantity = lhQuantity + (originalRow.ProjectTime - (newAcumPeriod - overtimeByCountry)); } else { lhQuantity = lhQuantity + originalRow.ProjectTime; } } } if (lhQuantity > 0) { ProjectCostingSheetAddTDS.LabourHoursInformationRow newRow = ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).NewLabourHoursInformationRow(); GetEmployeeData(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRow);// ... Get Costs newRow.CostingSheetID = 0; newRow.Work_ = work_; newRow.EmployeeID = employeeListRow.EmployeeID; newRow.RefID = refId; newRow.LHQuantity = lhQuantity; newRow.MealsQuantity = Convert.ToInt32(mealsQuantity); if (mealsQuantity > 0) newRow.MealsUnitOfMeasurement = "Day"; else newRow.MealsUnitOfMeasurement = ""; if (motelQuantity > 0) newRow.MotelUnitOfMeasurement = "Day"; else newRow.MotelUnitOfMeasurement = ""; newRow.MealsCostCad = MealsAllowance.GetMealsAllowance(1, true, "Full Day"); newRow.MotelCostCad = 0; newRow.TotalCostCad = (Convert.ToDecimal(lhQuantity) * decimal.Round(newRow.LHCostCad, 2)) + (mealsQuantity * newRow.MealsCostCad) + (motelQuantity * newRow.MotelCostCad); newRow.MealsCostUsd = MealsAllowance.GetMealsAllowance(2, true, "Full Day"); newRow.MotelCostUsd = 0; newRow.TotalCostUsd = (Convert.ToDecimal(lhQuantity) * decimal.Round(newRow.LHCostUsd, 2)) + (mealsQuantity * newRow.MealsCostUsd) + (motelQuantity * newRow.MotelCostUsd); newRow.Deleted = false; newRow.InDatabase = false; newRow.COMPANY_ID = companyId; newRow.Name = employeeName; newRow.StartDate = newStartDate; newRow.EndDate = newEndDate; newRow.FromDatabase = true; newRow.Function_ = functionListRow.Function_; newRow.WorkFunction = work_ + " . " + functionListRow.Function_; newRow.Month = month; newRow.ClientName = clientName; newRow.ProjectName = projectName; ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).AddLabourHoursInformationRow(newRow); } if (overtime > 0) { refId++; ProjectCostingSheetAddTDS.LabourHoursInformationRow newRowOt = ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).NewLabourHoursInformationRow(); GetEmployeeDataOvertime(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRowOt);// ... Get Costs for Overtime newRowOt.CostingSheetID = projectId; newRowOt.Work_ = work_; newRowOt.EmployeeID = employeeListRow.EmployeeID; newRowOt.RefID = refId; newRowOt.LHQuantity = overtime; newRowOt.MealsQuantity = 0;//This is 0 because this row is only for overtime data mealsQuantity = 0; motelQuantity = 0; newRowOt.MealsUnitOfMeasurement = ""; newRowOt.MotelUnitOfMeasurement = ""; newRowOt.MealsCostCad = MealsAllowance.GetMealsAllowance(1, true, "Full Day"); newRowOt.MotelCostCad = 0; newRowOt.TotalCostCad = (Convert.ToDecimal(overtime) * decimal.Round(newRowOt.LHCostCad, 2)); newRowOt.MealsCostUsd = MealsAllowance.GetMealsAllowance(2, true, "Full Day"); newRowOt.MotelCostUsd = 0; newRowOt.TotalCostUsd = (Convert.ToDecimal(overtime) * decimal.Round(newRowOt.LHCostUsd, 2)); newRowOt.Deleted = false; newRowOt.InDatabase = false; newRowOt.COMPANY_ID = companyId; newRowOt.Name = employeeName + " - Overtime"; newRowOt.StartDate = newStartDate; newRowOt.EndDate = newEndDate; newRowOt.FromDatabase = true; newRowOt.Function_ = functionListRow.Function_; newRowOt.WorkFunction = work_ + " . " + functionListRow.Function_; newRowOt.Month = month; newRowOt.ClientName = clientName; newRowOt.ProjectName = projectName; ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).AddLabourHoursInformationRow(newRowOt); } } newStartDate = newEndDate.AddDays(1); } if (newEndDate <= endDate) { ProjectCostingSheetAddOriginalLabourHourGateway projectCostingSheetAddOriginalLabourHourGateway = new ProjectCostingSheetAddOriginalLabourHourGateway(Data); projectCostingSheetAddOriginalLabourHourGateway.LoadByProjectStartDateEndDateWorkFunctionEmployeeId(projectId, newStartDate, endDate, work_, functionListRow.Function_, employeeListRow.EmployeeID); if (projectCostingSheetAddOriginalLabourHourGateway.Table.Rows.Count > 0) { double lhQuantity = 0; double overtime = 0; decimal mealsQuantity = 0; decimal motelQuantity = 0; string employeeName = ""; refId++; foreach (ProjectCostingSheetAddTDS.OriginalLabourHourRow originalRow in (ProjectCostingSheetAddTDS.OriginalLabourHourDataTable)projectCostingSheetAddOriginalLabourHourGateway.Table) { employeeName = originalRow.EmployeeName; // Meal hours quantity if (!originalRow.IsMealsCountryNull()) { if (originalRow.MealsAllowance > 0) { mealsQuantity++; } } double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID); if (acumPeriod > overtimeByCountry) { overtime = overtime + originalRow.ProjectTime; } else { double newAcumPeriod = acumPeriod + originalRow.ProjectTime; if (newAcumPeriod > overtimeByCountry) { overtime = overtime + (newAcumPeriod - overtimeByCountry); lhQuantity = lhQuantity + (originalRow.ProjectTime - (newAcumPeriod - overtimeByCountry)); } else { lhQuantity = lhQuantity + originalRow.ProjectTime; } } } if (lhQuantity > 0) { ProjectCostingSheetAddTDS.LabourHoursInformationRow newRow = ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).NewLabourHoursInformationRow(); GetEmployeeData(newStartDate, endDate, employeeListRow.EmployeeID, work_, newRow); newRow.CostingSheetID = 0; newRow.Work_ = work_; newRow.EmployeeID = employeeListRow.EmployeeID; newRow.RefID = refId; newRow.LHQuantity = lhQuantity; newRow.MealsQuantity = Convert.ToInt32(mealsQuantity); if (mealsQuantity > 0) newRow.MealsUnitOfMeasurement = "Day"; else newRow.MealsUnitOfMeasurement = ""; if (motelQuantity > 0) newRow.MotelUnitOfMeasurement = "Day"; else newRow.MotelUnitOfMeasurement = ""; newRow.MealsCostCad = MealsAllowance.GetMealsAllowance(1, true, "Full Day"); newRow.MotelCostCad = 0; newRow.TotalCostCad = (Convert.ToDecimal(lhQuantity) * decimal.Round(newRow.LHCostCad, 2)) + (mealsQuantity * newRow.MealsCostCad) + (motelQuantity * newRow.MotelCostCad); newRow.MealsCostUsd = MealsAllowance.GetMealsAllowance(2, true, "Full Day"); newRow.MotelCostUsd = 0; newRow.TotalCostUsd = (Convert.ToDecimal(lhQuantity) * decimal.Round(newRow.LHCostUsd, 2)) + (mealsQuantity * newRow.MealsCostUsd) + (motelQuantity * newRow.MotelCostUsd); newRow.Deleted = false; newRow.InDatabase = false; newRow.COMPANY_ID = companyId; newRow.Name = employeeName; newRow.StartDate = newStartDate; newRow.EndDate = endDate; newRow.FromDatabase = true; newRow.Function_ = functionListRow.Function_; newRow.WorkFunction = work_ + " . " + functionListRow.Function_; newRow.Month = month; newRow.ClientName = clientName; newRow.ProjectName = projectName; ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).AddLabourHoursInformationRow(newRow); } if (overtime > 0) { refId++; ProjectCostingSheetAddTDS.LabourHoursInformationRow newRowOt = ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).NewLabourHoursInformationRow(); GetEmployeeDataOvertime(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRowOt);// ... Get Costs for Overtime newRowOt.CostingSheetID = 0; newRowOt.Work_ = work_; newRowOt.EmployeeID = employeeListRow.EmployeeID; newRowOt.RefID = refId; newRowOt.LHQuantity = overtime; newRowOt.MealsQuantity = 0;//This is 0 because this row is only for overtime data mealsQuantity = 0; motelQuantity = 0; newRowOt.MealsUnitOfMeasurement = ""; newRowOt.MotelUnitOfMeasurement = ""; newRowOt.MealsCostCad = MealsAllowance.GetMealsAllowance(1, true, "Full Day"); newRowOt.MotelCostCad = 0; newRowOt.TotalCostCad = (Convert.ToDecimal(overtime) * decimal.Round(newRowOt.LHCostCad, 2)); newRowOt.MealsCostUsd = MealsAllowance.GetMealsAllowance(2, true, "Full Day"); newRowOt.MotelCostUsd = 0; newRowOt.TotalCostUsd = (Convert.ToDecimal(overtime) * decimal.Round(newRowOt.LHCostUsd, 2)); newRowOt.Deleted = false; newRowOt.InDatabase = false; newRowOt.COMPANY_ID = companyId; newRowOt.Name = employeeName + " - Overtime"; newRowOt.StartDate = newStartDate; newRowOt.EndDate = endDate; newRowOt.FromDatabase = true; newRowOt.Function_ = functionListRow.Function_; newRowOt.WorkFunction = work_ + " . " + functionListRow.Function_; newRowOt.Month = month; newRowOt.ClientName = clientName; newRowOt.ProjectName = projectName; ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).AddLabourHoursInformationRow(newRowOt); } } } } else { ProjectCostingSheetAddOriginalLabourHourGateway projectCostingSheetAddOriginalLabourHourGateway = new ProjectCostingSheetAddOriginalLabourHourGateway(Data); projectCostingSheetAddOriginalLabourHourGateway.LoadByProjectStartDateEndDateWorkFunctionEmployeeId(projectId, startDate, endDate, work_, functionListRow.Function_, employeeListRow.EmployeeID); if (projectCostingSheetAddOriginalLabourHourGateway.Table.Rows.Count > 0) { double lhQuantity = 0; double overtime = 0; decimal mealsQuantity = 0; decimal motelQuantity = 0; string employeeName = ""; refId++; foreach (ProjectCostingSheetAddTDS.OriginalLabourHourRow originalRow in (ProjectCostingSheetAddTDS.OriginalLabourHourDataTable)projectCostingSheetAddOriginalLabourHourGateway.Table) { employeeName = originalRow.EmployeeName; // Meal hours quantity if (!originalRow.IsMealsCountryNull()) { if (originalRow.MealsAllowance > 0) { mealsQuantity++; } } double acumPeriod = GetTotalHoursByEmployeeIdPeriodId(originalRow.EmployeeID, originalRow.Date_, originalRow.ProjectTimeID); if (acumPeriod > overtimeByCountry) { overtime = overtime + originalRow.ProjectTime; } else { double newAcumPeriod = acumPeriod + originalRow.ProjectTime; if (newAcumPeriod > overtimeByCountry) { overtime = overtime + (newAcumPeriod - overtimeByCountry); lhQuantity = lhQuantity + (originalRow.ProjectTime - (newAcumPeriod - overtimeByCountry)); } else { lhQuantity = lhQuantity + originalRow.ProjectTime; } } } if (lhQuantity > 0) { ProjectCostingSheetAddTDS.LabourHoursInformationRow newRow = ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).NewLabourHoursInformationRow(); GetEmployeeData(startDate, endDate, employeeListRow.EmployeeID, work_, newRow); newRow.CostingSheetID = 0; newRow.Work_ = work_; newRow.EmployeeID = employeeListRow.EmployeeID; newRow.RefID = refId; newRow.LHQuantity = lhQuantity; newRow.MealsQuantity = Convert.ToInt32(mealsQuantity); if (mealsQuantity > 0) newRow.MealsUnitOfMeasurement = "Day"; else newRow.MealsUnitOfMeasurement = ""; if (motelQuantity > 0) newRow.MotelUnitOfMeasurement = "Day"; else newRow.MotelUnitOfMeasurement = ""; newRow.MealsCostCad = MealsAllowance.GetMealsAllowance(1, true, "Full Day"); newRow.MotelCostCad = 0; newRow.TotalCostCad = (Convert.ToDecimal(lhQuantity) * decimal.Round(newRow.LHCostCad, 2)) + (mealsQuantity * newRow.MealsCostCad) + (motelQuantity * newRow.MotelCostCad); newRow.MealsCostUsd = MealsAllowance.GetMealsAllowance(2, true, "Full Day"); newRow.MotelCostUsd = 0; newRow.TotalCostUsd = (Convert.ToDecimal(lhQuantity) * decimal.Round(newRow.LHCostUsd, 2)) + (mealsQuantity * newRow.MealsCostUsd) + (motelQuantity * newRow.MotelCostUsd); newRow.Deleted = false; newRow.InDatabase = false; newRow.COMPANY_ID = companyId; newRow.Name = employeeName; newRow.StartDate = startDate; newRow.EndDate = endDate; newRow.FromDatabase = true; newRow.Function_ = functionListRow.Function_; newRow.WorkFunction = work_ + " . " + functionListRow.Function_; newRow.Month = month; newRow.ClientName = clientName; newRow.ProjectName = projectName; ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).AddLabourHoursInformationRow(newRow); } if (overtime > 0) { refId++; ProjectCostingSheetAddTDS.LabourHoursInformationRow newRowOt = ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).NewLabourHoursInformationRow(); GetEmployeeDataOvertime(newStartDate, newEndDate, employeeListRow.EmployeeID, work_, newRowOt);// ... Get Costs for Overtime newRowOt.CostingSheetID = 0; newRowOt.Work_ = work_; newRowOt.EmployeeID = employeeListRow.EmployeeID; newRowOt.RefID = refId; newRowOt.LHQuantity = overtime; newRowOt.MealsQuantity = 0;//This is 0 because this row is only for overtime data mealsQuantity = 0; motelQuantity = 0; newRowOt.MealsUnitOfMeasurement = ""; newRowOt.MotelUnitOfMeasurement = ""; newRowOt.MealsCostCad = MealsAllowance.GetMealsAllowance(1, true, "Full Day"); newRowOt.MotelCostCad = 0; newRowOt.TotalCostCad = (Convert.ToDecimal(overtime) * decimal.Round(newRowOt.LHCostCad, 2)); newRowOt.MealsCostUsd = MealsAllowance.GetMealsAllowance(2, true, "Full Day"); newRowOt.MotelCostUsd = 0; newRowOt.TotalCostUsd = (Convert.ToDecimal(overtime) * decimal.Round(newRowOt.LHCostUsd, 2)); newRowOt.Deleted = false; newRowOt.InDatabase = false; newRowOt.COMPANY_ID = companyId; newRowOt.Name = employeeName + " - Overtime"; newRowOt.StartDate = startDate; newRowOt.EndDate = endDate; newRowOt.FromDatabase = true; newRowOt.Function_ = functionListRow.Function_; newRowOt.WorkFunction = work_ + " . " + functionListRow.Function_; newRowOt.Month = month; newRowOt.ClientName = clientName; newRowOt.ProjectName = projectName; ((ProjectCostingSheetAddTDS.LabourHoursInformationDataTable)Table).AddLabourHoursInformationRow(newRowOt); } } } } } } }
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, ""); } } }
private void UpdateState() { ProjectGateway projectGateway = new ProjectGateway(projectTDS); int projectId = int.Parse(hdfProjectId.Value); projectGateway.LoadByProjectId(projectId); 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 = projectGateway.GetProjectLeadID(projectId); int salesmanId = projectGateway.GetSalesmanID(projectId); string projectType = projectGateway.GetProjectType(projectId); string projectState = null; switch ((string)Request.QueryString["state"]) { //Proposal case "proposal_award": projectState = "Awarded"; break; case "proposal_lost_bid": projectState = "Lost Bid"; break; case "proposal_cancel": projectState = "Canceled"; break; case "proposal_bidding": projectState = "Bidding"; break; case "proposal_unpromote_to_ballpark": projectState = "Active"; projectType = "Ballpark"; break; case "proposal_promote_to_project": projectState = "Active"; projectType = "Project"; break; //Project case "project_waiting": projectState = "Waiting"; break; case "project_activate": projectState = "Active"; break; case "project_inactivate": projectState = "Inactive"; break; case "project_complete": projectState = "Complete"; break; case "project_cancel": projectState = "Canceled"; break; case "project_unpromote_to_ballpark": projectState = "Active"; projectType = "Ballpark"; break; case "project_unpromote_to_proposal": projectState = "Awarded"; projectType = "Proposal"; break; case "project_tagAsInternal": projectState = "Active"; projectType = "Internal"; break; //Internal Project case "internalProject_activate": projectState = "Active"; break; case "internalProject_complete": projectState = "Complete"; break; case "internalProject_cancel": projectState = "Canceled"; break; case "internalProject_promote_to_proposal": projectState = "Awarded"; projectType = "Proposal"; break; case "internalProject_promote_to_project": projectState = "Active"; projectType = "Project"; break; //Ballpark case "ballparkProject_activate": projectState = "Active"; break; case "ballparkProject_cancel": projectState = "Canceled"; break; case "ballparkProject_promote_to_proposal": projectState = "Bidding"; projectType = "Proposal"; break; case "ballparkProject_promote_to_project": projectState = "Active"; projectType = "Project"; break; } string name = projectGateway.GetName(projectId); string description = projectGateway.GetDescription(projectId); DateTime? proposalDate = projectGateway.GetProposalDate(projectId); DateTime? startDate = projectGateway.GetStartDate(projectId); DateTime? endDate = projectGateway.GetEndDate(projectId); int clientId = projectGateway.GetClientID(projectId); string clientProjectNumber = projectGateway.GetClientProjectNumber(projectId); int? clientPrimaryContactId = projectGateway.GetClientPrimaryContactID(projectId); int? clientSecondaryContactId = projectGateway.GetClientSecondaryContactID(projectId); bool deleted = projectGateway.GetDeleted(projectId); int? libraryCategoriesId = projectGateway.GetLibraryCategoriesId(projectId); bool fairWageApplies = projectGateway.GetFairWageApplies(projectId); // Update project Project project = new Project(projectTDS); string projectNumber = project.UpdateProjectNumber(projectId, salesmanId); 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); //Insert in history ProjectHistory projectHistory = new ProjectHistory(projectTDS); int newRefId = projectHistory.GetNewRefId(); projectHistory.Insert(projectId, newRefId, projectState, DateTime.Now, Convert.ToInt32(Session["loginID"]), Int32.Parse(hdfCompanyId.Value.Trim())); }