예제 #1
0
 public WorkorderGeneration(int jobID)
 {
     WoID   = 0;
     _jobID = jobID;
     _cp    = new ProjectCompany(_jobID);
     _p     = new ProjectDetails(_jobID);
 }
예제 #2
0
        void BtnAddToProjectClick(object sender, EventArgs e)
        {
            //加入到项目相关单位
            ProjectCompanies newPc = new ProjectCompanies();
            ProjectCompany   tPc   = new ProjectCompany();

            if (comboBox1.SelectedValue != null && comboBox1.SelectedValue.GetType() != typeof(DataRowView))
            {
                tPc.ProjectID = Convert.ToInt32(comboBox1.SelectedValue);
            }
            else
            {
                return;
            }
            if (dataGridViewCompanies.CurrentRow != null)
            {
                tPc.CompanyID     = Convert.ToInt32(dataGridViewCompanies.CurrentRow.Cells["CompanyID"].Value);
                newPc.CompanyType = Convert.ToInt32(dataGridViewCompanies.CurrentRow.Cells["CompanyType"].Value);
            }
            newPc.Ps = tPc;

            BLL.CompanyBLL.AddProjectCompany(newPc);

            //刷新项目供应商
            RefreshProjectCompnies(newPc.Ps.ProjectID);
        }
예제 #3
0
        /// <summary>
        /// Create a new project
        /// </summary>
        /// <param name="userEmployeeID">it is employeenumber in FW_Employees</param>
        private int CreateNewProject(int userEmployeeID)
        {
            int newJobID = 0;

            try
            {
                var job = new ProjectInsert(userEmployeeID);
                if (job.ValidationErrorID == 0)
                {
                    job.Insert();
                    newJobID = job.JobID;

                    var cp = new ProjectCompany(newJobID);
                    cp.Insert(newJobID, 0, true, true, true);

                    var est = new MyEstRevCreate();
                    est.Create(newJobID);
                    LogMethods.Log.Debug("CreateNewProject:Debug:" + "Done");
                }
                else
                {
                    LogMethods.Log.Error("CreateNewProject:Error:" + job.ValidationErrorID);
                }
            }
            catch (Exception e)
            {
                LogMethods.Log.Error("CreateNewProject:Error:" + e.Message);
            }

            return(newJobID);
        }
예제 #4
0
        public async Task <byte[]> GetDocumentData(ProjectCompany ownerCompany, IList <ProjectCompanyFactShare> factShares, Signatory signature, string templatePath, IList <ProjectCompanyShare> shares)
        {
            pageNumber             = 1;
            this.ownerCompany      = ownerCompany;
            this.factShares        = factShares;
            this.shares            = shares;
            sheets                 = new List <SheetBase>();
            companyNumberContainer = new CompanyNumberContainer();
            allCompanies           = (await projectCompanyService.GetAllByProjectId(ownerCompany.ProjectId)).ToDictionary(x => x.Id);


            //currentCompany = await projectCompanyService.GetById(ownerCompany.Id);

            byte[] result;
            using (var package = new ExcelPackage(new FileInfo(templatePath)))
            {
                CreateSheets(package.Workbook, signature);
                foreach (var sheet in sheets)
                {
                    sheet.InitRanges();
                    sheet.WriteValues();
                }
                result = package.GetAsByteArray();
            }
            return(await Task.Run(() => result));
        }
