Beispiel #1
0
        ///<summary>
        ///Purpose   : cancel booking
        ///Parameters: Input04
        ///Expected  : - delete data from tbt_inventoryBookingDeatail and tbt_inventoryBooking where ContractCode = doBooking.ContractCode
        ///            - Write transaction log
        ///            - blnExistContractCode = 1 (true)
        ///</summary>
        ///
        public string Case6()
        {
            IInventoryHandler invenhandler = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler;
            string            result       = "";

            bool?expectedObj = true;
            bool?actualObj   = null;

            string expected = expectedObj.ToString().ToUpper();
            string actual   = "";

            try
            {
                actualObj = invenhandler.CancelBooking(Input04());

                actual = actualObj.ToString().ToUpper();
            }
            catch (ApplicationErrorException ex)
            {
                actual = ex.ErrorResult.Message.Code;
            }
            catch (Exception ex)
            {
                actual = ex.StackTrace;
            }

            result = String.Format(RESULT_FORMAT, 6, expected, actual, CompareResult_bool(expectedObj, actualObj));

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Update data to database when click [Confirm] button in ‘Action button’ section
        /// </summary>
        /// <param name="doCancalReason"></param>
        /// <returns></returns>
        public ActionResult CTS090_ConfirmRegisterCancelData(CTS090_doCancelReason doCancalReason)
        {
            ObjectResultData res = new ObjectResultData();
            CTS090_RegisterCancelTargetData registerCancelData;
            List <tbt_SaleBasic>            tbt_SaleBasicList;
            ISaleContractHandler            saleHandler;
            IBillingTempHandler             billingHandler;
            List <tbt_BillingTemp>          tbt_BillingTempList;
            IQuotationHandler     guotHandler;
            doUpdateQuotationData doUpdateQuotation;

            try
            {
                //CheckSystemStatus
                if (CheckIsSuspending(res) == true)
                {
                    return(Json(res));
                }

                //Check screen permission
                if (CheckUserPermission(ScreenID.C_SCREEN_ID_CANCEL_SALE_CONTRACT, FunctionID.C_FUNC_ID_OPERATE) == false)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                    return(Json(res));
                }


                //ValidateScreenBusiness
                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                if (doCancalReason.CancelDate > DateTime.Now.Date)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3154, null, new string[] { "dpCancelDate" });
                    return(Json(res));
                }

                //ValidateDataBusiness
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                ValidateDataBusiness_CTS090(res);
                if (res.IsError)
                {
                    return(Json(res));
                }


                CTS090_ScreenParameter sParam = GetScreenObject <CTS090_ScreenParameter>();
                using (TransactionScope scope = new TransactionScope())
                {
                    /*--- RegisterCancelContract ---*/
                    saleHandler        = ServiceContainer.GetService <ISaleContractHandler>() as ISaleContractHandler;
                    registerCancelData = sParam.CTS090_Session;
                    if (registerCancelData.RegisterCancelData != null)
                    {
                        string strContractCode        = registerCancelData.RegisterCancelData.ContractCode;
                        string strOCCCode             = registerCancelData.RegisterCancelData.OCC;
                        string strQuotationTargetCode = registerCancelData.RegisterCancelData.QuotationTargetCode;
                        string strAlphabet            = registerCancelData.RegisterCancelData.Alphabet;

                        //MapSaleContractData
                        bool isUpdateQuotation = false;
                        if (registerCancelData.RegisterCancelData.ChangeType == SaleChangeType.C_SALE_CHANGE_TYPE_NEW_SALE)
                        {
                            registerCancelData.RegisterCancelData.ContractStatus = ContractStatus.C_CONTRACT_STATUS_CANCEL;
                            isUpdateQuotation = true;
                        }
                        registerCancelData.RegisterCancelData.OCC        = registerCancelData.InitialData.OCCCode;
                        registerCancelData.RegisterCancelData.ChangeType = SaleChangeType.C_SALE_CHANGE_TYPE_CANCEL;
                        registerCancelData.RegisterCancelData.SaleProcessManageStatus = SaleProcessManageStatus.C_SALE_PROCESS_STATUS_CANCEL;
                        registerCancelData.RegisterCancelData.ApproveNo1          = doCancalReason.ApproveNo1;
                        registerCancelData.RegisterCancelData.CancelReasonType    = doCancalReason.CancelReasonType;
                        registerCancelData.RegisterCancelData.CancelDate          = doCancalReason.CancelDate;
                        registerCancelData.RegisterCancelData.CancelProcessDate   = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                        registerCancelData.RegisterCancelData.ChangeImplementDate = doCancalReason.CancelDate;

                        //Save cancel contract data
                        tbt_SaleBasicList = saleHandler.UpdateTbt_SaleBasic(registerCancelData.RegisterCancelData);

                        //Delete billing temp
                        billingHandler      = ServiceContainer.GetService <IBillingTempHandler>() as IBillingTempHandler;
                        tbt_BillingTempList = billingHandler.DeleteBillingTempByContractCodeOCC(strContractCode, strOCCCode);

                        //Lock quotation
                        guotHandler = ServiceContainer.GetService <IQuotationHandler>() as IQuotationHandler;
                        bool isLockQuotComplete = guotHandler.LockQuotation(strQuotationTargetCode, strAlphabet, LockStyle.C_LOCK_STYLE_ALL);

                        if (isUpdateQuotation)
                        {
                            //Update quotation data
                            doUpdateQuotation = new doUpdateQuotationData();
                            doUpdateQuotation.QuotationTargetCode = strQuotationTargetCode;
                            doUpdateQuotation.Alphabet            = strAlphabet;
                            doUpdateQuotation.LastUpdateDate      = DateTime.MinValue; //null;
                            doUpdateQuotation.ContractCode        = strContractCode;
                            doUpdateQuotation.ActionTypeCode      = ActionType.C_ACTION_TYPE_CANCEL;
                            int iUpdateQuotRowCount = guotHandler.UpdateQuotationData(doUpdateQuotation);
                        }

                        //Delete installation basic
                        IInstallationHandler installHandler = ServiceContainer.GetService <IInstallationHandler>() as IInstallationHandler;
                        bool blnProcessResult = installHandler.DeleteInstallationBasicData(strContractCode);

                        //Cancel book
                        IInventoryHandler inventHandler = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler;
                        doBooking         booking       = new doBooking();
                        booking.ContractCode = registerCancelData.RegisterCancelData.ContractCode;
                        bool isCancelBookComplete = inventHandler.CancelBooking(booking);
                    }
                    /*--------------------------*/

                    scope.Complete();
                    res.ResultData = MessageUtil.GetMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0046);
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }