/// <summary>
        /// Saves this instance.
        /// </summary>
        /// <returns></returns>
        public int Save()
        {
            var companyProfile = new CompanyProfileModel
            {
                LineId                             = View.LineId,
                AssetOwnArea                       = View.AssetOwnArea,
                AssetOwnRoom                       = View.AssetOwnRoom,
                AssetBuyDate                       = View.AssetBuyDate,
                AssetOwnDescription                = View.AssetOwnDescription,
                AssetMutualArea                    = View.AssetMutualArea,
                AssetMutualRoom                    = View.AssetMutualRoom,
                AssetMutualMethod                  = View.AssetMutualMethod,
                AssetMutualDescription             = View.AssetMutualDescription,
                AssetRentContractLen               = View.AssetRentContractLen,
                AssetRentPrice                     = View.AssetRentPrice,
                AssetRentRoom                      = View.AssetRentRoom,
                AssetRentArea                      = View.AssetRentArea,
                AssetRentDescription               = View.AssetRentDescription,
                AssetNumberOfCars                  = View.AssetNumberOfCars,
                AssetCarDetail                     = View.AssetCarDetail,
                EmployeePayrollsTotal              = View.EmployeePayrollsTotal,
                EmployeeNumberOfWifeOrHusband      = View.EmployeeNumberOfWifeOrHusband,
                EmployeeNumberOfOfficers           = View.EmployeeNumberOfOfficers,
                EmployeeNumberOfStaff              = View.EmployeeNumberOfStaff,
                EmployeeOtherCompany               = View.EmployeeOtherCompany,
                EmployeeNumberOfSecondingOfficers  = View.EmployeeNumberOfSecondingOfficers,
                EmployeeDetail                     = View.EmployeeDetail,
                EmployeeNumberOfRentLocal          = View.EmployeeNumberOfRentLocal,
                ProfileAddress                     = View.ProfileAddress,
                ProfileFoundDate                   = View.ProfileFoundDate,
                ProfileHeadPhone                   = View.ProfileHeadPhone,
                ProfileAmbassadorName              = View.ProfileAmbassadorName,
                ProfileAmbassadorPhone             = View.ProfileAmbassadorPhone,
                ProfileAmbassadorStartDate         = View.ProfileAmbassadorStartDate,
                ProfileAmbassadorFinishDate        = View.ProfileAmbassadorFinishDate,
                ProfileAccountingManagerName       = View.ProfileAccountingManagerName,
                ProfileAccountingManagerPhone      = View.ProfileAccountingManagerPhone,
                ProfileAccountingManagerStartDate  = View.ProfileAccountingManagerStartDate,
                ProfileAccountingManagerFinishDate = View.ProfileAccountingManagerFinishDate,
                ProfileAccountantName              = View.ProfileAccountantName,
                ProfileAccountantPhone             = View.ProfileAccountantPhone,
                ProfileAccountantStartDate         = View.ProfileAccountantStartDate,
                ProfileAccountantFinishDate        = View.ProfileAccountantFinishDate,
                ProfileMinimumSalary               = View.ProfileMinimumSalary,
                ProfileSalaryGroup                 = View.ProfileSalaryGroup,
                ProfileWorkingArea                 = View.ProfileWorkingArea,
                ProfileCurrencyCodeFinalization    = View.ProfileCurrencyCodeFinalization,
                ProfileServices                    = View.ProfileServices,
                ProfileReportHeader                = View.ProfileReportHeader,
                ProfileBankName                    = View.ProfileBankName,
                ProfileBankAddress                 = View.ProfileBankAddress,
                ProfileBankAccount                 = View.ProfileBankAccount,
                ProfileBankCIF                     = View.ProfileBankCIF,
                OtherNote                          = View.OtherNote,
                NativeCategory                     = View.NativeCategory,
                ManagementArea                     = View.ManagementArea,
            };

            return(Model.GetCompanyProfile(1) != null?Model.UpdateCompanyProfile(companyProfile) : Model.AddCompanyProfile(companyProfile));
        }