예제 #5
0
 protected KikSheetBase(ExcelWorksheet sheet, ProjectCompany company, Signatory signatore, int pageNumber)
 {
     Sheet      = sheet;
     Company    = company;
     Signatore  = signatore;
     PageNumber = pageNumber;
 }
 private void ProcessPage2(int currentSheetNum, XLWorkbook wb, ProjectCompany company)
 {
     WriteStringInTripledCells(9, 16, company.IndividualCompany.Surname, wb, currentSheetNum);
     WriteStringInTripledCells(11, 16, company.IndividualCompany.Name, wb, currentSheetNum);
     WriteStringInTripledCells(13, 16, company.IndividualCompany.MiddleName, wb, currentSheetNum);
     WriteStringInTripledCells(13, 16, company.IndividualCompany.MiddleName, wb, currentSheetNum);
     WriteStringInTripledCells(15, 16, company.IndividualCompany.GenderCodeId.ToString(), wb, currentSheetNum);
     WriteStringInTripledCells(15, 70, company.IndividualCompany.BirthDate.Date.ToString("dd"), wb, currentSheetNum);
     WriteStringInTripledCells(15, 79, company.IndividualCompany.BirthDate.Month.ToString("D2"), wb, currentSheetNum);
     WriteStringInTripledCells(15, 88, company.IndividualCompany.BirthDate.Year.ToString("D4"), wb, currentSheetNum);
     WriteStringInTripledCells(19, 1, company.IndividualCompany.BirthPlace, wb, currentSheetNum);
     WriteStringInTripledCells(24, 16, company.IndividualCompany.GenderCodeId.ToString(), wb, currentSheetNum);
     WriteStringInTripledCells(26, 115, company.IndividualCompany.ConfirmedPersonalityDocInfoId.ToString() ?? "1", wb, currentSheetNum);
     WriteStringInTripledCells(28, 13, company.IndividualCompany.ConfirmedPersonalityDocInfo.SeriesAndNumber, wb, currentSheetNum);
     WriteStringInTripledCells(28, 91, company.IndividualCompany.ConfirmedPersonalityDocInfo.IssueDate.Date.ToString("dd"), wb, currentSheetNum);
     WriteStringInTripledCells(28, 100, company.IndividualCompany.ConfirmedPersonalityDocInfo.IssueDate.Month.ToString("D2"), wb, currentSheetNum);
     WriteStringInTripledCells(28, 109, company.IndividualCompany.ConfirmedPersonalityDocInfo.IssueDate.Year.ToString("D4"), wb, currentSheetNum);
     WriteStringInTripledCells(30, 16, company.IndividualCompany.ConfirmedPersonalityDocInfo.IssuePlace, wb, currentSheetNum);
     WriteStringInTripledCells(35, 13, company.IndividualCompany.VerifedPersonalityDocInfo.SeriesAndNumber, wb, currentSheetNum);
     WriteStringInTripledCells(35, 91, company.IndividualCompany.VerifedPersonalityDocInfo.IssueDate.Date.ToString("dd"), wb, currentSheetNum);
     WriteStringInTripledCells(35, 100, company.IndividualCompany.VerifedPersonalityDocInfo.IssueDate.Month.ToString("D2"), wb, currentSheetNum);
     WriteStringInTripledCells(35, 109, company.IndividualCompany.VerifedPersonalityDocInfo.IssueDate.Year.ToString("D4"), wb, currentSheetNum);
     WriteStringInTripledCells(37, 16, company.IndividualCompany.VerifedPersonalityDocInfo.IssuePlace, wb, currentSheetNum);
     WriteStringInTripledCells(39, 91, company.IndividualCompany.ConfirmedPersonalityDocInfoId.ToString(), wb, currentSheetNum);
     WriteStringInTripledCells(41, 22, company.IndividualCompany.PostIndex, wb, currentSheetNum);
     WriteStringInTripledCells(43, 22, company.IndividualCompany.District, wb, currentSheetNum);
     WriteStringInTripledCells(45, 22, company.IndividualCompany.City, wb, currentSheetNum);
     WriteStringInTripledCells(47, 22, company.IndividualCompany.CityType, wb, currentSheetNum);
     WriteStringInTripledCells(49, 22, company.IndividualCompany.District, wb, currentSheetNum);
     WriteStringInTripledCells(51, 16, company.IndividualCompany.HouseNumber, wb, currentSheetNum);
     WriteStringInTripledCells(51, 59, company.IndividualCompany.BuildingNumber, wb, currentSheetNum);
     WriteStringInTripledCells(51, 97, company.IndividualCompany.AppartamentNumber, wb, currentSheetNum);
     WriteStringInTripledCells(54, 112, "1", wb, currentSheetNum);
     WriteStringInTripledCells(56, 1, company.IndividualCompany.ForeignAddress ?? "", wb, currentSheetNum);
 }
 public void UpdateProjectToCompany(ProjectCompany projectCompany, DateProjectCompany dateProjectCompany)
 {
     using (var ctx = new SystemCompanyEntities())
     {
         var PC =
             ctx.ProjectCompanies.First(
                 pC => pC.idProject == projectCompany.idProject && pC.idCompany == projectCompany.idCompany);
         PC.idProject = projectCompany.idProject;
         PC.idCompany = projectCompany.idCompany;
         PC.priceType = projectCompany.priceType;
         PC.paid = projectCompany.paid;
         PC.destination = projectCompany.destination;
         PC.discriptions = projectCompany.discriptions;
         ctx.SaveChanges();
         var DPC =
             ctx.DateProjectCompany.First(
                 dpC =>
                 dpC.idProject == dateProjectCompany.idProject && dpC.idCompany == dateProjectCompany.idCompany);
         DPC.idCompany = dateProjectCompany.idCompany;
         DPC.idProject = dateProjectCompany.idProject;
         DPC.DateStartProject = dateProjectCompany.DateStartProject;
         DPC.DateFinishProject = dateProjectCompany.DateFinishProject;
         ctx.SaveChanges();
     }
 }
        public XLWorkbook GetFilledKikDoc(string path, ProjectCompany company)
        {
            var kikWorkDoc = new XLWorkbook(path);

            WriteStringInTripledCells(18, 1, company.Name, kikWorkDoc, 1);
            return(kikWorkDoc);
        }
 private void CheckDependent(ProjectCompany dependent)
 {
     if (dependent.State == State.Individual)
     {
         throw new ArgumentException($"Dependent Project Company can not be Individual. Dependent Id = {dependent.Id}");
     }
 }
