/// <summary>
        /// Update sale basic
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        private bool CTS190_UpdateSaleBasic(List <tbt_ContractDocument> dt)
        {
            try
            {
                if (dt == null || dt.Count == 0)
                {
                    return(false);
                }

                ISaleContractHandler handlerRC = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;

                // Get SaleBasic (SB)
                List <tbt_SaleBasic> dtSB = handlerRC.GetTbt_SaleBasic(dt[0].ContractCode, dt[0].OCC, null);

                if (dtSB.Count == 0)
                {
                    return(false);
                }

                dtSB[0].DocReceiveDate = dt[0].CollectDocDate;
                dtSB[0].DocAuditResult = dt[0].DocAuditResult;
                dtSB[0].DocumentCode   = dt[0].DocumentCode;


                handlerRC.UpdateTbt_SaleBasic(dtSB[0]);


                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        //public ActionResult CMS020_SearchBar_Authority()
        //{
        //    return InitialScreenEnvironment("CMS020_SearchBar");

        //}

        ////[Initialize("CMS020_SearchBar")]
        //public ActionResult CMS020_SearchBar()
        //{
        //    return View();
        //}

        /// <summary>
        /// Retrieve contract data from tbt_RentalContractBasic or tbt_SaleBasic.
        /// </summary>
        /// <param name="strContractCode"></param>
        /// <param name="strUserCode"></param>
        /// <returns></returns>
        private dsContractData CMS020_RetrieveContract(string strContractCode, string strUserCode)
        {
            try
            {
                CommonUtil cm = new CommonUtil();
                strContractCode = cm.ConvertContractCode(strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                dsContractData                 dsContractData = new dsContractData();
                IRentralContractHandler        RentHand       = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;
                List <tbt_RentalContractBasic> dtRCB          = RentHand.GetTbt_RentalContractBasic(strContractCode, strUserCode);

                if (dtRCB.Count == 0)
                {
                    ISaleContractHandler SaleHand = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;
                    List <tbt_SaleBasic> dtSB     = SaleHand.GetTbt_SaleBasic(strContractCode, null, FlagType.C_FLAG_ON);

                    if (dtSB.Count > 0)
                    {
                        dsContractData.dtSB  = dtSB;
                        dsContractData.dtRCB = null;
                    }
                }
                else
                {
                    dsContractData.dtSB  = null;
                    dsContractData.dtRCB = dtRCB;
                }

                return(dsContractData);
            }
            catch (Exception) { throw; }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Reset data of screen
        /// </summary>
        /// <param name="lastOCC"></param>
        /// <returns></returns>
        public ActionResult ResetClick_CTS061(string lastOCC)
        {
            string expectedInstallCompleteDate = "";

            ObjectResultData res = new ObjectResultData();
            ObjectResultData resValidateBusiness = new ObjectResultData();
            CommonUtil       util = new CommonUtil();

            CTS061_ScreenParameter session;
            ISaleContractHandler   salehandler        = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;
            IUserControlHandler    usercontrolhandler = ServiceContainer.GetService <IUserControlHandler>() as IUserControlHandler;

            try
            {
                //Set screen to Initial state
                session = CTS061_GetImportData();
                expectedInstallCompleteDate = CommonUtil.TextDate(salehandler.GetTbt_SaleBasic(session.DSSaleContract.dtTbt_SaleBasic[0].ContractCode, lastOCC, true)[0].ExpectedInstallCompleteDate);
                var saleContractInfo = usercontrolhandler.GetSaleContractBasicInformationData(session.ContractCode, null);

                InitialScreen_CTS061(session.ContractCode);
                session = GetScreenObject <CTS061_ScreenParameter>();

                CTS061_ScreenOutputObject outObj = new CTS061_ScreenOutputObject()
                {
                    CanOperate                  = true,
                    ContractCode                = session.ContractCode,
                    ContractCodeShort           = util.ConvertContractCode(session.ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT),
                    ExpectedInstallCompleteDate = expectedInstallCompleteDate,
                    InstallationStatusCode      = saleContractInfo[0].InstallationStatusCode,
                    InstallationStatusCodeName  = saleContractInfo[0].InstallationStatusCodeName,
                    LastOCC              = salehandler.GetLastOCC(session.ContractCode),
                    ImportantFlag        = saleContractInfo[0].PurchaserCustomerImportant.GetValueOrDefault(),
                    OperationOfficeName  = CommonUtil.TextCodeName(saleContractInfo[0].OperationOfficeCode, saleContractInfo[0].OperationOfficeName),
                    PurchaserAddressEN   = saleContractInfo[0].PurchaserAddressEN,
                    PurchaserAddressLC   = saleContractInfo[0].PurchaserAddressLC,
                    PurchaserCustCode    = util.ConvertCustCode(saleContractInfo[0].PurchaserCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT),
                    PurchaserNameEN      = saleContractInfo[0].PurchaserNameEN,
                    PurchaserNameLC      = saleContractInfo[0].PurchaserNameLC,
                    RealCustomerCustCode = util.ConvertCustCode(saleContractInfo[0].RealCustomerCustCode, CommonUtil.CONVERT_TYPE.TO_SHORT),
                    SiteAddressEN        = saleContractInfo[0].SiteAddressEN,
                    SiteAddressLC        = saleContractInfo[0].SiteAddressLC,
                    SiteCode             = util.ConvertSiteCode(saleContractInfo[0].SiteCode, CommonUtil.CONVERT_TYPE.TO_SHORT),
                    SiteNameEN           = saleContractInfo[0].SiteNameEN,
                    SiteNameLC           = saleContractInfo[0].SiteNameLC
                };

                res.ResultData = outObj;
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Ejemplo n.º 4
0
        public ActionResult CMS180()
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                CMS180_ScreenParameter param = GetScreenObject <CMS180_ScreenParameter>();
                //for test
                //param.ContractCode = "N2700112";
                //param.InstallationSlipNo = "70000120120101";

                //Prepare for show section
                if (!CommonUtil.IsNullOrEmpty(param))
                {
                    ViewBag.ContractCode       = param.ContractCode;
                    ViewBag.InstallationSlipNo = param.InstallationSlipNo;
                }


                if (string.IsNullOrEmpty(param.ContractCode) == false)
                {
                    //Finding service type code
                    CommonUtil c = new CommonUtil();
                    string     longContractCode = c.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                    //Rental
                    IRentralContractHandler        handlerR         = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;
                    List <tbt_RentalContractBasic> dtRentalContract = handlerR.GetTbt_RentalContractBasic(longContractCode, null);
                    if (dtRentalContract.Count > 0)
                    {
                        param.ServiceTypeCode = ServiceType.C_SERVICE_TYPE_RENTAL;
                    }
                    else
                    {
                        // Sale
                        ISaleContractHandler handlerS       = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;
                        List <tbt_SaleBasic> dtSaleContract = handlerS.GetTbt_SaleBasic(longContractCode, null, true);
                        if (dtSaleContract.Count > 0)
                        {
                            param.ServiceTypeCode = ServiceType.C_SERVICE_TYPE_SALE;
                        }
                    }
                }
                ViewBag.ServiceTypeCode = param.ServiceTypeCode;
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            //ViewBag.AttachKey = GetCurrentKey();
            return(View());
        }
        /// <summary>
        /// Check data authority
        /// </summary>
        /// <param name="dtContractDocReceive"></param>
        /// <returns></returns>
        private bool CTS190_CheckDataAuthority(dtContractDocHeader dtContractDocReceive)
        {
            bool hasAuthority = false;

            // Old
            //List<OfficeDataDo> list = (from p in CommonUtil.dsTransData.dtOfficeData
            //                           where p.OfficeCode == dtContractDocReceive.ContractOfficeCode ||
            //                                 p.OfficeCode == dtContractDocReceive.OperationOfficeCode
            //                           select p).ToList<OfficeDataDo>();

            //hasAuthority = (list.Count > 0);

            IRentralContractHandler handlerRC   = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;
            ISaleContractHandler    handlerSale = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;
            // get RCB
            List <tbt_RentalContractBasic> dtRCB = handlerRC.GetTbt_RentalContractBasic(dtContractDocReceive.ContractCode, null);
            // get Sale basic
            List <tbt_SaleBasic> dtSB = handlerSale.GetTbt_SaleBasic(dtContractDocReceive.ContractCode, null, true);


            List <OfficeDataDo> list = new List <OfficeDataDo>();

            if (dtRCB.Count > 0)
            {
                list = (from p in CommonUtil.dsTransData.dtOfficeData
                        where p.OfficeCode == dtRCB[0].ContractOfficeCode ||
                        p.OfficeCode == dtRCB[0].OperationOfficeCode
                        select p).ToList <OfficeDataDo>();
            }
            else if (dtSB.Count > 0)
            {
                list = (from p in CommonUtil.dsTransData.dtOfficeData
                        where p.OfficeCode == dtSB[0].ContractOfficeCode ||
                        p.OfficeCode == dtSB[0].OperationOfficeCode
                        select p).ToList <OfficeDataDo>();
            }

            hasAuthority = (list.Count > 0);

            return(hasAuthority);
        }
        //BLP014 - calculate difference of monthly fee

        /// <summary>
        /// Process BLP014 - Calculate difference monthly fee
        /// </summary>
        /// <param name="contractCode"></param>
        /// <param name="billingOCC"></param>
        /// <param name="changeDate"></param>
        /// <param name="monthlyBillingAmount"></param>
        /// <returns></returns>
        public AdjustOnNextPeriod CalculateDifferenceMonthlyFee(string contractCode, string billingOCC, DateTime changeDate, decimal monthlyBillingAmount, string callerObject)
        {
            var billingBasic = this.GetBillingBasic(contractCode, billingOCC, null, null, null, CurrencyUtil.C_CURRENCY_LOCAL, CurrencyUtil.C_CURRENCY_US);
            AdjustOnNextPeriod billingAdjustOnNextPeriod = null;

            if (billingBasic.Count == 0)
            {
                return(null);
            }

            var iChangeDate = Convert.ToInt32(changeDate.ToString("yyyyMMdd"));
            var iLastBillingDate_plus2day = Convert.ToInt32(billingBasic[0].LastBillingDate.Value.AddDays(2).ToString("yyyyMMdd"));
            var iLastBillingDate          = Convert.ToInt32(billingBasic[0].LastBillingDate.Value.ToString("yyyyMMdd"));


            // Case #1 : Change monthly fee
            if (monthlyBillingAmount > 0 || callerObject == ProcessID.C_PROCESS_ID_MANAGE_BILLING_BASIC_RESUME || callerObject == ProcessID.C_PROCESS_ID_MANAGE_BILLING_BASIC_STOP)
            {
                // Set start / end date
                DateTime dtBillingStartDate = changeDate;
                //DateTime dtBillingEndDate =  billingBasic[0].LastBillingDate.HasValue? billingBasic[0].LastBillingDate.Value.AddDays(1) : new DateTime(1,1,1);

                DateTime dtBillingEndDate = billingBasic[0].LastBillingDate.HasValue ? billingBasic[0].LastBillingDate.Value : new DateTime(1, 1, 1);


                if (iChangeDate <= iLastBillingDate)
                {
                    //decimal decNewBillingAmount = this.CalCulateBillingAmountPerHistory(dtBillingStartDate, dtBillingEndDate, monthlyBillingAmount, billingBasic[0].CalDailyFeeStatus);
                    //decimal decOldBillingAmount = this.CalculateBillingAmount(contractCode, billingOCC, billingBasic[0].CalDailyFeeStatus, dtBillingStartDate, dtBillingEndDate);
                    //decimal decDiffBillingAmount = 0;

                    //if (billingBasic[0].AdjustBillingPeriodAmount != null)
                    //{
                    //    decDiffBillingAmount = (decNewBillingAmount - decOldBillingAmount) + Convert.ToDecimal(billingBasic[0].AdjustBillingPeriodAmount);
                    //}
                    //else
                    //{
                    //    decDiffBillingAmount = (decNewBillingAmount - decOldBillingAmount);
                    //}

                    decimal decDiffMonthlyBillingAmount = monthlyBillingAmount - Convert.ToDecimal(billingBasic[0].MonthlyBillingAmount);
                    decimal decDiffBillingAmount        = this.CalCulateBillingAmountPerHistory(dtBillingStartDate, dtBillingEndDate, decDiffMonthlyBillingAmount, billingBasic[0].CalDailyFeeStatus) + Convert.ToDecimal(billingBasic[0].AdjustBillingPeriodAmount);
                    decDiffBillingAmount = RoundUp(decDiffBillingAmount, 2);                            //Add by Jutarat A. on 27012014

                    if (monthlyBillingAmount > Convert.ToDecimal(billingBasic[0].MonthlyBillingAmount)) // In case increase monthly fee, generate billing detail of "Difference of contract fee"
                    {
                        if (decDiffBillingAmount > 0)
                        {
                            DateTime?autoTransferDate = null;
                            if (billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_AUTO_TRANSFER || billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_CREDIT_CARD_TRANSFER)
                            {
                                autoTransferDate = this.GetNextAutoTransferDate(contractCode, billingOCC, billingBasic[0].PaymentMethod);

                                if (autoTransferDate.HasValue == false)
                                {
                                    billingBasic[0].PaymentMethod = PaymentMethod.C_PAYMENT_METHOD_BANK_TRANSFER;
                                }
                            }

                            // Billing type
                            var billingTypeDetail = this.GetBillingTypeDetailContinues(contractCode, billingOCC, BillingTypeGroup.C_BILLING_TYPE_GROUP_CONTINUES);

                            // CREATE Billing detail
                            if (billingTypeDetail.Count > 0)
                            {
                                string strBillingTypeCode = this.GetBillingTypeDifferenceFee(billingTypeDetail[0].BillingTypeCode);
                                // Prepare BillingDetail (data object)
                                tbt_BillingDetail billingDetail = new tbt_BillingDetail()
                                {
                                    ContractCode     = contractCode,
                                    BillingOCC       = billingOCC,
                                    IssueInvDate     = DateTime.Now,
                                    IssueInvFlag     = true,
                                    BillingTypeCode  = strBillingTypeCode,
                                    BillingAmount    = decDiffBillingAmount,
                                    BillingStartDate = dtBillingStartDate,
                                    BillingEndDate   = dtBillingEndDate,
                                    PaymentMethod    = billingBasic[0].PaymentMethod,
                                    PaymentStatus    = ((billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_AUTO_TRANSFER || billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_CREDIT_CARD_TRANSFER) ?
                                                        PaymentStatus.C_PAYMENT_STATUS_DETAIL_AUTO_CREDIT :
                                                        PaymentStatus.C_PAYMENT_STATUS_DETAIL_BANK_COLLECT),
                                    AutoTransferDate   = autoTransferDate,
                                    StartOperationDate = billingBasic[0].StartOperationDate
                                };

                                IRentralContractHandler rentalContralHandler             = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;
                                List <dtTbt_RentalContractBasicForView> dtRentalContract = rentalContralHandler.GetTbt_RentalContractBasicForView(contractCode);
                                if (dtRentalContract.Count > 0)
                                {
                                    billingDetail.ContractOCC = dtRentalContract[0].LastOCC;
                                }
                                else
                                {
                                    ISaleContractHandler saleHandler = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;
                                    List <tbt_SaleBasic> dtSaleBasic = saleHandler.GetTbt_SaleBasic(contractCode, null, true);
                                    if (dtSaleBasic != null && dtSaleBasic.Count > 0)
                                    {
                                        billingDetail.ContractOCC = dtSaleBasic[0].OCC;
                                    }
                                }
                                billingDetail.ForceIssueFlag = false;
                                // CREATE
                                this.ManageBillingDetail(billingDetail);

                                billingAdjustOnNextPeriod = new AdjustOnNextPeriod(); // set AdjustOnNextPeriod to empty
                            }
                        }
                        else if (decDiffBillingAmount < 0)
                        {
                            billingAdjustOnNextPeriod = new AdjustOnNextPeriod()
                            {
                                AdjustType = AdjustType.C_ADJUST_TYPE_REDUCT,
                                AdjustBillingPeriodAmount    = decDiffBillingAmount,
                                AdjustBillingPeriodStartDate = dtBillingStartDate,
                                AdjustBillingPeriodEndDate   = dtBillingEndDate
                            };
                        }
                        else // decDiffBillingAmount == billingBasic[0].AdjustBillingPeriodAmount
                        {
                            billingAdjustOnNextPeriod = new AdjustOnNextPeriod(); // set AdjustOnNextPeriod to empty
                        }
                    }
                    else if (monthlyBillingAmount < Convert.ToDecimal(billingBasic[0].MonthlyBillingAmount)) // In case decrease monthly fee, calculate "Adjust-on-next-period amount"
                    {
                        if (decDiffBillingAmount > 0)
                        {
                            billingAdjustOnNextPeriod = new AdjustOnNextPeriod()
                            {
                                AdjustType = AdjustType.C_ADJUST_TYPE_ADD,
                                AdjustBillingPeriodAmount    = decDiffBillingAmount,
                                AdjustBillingPeriodStartDate = dtBillingStartDate,
                                AdjustBillingPeriodEndDate   = dtBillingEndDate
                            };
                        }
                        else if (decDiffBillingAmount < 0)
                        {
                            billingAdjustOnNextPeriod = new AdjustOnNextPeriod()
                            {
                                AdjustType = AdjustType.C_ADJUST_TYPE_REDUCT,
                                AdjustBillingPeriodAmount    = decDiffBillingAmount,
                                AdjustBillingPeriodStartDate = dtBillingStartDate,
                                AdjustBillingPeriodEndDate   = dtBillingEndDate
                            };
                        }
                        else
                        {
                            billingAdjustOnNextPeriod = new AdjustOnNextPeriod();
                        }
                    }
                }
            }
            else // Case #2 : Monthly billing amount = 0, and it's not during stop , cancel contract   --- 4.
            {
                if (iChangeDate >= iLastBillingDate_plus2day)
                {
                    // Set start / end date
                    DateTime dtBillingStartDate = billingBasic[0].LastBillingDate.HasValue ? billingBasic[0].LastBillingDate.Value.AddDays(1) : new DateTime(1, 1, 1);
                    DateTime dtBillingEndDate   = changeDate.AddDays(-1); // tt

                    decimal decBillingAmount = this.CalculateBillingAmount(contractCode, billingOCC, billingBasic[0].CalDailyFeeStatus, dtBillingStartDate, dtBillingEndDate);

                    DateTime?autoTransferDate = null;
                    if (billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_AUTO_TRANSFER || billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_CREDIT_CARD_TRANSFER)
                    {
                        autoTransferDate = this.GetNextAutoTransferDate(contractCode, billingOCC, billingBasic[0].PaymentMethod);

                        if (autoTransferDate.HasValue == false)
                        {
                            billingBasic[0].PaymentMethod = PaymentMethod.C_PAYMENT_METHOD_BANK_TRANSFER;
                        }
                    }

                    // Billing type
                    var billingTypeDetail = this.GetBillingTypeDetailContinues(contractCode, billingOCC, BillingTypeGroup.C_BILLING_TYPE_GROUP_CONTINUES);

                    // CREATE Billing detail
                    tbt_BillingDetail billingDetail        = new tbt_BillingDetail();
                    tbt_BillingDetail billingDetail_manage = new tbt_BillingDetail();
                    if (billingTypeDetail.Count > 0)
                    {
                        string strBillingTypeCode = this.GetBillingTypeDifferenceFee(billingTypeDetail[0].BillingTypeCode);
                        // Prepare BillingDetail (data object)
                        billingDetail = new tbt_BillingDetail()
                        {
                            ContractCode     = contractCode,
                            BillingOCC       = billingOCC,
                            IssueInvDate     = DateTime.Now,
                            IssueInvFlag     = true,
                            BillingTypeCode  = strBillingTypeCode,
                            BillingAmount    = decBillingAmount,
                            BillingStartDate = dtBillingStartDate,
                            BillingEndDate   = dtBillingEndDate,
                            PaymentMethod    = billingBasic[0].PaymentMethod,
                            PaymentStatus    = ((billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_AUTO_TRANSFER || billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_CREDIT_CARD_TRANSFER) ?
                                                PaymentStatus.C_PAYMENT_STATUS_DETAIL_AUTO_CREDIT :
                                                PaymentStatus.C_PAYMENT_STATUS_DETAIL_BANK_COLLECT),
                            AutoTransferDate   = autoTransferDate,
                            StartOperationDate = billingBasic[0].StartOperationDate
                        };

                        IRentralContractHandler rentalContralHandler             = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;
                        List <dtTbt_RentalContractBasicForView> dtRentalContract = rentalContralHandler.GetTbt_RentalContractBasicForView(contractCode);
                        if (dtRentalContract.Count > 0)
                        {
                            billingDetail.ContractOCC = dtRentalContract[0].LastOCC;
                        }
                        else
                        {
                            ISaleContractHandler saleHandler = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;
                            List <tbt_SaleBasic> dtSaleBasic = saleHandler.GetTbt_SaleBasic(contractCode, null, true);
                            if (dtSaleBasic != null && dtSaleBasic.Count > 0)
                            {
                                billingDetail.ContractOCC = dtSaleBasic[0].OCC;
                            }
                        }
                        billingDetail.ForceIssueFlag = false;
                        // CREATE !
                        billingDetail_manage = this.ManageBillingDetail(billingDetail);
                    }

                    // CREATE Invoice
                    tbt_Invoice newInvoice = new tbt_Invoice()
                    {
                        AutoTransferDate     = autoTransferDate,
                        BillingTargetCode    = billingBasic[0].BillingTargetCode,
                        BillingTypeCode      = billingDetail.BillingTypeCode,
                        InvoicePaymentStatus = ((billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_AUTO_TRANSFER || billingBasic[0].PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_CREDIT_CARD_TRANSFER) ?
                                                PaymentStatus.C_PAYMENT_STATUS_INV_AUTO_CREDIT :
                                                PaymentStatus.C_PAYMENT_STATUS_INV_BANK_COLLECT),
                        IssueInvFlag  = true,
                        PaymentMethod = billingBasic[0].PaymentMethod,
                        IssueInvDate  = changeDate,
                    };

                    // CREATE !
                    List <tbt_BillingDetail> billingDetailList = new List <tbt_BillingDetail>();
                    billingDetailList.Add(billingDetail_manage);
                    this.ManageInvoiceByCommand(newInvoice, billingDetailList, false);
                }
                else if (iChangeDate <= iLastBillingDate)
                {
                    var invoice_betweenChangeDate = this.GetInvoiceOfChangeDate(contractCode, billingOCC, changeDate);

                    string[] statusList = { PaymentStatus.C_PAYMENT_STATUS_INV_BANK_COLLECT,
                                            PaymentStatus.C_PAYMENT_STATUS_INV_AUTO_CREDIT,
                                            PaymentStatus.C_PAYMENT_STATUS_FAIL_AUTO_INV_BANK,
                                            PaymentStatus.C_PAYMENT_STATUS_FAIL_NOTE_INV_BANK,
                                            PaymentStatus.C_PAYMENT_STATUS_FAIL_CHEQUE_INV_BANK,
                                            PaymentStatus.C_PAYMENT_STATUS_COUNTER_BAL };

                    if (invoice_betweenChangeDate.Count > 0 && statusList.Contains(invoice_betweenChangeDate[0].InvoicePaymentStatus))
                    {
                        // Cancel Invoice !!

                        var header = GetTbt_Invoice(invoice_betweenChangeDate[0].InvoiceNo, null);  // null mean Lastest InvoiceOCC
                        List <tbt_BillingDetail> detail = new List <tbt_BillingDetail>();
                        if (header.Count > 0)
                        {
                            detail = this.GetTbt_BillingDetailOfInvoice(header[0].InvoiceNo, header[0].InvoiceOCC);

                            this.UpdateInvoicePaymentStatus(header[0], detail, PaymentStatus.C_PAYMENT_STATUS_CANCEL);
                        }
                    }
                }
            }

            if (callerObject != ProcessID.C_PROCESS_ID_MANAGE_BILLING_BASIC_CANCEL)
            {
                // Create billing history
                tbt_MonthlyBillingHistory billingHistory = new tbt_MonthlyBillingHistory()
                {
                    ContractCode         = contractCode,
                    BillingOCC           = billingOCC,
                    MonthlyBillingAmount = monthlyBillingAmount,
                    BillingStartDate     = changeDate
                };
                this.CreateMonthlyBillingHistory(billingHistory);
            }


            return(billingAdjustOnNextPeriod);
        }
Ejemplo n.º 7
0
        //BackClick perform in javascript

        #endregion

        #region Method

        /// <summary>
        /// Check system suspending, user’s permission and user’s authority of screen
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult CTS061_Authority(CTS061_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                CommonUtil           util          = new CommonUtil();
                ICommonHandler       commonHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                ISaleContractHandler saleHandler   = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;

                //1.1 Check suspending
                if (commonHandler.IsSystemSuspending())
                {
                    res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0049, new string[] { String.Format("Contract Code: {0}", param.ContractCode) }, null);
                    return(Json(res));
                }

                //1.2 Check user's permission
                if (!CheckUserPermission(ScreenID.C_SCREEN_ID_CQ12_CHANGE_COMPLETE_INSTALLATION_DATE, FunctionID.C_FUNC_ID_OPERATE))
                {
                    res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0053, null, null);
                    return(Json(res));
                }

                // Check parameter
                if ((param == null) ||
                    (String.IsNullOrEmpty(param.ContractCode)))
                {
                    //if (String.IsNullOrEmpty(CommonUtil.dsTransData.dtCommonSearch.ContractCode))
                    //{
                    //    // Not valid
                    //    //res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0011, new string[] { "Contract Code" }, null);
                    //    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0147, null, null);
                    //    return Json(res);
                    //}
                    //else
                    //{
                    //    param.ContractCode = CommonUtil.dsTransData.dtCommonSearch.ContractCode;
                    //}

                    if (param.CommonSearch != null)
                    {
                        if (CommonUtil.IsNullOrEmpty(param.CommonSearch.ContractCode) == false)
                        {
                            param.ContractCode = param.CommonSearch.ContractCode;
                        }
                    }
                    if (String.IsNullOrEmpty(param.ContractCode))
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0147, null, null);
                        return(Json(res));
                    }
                }

                // Check is contact exists
                var contractObj = saleHandler.GetTbt_SaleBasic(util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG), null, true);
                if ((contractObj == null) ||
                    (contractObj.Count == 0))
                {
                    // Not found
                    //res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0011, new string[] { String.Format("Contract Code: {0}", param.ContractCode) }, null);
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0124, null, null);
                    return(Json(res));
                }

                string lastOCC        = saleHandler.GetLastOCC(contractObj[0].ContractCode);
                var    dsSaleContract = saleHandler.GetEntireContract(contractObj[0].ContractCode, lastOCC);

                if ((dsSaleContract != null) &&
                    (dsSaleContract.dtTbt_SaleBasic != null) &&
                    (dsSaleContract.dtTbt_SaleBasic.Count != 0))
                {
                    /*
                     * if (CommonUtil.dsTransData.dtOfficeData.FindAll(delegate(OfficeDataDo s) { return s.OfficeCode == dsSaleContract.dtTbt_SaleBasic[0].ContractOfficeCode; }).Count == 0)
                     * {
                     *  res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0063, null, null);
                     *  return Json(res);
                     * }
                     *
                     * if (CommonUtil.dsTransData.dtOfficeData.FindAll(delegate(OfficeDataDo s) { return s.OfficeCode == dsSaleContract.dtTbt_SaleBasic[0].OperationOfficeCode; }).Count == 0)
                     * {
                     *  res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0063, null, null);
                     *  return Json(res);
                     * }*/

                    var existsContarctOffice = CommonUtil.dsTransData.dtOfficeData.Where(x => x.OfficeCode == dsSaleContract.dtTbt_SaleBasic[0].ContractOfficeCode);
                    var existsOperateOffice  = CommonUtil.dsTransData.dtOfficeData.Where(x => x.OfficeCode == dsSaleContract.dtTbt_SaleBasic[0].OperationOfficeCode);

                    if ((existsContarctOffice.Count() <= 0) && (existsOperateOffice.Count() <= 0))
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0063, null, null);
                        res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                        return(Json(res));
                    }

                    if (dsSaleContract.dtTbt_SaleBasic[0].InstallationCompleteFlag == FlagType.C_FLAG_ON)
                    {
                        res.AddErrorMessage("Contract", MessageUtil.MessageList.MSG3058, null, null);
                        return(Json(res));
                    }
                }
                else
                {
                    res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0011, new string[] { String.Format("Contract Code: {0}", param.ContractCode) }, null);
                    return(Json(res));
                }

                param.ScreenParameter = new CTS061_Parameter()
                {
                    contractCode = util.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG)
                };
                param.ContractCode = param.ScreenParameter.contractCode;

                return(InitialScreenEnvironment <CTS061_ScreenParameter>("CTS061", param, res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
        public ActionResult CMS420()
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                CMS420_ScreenParameter param = GetScreenObject <CMS420_ScreenParameter>();
                CommonUtil             cm    = new CommonUtil();

                ViewBag._ContractCode = param.ContractCode;
                ViewBag._BillingOCC   = param.BillingOCC;

                string strContractCode = cm.ConvertContractCode(param.ContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                ViewBag._CallerScreen = param.CallerScreenID;

                IViewBillingHandler   viewBillingHandler = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;
                IBillingHandler       billingHandler     = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
                ICommonHandler        comHand            = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doMiscTypeCode> tmpCurrencies      = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                {
                    new doMiscTypeCode()
                    {
                        FieldName = MiscType.C_CURRENCT,
                        ValueCode = "%"
                    }
                }).ToList();

                List <dtViewBillingOccList>            viewBillingOccListData        = viewBillingHandler.GetViewBillingOccList(strContractCode);
                List <dtViewBillingBasic>              viewBillingBasicData          = viewBillingHandler.GetViewBillingBasic(strContractCode, param.BillingOCC, null, null, null, null);
                List <doTbt_MonthlyBillingHistoryList> monthlyBillingHistoryListData = billingHandler.GetBillingHistoryList(strContractCode, param.BillingOCC, CurrencyUtil.C_CURRENCY_LOCAL, CurrencyUtil.C_CURRENCY_US);

                for (int i = 0; i < viewBillingOccListData.Count(); i++)
                {
                    viewBillingOccListData[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                }
                for (int i = 0; i < viewBillingBasicData.Count(); i++)
                {
                    viewBillingBasicData[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                }
                for (int i = 0; i < monthlyBillingHistoryListData.Count(); i++)
                {
                    monthlyBillingHistoryListData[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                }

                ICommonHandler handlerCommon = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

                ViewBag.IsSpecialCareful                     = "0";
                ViewBag.txtVATUnchargedBillingTarget         = false;
                ViewBag.txtResultBasedMaintenanceBillingFlag = false;

                if (viewBillingOccListData.Count > 0)
                {
                    //Language mapping
                    CommonUtil.MappingObjectLanguage <dtViewBillingOccList>(viewBillingOccListData);

                    ViewBag.txtContractCode = cm.ConvertContractCode(viewBillingOccListData[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                }

                if (param.BillingOCC != null)
                {
                    if (viewBillingBasicData.Count > 0)
                    {
                        //Language mapping
                        CommonUtil.MappingObjectLanguage <dtViewBillingBasic>(viewBillingBasicData);

                        //Misc mapping
                        MiscTypeMappingList miscMapping = new MiscTypeMappingList();
                        miscMapping.AddMiscType(viewBillingBasicData.ToArray <dtViewBillingBasic>());
                        handlerCommon.MiscTypeMappingList(miscMapping);

                        if (viewBillingBasicData[0].CarefulFlag.HasValue)
                        {
                            ViewBag.IsSpecialCareful = viewBillingBasicData[0].CarefulFlag.Value == true ? "1" : "0";
                        }

                        ViewBag.IsPaymentMethod = viewBillingBasicData[0].PaymentMethod;

                        ViewBag.txtBillingCode               = string.Format("{0}-{1}", cm.ConvertContractCode(viewBillingBasicData[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT), viewBillingBasicData[0].BillingOCC);
                        ViewBag.txtBillingOffice             = CommonUtil.TextCodeName(viewBillingBasicData[0].BillingOfficeCode, viewBillingBasicData[0].OfficeName);
                        ViewBag.txtDebtTracingOffice         = CommonUtil.TextCodeName(viewBillingBasicData[0].DebtTracingOfficeCode, viewBillingBasicData[0].DebtTracingOfficeName);
                        ViewBag.txtBillingTargetCode         = cm.ConvertBillingTargetCode(viewBillingBasicData[0].BillingTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        ViewBag.txtPreviousBillingTargetCode = cm.ConvertBillingTargetCode(viewBillingBasicData[0].PreviousBillingTargetCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                        ViewBag.txtCustomerType              = viewBillingBasicData[0].CustTypeCodeName;
                        ViewBag.txtBillingClientNameEN       = viewBillingBasicData[0].FullNameEN;
                        ViewBag.txtBillingClientBranchNameEN = viewBillingBasicData[0].BranchNameEN;
                        ViewBag.txtBillingClientAddressEN    = viewBillingBasicData[0].AddressEN;
                        ViewBag.txtBillingClientNameLC       = viewBillingBasicData[0].FullNameLC;
                        ViewBag.txtBillingClientBranchNameLC = viewBillingBasicData[0].BranchNameLC;
                        ViewBag.txtBillingClientAddressLC    = viewBillingBasicData[0].AddressLC;
                        ViewBag.txtMonthlyBillingAmount      = viewBillingBasicData[0].TextTransferMonthlyBillingAmount;
                        //ViewBag.txtMonthlyBillingAmount = CommonUtil.TextNumeric(viewBillingBasicData[0].MonthlyBillingAmount);
                        ViewBag.txtPaymentMethod                   = viewBillingBasicData[0].PaymentMethodName;
                        ViewBag.txtBillingCycle                    = CommonUtil.TextNumeric(viewBillingBasicData[0].BillingCycle, 0);
                        ViewBag.txtCreditTerm                      = CommonUtil.TextNumeric(viewBillingBasicData[0].CreditTerm);
                        ViewBag.txtCalculationDailyFee             = viewBillingBasicData[0].CalDailyFeeStatusName;
                        ViewBag.txtLastBillingDate                 = CommonUtil.TextDate(viewBillingBasicData[0].LastBillingDate);
                        ViewBag.txtManagementCodeForSortDetails    = viewBillingBasicData[0].SortingType;
                        ViewBag.txtAdjustEndingDateOfBillingPeriod = CommonUtil.TextDate(viewBillingBasicData[0].AdjustEndDate);
                        ViewBag.txtBillingFlag                     = viewBillingBasicData[0].StopBillingFlagCodeName;
                        ViewBag.txtVATUnchargedBillingTarget       = viewBillingBasicData[0].VATUnchargedFlag.HasValue ? viewBillingBasicData[0].VATUnchargedFlag.Value : false;
                        ViewBag.txtBalanceOfDepositFee             = viewBillingBasicData[0].TextTransferBalanceDeposit;
                        //ViewBag.txtBalanceOfDepositFee = CommonUtil.TextNumeric(viewBillingBasicData[0].BalanceDeposit);
                        ViewBag.txtMonthlyFeeBeforeStop = viewBillingBasicData[0].TextTransferMonthlyFeeBeforeStop;
                        //ViewBag.txtMonthlyFeeBeforeStop = CommonUtil.TextNumeric(viewBillingBasicData[0].MonthlyFeeBeforeStop);
                        ViewBag.txtResultBasedMaintenanceBillingFlag = viewBillingBasicData[0].ResultBasedMaintenanceFlag.HasValue ? viewBillingBasicData[0].ResultBasedMaintenanceFlag.Value : false;
                        ViewBag.txtLastPaymentConditionChangingDate  = CommonUtil.TextDate(viewBillingBasicData[0].ChangeDate);
                        ViewBag.txtRegisteringDateOfLastChanging     = CommonUtil.TextDate(viewBillingBasicData[0].ChangeDate);
                        ViewBag.txtApproveNo         = viewBillingBasicData[0].ApproveNo;
                        ViewBag.txtDocumentReceiving = viewBillingBasicData[0].DocAuditResultName;

                        ViewBag.txtAdjustmentType      = viewBillingBasicData[0].AdjustType;
                        ViewBag.txtAdjustBillingAmount = viewBillingBasicData[0].TextTransferAdjustBillingPeriodAmount;
                        //ViewBag.txtAdjustBillingAmount = CommonUtil.TextNumeric(viewBillingBasicData[0].AdjustBillingPeriodAmount);

                        ViewBag.txtAdjustBillingPeriodStartDate = CommonUtil.TextDate(viewBillingBasicData[0].AdjustBillingPeriodStartDate);
                        ViewBag.txtAdjustBillingPeriodEndDate   = CommonUtil.TextDate(viewBillingBasicData[0].AdjustBillingPeriodEndDate);

                        ViewBag.txtIDNo = viewBillingBasicData[0].IDNo; //Add by Jutarat A. on 12122013
                    }

                    if (monthlyBillingHistoryListData != null)
                    {
                        if (monthlyBillingHistoryListData.Count > 0)
                        {
                            ViewBag.txtLastMonthlyBillingAmount = monthlyBillingHistoryListData[0].TextTransferMonthlyBillingAmount;
                            ViewBag.txtLastDate = CommonUtil.TextDate(monthlyBillingHistoryListData[0].BillingStartDate);
                            ViewBag.txtBillingAmountBeforeChanging1 = monthlyBillingHistoryListData.Count < 2 ? null : monthlyBillingHistoryListData[1].TextTransferMonthlyBillingAmount;
                            ViewBag.txtDateBeforeChanging1          = monthlyBillingHistoryListData.Count < 2 ? null : CommonUtil.TextDate(monthlyBillingHistoryListData[1].BillingStartDate);
                            ViewBag.txtBillingAmountBeforeChanging2 = monthlyBillingHistoryListData.Count < 3 ? null : monthlyBillingHistoryListData[2].TextTransferMonthlyBillingAmount;
                            ViewBag.txtDateBeforeChanging2          = monthlyBillingHistoryListData.Count < 3 ? null : CommonUtil.TextDate(monthlyBillingHistoryListData[2].BillingStartDate);
                            ViewBag.txtBillingAmountBeforeChanging3 = monthlyBillingHistoryListData.Count < 4 ? null : monthlyBillingHistoryListData[3].TextTransferMonthlyBillingAmount;
                            ViewBag.txtDateBeforeChanging3          = monthlyBillingHistoryListData.Count < 4 ? null : CommonUtil.TextDate(monthlyBillingHistoryListData[3].BillingStartDate);
                            ViewBag.txtBillingAmountBeforeChanging4 = monthlyBillingHistoryListData.Count < 5 ? null : monthlyBillingHistoryListData[4].TextTransferMonthlyBillingAmount;
                            ViewBag.txtDateBeforeChanging4          = monthlyBillingHistoryListData.Count < 5 ? null : CommonUtil.TextDate(monthlyBillingHistoryListData[4].BillingStartDate);
                            ViewBag.txtBillingAmountBeforeChanging5 = monthlyBillingHistoryListData.Count < 6 ? null : monthlyBillingHistoryListData[5].TextTransferMonthlyBillingAmount;
                            ViewBag.txtDateBeforeChanging5          = monthlyBillingHistoryListData.Count < 6 ? null : CommonUtil.TextDate(monthlyBillingHistoryListData[5].BillingStartDate);
                        }
                    }
                }

                //Finding service type code
                if (string.IsNullOrEmpty(strContractCode) == false)
                {
                    //Rental
                    IRentralContractHandler        handlerR         = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;
                    List <tbt_RentalContractBasic> dtRentalContract = handlerR.GetTbt_RentalContractBasic(strContractCode, null);
                    if (dtRentalContract.Count > 0)
                    {
                        param.ServiceTypeCode   = ServiceType.C_SERVICE_TYPE_RENTAL;
                        ViewBag.ServiceTypeCode = ServiceType.C_SERVICE_TYPE_RENTAL;
                        ViewBag.ProductTypeCode = dtRentalContract[0].ProductTypeCode;
                    }
                    else
                    {
                        // Sale
                        ISaleContractHandler handlerS       = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;
                        List <tbt_SaleBasic> dtSaleContract = handlerS.GetTbt_SaleBasic(strContractCode, null, true);
                        if (dtSaleContract.Count > 0)
                        {
                            param.ServiceTypeCode   = ServiceType.C_SERVICE_TYPE_SALE;
                            ViewBag.ServiceTypeCode = ServiceType.C_SERVICE_TYPE_SALE;
                            ViewBag.ProductTypeCode = dtSaleContract[0].ProductTypeCode;
                        }
                    }
                }

                return(View());
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Import quotation data
        /// </summary>
        /// <param name="ScreenID"></param>
        /// <param name="DataList"></param>
        /// <returns></returns>
        public ActionResult QUS050_ImportData(string ScreenID, List <string> DataList)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                dsImportData importData = new dsImportData()
                {
                    dtTbt_QuotationCustomer           = new List <tbt_QuotationCustomer>(),
                    dtTbt_QuotationSite               = new List <tbt_QuotationSite>(),
                    dtTbt_QuotationTarget             = new List <tbt_QuotationTarget>(),
                    dtTbt_QuotationBasic              = new List <tbt_QuotationBasic>(),
                    dtTbt_QuotationOperationType      = new List <tbt_QuotationOperationType>(),
                    dtTbt_QuotationInstrumentDetails  = new List <tbt_QuotationInstrumentDetails>(),
                    dtTbt_QuotationFacilityDetails    = new List <tbt_QuotationFacilityDetails>(),
                    dtTbt_QuotationBeatGuardDetails   = new List <tbt_QuotationBeatGuardDetails>(),
                    dtTbt_QuotationSentryGuardDetails = new List <tbt_QuotationSentryGuardDetails>(),
                    dtTbt_QuotationMaintenanceLinkage = new List <tbt_QuotationMaintenanceLinkage>()
                };

                #region Mapping Data

                List <object> impLst = new List <object>()
                {
                    importData.dtTbt_QuotationCustomer,
                    importData.dtTbt_QuotationSite,
                    importData.dtTbt_QuotationTarget,
                    importData.dtTbt_QuotationBasic,
                    importData.dtTbt_QuotationOperationType,
                    importData.dtTbt_QuotationInstrumentDetails,
                    importData.dtTbt_QuotationFacilityDetails,
                    importData.dtTbt_QuotationBeatGuardDetails,
                    importData.dtTbt_QuotationSentryGuardDetails,
                    importData.dtTbt_QuotationMaintenanceLinkage
                };

                string      filePath = CommonUtil.WebPath + SECOM_AJIS.Common.Util.ConstantValue.CommonValue.IMPORT_TEMPLATE_FILE;
                XmlDocument doc      = new XmlDocument();
                doc.Load(filePath);
                XmlNodeList nodes = doc.SelectNodes("tables/table");

                bool          isError     = false;
                List <string> setFailList = new List <string>();
                int           lineIdx     = 0;
                int           nodeIdx     = 0;
                for (; nodeIdx < nodes.Count; nodeIdx++)
                {
                    if (lineIdx < DataList.Count)
                    {
                        /* --- Check Table name --- */
                        string[] tbName = DataList[lineIdx].Split(",".ToCharArray());
                        if (nodes[nodeIdx].Attributes["name"].Value != tbName[0] ||
                            lineIdx + 1 >= DataList.Count)
                        {
                            isError = true;
                            break;
                        }

                        lineIdx += 1;

                        /* --- Check Column --- */
                        bool     isSameCol = false;
                        string[] cols      = DataList[lineIdx].Split(",".ToCharArray());
                        if (cols != null)
                        {
                            if (nodes[nodeIdx].ChildNodes.Count <= cols.Length)
                            {
                                int colIdx = 0;
                                for (; colIdx < nodes[nodeIdx].ChildNodes.Count; colIdx++)
                                {
                                    string colName  = cols[colIdx] == null ? "" : cols[colIdx];
                                    string cColName = nodes[nodeIdx].ChildNodes[colIdx].Attributes["name"].Value;
                                    if (cColName == null)
                                    {
                                        cColName = "";
                                    }

                                    colName  = colName.Trim().ToUpper();
                                    cColName = cColName.Trim().ToUpper();

                                    if (colName != cColName)
                                    {
                                        break;
                                    }
                                }

                                bool isColOver = false;
                                if (colIdx < cols.Length)
                                {
                                    for (int nColIdx = colIdx; nColIdx < cols.Length; nColIdx++)
                                    {
                                        if (CommonUtil.IsNullOrEmpty(cols[nColIdx]) == false)
                                        {
                                            isColOver = true;
                                            break;
                                        }
                                    }
                                }
                                if (isColOver == false &&
                                    colIdx == nodes[nodeIdx].ChildNodes.Count)
                                {
                                    isSameCol = true;
                                }
                            }
                        }
                        if (isSameCol == false)
                        {
                            isError = true;
                            break;
                        }

                        /* --- Get next Table --- */
                        string nextTable = null;
                        if (nodeIdx + 1 < nodes.Count)
                        {
                            nextTable = nodes[nodeIdx + 1].Attributes["name"].Value;
                        }

                        /* --- Loop fill data to each table --- */
                        lineIdx += 1;
                        while (lineIdx < DataList.Count)
                        {
                            tbName = DataList[lineIdx].Split(",".ToCharArray());
                            if (nextTable == tbName[0])
                            {
                                break;
                            }

                            bool isEmpty = true;
                            foreach (string d in tbName)
                            {
                                if (CommonUtil.IsNullOrEmpty(d) == false)
                                {
                                    isEmpty = false;
                                    break;
                                }
                            }
                            if (isEmpty)
                            {
                                isError = true;
                                break;
                            }

                            string data = DataList[lineIdx];

                            string[] lst = new string[nodes[nodeIdx].ChildNodes.Count];
                            for (int dIdx = 0; dIdx < nodes[nodeIdx].ChildNodes.Count; dIdx++)
                            {
                                if (data.Length <= 0 && dIdx < nodes[nodeIdx].ChildNodes.Count - 1)
                                {
                                    isError = true;
                                    break;
                                }

                                int tIdx  = 0;
                                int cmIdx = data.IndexOf(",");
                                int ccIdx = data.IndexOf("\"");

                                string val = string.Empty;
                                if (cmIdx < 0)
                                {
                                    val = data;
                                }
                                else if (cmIdx < ccIdx || ccIdx < 0)
                                {
                                    val   = data.Substring(tIdx, cmIdx);
                                    tIdx += cmIdx + 1;
                                }
                                else
                                {
                                    int cceIdx = data.IndexOf("\"", ccIdx + 1);
                                    if (cceIdx <= 0)
                                    {
                                        val = data;
                                    }
                                    else
                                    {
                                        val   = data.Substring(tIdx + 1, cceIdx - 1);
                                        tIdx += cceIdx + 2;
                                    }
                                }

                                lst[dIdx] = val;
                                data      = data.Substring(tIdx);
                            }

                            lineIdx += 1;
                            if (isError)
                            {
                                break;
                            }
                            else
                            {
                                if (nodeIdx < impLst.Count)
                                {
                                    object obj = impLst[nodeIdx];

                                    /* --- Create Object --- */
                                    object objDo = Activator.CreateInstance(obj.GetType().GetGenericArguments()[0]);

                                    MethodInfo mf = obj.GetType().GetMethod("Add");
                                    if (mf != null)
                                    {
                                        mf.Invoke(obj, new object[] { objDo });
                                    }

                                    for (int colIdx = 0; colIdx < nodes[nodeIdx].ChildNodes.Count; colIdx++)
                                    {
                                        bool canSetValue = CommonUtil.SetObjectValue(objDo, nodes[nodeIdx].ChildNodes[colIdx].Attributes["name"].Value, lst[colIdx] != string.Empty ? lst[colIdx] : null);
                                        if (canSetValue == false)
                                        {
                                            string v = nodes[nodeIdx].ChildNodes[colIdx].Attributes["name"].Value;
                                            if (setFailList.IndexOf(v) < 0)
                                            {
                                                setFailList.Add(v);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (isError)
                    {
                        break;
                    }
                }

                if (nodeIdx < nodes.Count)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2020);
                    return(Json(res));
                }
                if (setFailList.Count > 0)
                {
                    string txt = CommonUtil.TextList(setFailList.ToArray());
                    res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2084, new string[] { txt });
                    return(Json(res));
                }

                #endregion
                #region Check Mandatory

                ValidatorUtil validator = new ValidatorUtil();
                List <object> objLst    = new List <object>();
                if (ScreenID == SECOM_AJIS.Common.Util.ConstantValue.ScreenID.C_SCREEN_ID_QTN_TARGET)
                {
                    if (importData.dtTbt_QuotationCustomer.Count == 0)
                    {
                        validator.AddErrorMessage(
                            MessageUtil.MODULE_COMMON,
                            MessageUtil.MessageList.MSG0007,
                            "CustomerList",
                            "CustPartTypeCode, CustCode (or CustNameEN, CustNameLC, CustTypeCode, RegionCode)");
                    }
                    else
                    {
                        int cidx = 1;
                        foreach (tbt_QuotationCustomer cust in importData.dtTbt_QuotationCustomer)
                        {
                            if (CommonUtil.IsNullOrEmpty(cust.CustPartTypeCode))
                            {
                                validator.AddErrorMessage(
                                    MessageUtil.MODULE_COMMON,
                                    MessageUtil.MessageList.MSG0007,
                                    "CustPartTypeCode" + cidx,
                                    "CustPartTypeCode" + cidx);
                            }
                            if (CommonUtil.IsNullOrEmpty(cust.CustCode))
                            {
                                List <string> eLst = new List <string>();

                                if (CommonUtil.IsNullOrEmpty(cust.CustNameEN))
                                {
                                    eLst.Add("CustNameEN" + cidx);
                                }
                                if (CommonUtil.IsNullOrEmpty(cust.CustNameLC))
                                {
                                    eLst.Add("CustNameLC" + cidx);
                                }
                                if (CommonUtil.IsNullOrEmpty(cust.CustTypeCode))
                                {
                                    eLst.Add("CustTypeCode" + cidx);
                                }
                                if (CommonUtil.IsNullOrEmpty(cust.RegionCode))
                                {
                                    eLst.Add("RegionCode" + cidx);
                                }

                                if (eLst.Count == 4)
                                {
                                    validator.AddErrorMessage(
                                        MessageUtil.MODULE_COMMON,
                                        MessageUtil.MessageList.MSG0007,
                                        "Customer" + cidx,
                                        string.Format("CustCode{0} (or CustNameEN{0}, CustNameLC{0}, CustTypeCode{0}, RegionCode{0})", cidx));
                                }
                                else
                                {
                                    foreach (string s in eLst)
                                    {
                                        validator.AddErrorMessage(
                                            MessageUtil.MODULE_COMMON,
                                            MessageUtil.MessageList.MSG0007,
                                            s,
                                            s);
                                    }
                                }
                            }

                            cidx++;
                        }
                    }

                    tbt_QuotationSite site = new tbt_QuotationSite();
                    if (importData.dtTbt_QuotationSite.Count > 0)
                    {
                        site = importData.dtTbt_QuotationSite[0];
                    }
                    if (CommonUtil.IsNullOrEmpty(site.SiteNo))
                    {
                        List <string> eLst = new List <string>();
                        if (CommonUtil.IsNullOrEmpty(site.SiteNameEN))
                        {
                            eLst.Add("SiteNameEN");
                        }
                        if (CommonUtil.IsNullOrEmpty(site.SiteNameLC))
                        {
                            eLst.Add("SiteNameLC");
                        }
                        if (CommonUtil.IsNullOrEmpty(site.AddressEN))
                        {
                            eLst.Add("AddressEN");
                        }
                        if (CommonUtil.IsNullOrEmpty(site.AddressLC))
                        {
                            eLst.Add("AddressLC");
                        }
                        //if (CommonUtil.IsNullOrEmpty(site.RoadEN))
                        //    eLst.Add("RoadEN");
                        //if (CommonUtil.IsNullOrEmpty(site.RoadLC))
                        //    eLst.Add("RoadLC");
                        if (CommonUtil.IsNullOrEmpty(site.SubDistrictEN))
                        {
                            eLst.Add("SubDistrictEN");
                        }
                        if (CommonUtil.IsNullOrEmpty(site.SubDistrictLC))
                        {
                            eLst.Add("SubDistrictLC");
                        }
                        if (CommonUtil.IsNullOrEmpty(site.BuildingUsageCode))
                        {
                            eLst.Add("BuildingUsageCode");
                        }
                        if (CommonUtil.IsNullOrEmpty(site.ProvinceCode))
                        {
                            eLst.Add("ProvinceCode");
                        }
                        if (CommonUtil.IsNullOrEmpty(site.ProvinceCode))
                        {
                            eLst.Add("DistrictCode");
                        }

                        if (eLst.Count == 11)
                        {
                            validator.AddErrorMessage(
                                MessageUtil.MODULE_COMMON,
                                MessageUtil.MessageList.MSG0007,
                                "Site",
                                "SiteNo (or SiteNameEN, SiteNameLC, AddressEN, AddressLC, SubDistrictEN, SubDistrictLC, BuildingUsageCode, ProvinceCode, DistrictCode)");
                        }
                        else
                        {
                            foreach (string s in eLst)
                            {
                                validator.AddErrorMessage(
                                    MessageUtil.MODULE_COMMON,
                                    MessageUtil.MessageList.MSG0007,
                                    s,
                                    s);
                            }
                        }
                    }

                    if (importData.dtTbt_QuotationTarget.Count == 0)
                    {
                        importData.dtTbt_QuotationTarget.Add(new tbt_QuotationTarget());
                    }
                    foreach (tbt_QuotationTarget target in importData.dtTbt_QuotationTarget)
                    {
                        objLst.Add(CommonUtil.CloneObject <tbt_QuotationTarget, QUS050_tbt_QuotationTarget>(target));
                    }
                }
                else
                {
                    if (importData.dtTbt_QuotationTarget.Count == 0)
                    {
                        importData.dtTbt_QuotationTarget.Add(new tbt_QuotationTarget());
                    }
                    foreach (tbt_QuotationTarget target in importData.dtTbt_QuotationTarget)
                    {
                        objLst.Add(CommonUtil.CloneObject <tbt_QuotationTarget, QUS050_tbt_QuotationTarget_D>(target));
                    }

                    if (importData.dtTbt_QuotationBasic.Count == 0)
                    {
                        importData.dtTbt_QuotationBasic.Add(new tbt_QuotationBasic());
                    }
                    foreach (tbt_QuotationBasic basic in importData.dtTbt_QuotationBasic)
                    {
                        /* --- Update QuotationTargetCode --- */
                        /* ---------------------------------- */
                        basic.QuotationTargetCode = importData.dtTbt_QuotationTarget[0].QuotationTargetCode;
                        /* ---------------------------------- */

                        objLst.Add(CommonUtil.CloneObject <tbt_QuotationBasic, QUS050_tbt_QuotationBasic>(basic));
                    }
                }

                ValidatorUtil.BuildErrorMessage(res, validator, objLst.ToArray());
                if (res.IsError)
                {
                    return(Json(res));
                }

                #endregion
                #region Business Check

                if (ScreenID == SECOM_AJIS.Common.Util.ConstantValue.ScreenID.C_SCREEN_ID_QTN_TARGET)
                {
                    bool isFoundTarget = false;
                    bool isFoundReal   = false;
                    if (importData.dtTbt_QuotationCustomer.Count > 0 && importData.dtTbt_QuotationCustomer.Count <= 2)
                    {
                        foreach (tbt_QuotationCustomer cust in importData.dtTbt_QuotationCustomer)
                        {
                            if (cust.CustPartTypeCode != SECOM_AJIS.Common.Util.ConstantValue.CustPartType.C_CUST_PART_TYPE_CONTRACT_TARGET &&
                                cust.CustPartTypeCode != SECOM_AJIS.Common.Util.ConstantValue.CustPartType.C_CUST_PART_TYPE_REAL_CUST)
                            {
                                res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2025);
                                return(Json(res));
                            }

                            if (cust.CustPartTypeCode == SECOM_AJIS.Common.Util.ConstantValue.CustPartType.C_CUST_PART_TYPE_CONTRACT_TARGET)
                            {
                                if (isFoundTarget == true)
                                {
                                    res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2093);
                                    return(Json(res));
                                }
                                else
                                {
                                    isFoundTarget = true;
                                }
                            }
                            else if (cust.CustPartTypeCode == SECOM_AJIS.Common.Util.ConstantValue.CustPartType.C_CUST_PART_TYPE_REAL_CUST)
                            {
                                if (isFoundReal == true)
                                {
                                    res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2093);
                                    return(Json(res));
                                }
                                else
                                {
                                    isFoundReal = true;
                                }
                            }

                            QUS050_tbt_QuotationCustomer_BC custBC =
                                CommonUtil.CloneObject <tbt_QuotationCustomer, QUS050_tbt_QuotationCustomer_BC>(cust);
                            ObjectResultData r = ValidatorUtil.BuildErrorMessage(custBC);
                            if (r != null)
                            {
                                if (r.IsError)
                                {
                                    res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2021);
                                    return(Json(res));
                                }
                            }
                        }
                        if (isFoundTarget == false)
                        {
                            res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2024);
                            return(Json(res));
                        }
                    }
                    else
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2026);
                        return(Json(res));
                    }

                    if (importData.dtTbt_QuotationSite != null)
                    {
                        if (importData.dtTbt_QuotationSite.Count > 0)
                        {
                            QUS050_tbt_QuotationSite_BC siteBC =
                                CommonUtil.CloneObject <tbt_QuotationSite, QUS050_tbt_QuotationSite_BC>(importData.dtTbt_QuotationSite[0]);
                            ValidatorUtil.BuildErrorMessage(res, new object[] { siteBC });
                            if (res.IsError)
                            {
                                return(Json(res));
                            }
                        }
                    }
                }

                #endregion
                #region Data Authority Check

                string QuotationOfficeCode = null;
                if (ScreenID == SECOM_AJIS.Common.Util.ConstantValue.ScreenID.C_SCREEN_ID_QTN_TARGET)
                {
                    if (importData.dtTbt_QuotationTarget != null)
                    {
                        if (importData.dtTbt_QuotationTarget.Count > 0)
                        {
                            QuotationOfficeCode = importData.dtTbt_QuotationTarget[0].QuotationOfficeCode;
                        }
                    }
                }
                else
                {
                    IQuotationHandler handler = ServiceContainer.GetService <IQuotationHandler>() as IQuotationHandler;
                    if (importData.dtTbt_QuotationBasic.Count > 0)
                    {
                        CommonUtil cmm = new CommonUtil();
                        string     qt  = cmm.ConvertQuotationTargetCode(importData.dtTbt_QuotationBasic[0].QuotationTargetCode, CommonUtil.CONVERT_TYPE.TO_LONG);

                        doGetQuotationDataCondition cond = new doGetQuotationDataCondition()
                        {
                            QuotationTargetCode = qt
                        };
                        List <tbt_QuotationTarget> lst = handler.GetTbt_QuotationTarget(cond);
                        if (lst.Count <= 0)
                        {
                            ISaleContractHandler shandler = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;
                            List <tbt_SaleBasic> sLst     = shandler.GetTbt_SaleBasic(qt, null, true);
                            if (sLst.Count <= 0)
                            {
                                IRentralContractHandler        rhandler = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;
                                List <tbt_RentalContractBasic> rLst     = rhandler.GetTbt_RentalContractBasic(qt, null);
                                if (rLst.Count <= 0)
                                {
                                    res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2003, new string[] { importData.dtTbt_QuotationBasic[0].QuotationTargetCode });
                                    return(Json(res));
                                }
                                else
                                {
                                    if (rLst[0].ContractStatus == ContractStatus.C_CONTRACT_STATUS_BEF_START)
                                    {
                                        QuotationOfficeCode = rLst[0].ContractOfficeCode;
                                    }
                                    else
                                    {
                                        QuotationOfficeCode = rLst[0].OperationOfficeCode;
                                    }
                                }
                            }
                            else
                            {
                                if (sLst[0].ContractStatus == ContractStatus.C_CONTRACT_STATUS_BEF_START)
                                {
                                    QuotationOfficeCode = sLst[0].ContractOfficeCode;
                                }
                                else
                                {
                                    QuotationOfficeCode = sLst[0].OperationOfficeCode;
                                }
                            }
                        }
                        else
                        {
                            QuotationOfficeCode = lst[0].OperationOfficeCode;
                        }
                    }
                }

                if (QuotationOfficeCode != null && CommonUtil.dsTransData.dtOfficeData != null)
                {
                    bool isFound = false;
                    foreach (OfficeDataDo office in CommonUtil.dsTransData.dtOfficeData)
                    {
                        if (office.OfficeCode == QuotationOfficeCode)
                        {
                            isFound = true;
                            break;
                        }
                    }
                    if (isFound == false)
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_QUOTATION, MessageUtil.MessageList.MSG2023);
                        return(Json(res));
                    }
                }

                #endregion

                QUS050_ScreenParameter param = GetScreenObject <QUS050_ScreenParameter>();
                if (param != null)
                {
                    param.ImportData = importData;
                }

                res.ResultData = new object[] { importData, GetCurrentKey() };
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }
            return(Json(res));
        }
        /// <summary>
        /// Check permission for access screen CMS190
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult CMS190_Authority(CMS190_ScreenParameter param) // IN parameter: string strContractCode, string strServiceTypeCode
        {
            ObjectResultData res = new ObjectResultData();


            // Check permission
            if (!CheckUserPermission(ScreenID.C_SCREEN_ID_VIEW_CONTRACT_DIGEST, FunctionID.C_FUNC_ID_OPERATE))
            {
                res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                return(Json(res));
            }

            if (String.IsNullOrEmpty(param.strContractCode))
            {
                //param.strContractCode = CommonUtil.dsTransData.dtCommonSearch.ContractCode;
                if (param.CommonSearch != null)
                {
                    if (CommonUtil.IsNullOrEmpty(param.CommonSearch.ContractCode) == false)
                    {
                        param.strContractCode = param.CommonSearch.ContractCode;
                    }
                }
            }

            // Check parameter
            if (CommonUtil.IsNullOrEmpty(param.strContractCode) == true)
            {
                //res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0040);
                res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0147);
                return(Json(res));
            }

            // Check exist data
            try
            {
                CommonUtil c            = new CommonUtil();
                string     ContractCode = c.ConvertContractCode(param.strContractCode, CommonUtil.CONVERT_TYPE.TO_LONG);


                // Rental
                IRentralContractHandler handlerR = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;
                // Sale
                ISaleContractHandler handlerS = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;

                //List<dtTbt_RentalContractBasicForView> dtRentalContract = new List<dtTbt_RentalContractBasicForView>();
                //List<dtTbt_SaleBasicForView> dtSaleContract = new List<dtTbt_SaleBasicForView>();

                List <tbt_RentalContractBasic> dtRentalContract = new List <tbt_RentalContractBasic>();
                List <tbt_SaleBasic>           dtSaleContract   = new List <tbt_SaleBasic>();

                // get data for check exist
                if (param.strServiceTypeCode == ServiceType.C_SERVICE_TYPE_RENTAL)
                {
                    dtRentalContract = handlerR.GetTbt_RentalContractBasic(ContractCode, null);
                }
                else if (param.strServiceTypeCode == ServiceType.C_SERVICE_TYPE_SALE)
                {
                    dtSaleContract = handlerS.GetTbt_SaleBasic(ContractCode, null, true);
                }
                else
                {
                    dtRentalContract = handlerR.GetTbt_RentalContractBasic(ContractCode, null);


                    if (dtRentalContract.Count == 0)
                    {
                        dtSaleContract = handlerS.GetTbt_SaleBasic(ContractCode, null, true);

                        param.strServiceTypeCode = ServiceType.C_SERVICE_TYPE_SALE;
                    }
                    else
                    {
                        param.strServiceTypeCode = ServiceType.C_SERVICE_TYPE_RENTAL;
                    }
                }


                CommonUtil comUtil = new CommonUtil();

                if (dtRentalContract.Count > 0)
                {
                    param.strContractCode = comUtil.ConvertContractCode(dtRentalContract[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                }
                else if (dtSaleContract.Count > 0)
                {
                    param.strContractCode = comUtil.ConvertContractCode(dtSaleContract[0].ContractCode, CommonUtil.CONVERT_TYPE.TO_SHORT);
                }
                // parameter
                param.ContractCode    = param.strContractCode;
                param.ServiceTypeCode = param.strServiceTypeCode;


                if (dtRentalContract.Count == 0 && dtSaleContract.Count == 0)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                    return(Json(res));
                }

                //CommonUtil.dsTransData.dtCommonSearch.ContractCode = param.strContractCode;
                //CommonUtil.dsTransData.dtCommonSearch.ProjectCode = null;
                param.CommonSearch = new ScreenParameter.CommonSearchDo()
                {
                    ContractCode = param.strContractCode
                };
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }

            return(InitialScreenEnvironment <CMS190_ScreenParameter>("CMS190", param, res));
        }
Ejemplo n.º 11
0
        public void UpdateOperationOffice(string contractCode, string operationOfficeCode)
        {
            try
            {
                if (string.IsNullOrEmpty(contractCode) || string.IsNullOrEmpty(operationOfficeCode))
                {
                    return;
                }

                ISaleContractHandler saleHandler = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;
                var lstSales = saleHandler.GetTbt_SaleBasic(contractCode, null, null);
                if (lstSales != null && lstSales.Count > 0)
                {
                    foreach (var sale in lstSales)
                    {
                        sale.OperationOfficeCode = operationOfficeCode;
                        saleHandler.UpdateTbt_SaleBasic(sale);
                    }
                }

                IQuotationHandler quotationHandler = ServiceContainer.GetService <IQuotationHandler>() as IQuotationHandler;

                var lstQuotationTarget = quotationHandler.GetTbt_QuotationTargetByContractCode(contractCode);
                if (lstQuotationTarget != null && lstQuotationTarget.Count > 0)
                {
                    foreach (var q in lstQuotationTarget)
                    {
                        quotationHandler.UpdateQuotationTarget(new doUpdateQuotationTargetData()
                        {
                            QuotationTargetCode    = q.QuotationTargetCode,
                            ContractTransferStatus = q.ContractTransferStatus,
                            ContractCode           = q.ContractCode,
                            TransferDate           = q.TransferDate,
                            TransferAlphabet       = q.TransferAlphabet,
                            LastAlphabet           = q.LastAlphabet,
                            QuotationOfficeCode    = q.QuotationTargetCode,
                            OperationOfficeCode    = operationOfficeCode,
                        });
                    }
                }

                IInstallationHandler installHandler = ServiceContainer.GetService <IInstallationHandler>() as IInstallationHandler;

                var lstInstallationBasic = installHandler.GetTbt_InstallationBasicData(contractCode);
                if (lstInstallationBasic != null && lstInstallationBasic.Count > 0)
                {
                    foreach (var ib in lstInstallationBasic)
                    {
                        ib.OperationOfficeCode = operationOfficeCode;
                        installHandler.UpdateTbt_InstallationBasic(ib);
                    }
                }

                var lstInstallationHistory = installHandler.GetTbt_InstallationHistory(contractCode, null, null);
                if (lstInstallationHistory != null && lstInstallationHistory.Count > 0)
                {
                    foreach (var ih in lstInstallationHistory)
                    {
                        ih.OperationOfficeCode = operationOfficeCode;
                    }

                    installHandler.UpdateTbt_InstallationHistory(lstInstallationHistory);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }