/// <summary> /// Generate Project Number for new Project /// </summary> /// <param name="countryId">CountryId</param> /// <param name="officeId">OfficeId</param> /// <param name="salesmanId">SalesmanId - EmployeeId</param> /// <param name="date">Date to generate</param> /// <param name="companyId">companyId</param> /// <returns>Project Number generated</returns> public string GenerateProjectNumber(Int64 countryId, int officeId, int salesmanId, DateTime date, int companyId) { CountryGateway countryGateway = new CountryGateway(new DataSet()); countryGateway.LoadByCountryId(countryId); string pnCountryId = countryGateway.GetIdForProjects(countryId); OfficeGateway officeGateway = new OfficeGateway(new DataSet()); officeGateway.LoadByOfficeId(officeId); string pnOfficeId = officeGateway.GetIdForProjects(officeId); SalesmanGateway salesmanGateway = new SalesmanGateway(new DataSet()); salesmanGateway.LoadBySalesmanId(salesmanId); string pnSalesmanId = salesmanGateway.GetIdForProjects(salesmanId); ProjectNumberGateway projectNumberGateway = new ProjectNumberGateway(Data); projectNumberGateway.Load(); ProjectNumber projectNumber = new ProjectNumber(Data); string pnYearCode = projectNumber.GetYearCode(date.Year); string pnProjectIncrement = projectNumber.GetProjectIncrement(date.Year, companyId); string newProjectNumber = pnCountryId + pnOfficeId + pnSalesmanId + pnYearCode + pnProjectIncrement; return newProjectNumber; }
/// <summary> /// Update Project Number for existing Project /// </summary> /// <param name="projectId">ProjectId</param> /// <param name="salesmasId">SalesmanId - EmployeeId</param> /// <returns>Project Number updated</returns> public string UpdateProjectNumber(int projectId, int salesmasId) { ProjectTDS.LFS_PROJECTRow projectRow = GetRow(projectId); // Get id for projects's salesman SalesmanGateway salesmanGateway = new SalesmanGateway(); salesmanGateway.LoadBySalesmanId(salesmasId); string idForProjects = salesmanGateway.GetIdForProjects(salesmasId); // Update project number return projectRow.ProjectNumber.Substring(0, 4) + idForProjects + projectRow.ProjectNumber.Substring(6, 5); }
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(); }
/// <summary> /// GetProjectNumber /// </summary> /// <param name="row">row</param> /// <param name="companyId">companyId</param> /// <returns></returns> private string GetProjectNumber(DataMigrationTDS.DataMigrationProjectRow row, int companyId) { DateTime date = DateTime.Now; CountryGateway countryGateway = new CountryGateway(new DataSet()); countryGateway.LoadByCountryId(row.CountryID); string pnCountryId = countryGateway.GetIdForProjects(row.CountryID); OfficeGateway officeGateway = new OfficeGateway(new DataSet()); officeGateway.LoadByOfficeId(row.OfficeID); string pnOfficeId = officeGateway.GetIdForProjects(row.OfficeID); SalesmanGateway salesmanGateway = new SalesmanGateway(new DataSet()); salesmanGateway.LoadBySalesmanId(row.SalesmanID); string pnSalesmanId = salesmanGateway.GetIdForProjects(row.SalesmanID); ProjectNumberGateway projectNumberGateway = new ProjectNumberGateway(); projectNumberGateway.Load(); ProjectNumber projectNumber = new ProjectNumber(projectNumberGateway.Data); string pnYearCode = projectNumber.GetYearCode(date.Year); string pnProjectIncrement = projectNumber.GetProjectIncrement(date.Year, companyId); string newProjectNumber = pnCountryId + pnOfficeId + pnSalesmanId + pnYearCode + pnProjectIncrement; return newProjectNumber; }
/// <summary> /// Update a new enployee (direct to DB) /// </summary> /// <param name="salesmanId">salesmanId</param> /// <param name="originalIdForProjects">originalIdForProjects</param> /// <param name="newIdForProjects">newIdForProjects</param> public void UpdateDirect(int salesmanId, string originalIdForProjects, string newIdForProjects) { SalesmanGateway salesmanGateway = new SalesmanGateway(null); salesmanGateway.Update(salesmanId, originalIdForProjects, newIdForProjects); }
// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // /// <summary> /// Insert a new enployee (direct to DB) /// </summary> /// <param name="salesmanId">salesmanId</param> /// <param name="idForProjects">idForProjects</param> public void InsertDirect(int salesmanId, string idForProjects) { SalesmanGateway salesmanGateway = new SalesmanGateway(null); salesmanGateway.Insert(salesmanId, idForProjects); }
// ///////////////////////////////////////////////////////////////////////////////////////////////////// // // STEP4 - FINISH // // //////////////////////////////////////////////////////////////////////// // STEP4 - FINISH - AUXILIAR EVENTS // protected void cvSalesmanIdForProjects_ServerValidate(object source, ServerValidateEventArgs args) { int employeeId = Int32.Parse(Request.QueryString["employee_id"]); SalesmanGateway salesmanGateway = new SalesmanGateway(new DataSet()); args.IsValid = !(salesmanGateway.IsIdForProjectInUse(args.Value, employeeId)); }