예제 #10
0
        public NPReportCompany(ProjectCompanyFactShare factShare, CompanyNumberContainer numbers)
        {
            ProjectCompany = factShare.DependentProjectCompany;
            OwnerCompany   = factShare.OwnerProjectCompany;
            this.factShare = factShare;

            switch (ProjectCompany.State)
            {
            case State.Domestic:
                Number = ++numbers.DomesticCompanyNumber;
                break;

            case State.ForeignLight:
                Number = ++numbers.ForeignLightCompanyNumber;
                break;

            case State.Foreign:
                Number = ++numbers.ForeignCompanyNumber;
                break;

            case State.Individual:
            default:
                throw new ArgumentException($"Expected Project Company State Domestic, Foreign, ForeignLight. Got {ProjectCompany.State}");
            }
        }
        public XLWorkbook GetFilledNotificationOfParticipation(string path, ProjectCompany company)
        {
            var notificationDoc = new XLWorkbook(path);

            //var dependedForeginCompaies = company.OwnerProjectCompanyShares.Where(x => x.DependentProjectCompany.State == State.Foreign);
            //var dependedFactForeginCompaies = company.OwnerProjectCompanyFactShares.Where(x => x.DependentProjectCompany.State == State.Foreign);

            //var dependedDomesticCompaies = company.OwnerProjectCompanyShares.Where(x => x.DependentProjectCompany.State == State.Domestic);
            //var dependedDomesticCompaiesCount = dependedDomesticCompaies.Count();
            //var dependedFactDomesticCompaies = company.OwnerProjectCompanyFactShares.Where(x => x.DependentProjectCompany.State == State.Domestic);

            //var dependedForeginLightCompaies = company.OwnerProjectCompanyShares.Where(x => x.DependentProjectCompany.State == State.ForeignLight);
            //var dependedForeginLightCompaiesCount = dependedForeginLightCompaies.Count();
            //var dependedFactForeginLightCompaies = company.OwnerProjectCompanyFactShares.Where(x => x.DependentProjectCompany.State == State.ForeignLight);

            CompanyId  = company.Id;
            SheetCount = 1;

            ProcessPage1(SheetCount, notificationDoc, company);
            SheetCount++;
            if (company.State == State.Individual)
            {
                ProcessPage2(SheetCount, notificationDoc, company);
            }
            SheetCount++;

            int fCompanyNumber = 1;

            //foreach (var share in dependedForeginCompaies)
            //{
            //    var factShare = new ProjectCompanyFactShare();
            //    //if (dependedFactForeginCompaies.Count()>0 )
            //    //{
            //    //    factShare = dependedFactForeginCompaies.Where(f => f.DependentProjectCompanyId == share.DependentProjectCompanyId).FirstOrDefault();
            //    //}

            //    ProcessListA(SheetCount, fCompanyNumber, notificationDoc, share, factShare);

            //    notificationDoc.Worksheet(SheetCount).CopyTo(NamedRusSheet + (SheetCount + 1), SheetCount + 1);
            //    SheetCount++;
            //    fCompanyNumber++;
            //}
            //SheetCount += dependedForeginCompaiesCount;

            //FillNpForeginLight(notificationDoc, dependedForeginLightCompaies, SheetCount);
            //SheetCount += dependedForeginLightCompaiesCount;

            //FillNpPersonalCompanyDetailShare(notificationDoc, dependedPersonalCompaies, dependedFactPersonalCompaies, SheetCount);
            //SheetCount += dependedPersonalCompaiesCount;

            //FillNpForeginCompanyDetailShare(notificationDoc, dependedForeginCompaies, dependedFactForeginCompaies, SheetCount);
            //SheetCount += dependedForeginCompaiesCount;

            //FillNpForeginLightDetailShare(notificationDoc, dependedForeginLightCompaies, dependedFactForeginLightCompaies, SheetCount);
            //SheetCount += dependedForeginLightCompaiesCount;
            ////Fill PageCountOnFirstPage
            //RemoveLastSheet(notificationDoc);
            return(notificationDoc);
        }