Beispiel #2
0
 public async Task <ActionResult> UpdateCompanyFullProfile([FromBody] CompanyProfileModel companyProfileModel) => await Exec(async operation =>
 {
     var(_, id) = VerifyUser(UserRole.Company);
     if (!ModelState.IsValid)
     {
         throw new Exception(ExceptionMessage.ModelIsInvalid);
     }
     var entity = companyProfileModel.ToEntity(id);
     await companyProfileService.UpdateCompanyFullProfile(operation, entity);
 });
        // GET: CompanyProfile/Create
        public ActionResult Create()
        {
            //10/10/2019 aakansha
            ViewBag.FormName = "CompanyProfile";
            var companyProfile = new CompanyProfileModel();

            try
            {
                var companyProfileFrom = _companyProfileService.GetAllCompanyProfile();
                if (companyProfileFrom != null)
                {
                    companyProfile = companyProfileFrom.ToModel();

                    //16/09/19 aakansha
                    var DownloadHistoryListData = _companyProfileService.GetAllDownloadHistory();
                    var downloadhistory         = DownloadHistoryListData.Select(a =>
                                                                                 new DownloadHistoryModel
                    {
                        DocFormat        = a.DocumentFormat,
                        DocType          = a.DocumentType,
                        DocName          = a.DocumentName,
                        DownloadDateTime = a.DownloadDateTime,
                        UserId           = a.UserId,
                        ProcessTypeId    = a.ProcessTypeId,
                        ProcessType      = (ProcessType)a.ProcessTypeId
                    }).ToList();
                    if (downloadhistory.Count() != 0)
                    {
                        companyProfile.DownloadHistoryList = downloadhistory;
                    }
                    return(View(companyProfile));
                }
            }
            catch (Exception ex)
            {
                AddNotification(NotificationMessage.TitleError, NotificationMessage.ErrorMsg, NotificationMessage.TypeError);
            }

            return(View(companyProfile));
        }
        /// <summary>
        /// Saves this instance.
        /// </summary>
        /// <returns></returns>
        public int SaveCompanyProfile()
        {
            _companyProfile = Model.GetCompanyProfile(1);
            var     dbOptionModels    = View.DBOptions;
            string  companyDirector   = "";
            string  companyAccountant = "";
            decimal baseOfSalary      = 0;
            string  companyAdrress    = "";
            string  companyCode       = "";

            foreach (var dbOptionModel in dbOptionModels)
            {
                //if (dbOptionModel.OptionId == "CompanyDirector")
                //{
                //    companyDirector = dbOptionModel.OptionValue;
                //}
                if (dbOptionModel.OptionId == "CompanyAccountant")
                {
                    companyAccountant = dbOptionModel.OptionValue;
                }

                if (dbOptionModel.OptionId == "BaseOfSalary")
                {
                    baseOfSalary = Convert.ToDecimal(dbOptionModel.OptionValue);
                }

                if (dbOptionModel.OptionId == "CompanyAdrress")
                {
                    companyAdrress = dbOptionModel.OptionValue;
                }

                if (dbOptionModel.OptionId == "CompanyAdrress")
                {
                    companyAdrress = dbOptionModel.OptionValue;
                }

                if (dbOptionModel.OptionId == "CompanyCode")
                {
                    companyCode = dbOptionModel.OptionValue;
                }
            }
            var companyProfile = new CompanyProfileModel
            {
                LineId                             = _companyProfile == null ?0: _companyProfile.LineId,
                AssetOwnArea                       = _companyProfile == null ?0:_companyProfile.AssetOwnArea,
                AssetOwnRoom                       = _companyProfile == null ?0:_companyProfile.AssetOwnRoom,
                AssetBuyDate                       = _companyProfile == null ?DateTime.Now:_companyProfile.AssetBuyDate,
                AssetOwnDescription                = _companyProfile == null ?"": _companyProfile.AssetOwnDescription,
                AssetMutualArea                    = _companyProfile == null ?0: _companyProfile.AssetMutualArea,
                AssetMutualRoom                    = _companyProfile == null ?0: _companyProfile.AssetMutualRoom,
                AssetMutualMethod                  = _companyProfile == null ? "": _companyProfile.AssetMutualMethod,
                AssetMutualDescription             = _companyProfile == null ? "": _companyProfile.AssetMutualDescription,
                AssetRentContractLen               = _companyProfile == null ?0: _companyProfile.AssetRentContractLen,
                AssetRentPrice                     = _companyProfile == null ?0: _companyProfile.AssetRentPrice,
                AssetRentRoom                      = _companyProfile == null ?0: _companyProfile.AssetRentRoom,
                AssetRentArea                      = _companyProfile == null ?0: _companyProfile.AssetRentArea,
                AssetRentDescription               = _companyProfile == null ? "": _companyProfile.AssetRentDescription,
                AssetNumberOfCars                  = _companyProfile == null ?0: _companyProfile.AssetNumberOfCars,
                AssetCarDetail                     = _companyProfile == null ? "": _companyProfile.AssetCarDetail,
                EmployeePayrollsTotal              = _companyProfile == null ?0: _companyProfile.EmployeePayrollsTotal,
                EmployeeNumberOfWifeOrHusband      = _companyProfile == null ?0: _companyProfile.EmployeeNumberOfWifeOrHusband,
                EmployeeNumberOfOfficers           = _companyProfile == null ?0: _companyProfile.EmployeeNumberOfOfficers,
                EmployeeNumberOfStaff              = _companyProfile == null ?0: _companyProfile.EmployeeNumberOfStaff,
                EmployeeOtherCompany               = _companyProfile == null ?0: _companyProfile.EmployeeOtherCompany,
                EmployeeNumberOfSecondingOfficers  = _companyProfile == null ?0: _companyProfile.EmployeeNumberOfSecondingOfficers,
                EmployeeDetail                     = _companyProfile == null ? "": _companyProfile.EmployeeDetail,
                EmployeeNumberOfRentLocal          = _companyProfile == null ?0: _companyProfile.EmployeeNumberOfRentLocal,
                ProfileAddress                     = companyAdrress,
                ProfileFoundDate                   = _companyProfile == null ? DateTime.Now: _companyProfile.ProfileFoundDate,
                ProfileHeadPhone                   = _companyProfile == null ? "": _companyProfile.ProfileHeadPhone,
                ProfileAmbassadorName              = companyDirector,
                ProfileAmbassadorPhone             = _companyProfile == null ?"": _companyProfile.ProfileAmbassadorPhone,
                ProfileAmbassadorStartDate         = _companyProfile == null ? DateTime.Now: _companyProfile.ProfileAmbassadorStartDate,
                ProfileAmbassadorFinishDate        = _companyProfile == null ? DateTime.Now: _companyProfile.ProfileAmbassadorFinishDate,
                ProfileAccountingManagerName       = _companyProfile == null ? "" : _companyProfile.ProfileAccountingManagerName,
                ProfileAccountingManagerPhone      = _companyProfile == null ? "": _companyProfile.ProfileAccountingManagerPhone,
                ProfileAccountingManagerStartDate  = _companyProfile == null ? DateTime.Now: _companyProfile.ProfileAccountingManagerStartDate,
                ProfileAccountingManagerFinishDate = _companyProfile == null ? DateTime.Now: _companyProfile.ProfileAccountingManagerFinishDate,
                ProfileAccountantName              = companyAccountant,
                ProfileAccountantPhone             = _companyProfile == null ? "": _companyProfile.ProfileAccountantPhone,
                ProfileAccountantStartDate         = _companyProfile == null ? DateTime.Now: _companyProfile.ProfileAccountantStartDate,
                ProfileAccountantFinishDate        = _companyProfile == null ? DateTime.Now: _companyProfile.ProfileAccountantFinishDate,
                ProfileMinimumSalary               = baseOfSalary,
                ProfileSalaryGroup                 = _companyProfile == null ? "": _companyProfile.ProfileSalaryGroup,
                ProfileWorkingArea                 = _companyProfile == null ? "": _companyProfile.ProfileWorkingArea,
                ProfileCurrencyCodeFinalization    = _companyProfile == null ? "": _companyProfile.ProfileCurrencyCodeFinalization,
                ProfileServices                    = _companyProfile == null ? "": _companyProfile.ProfileServices,
                ProfileReportHeader                = _companyProfile == null ? "": _companyProfile.ProfileReportHeader,
                ProfileBankName                    = _companyProfile == null ? "": _companyProfile.ProfileBankName,
                ProfileBankAddress                 = _companyProfile == null ? "": _companyProfile.ProfileBankAddress,
                ProfileBankAccount                 = _companyProfile == null ? "": _companyProfile.ProfileBankAccount,
                ProfileBankCIF                     = _companyProfile == null ? "": _companyProfile.ProfileBankCIF,
                OtherNote                          = _companyProfile == null ? "": _companyProfile.OtherNote
            };

            return(_companyProfile != null?Model.UpdateCompanyProfile(companyProfile) : Model.AddCompanyProfile(companyProfile));
        }
        /// <summary>
        /// Saves this instance.
        /// </summary>
        /// <returns></returns>
        public int SaveCompanyProfile()
        {
            _companyProfile = Model.GetCompanyProfile(1);
            var   fixedAssetsHouseModels = Model.GetBuildings().Where(x => x.IsActive = true);
            int   fixedAssetsHouse       = fixedAssetsHouseModels.ToList().Count;
            float assetRentArea          = 0;

            foreach (var fixedAssetsModel in fixedAssetsHouseModels)
            {
                assetRentArea = assetRentArea + float.Parse(fixedAssetsModel.Area.ToString());
            }

            var companyProfile = new CompanyProfileModel
            {
                LineId                             = _companyProfile.LineId,
                AssetOwnArea                       = _companyProfile.AssetOwnArea,
                AssetOwnRoom                       = _companyProfile.AssetOwnRoom,
                AssetBuyDate                       = _companyProfile.AssetBuyDate,
                AssetOwnDescription                = _companyProfile.AssetOwnDescription,
                AssetMutualArea                    = _companyProfile.AssetMutualArea,
                AssetMutualRoom                    = _companyProfile.AssetMutualRoom,
                AssetMutualMethod                  = _companyProfile.AssetMutualMethod,
                AssetMutualDescription             = _companyProfile.AssetMutualDescription,
                AssetRentContractLen               = _companyProfile.AssetRentContractLen,
                AssetRentPrice                     = _companyProfile.AssetRentPrice,
                AssetRentRoom                      = fixedAssetsHouse,
                AssetRentArea                      = assetRentArea,
                AssetRentDescription               = _companyProfile.AssetRentDescription,
                AssetNumberOfCars                  = _companyProfile.AssetNumberOfCars,
                AssetCarDetail                     = _companyProfile.AssetCarDetail,
                EmployeePayrollsTotal              = _companyProfile.EmployeePayrollsTotal,
                EmployeeNumberOfWifeOrHusband      = _companyProfile.EmployeeNumberOfWifeOrHusband,
                EmployeeNumberOfOfficers           = _companyProfile.EmployeeNumberOfOfficers,
                EmployeeNumberOfStaff              = _companyProfile.EmployeeNumberOfStaff,
                EmployeeOtherCompany               = _companyProfile.EmployeeOtherCompany,
                EmployeeNumberOfSecondingOfficers  = _companyProfile.EmployeeNumberOfSecondingOfficers,
                EmployeeDetail                     = _companyProfile.EmployeeDetail,
                EmployeeNumberOfRentLocal          = _companyProfile.EmployeeNumberOfRentLocal,
                ProfileAddress                     = _companyProfile.ProfileAddress,
                ProfileFoundDate                   = _companyProfile.ProfileFoundDate,
                ProfileHeadPhone                   = _companyProfile.ProfileHeadPhone,
                ProfileAmbassadorName              = _companyProfile.ProfileAmbassadorName,
                ProfileAmbassadorPhone             = _companyProfile.ProfileAmbassadorPhone,
                ProfileAmbassadorStartDate         = _companyProfile.ProfileAmbassadorStartDate,
                ProfileAmbassadorFinishDate        = _companyProfile.ProfileAmbassadorFinishDate,
                ProfileAccountingManagerName       = _companyProfile.ProfileAccountingManagerName,
                ProfileAccountingManagerPhone      = _companyProfile.ProfileAccountingManagerPhone,
                ProfileAccountingManagerStartDate  = _companyProfile.ProfileAccountingManagerStartDate,
                ProfileAccountingManagerFinishDate = _companyProfile.ProfileAccountingManagerFinishDate,
                ProfileAccountantName              = _companyProfile.ProfileAccountantName,
                ProfileAccountantPhone             = _companyProfile.ProfileAccountantPhone,
                ProfileAccountantStartDate         = _companyProfile.ProfileAccountantStartDate,
                ProfileAccountantFinishDate        = _companyProfile.ProfileAccountantFinishDate,
                ProfileMinimumSalary               = _companyProfile.ProfileMinimumSalary,
                ProfileSalaryGroup                 = _companyProfile.ProfileSalaryGroup,
                ProfileWorkingArea                 = _companyProfile.ProfileWorkingArea,
                ProfileCurrencyCodeFinalization    = _companyProfile.ProfileCurrencyCodeFinalization,
                ProfileServices                    = _companyProfile.ProfileServices,
                ProfileReportHeader                = _companyProfile.ProfileReportHeader,
                ProfileBankName                    = _companyProfile.ProfileBankName,
                ProfileBankAddress                 = _companyProfile.ProfileBankAddress,
                ProfileBankAccount                 = _companyProfile.ProfileBankAccount,
                ProfileBankCIF                     = _companyProfile.ProfileBankCIF,
                OtherNote                          = _companyProfile.OtherNote
            };

            return(Model.GetCompanyProfile(1) != null?Model.UpdateCompanyProfile(companyProfile) : Model.AddCompanyProfile(companyProfile));
        }
        /// <summary>
        /// Saves this instance.
        /// </summary>
        /// <returns></returns>
        public int SaveCompanyProfile()
        {
            _companyProfile = Model.GetCompanyProfile(1);
            _dbOptions      = Model.GetDBOptions();
            // List<EmployeeModel> employeeNumberOfOfficers = _employeesPresenter.GetEmployees();
            //  txtEmployeeNumberOfOfficers.EditValue = employeeNumberOfOfficers.Where(x => DateTime.Parse(x.StartingDate) <= DateTime.Parse(CommonVariable.PostedDate)
            //     && DateTime.Parse(x.RetiredDate) >= DateTime.Parse(CommonVariable.PostedDate) && x.IsOffice).ToList().Count().ToString();
            int      employeeNumberOfOfficerCount       = 0;
            int      employeeNumberOfWifeOrHusbandCount = 0;
            int      employeeNumberCount = 0;
            DateTime postedDate;

            foreach (var optionModel in _dbOptions)
            {
                if (optionModel.OptionId == "PostedDate")
                {
                    postedDate = DateTime.Parse(optionModel.OptionValue);
                    var employeeNumberOfOfficers =
                        Model.GetEmployees()
                        .Where(x => x.RetiredDate != null && DateTime.Parse(x.RetiredDate) >= postedDate && x.IsOffice && x.IsActive);
                    int Count = employeeNumberOfOfficers.Count();
                    employeeNumberOfOfficerCount = employeeNumberOfOfficerCount + Count;

                    var employeeNumberOfWifeOrHusband =
                        Model.GetEmployees()
                        .Where(x => x.RetiredDate != null && DateTime.Parse(x.RetiredDate) >= postedDate && x.IsOffice == false && x.IsActive);
                    int CountEmployeeNumberOfWifeOrHusband = employeeNumberOfWifeOrHusband.Count();
                    employeeNumberOfWifeOrHusbandCount = employeeNumberOfWifeOrHusbandCount + CountEmployeeNumberOfWifeOrHusband;

                    employeeNumberCount = employeeNumberOfWifeOrHusbandCount + employeeNumberOfOfficerCount;
                }
            }
            int a = 0;

            var companyProfile = new CompanyProfileModel
            {
                LineId                             = _companyProfile.LineId,
                AssetOwnArea                       = _companyProfile.AssetOwnArea,
                AssetOwnRoom                       = _companyProfile.AssetOwnRoom,
                AssetBuyDate                       = _companyProfile.AssetBuyDate,
                AssetOwnDescription                = _companyProfile.AssetOwnDescription,
                AssetMutualArea                    = _companyProfile.AssetMutualArea,
                AssetMutualRoom                    = _companyProfile.AssetMutualRoom,
                AssetMutualMethod                  = _companyProfile.AssetMutualMethod,
                AssetMutualDescription             = _companyProfile.AssetMutualDescription,
                AssetRentContractLen               = _companyProfile.AssetRentContractLen,
                AssetRentPrice                     = _companyProfile.AssetRentPrice,
                AssetRentRoom                      = _companyProfile.AssetRentRoom,
                AssetRentArea                      = _companyProfile.AssetRentArea,
                AssetRentDescription               = _companyProfile.AssetRentDescription,
                AssetNumberOfCars                  = _companyProfile.AssetNumberOfCars,
                AssetCarDetail                     = _companyProfile.AssetCarDetail,
                EmployeePayrollsTotal              = employeeNumberCount,
                EmployeeNumberOfWifeOrHusband      = employeeNumberOfWifeOrHusbandCount,
                EmployeeNumberOfOfficers           = employeeNumberOfOfficerCount,
                EmployeeNumberOfStaff              = _companyProfile.EmployeeNumberOfStaff,
                EmployeeOtherCompany               = _companyProfile.EmployeeOtherCompany,
                EmployeeNumberOfSecondingOfficers  = _companyProfile.EmployeeNumberOfSecondingOfficers,
                EmployeeDetail                     = _companyProfile.EmployeeDetail,
                EmployeeNumberOfRentLocal          = _companyProfile.EmployeeNumberOfRentLocal,
                ProfileAddress                     = _companyProfile.ProfileAddress,
                ProfileFoundDate                   = _companyProfile.ProfileFoundDate,
                ProfileHeadPhone                   = _companyProfile.ProfileHeadPhone,
                ProfileAmbassadorName              = _companyProfile.ProfileAmbassadorName,
                ProfileAmbassadorPhone             = _companyProfile.ProfileAmbassadorPhone,
                ProfileAmbassadorStartDate         = _companyProfile.ProfileAmbassadorStartDate,
                ProfileAmbassadorFinishDate        = _companyProfile.ProfileAmbassadorFinishDate,
                ProfileAccountingManagerName       = _companyProfile.ProfileAccountingManagerName,
                ProfileAccountingManagerPhone      = _companyProfile.ProfileAccountingManagerPhone,
                ProfileAccountingManagerStartDate  = _companyProfile.ProfileAccountingManagerStartDate,
                ProfileAccountingManagerFinishDate = _companyProfile.ProfileAccountingManagerFinishDate,
                ProfileAccountantName              = _companyProfile.ProfileAccountantName,
                ProfileAccountantPhone             = _companyProfile.ProfileAccountantPhone,
                ProfileAccountantStartDate         = _companyProfile.ProfileAccountantStartDate,
                ProfileAccountantFinishDate        = _companyProfile.ProfileAccountantFinishDate,
                ProfileMinimumSalary               = _companyProfile.ProfileMinimumSalary,
                ProfileSalaryGroup                 = _companyProfile.ProfileSalaryGroup,
                ProfileWorkingArea                 = _companyProfile.ProfileWorkingArea,
                ProfileCurrencyCodeFinalization    = _companyProfile.ProfileCurrencyCodeFinalization,
                ProfileServices                    = _companyProfile.ProfileServices,
                ProfileReportHeader                = _companyProfile.ProfileReportHeader,
                ProfileBankName                    = _companyProfile.ProfileBankName,
                ProfileBankAddress                 = _companyProfile.ProfileBankAddress,
                ProfileBankAccount                 = _companyProfile.ProfileBankAccount,
                ProfileBankCIF                     = _companyProfile.ProfileBankCIF,
                OtherNote                          = _companyProfile.OtherNote
            };

            return(Model.GetCompanyProfile(1) != null?Model.UpdateCompanyProfile(companyProfile) : Model.AddCompanyProfile(companyProfile));
        }
        /// <summary>
        /// Displays the specified companyProfile identifier.
        /// </summary>
        /// <param name="companyProfileId">The companyProfile identifier.</param>
        public void Display(string companyProfileId)
        {
            if (companyProfileId == null)
            {
                View.LineId = 0; return;
            }

            _companyProfile = Model.GetCompanyProfile(int.Parse(companyProfileId));
            if (_companyProfile == null)
            {
                return;
            }

            View.LineId                             = _companyProfile.LineId;
            View.AssetOwnArea                       = _companyProfile.AssetOwnArea;
            View.AssetOwnRoom                       = _companyProfile.AssetOwnRoom;
            View.AssetBuyDate                       = _companyProfile.AssetBuyDate;
            View.AssetOwnDescription                = _companyProfile.AssetOwnDescription;
            View.AssetMutualArea                    = _companyProfile.AssetMutualArea;
            View.AssetMutualRoom                    = _companyProfile.AssetMutualRoom;
            View.AssetMutualMethod                  = _companyProfile.AssetMutualMethod;
            View.AssetMutualDescription             = _companyProfile.AssetMutualDescription;
            View.AssetRentContractLen               = _companyProfile.AssetRentContractLen;
            View.AssetRentPrice                     = _companyProfile.AssetRentPrice;
            View.AssetRentRoom                      = _companyProfile.AssetRentRoom;
            View.AssetRentArea                      = _companyProfile.AssetRentArea;
            View.AssetRentDescription               = _companyProfile.AssetRentDescription;
            View.AssetNumberOfCars                  = _companyProfile.AssetNumberOfCars;
            View.AssetCarDetail                     = _companyProfile.AssetCarDetail;
            View.EmployeePayrollsTotal              = _companyProfile.EmployeePayrollsTotal;
            View.EmployeeNumberOfWifeOrHusband      = _companyProfile.EmployeeNumberOfWifeOrHusband;
            View.EmployeeNumberOfOfficers           = _companyProfile.EmployeeNumberOfOfficers;
            View.EmployeeNumberOfStaff              = _companyProfile.EmployeeNumberOfStaff;
            View.EmployeeOtherCompany               = _companyProfile.EmployeeOtherCompany;
            View.EmployeeNumberOfSecondingOfficers  = _companyProfile.EmployeeNumberOfSecondingOfficers;
            View.EmployeeDetail                     = _companyProfile.EmployeeDetail;
            View.EmployeeNumberOfRentLocal          = _companyProfile.EmployeeNumberOfRentLocal;
            View.ProfileAddress                     = _companyProfile.ProfileAddress;
            View.ProfileFoundDate                   = _companyProfile.ProfileFoundDate;
            View.ProfileHeadPhone                   = _companyProfile.ProfileHeadPhone;
            View.ProfileAmbassadorName              = _companyProfile.ProfileAmbassadorName;
            View.ProfileAmbassadorPhone             = _companyProfile.ProfileAmbassadorPhone;
            View.ProfileAmbassadorStartDate         = _companyProfile.ProfileAmbassadorStartDate;
            View.ProfileAmbassadorFinishDate        = _companyProfile.ProfileAmbassadorFinishDate;
            View.ProfileAccountingManagerName       = _companyProfile.ProfileAccountingManagerName;
            View.ProfileAccountingManagerPhone      = _companyProfile.ProfileAccountingManagerPhone;
            View.ProfileAccountingManagerStartDate  = _companyProfile.ProfileAccountingManagerStartDate;
            View.ProfileAccountingManagerFinishDate = _companyProfile.ProfileAccountingManagerFinishDate;
            View.ProfileAccountantName              = _companyProfile.ProfileAccountantName;
            View.ProfileAccountantPhone             = _companyProfile.ProfileAccountantPhone;
            View.ProfileAccountantStartDate         = _companyProfile.ProfileAccountantStartDate;
            View.ProfileAccountantFinishDate        = _companyProfile.ProfileAccountantFinishDate;
            View.ProfileMinimumSalary               = _companyProfile.ProfileMinimumSalary;
            View.ProfileSalaryGroup                 = _companyProfile.ProfileSalaryGroup;
            View.ProfileWorkingArea                 = _companyProfile.ProfileWorkingArea;
            View.ProfileCurrencyCodeFinalization    = _companyProfile.ProfileCurrencyCodeFinalization;
            View.ProfileServices                    = _companyProfile.ProfileServices;
            View.ProfileReportHeader                = _companyProfile.ProfileReportHeader;
            View.ProfileBankName                    = _companyProfile.ProfileBankName;
            View.ProfileBankAddress                 = _companyProfile.ProfileBankAddress;
            View.ProfileBankAccount                 = _companyProfile.ProfileBankAccount;
            View.ProfileBankCIF                     = _companyProfile.ProfileBankCIF;
            View.OtherNote                          = _companyProfile.OtherNote;
            View.NativeCategory                     = _companyProfile.NativeCategory;
            View.ManagementArea                     = _companyProfile.ManagementArea;
        }
