/// <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); }
/// <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; }