예제 #12
0
 public KikSheet1(ExcelWorksheet sheet, ProjectCompany company, Signatory signatore, int pageNumber, int year, int totalPagesCount, int correction,
                  int taxAuthorityCode) : base(sheet, company, 1)
 {
     this.year             = year;
     this.totalPagesCount  = totalPagesCount;
     this.correction       = correction;
     this.taxAuthorityCode = taxAuthorityCode;;
 }
예제 #13
0
        public QuoteTitleGenerate(int jobID, int estRevID)
        {
            _jobID    = jobID;
            _estRevID = estRevID;
            var cp = new ProjectCompany(jobID);

            _cID = cp.QuoteToCompanyID;
        }
 public void InsertProjectToCompany(ProjectCompany projectCompany, DateProjectCompany dateProjectCompany)
 {
     using (var ctx = new SystemCompanyEntities())
     {
         ctx.AddToProjectCompanies(projectCompany);
         ctx.SaveChanges();
         ctx.AddToDateProjectCompany(dateProjectCompany);
         ctx.SaveChanges();
     }
 }
예제 #15
0
        private int GetValidationErrorID()
        {
            //Quote To
            var cp = new ProjectCompany(_jobID);

            if (!cp.isThereABilltoCompany)
            {
                return((int)NValidationErrorValue.BillTo);
            }
            return(0);
        }
예제 #16
0
        private IEnumerable <ProjectCompanyShare> GetCompanyOwnShares(ProjectCompany company)
        {
            var shares    = new List <ProjectCompanyShare>();
            var ownShares = company.OwnerProjectCompanyShares ?? new List <ProjectCompanyShare>();

            shares.AddRange(ownShares);
            foreach (var share in ownShares)
            {
                shares.AddRange(GetCompanyOwnShares(share.DependentProjectCompany));
            }
            return(shares);
        }
 public void DeleteProjectToCompany(ProjectCompany projectCompany)
 {
     using (var ctx = new SystemCompanyEntities())
     {
         var PC =
             ctx.ProjectCompanies.First(
                 pC => pC.idProject == projectCompany.idProject && pC.idCompany == projectCompany.idCompany);
         ctx.ProjectCompanies.DeleteObject(PC);
         ctx.SaveChanges();
         var DPC =
             ctx.DateProjectCompany.First(
                 pC => pC.idProject == projectCompany.idProject && pC.idCompany == projectCompany.idCompany);
         ctx.DateProjectCompany.DeleteObject(DPC);
         ctx.SaveChanges();
     }
 }
 public IEnumerable<ProjectCompany> ViewingOldDestination(ProjectCompany projectCompany)
 {
     using (var ctx = new SystemCompanyEntities())
     {
         var query = ctx.ProjectCompanies.Where(item => item.idCompany == projectCompany.idCompany && item.idProject == projectCompany.idProject).Select(item => new { Destination = item.destination }).ToList();
         var list = new List<ProjectCompany>();
         foreach (var result in query)
         {
             list.Add(new ProjectCompany
             {
                 destination = result.Destination
             });
         }
         return list;
     }
     
 }
