예제 #1
0
        /// <summary>
        /// Validate business of screen
        /// </summary>
        /// <param name="res"></param>
        /// <param name="tbt_SaleBasicData"></param>
        public void ValidateDataBusiness_CTS090(ObjectResultData res, tbt_SaleBasic tbt_SaleBasicData = null)
        {
            CTS090_RegisterCancelTargetData registerCancelData;
            IInstallationHandler            installHandler = ServiceContainer.GetService <IInstallationHandler>() as IInstallationHandler;

            try
            {
                if (tbt_SaleBasicData != null)
                {
                    registerCancelData = new CTS090_RegisterCancelTargetData();
                    registerCancelData.RegisterCancelData = tbt_SaleBasicData;
                }
                else
                {
                    CTS090_ScreenParameter sParam = GetScreenObject <CTS090_ScreenParameter>();
                    registerCancelData = sParam.CTS090_Session;
                }

                if (registerCancelData != null)
                {
                    //Check change type
                    if ((registerCancelData.RegisterCancelData != null && registerCancelData.RegisterCancelData.ChangeType != null) &&
                        ((registerCancelData.RegisterCancelData.ChangeType != SaleChangeType.C_SALE_CHANGE_TYPE_NEW_SALE) &&
                         (registerCancelData.RegisterCancelData.ChangeType != SaleChangeType.C_SALE_CHANGE_TYPE_ADD_SALE)))
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3168, null, null);
                        return;
                    }

                    //Check complete installation status
                    if ((registerCancelData.RegisterCancelData != null && registerCancelData.RegisterCancelData.InstallationCompleteFlag != null) &&
                        (registerCancelData.RegisterCancelData.InstallationCompleteFlag == FlagType.C_FLAG_ON))
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3058, null, null);
                        return;
                    }

                    //Check cancel status
                    if ((registerCancelData.RegisterCancelData != null && registerCancelData.RegisterCancelData.SaleProcessManageStatus != null) &&
                        (registerCancelData.RegisterCancelData.SaleProcessManageStatus == SaleProcessManageStatus.C_SALE_PROCESS_STATUS_CANCEL))
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3105, null, null);
                        return;
                    }

                    //Add by Jutarat A. on 06062013
                    //Check installation status
                    //Get installation basic
                    List <tbt_InstallationBasic> doTbt_InstallationBasicValidate = installHandler.GetTbt_InstallationBasicData(registerCancelData.RegisterCancelData.ContractCode);
                    if (doTbt_InstallationBasicValidate != null && doTbt_InstallationBasicValidate.Count > 0 &&
                        doTbt_InstallationBasicValidate[0].InstallationStatus != InstallationStatus.C_INSTALL_STATUS_INSTALL_NOT_REGISTERED)
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3309, null, null);
                        return;
                    }
                    //End Add
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }
        }
예제 #2
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;
            }
        }