Beispiel #8
0
        public OrderQuotationViewModel GetOrderQuote([FromBody] GetOrderQuoteRequestModel requestModel)
        {
            var companyProfile  = new CompanyProfileModel();
            var customerDetails = new OrderCustomerDetailModel();
            var orderDetails    = new OrderDetailModel();
            var addressDetails  = new AddressDetailsModel();

            var existingCompany = Context.CompanyProfiles.Include(cp => cp.BankingDetails).Include(cp => cp.Addresses).FirstOrDefault(cp => cp.CompanyProfileId == requestModel.CompanyProfileId);

            if (existingCompany != null)
            {
                companyProfile.DisplayName    = existingCompany.DisplayName;
                companyProfile.RegistrationNo = existingCompany.RegistrationNo;
                companyProfile.TaxReferenceNo = existingCompany.TaxReferenceNo;
                companyProfile.TelephoneNo    = existingCompany.TelephoneNo;
                companyProfile.EmailAddress   = existingCompany.EmailAddress;

                if (existingCompany.Addresses.Count > 0)
                {
                    companyProfile.AddressLine1 = existingCompany.Addresses[0].AddressLine1;
                    companyProfile.AddressLine2 = existingCompany.Addresses[0].AddressLine2;
                    companyProfile.City         = existingCompany.Addresses[0].City;
                    companyProfile.Country      = existingCompany.Addresses[0].Country;
                    companyProfile.PostalCode   = existingCompany.Addresses[0].PostalCode;
                }

                if (existingCompany.BankingDetails.Count > 0)
                {
                    companyProfile.BankingDetails = new BankingDetailsModel
                    {
                        AccountHolder = existingCompany.BankingDetails[0].AccountHolder,
                        AccountNo     = existingCompany.BankingDetails[0].AccountNo,
                        BankName      = existingCompany.BankingDetails[0].BankName,
                        AccountType   = existingCompany.BankingDetails[0].AccountType,
                        BranchCode    = existingCompany.BankingDetails[0].BranchCode,
                    };
                }
            }

            var order            = Context.Orders.Include(o => o.OrderDetails).First(o => o.OrderId == requestModel.OrderId);
            var existingCustomer = Context.Customers.Include(c => c.Addresses).Include(c => c.ContactPeople).FirstOrDefault(c => c.CustomerId == order.CustomerId);

            var existingContact = existingCustomer != null?existingCustomer.ContactPeople.FirstOrDefault(cp => cp.ContactId == order.ContactId) : null;

            var existingAddresss = existingCustomer != null?existingCustomer.Addresses.FirstOrDefault(cp => cp.AddressDetailId == order.AddressDetailId) : null;

            if (existingCustomer != null)
            {
                customerDetails.OrderId              = order.OrderId;
                customerDetails.CustomerName         = existingCustomer.CustomerName;
                customerDetails.CustomerContactNo    = existingCustomer.ContactNo;
                customerDetails.CustomerAccountNo    = existingCustomer.AccountNo;
                customerDetails.CustomerDetails      = existingCustomer.CustomerDetails;
                customerDetails.CustomerEmailAddress = existingCustomer.EmailAddress;

                if (existingContact != null)
                {
                    customerDetails.ContactName         = existingContact.ContactName;
                    customerDetails.ContactNo           = existingContact.ContactNo;
                    customerDetails.ContactEmailAddress = existingContact.EmailAddress;
                }
                else
                {
                    customerDetails.ContactName = existingCustomer.CustomerName;
                }

                if (existingAddresss != null)
                {
                    addressDetails.AddressLine1 = existingAddresss.AddressLine1;
                    addressDetails.AddressLine2 = existingAddresss.AddressLine2;
                    addressDetails.City         = existingAddresss.City;
                    addressDetails.Country      = existingAddresss.Country;
                    addressDetails.PostalCode   = existingAddresss.PostalCode;
                }
            }

            orderDetails.Discount   = order.DiscountTotal;
            orderDetails.OrderNo    = order.OrderNo;
            orderDetails.OrderId    = order.OrderId;
            orderDetails.CreateDate = order.CreateDate;
            orderDetails.SubTotal   = order.SubTotal;
            orderDetails.VatTotal   = order.VatTotal;
            orderDetails.Total      = order.OrderTotal;

            var salesPerson = SecurityContext.Users.FirstOrDefault(u => u.Username == order.CreateUser);

            if (salesPerson != null)
            {
                orderDetails.CreateUser = (salesPerson.FirstName + " " + salesPerson.LastName).Trim() != string.Empty ? (salesPerson.FirstName + " " + salesPerson.LastName) : order.CreateUser; // replace with first and last name of user
            }
            else
            {
                orderDetails.CreateUser = order.CreateUser;
            }

            var maxLineNo = order.OrderDetails.Max(o => o.LineNo);

            foreach (var linedetail in order.OrderDetails.Where(o => o.LineNo == maxLineNo))
            {
                var newLineDetail = new OrderLineDetailModel
                {
                    Discount        = linedetail.Discount,
                    ItemDescription = linedetail.ItemDescription,
                    Quantity        = linedetail.Quantity,
                    UnitPrice       = linedetail.UnitPrice,
                    LineTotal       = linedetail.LineTotal
                };

                orderDetails.OrderLineDetails.Add(newLineDetail);
            }

            return(new OrderQuotationViewModel
            {
                CompanyProfile = companyProfile,
                CustomerDetail = customerDetails,
                DeliveryAddress = addressDetails,
                OrderTotals = orderDetails
            });
        }
        /// <summary>
        /// Saves this instance.
        /// </summary>
        /// <returns></returns>
        public int SaveCompanyProfile()
        {
            _companyProfile = Model.GetCompanyProfile(1);
            var   fixedAssetsHouseModels = Model.GetAllFixedAssetsWithStoreProdure("uspGet_FixedAsset_ByState_Houser");
            var   fixedAssetsCarModels   = Model.GetAllFixedAssetsWithStoreProdure("uspGet_FixedAsset_ByState_Car");
            int   fixedAssetsCar         = fixedAssetsCarModels.ToList().Count;
            int   fixedAssetsHouse       = fixedAssetsHouseModels.ToList().Count;
            float assetOwnArea           = 0;

            foreach (var fixedAssetsModel in fixedAssetsHouseModels)
            {
                assetOwnArea = assetOwnArea + float.Parse(fixedAssetsModel.AreaOfBuilding.ToString());
            }
            var companyProfile = new CompanyProfileModel();

            companyProfile.LineId                             = _companyProfile.LineId;
            companyProfile.AssetOwnArea                       = assetOwnArea;
            companyProfile.AssetOwnRoom                       = fixedAssetsHouse;
            companyProfile.AssetBuyDate                       = _companyProfile.AssetBuyDate;
            companyProfile.AssetOwnDescription                = _companyProfile.AssetOwnDescription;
            companyProfile.AssetMutualArea                    = _companyProfile.AssetMutualArea;
            companyProfile.AssetMutualRoom                    = _companyProfile.AssetMutualRoom;
            companyProfile.AssetMutualMethod                  = _companyProfile.AssetMutualMethod;
            companyProfile.AssetMutualDescription             = _companyProfile.AssetMutualDescription;
            companyProfile.AssetRentContractLen               = _companyProfile.AssetRentContractLen;
            companyProfile.AssetRentPrice                     = _companyProfile.AssetRentPrice;
            companyProfile.AssetRentRoom                      = _companyProfile.AssetRentRoom;
            companyProfile.AssetRentArea                      = _companyProfile.AssetRentArea;
            companyProfile.AssetRentDescription               = _companyProfile.AssetRentDescription;
            companyProfile.AssetNumberOfCars                  = fixedAssetsCar;
            companyProfile.AssetCarDetail                     = _companyProfile.AssetCarDetail;
            companyProfile.EmployeePayrollsTotal              = _companyProfile.EmployeePayrollsTotal;
            companyProfile.EmployeeNumberOfWifeOrHusband      = _companyProfile.EmployeeNumberOfWifeOrHusband;
            companyProfile.EmployeeNumberOfOfficers           = _companyProfile.EmployeeNumberOfOfficers;
            companyProfile.EmployeeNumberOfStaff              = _companyProfile.EmployeeNumberOfStaff;
            companyProfile.EmployeeOtherCompany               = _companyProfile.EmployeeOtherCompany;
            companyProfile.EmployeeNumberOfSecondingOfficers  = _companyProfile.EmployeeNumberOfSecondingOfficers;
            companyProfile.EmployeeDetail                     = _companyProfile.EmployeeDetail;
            companyProfile.EmployeeNumberOfRentLocal          = _companyProfile.EmployeeNumberOfRentLocal;
            companyProfile.ProfileAddress                     = _companyProfile.ProfileAddress;
            companyProfile.ProfileFoundDate                   = _companyProfile.ProfileFoundDate;
            companyProfile.ProfileHeadPhone                   = _companyProfile.ProfileHeadPhone;
            companyProfile.ProfileAmbassadorName              = _companyProfile.ProfileAmbassadorName;
            companyProfile.ProfileAmbassadorPhone             = _companyProfile.ProfileAmbassadorPhone;
            companyProfile.ProfileAmbassadorStartDate         = _companyProfile.ProfileAmbassadorStartDate;
            companyProfile.ProfileAmbassadorFinishDate        = _companyProfile.ProfileAmbassadorFinishDate;
            companyProfile.ProfileAccountingManagerName       = _companyProfile.ProfileAccountingManagerName;
            companyProfile.ProfileAccountingManagerPhone      = _companyProfile.ProfileAccountingManagerPhone;
            companyProfile.ProfileAccountingManagerStartDate  = _companyProfile.ProfileAccountingManagerStartDate;
            companyProfile.ProfileAccountingManagerFinishDate = _companyProfile.ProfileAccountingManagerFinishDate;
            companyProfile.ProfileAccountantName              = _companyProfile.ProfileAccountantName;
            companyProfile.ProfileAccountantPhone             = _companyProfile.ProfileAccountantPhone;
            companyProfile.ProfileAccountantStartDate         = _companyProfile.ProfileAccountantStartDate;
            companyProfile.ProfileAccountantFinishDate        = _companyProfile.ProfileAccountantFinishDate;
            companyProfile.ProfileMinimumSalary               = _companyProfile.ProfileMinimumSalary;
            companyProfile.ProfileSalaryGroup                 = _companyProfile.ProfileSalaryGroup;
            companyProfile.ProfileWorkingArea                 = _companyProfile.ProfileWorkingArea;
            companyProfile.ProfileCurrencyCodeFinalization    = _companyProfile.ProfileCurrencyCodeFinalization;
            companyProfile.ProfileServices                    = _companyProfile.ProfileServices;
            companyProfile.ProfileReportHeader                = _companyProfile.ProfileReportHeader;
            companyProfile.ProfileBankName                    = _companyProfile.ProfileBankName;
            companyProfile.ProfileBankAddress                 = _companyProfile.ProfileBankAddress;
            companyProfile.ProfileBankAccount                 = _companyProfile.ProfileBankAccount;
            companyProfile.ProfileBankCIF                     = _companyProfile.ProfileBankCIF;
            companyProfile.OtherNote                          = _companyProfile.OtherNote;
            return(Model.GetCompanyProfile(1) != null?Model.UpdateCompanyProfile(companyProfile) : Model.AddCompanyProfile(companyProfile));
        }
        public IActionResult CreateGeneral(CompanyProfileModel model)
        {
            try
            {
                //address
                var address = _addressService.GetAddressById(model.CompanyAddressId);
                if (address == null)
                {
                    address = model.CompanyAddress;
                    address.CreatedOnUtc = DateTime.UtcNow;

                    _addressService.InsertAddress(address);
                }
                else
                {
                    address.Address1 = model.CompanyAddress.Address1;
                    address.Address2 = model.CompanyAddress.Address2;

                    address.City          = model.CompanyAddress.City;
                    address.ZipPostalCode = model.CompanyAddress.ZipPostalCode;
                    address.FirstName     = model.CompanyAddress.FirstName;
                    address.LastName      = model.CompanyAddress.LastName;
                    address.Email         = model.CompanyAddress.Email;


                    _addressService.UpdateAddress(address);
                }
                if (model.Id == 0)
                {
                    //General Data
                    var data = new CompanyProfile();

                    data.Email = model.CompanyAddress.Email;

                    data.License          = model.License;
                    data.CreatedOnUtc     = DateTime.UtcNow;
                    data.CompanyAddress   = address;
                    data.CompanyAddressId = address.Id;
                    data.Companyname      = model.Companyname;
                    _companyProfileService.InsertCompanyProfile(data);


                    return(Json(data.Id));
                }
                else
                {
                    var data = _companyProfileService.GetCompanyProfileById((int)model.Id);

                    data.Email = model.CompanyAddress.Email;

                    data.License        = model.License;
                    data.CreatedOnUtc   = DateTime.UtcNow;
                    data.CompanyAddress = address;
                    data.Companyname    = model.Companyname;
                    _companyProfileService.UpdateCompanyProfile(data);
                    return(Json(data.Id));
                }
            }
            catch (Exception e) {
                return(View());
            }
        }
        /// <summary>
        /// Gets the report estimate detail statement.
        /// </summary>
        /// <param name="frmParent">The FRM parent.</param>
        /// <param name="commonVariable">The common variable.</param>
        /// <param name="oRsTool">The o rs tool.</param>
        /// <returns></returns>
        public List <EstimateDetailStatementModel> GetReportCompanyProfiles(XtraForm frmParent, GlobalVariable commonVariable,
                                                                            ReportSharpHelper oRsTool)
        {
            var estimateDetailStatementModel = new List <EstimateDetailStatementModel>();

            if (!oRsTool.IsRefresh)
            {
                using (var frmXtraEstimateDetailStatement = new FrmXtraCompanyProfiles())
                {
                    frmXtraEstimateDetailStatement.ReporDate = _globalVariable.PostedDate;
                    if (frmXtraEstimateDetailStatement.ShowDialog() == DialogResult.OK)
                    {
                        _companyProfile = Model.GetCompanyProfile(1);
                        short yearOfEstimate = (short)DateTime.Parse(frmXtraEstimateDetailStatement.ToDate).Year;
                        int   year1          = yearOfEstimate + 1;

                        //var generalDescription = frmXtraEstimateDetailStatement.GeneralDescription;
                        //var employeeLeasingDescription = frmXtraEstimateDetailStatement.EmployeeLeasingDescription;
                        //var employeeContractDescription = frmXtraEstimateDetailStatement.EmployeeContractDescription;
                        //var buildingOfFixedAssetDescription =frmXtraEstimateDetailStatement.BuildingOfFixedAssetDescription;
                        //var descriptionForBuilding = frmXtraEstimateDetailStatement.DescriptionForBuilding;
                        //var carDescription = frmXtraEstimateDetailStatement.CarDescription;
                        //var inventoryDescription = frmXtraEstimateDetailStatement.InventoryDescription;
                        var partC      = frmXtraEstimateDetailStatement.PartC;
                        var reportDate = frmXtraEstimateDetailStatement.ReporDate;

                        if (!oRsTool.Parameters.ContainsKey("FromDate"))
                        {
                            oRsTool.Parameters.Add("FromDate", frmXtraEstimateDetailStatement.FromDate);
                        }
                        if (!oRsTool.Parameters.ContainsKey("ToDate"))
                        {
                            oRsTool.Parameters.Add("ToDate", frmXtraEstimateDetailStatement.ToDate);
                        }

                        string NativeCategory = "";
                        string ManagementArea = "";
                        switch (_companyProfile.NativeCategory)
                        {
                        case 0:
                            NativeCategory = "Thuận lợi";
                            break;

                        case 1:
                            NativeCategory = "Khá";
                            break;

                        case 2:
                            NativeCategory = "Trung bình";
                            break;

                        case 3:
                            NativeCategory = "Khó khăn";
                            break;

                        case 4:
                            NativeCategory = "Đặc biệt khó khăn";
                            break;
                        }

                        switch (_companyProfile.ManagementArea)
                        {
                        case 0:
                            ManagementArea = "Vụ Đông Bắc Á";
                            break;

                        case 1:
                            ManagementArea = "Vụ Đông Nam Á - Nam Á - Nam TBD";
                            break;

                        case 2:
                            ManagementArea = "Vụ Châu Âu";
                            break;

                        case 3:
                            ManagementArea = "Vụ Châu Mỹ";
                            break;

                        case 4:
                            ManagementArea = "Vụ Tây Á - Châu Phi";
                            break;

                        case 5:
                            ManagementArea = "Vụ ASEAN";
                            break;
                        }

                        var profileAmbassadorName         = "1. Thủ trưởng CQĐD: " + _companyProfile.ProfileAmbassadorName;
                        var profileAccountantName         = "Kế toán: " + _companyProfile.ProfileAccountantName;
                        var employeePayrollsTotal         = "2. Tổng số biên chế: " + _companyProfile.EmployeePayrollsTotal;
                        var employeeNumberOfOfficers      = "Trong đó số CBNV: " + _companyProfile.EmployeeNumberOfOfficers;
                        var employeeNumberOfWifeOrHusband = "Số PN/PQ: " + _companyProfile.EmployeeNumberOfWifeOrHusband;
                        var assetNumberOfCars             = "3. Tổng số xe ô tô: " + _companyProfile.AssetNumberOfCars;
                        var nativeCategory                  = "4. Loại địa bàn: " + NativeCategory;
                        var managementArea                  = "Khu vực quản lý: " + ManagementArea;
                        var profileWorkingArea              = "5. Kiêm nhiệm: " + _companyProfile.ProfileWorkingArea;
                        var profileMinimumSalary            = "6. Sinh hoạt phí tối thiểu: " + _companyProfile.ProfileMinimumSalary.ToString("C" + _globalVariable.CurrencyDecimalDigits, CultureInfo.CurrentCulture);
                        var profileCurrencyCodeFinalization = "7. Loại tiền quyết toán: " + _companyProfile.ProfileCurrencyCodeFinalization;
                        var otherNote = " " + partC;


                        oRsTool.Parameters.Add("YearOfEstimate", yearOfEstimate);
                        oRsTool.Parameters.Add("PartC", "");
                        oRsTool.Parameters.Add("PartC1", "");
                        oRsTool.Parameters.Add("GeneralDescription", "1. Danh sách CBNV:");
                        oRsTool.Parameters.Add("EmployeeLeasingDescription", "2. Danh sách cán bộ nhân viên (không bao gồm phu nhân, phu quân) của các cơ quan Việt Nam ở nước ngoài bên cạnh CQĐD được hưởng Trợ cấp ngành của Bộ Ngoại giao: Bộ phận Quân vụ, Khoa học công nghê, Bộ Công an, Phân xã Thông tấn xã Việt Nam, Cơ quan thường trú của Báo Nhân dân, Đài tiếng nói Việt Nam, Đài truyền hình Việt Nam, Trung tâm văn hoá Việt Nam ở nước ngoài:");
                        oRsTool.Parameters.Add("EmployeeContractDescription", " - Chi tiết công việc người địa phương hoặc lao động hợp đồng đang đảm nhiệm, mức lương đang hưởng/1 tháng (quy USD), thời điểm bắt đầu thuê, thời hạn của hợp đồng. Bảo hiểm và trang phục/1 năm (nếu có). \r\n - CQĐD có kiến nghị ra hạn hoặc thuê mới người địa phương trong năm " + yearOfEstimate + " đề nghị kê chi tiết.");
                        oRsTool.Parameters.Add("BuildingOfFixedAssetDescription", "3.1 - Nhà sở hữu của ta, nhà hỗ tương : Báo cáo chi tiết diện tích, số phòng và mục đích sử dụng.");
                        oRsTool.Parameters.Add("DescriptionForBuilding", "3.2- Nhà thuê: Báo cáo chi tiết địa chỉ, diện tích, số phòng, giá tiền thuê (USD), thời hạn hợp đồng từng căn hộ (Ngày ký, ngày hết hạn hợp đồng). CQĐD kiến nghị gia hạn hoặc thuê đổi trong năm " + yearOfEstimate + " , " + year1 + "  nếu hết hạn hợp đồng thuê.");
                        oRsTool.Parameters.Add("CarDescription", "Bộ phận Ngoại giao: \r\n - 01 xe Cadillac, 4 chỗ, mua năm 2009, nguyên giá 53.308,00 USD (xe số 1) \r\n ...");
                        oRsTool.Parameters.Add("InventoryDescription", "");
                        oRsTool.Parameters.Add("ReportDate", reportDate);
                        oRsTool.Parameters.Add("CompanyProvince", _globalVariable.CompanyProvince);


                        oRsTool.Parameters.Add("ProfileAmbassadorName", profileAmbassadorName);
                        oRsTool.Parameters.Add("ProfileAccountantName", profileAccountantName);
                        oRsTool.Parameters.Add("EmployeePayrollsTotal", employeePayrollsTotal);
                        oRsTool.Parameters.Add("EmployeeNumberOfOfficers", employeeNumberOfOfficers);
                        oRsTool.Parameters.Add("EmployeeNumberOfWifeOrHusband", employeeNumberOfWifeOrHusband);
                        oRsTool.Parameters.Add("AssetNumberOfCars", assetNumberOfCars);
                        oRsTool.Parameters.Add("NativeCategory", nativeCategory);
                        oRsTool.Parameters.Add("ManagementArea", managementArea);
                        oRsTool.Parameters.Add("ProfileWorkingArea", profileWorkingArea);
                        oRsTool.Parameters.Add("ProfileMinimumSalary", profileMinimumSalary);
                        oRsTool.Parameters.Add("OtherNote", otherNote);
                        oRsTool.Parameters.Add("ProfileCurrencyCodeFinalization", profileCurrencyCodeFinalization);

                        estimateDetailStatementModel.Add(new EstimateDetailStatementModel

                        {
                            Employees = Model.GetEstimateDetailStatement(yearOfEstimate, true).Employees.Where(
                                x => x.FinishedDate >= DateTime.Parse(frmXtraEstimateDetailStatement.FromDate) || x.Description == ".").ToList(),
                            Buildings = Model.GetEstimateDetailStatement(yearOfEstimate, true).Buildings.Where(
                                x => x.EndDate >= DateTime.Parse(frmXtraEstimateDetailStatement.FromDate) || x.Description == ".").ToList(),
                            EmployeeLeasings = Model.GetEstimateDetailStatement(yearOfEstimate, true).EmployeeLeasings.Where(
                                x => x.EndDate >= DateTime.Parse(frmXtraEstimateDetailStatement.FromDate) || x.Description == ".").ToList(),
                            EmployeeOthers = Model.GetEstimateDetailStatement(yearOfEstimate, true).EmployeeOthers.Where(
                                x => x.EndDate >= DateTime.Parse(frmXtraEstimateDetailStatement.FromDate)).ToList(),
                            EstimateDetailStatementPartBs = Model.GetEstimateDetailStatement(yearOfEstimate, true).EstimateDetailStatementPartBs,
                            FixedAssetCars = Model.GetEstimateDetailStatement(yearOfEstimate, true).FixedAssetCars.Where(
                                x => x.PurchasedDate <= DateTime.Parse(frmXtraEstimateDetailStatement.ToDate)).ToList(),
                            FixedAssets = Model.GetEstimateDetailStatement(yearOfEstimate, true).FixedAssets.Where(
                                x => x.PurchasedDate <= DateTime.Parse(frmXtraEstimateDetailStatement.ToDate)).ToList(),
                            Mutuals = Model.GetEstimateDetailStatement(yearOfEstimate, true).Mutuals.Where(
                                x => x.UseDate <= DateTime.Parse(frmXtraEstimateDetailStatement.ToDate)).ToList(),
                        });
                        float   countEmployee  = 0;
                        float   subsitenceFee  = 0;
                        decimal insurancePrice = 0;
                        decimal salaryPrice    = 0;
                        decimal uniformPrice   = 0;
                        int     oderNumber     = 0;
                        foreach (var estimateDetailStatement in estimateDetailStatementModel)
                        {
                            foreach (var employee in estimateDetailStatement.Employees)
                            {
                                if (employee.StartedDate.Year > 1900 && employee.FinishedDate.Year > 1900)
                                {
                                    countEmployee        = countEmployee + employee.WomenAllowance;
                                    subsitenceFee        = subsitenceFee + employee.SubsitenceFee;
                                    oderNumber           = oderNumber + 1;
                                    employee.OrderNumber = oderNumber;
                                }

                                else
                                {
                                    employee.WomenAllowance = countEmployee;
                                    employee.SubsitenceFee  = subsitenceFee;
                                }
                            }
                            oderNumber = 0;
                            foreach (var employee in estimateDetailStatement.EmployeeLeasings)
                            {
                                if (employee.StartDate.Year > 1900 && employee.EndDate.Year > 1900)
                                {
                                    insurancePrice = insurancePrice + employee.InsurancePrice;
                                    salaryPrice    = salaryPrice + employee.SalaryPrice;
                                    uniformPrice   = uniformPrice + employee.UniformPrice;

                                    oderNumber           = oderNumber + 1;
                                    employee.OrderNumber = oderNumber;
                                }

                                else
                                {
                                    employee.InsurancePrice = insurancePrice;
                                    employee.SalaryPrice    = salaryPrice;
                                    employee.UniformPrice   = uniformPrice;
                                }
                            }
                            oderNumber = 0;
                            foreach (var employee in estimateDetailStatement.EmployeeOthers)
                            {
                                if (employee.StartDate.Year > 1900 && employee.EndDate.Year > 1900)
                                {
                                    oderNumber           = oderNumber + 1;
                                    employee.OrderNumber = oderNumber;
                                }
                            }
                            oderNumber = 0;
                            foreach (var building in estimateDetailStatement.Buildings)
                            {
                                if (building.StartDate.Year > 1900 && building.EndDate.Year > 1900)
                                {
                                    oderNumber           = oderNumber + 1;
                                    building.OrderNumber = oderNumber;
                                }
                            }

                            oderNumber = 0;
                            foreach (var fixedAsset in estimateDetailStatement.FixedAssets)
                            {
                                oderNumber             = oderNumber + 1;
                                fixedAsset.OrderNumber = oderNumber;
                            }
                            oderNumber = 0;
                            foreach (var fixedAsset in estimateDetailStatement.FixedAssetCars)
                            {
                                oderNumber = oderNumber + 1;
                                fixedAsset.FixedAssetId = oderNumber;
                            }
                        }
                    }
                    else
                    {
                        estimateDetailStatementModel = null;
                    }
                }
                //var yearOfEstimate1 = short.Parse(oRsTool.Parameters["YearOfEstimate"].ToString());
                //estimateDetailStatementModel.Add(Model.GetEstimateDetailStatement(yearOfEstimate1, false));
            }
            else
            {
                var yearOfEstimate = short.Parse(oRsTool.Parameters["YearOfEstimate"].ToString());
                estimateDetailStatementModel.Add(Model.GetEstimateDetailStatement(yearOfEstimate, true));
            }


            return(estimateDetailStatementModel);
        }
 public static CompanyProfile ToEntity(this CompanyProfileModel model)
 {
     return(model.MapTo <CompanyProfileModel, CompanyProfile>());
 }