Пример #1
0
        /// <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>
        /// 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;
        }