예제 #19
0
        private ProjectCompanyShare GetShare(ProjectCompany owner, ProjectCompany dependent, double sharePart, bool isFounder, bool isControlledBy)
        {
            var share = new ProjectCompanyShare {
                OwnerProjectCompany = owner, DependentProjectCompany = dependent, SharePart = sharePart, CompanyStatus = "Status", ShareType = ShareType.Direct, ControlGrounds = "фактический контроль"
            };

            if (isFounder)
            {
                share.IsFounder      = isFounder;
                share.ControlGrounds = "учредитель";
            }
            if (isControlledBy)
            {
                share.IsControlledBy = isControlledBy;
            }

            return(share);
        }
        private void ProcessPage1(int currentSheetNum, XLWorkbook wb, ProjectCompany company)
        {
            var fullCompanyName  = "";
            var taxpayerCode     = 0;
            var reasonCode       = 0;
            int correctionNumber = 0;

            switch (company.State)
            {
            case State.Domestic:
                taxpayerCode    = 1;
                fullCompanyName = company.DomesticCompany.FullName;
                break;

            case State.Individual:
                taxpayerCode    = 2;
                fullCompanyName = company.IndividualCompany.Surname + " " + company.IndividualCompany.Name + " " +
                                  company.IndividualCompany.MiddleName;
                break;

            case State.Foreign:
                taxpayerCode    = 3;
                fullCompanyName = company.ForeignCompany.FullName;
                break;
            }

            WriteStringInTripledCells(1, 37, company.DomesticCompany.INN.ToString(), wb, currentSheetNum);
            WriteStringInTripledCells(4, 37, company.DomesticCompany.KPP, wb, currentSheetNum);
            WriteStringInTripledCells(4, 70, currentSheetNum.ToString("D3"), wb, currentSheetNum);
            WriteStringInTripledCells(12, 24, correctionNumber.ToString("D3"), wb, currentSheetNum);
            WriteStringInTripledCells(14, 28, taxpayerCode.ToString("D1"), wb, currentSheetNum);
            WriteStringInTripledCells(14, 76, reasonCode.ToString("D1"), wb, currentSheetNum);
            WriteStringInTripledCells(18, 1, fullCompanyName, wb, currentSheetNum);
            WriteStringInTripledCells(28, 10, company.DomesticCompany.OGRN.ToString(), wb, currentSheetNum);

            WriteMultipleStringInTripledCells(37, 1, fullCompanyName, wb, currentSheetNum);
            WriteStringInTripledCells(47, 10, company.DomesticCompany.INN.ToString(), wb, currentSheetNum);
        }
        public KikReportCompany(ProjectCompany ownerCompany, ProjectCompany projectCompany, CompanyNumberContainer numbers)
        {
            ProjectCompany = projectCompany;
            OwnerCompany   = ownerCompany;
            switch (ProjectCompany.State)
            {
            case State.Domestic:
                Number = ++numbers.DomesticCompanyNumber;
                break;

            case State.ForeignLight:
                Number = ++numbers.ForeignLightCompanyNumber;
                break;

            case State.Foreign:
                Number = ++numbers.ForeignCompanyNumber;
                break;

            case State.Individual:
            default:
                throw new ArgumentException($"Expected Project Company State Domestic, Foreign, ForeignLight. Got {ProjectCompany.State}");
            }
        }
예제 #22
0
        public void CreateProject()
        {
            var insertBidding = new ProjectInsertBidding(_salesID);

            insertBidding.JobTitle   = _biddingJob.TempProjectName;
            insertBidding.TargetDate = Convert.ToDateTime(_biddingJob.TempTargetDate);
            insertBidding.CustomerID = _biddingJob.BillToID;
            insertBidding.Insert();

            //For the purpose of databind, to highlight it
            NewJobID = insertBidding.JobID;

            UpdateProjectID();

            //Inser a related customer form
            var cp = new ProjectCompany(NewJobID);

            cp.Insert(NewJobID, _biddingJob.BillToID, true, true, true);

            var est = new SpecDomain.BLL.EstTitle.MyEstRevCreate();

            est.Create(NewJobID);
        }
예제 #23
0
        private int GetValidationErrorID()
        {
            var cp = new ProjectCompany(_jobID);

            //Install to Company
            if (!cp.isThereAInstallOrShipToCompany)
            {
                return(10);
            }

            //Bill to company if not subproject
            var p = new ProjectDetails(_jobID);

            if (!(p.IsSubProject | cp.isThereABilltoCompany))
            {
                return(11);
            }

            if (ChildrenCount == 0)
            {
                return(2);
            }
            return(0);
        }
예제 #24
0
        private int GetValidationErrorID()
        {
            //Quote To
            var est = new MyEstRev(_estRevID);
            var cp  = new ProjectCompany(_jobID);

            if (!cp.isThereAQuotetoCompany)
            {
                return((int)NValidationErrorValue.QuoteTo);
            }
            if (cp.QuoteToContactID < 1000)
            {
                return((int)NValidationErrorValue.QouteToContact);
            }
            if (!est.IsThisEstimationHaveChildren())
            {
                return((int)NValidationErrorValue.AtLeastOneItem);
            }
            if (!est.IsThisEstimationHasBenSubmited())
            {
                return(1102);                                       //Should be locked or have a reason
            }
            return(0);
        }
 public XLWorkbook GetFilledNotificationOfParticipation(string path, ProjectCompany company, List <ProjectCompanyShare> shares, List <ProjectCompanyFactShare> factShares)
 {
     return(GetFilledNotificationOfParticipation(path, company));
 }
 public ReportCompanyService(ProjectCompany ownerCompany, IList <ProjectCompanyShare> shares, IEnumerable <ProjectCompanyFactShare> factShares)
 {
     this.ownerCompany = ownerCompany;
     this.shares       = shares;
     this.factShares   = factShares;
 }
예제 #27
0
 public KikSheetBase(ExcelWorksheet sheet, ProjectCompany company, int pageNumber)
 {
     Sheet           = sheet;
     Company         = company;
     this.pageNumber = pageNumber;
 }
예제 #28
0
 protected NPSheetBase(ExcelWorksheet sheet, ProjectCompany ownerCompany, int pageNumber)
 {
     Sheet        = sheet;
     OwnerCompany = ownerCompany;
     PageNumber   = pageNumber;
 }
예제 #29
0
 public KikSheet1(ExcelWorksheet sheet, ProjectCompany ownerCompany, int year, int totalPagesCount) : base(sheet, ownerCompany, 1)
 {
     this.year            = year;
     this.totalPagesCount = totalPagesCount;
 }
예제 #30
0
        /**
         * Type = 1 => Billing
         * Type = 2 => Quoting
         * Type = 3 => Shipping
         */
        private void HandleAccount(string companyName, string companyStreet, string companyProvince, string companyPostalCode,
                                   string companyCity, string companyCountry, string firstName, string lastName, string phone, string contactID, string intersection, string corner, int misJobID, int employeeNumber, string accountID, int type, string legalName)
        {
            try
            {
                int customerID = CommonMethods.GetMISID(TableName.Customer, accountID, salesForceProjectID);
                if (customerID == 0)
                {
                    /* Add new billing address */
                    CUSTOMER customer = new CUSTOMER();
                    customer.NAME = companyName;
                    //customer.LEGALNAME_SAMEAS_NAME = true;

                    if (legalName == null)
                    {
                        customer.LEGALNAME_SAMEAS_NAME = true;
                        customer.LEGAL_NAME            = companyName;
                    }
                    else
                    {
                        customer.LEGALNAME_SAMEAS_NAME = false;
                        customer.LEGAL_NAME            = legalName;//companyName;
                    }
                    customer.ADDR_1       = companyStreet;
                    customer.ADDR_2       = "";
                    customer.CITY         = companyCity;
                    customer.STATE        = companyProvince;
                    customer.ZIPCODE      = companyPostalCode;
                    customer.COUNTRY      = companyCountry;
                    customer.SalesID      = employeeNumber;
                    customer.Sa1ID        = employeeNumber;
                    customer.TERRITORY    = "6"; //other
                    customer.ACTIVE_FLAG  = "Y";
                    customer.CURRENCY_ID  = "CAD";
                    customer.Intersection = intersection;
                    switch (corner)
                    {
                    case "North West":
                        customer.NorthWest = true;
                        break;

                    case "North East":
                        customer.NorthEast = true;
                        break;

                    case "South West":
                        customer.SouthWest = true;
                        break;

                    case "South East":
                        customer.SouthEast = true;
                        break;
                    }

                    ProjectCompany cp = new ProjectCompany(misJobID);
                    cp.Insert(misJobID, 0, false, false, false);
                    int jcID = SqlCommon.GetNewlyInsertedRecordID(TableName.Sales_JobMasterList_Customer);

                    /* check if the customer has existed */
                    int rowID = CommonMethods.GetCompanyMISID(TableName.Customer, accountID);
                    if (rowID == 0)
                    {
                        //if it is not existent
                        rowID = CreateCustomer(customer, jcID);
                    }

                    if (rowID > 0)
                    {
                        CommonMethods.InsertToMISSalesForceMapping(TableName.Customer, accountID, rowID.ToString(), salesForceProjectID);
                    }
                    HandleAccountContact(misJobID, jcID, contactID, rowID, firstName, lastName, phone, accountID, type);
                }
                else
                {
                    CUSTOMER customer = _db.CUSTOMERs.FirstOrDefault(x => x.ROWID == customerID);
                    customer.NAME = companyName;
                    //customer.LEGALNAME_SAMEAS_NAME = true;
                    if (legalName == null)
                    {
                        customer.LEGALNAME_SAMEAS_NAME = true;
                        customer.LEGAL_NAME            = companyName;
                    }
                    else
                    {
                        customer.LEGALNAME_SAMEAS_NAME = false;
                        customer.LEGAL_NAME            = legalName;//companyName;
                    }

                    customer.ADDR_1      = companyStreet;
                    customer.ADDR_2      = "";
                    customer.CITY        = companyCity;
                    customer.STATE       = companyProvince;
                    customer.ZIPCODE     = companyPostalCode;
                    customer.COUNTRY     = companyCountry;
                    customer.SalesID     = employeeNumber;
                    customer.Sa1ID       = employeeNumber;
                    customer.TERRITORY   = "6"; //other
                    customer.ACTIVE_FLAG = "Y";
                    customer.CURRENCY_ID = "CAD";

                    customer.Intersection = intersection;
                    switch (corner)
                    {
                    case "North West":
                        customer.NorthWest = true;
                        break;

                    case "North East":
                        customer.NorthEast = true;
                        break;

                    case "South West":
                        customer.SouthWest = true;
                        break;

                    case "South East":
                        customer.SouthEast = true;
                        break;
                    }

                    _db.Entry(customer).State = EntityState.Modified;
                    _db.SaveChanges();

                    Sales_JobMasterList_Customer sales_JobMasterList_Customer = _db.Sales_JobMasterList_Customer.FirstOrDefault(x => x.jobID == misJobID && x.cID == customer.ROWID);
                    if (sales_JobMasterList_Customer != null)
                    {
                        HandleAccountContact(misJobID, sales_JobMasterList_Customer.jcID, contactID, customerID, firstName, lastName, phone, accountID, type);
                    }
                }

                LogMethods.Log.Debug("HandleAccount:Debug:" + "Done");
            }
            catch (Exception e)
            {
                LogMethods.Log.Error("HandleAccount:Error:" + e.Message);
            }
        }