Exemple #1
0
        /// <summary>
        /// validate input data confirm and register data into database
        /// </summary>
        /// <returns></returns>
        public ActionResult ICS100_Confirm()
        {
            ICS100_ScreenParameter param        = GetScreenObject <ICS100_ScreenParameter>();
            ICS100_RegisterData    RegisterData = new ICS100_RegisterData();
            CommonUtil             comUtil      = new CommonUtil();

            // reuse param that send on Register Click
            if (param != null)
            {
                RegisterData = param.RegisterData;
            }

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            ObjectResultData resByIssue   = new ObjectResultData();
            ObjectResultData resByInvoice = new ObjectResultData();

            try
            {
                // Common Check Sequence

                // System Suspend
                ICommonHandler handlerCommon = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                IIncomeHandler incomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;

                if (handlerCommon.IsSystemSuspending())
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049);
                    return(Json(res));
                }

                using (TransactionScope scope = new TransactionScope())
                {
                    try
                    {
                        #region Tbt_MoneyCollectionInfo
                        for (int i = 0; i < RegisterData.Detail1.Count; i++)
                        {
                            decimal?ra             = (decimal?)Convert.ToDecimal(RegisterData.Detail1[i].txtReceiptAmount);
                            string  raCurrencyType = RegisterData.Detail1[i].txtReceiptAmountCurrencyType;
                            tbt_MoneyCollectionInfo _dotbt_MoneyCollectionInfo = new tbt_MoneyCollectionInfo()
                            {
                                ReceiptNo           = RegisterData.Detail1[i].txtReceiptNo,
                                ReceiptDate         = RegisterData.Detail1[i].dtpReceiptDate,
                                BillingTargetCode   = RegisterData.Detail1[i].txtBillingTargetCode,
                                CollectionArea      = RegisterData.Detail1[i].txtCollectionArea,
                                ExpectedCollectDate = (DateTime)RegisterData.Detail1[i].dtpExpectedCollectDate,
                                Memo = RegisterData.Detail1[i].txtMemo,

                                // add by jirawat jannet on 2016-10-28
                                ReceiptAmount             = raCurrencyType == CurrencyUtil.C_CURRENCY_LOCAL ? ra : null,
                                ReceiptAmountCurrencyType = RegisterData.Detail1[i].txtReceiptAmountCurrencyType,
                                ReceiptAmountUsd          = raCurrencyType == CurrencyUtil.C_CURRENCY_US ? ra : null
                            };
                            // Comment by Jirawat Jannet on 2016-10-28
                            //_dotbt_MoneyCollectionInfo.ReceiptNo = RegisterData.Detail1[i].txtReceiptNo;
                            //_dotbt_MoneyCollectionInfo.ReceiptDate = RegisterData.Detail1[i].dtpReceiptDate;
                            //_dotbt_MoneyCollectionInfo.BillingTargetCode = RegisterData.Detail1[i].txtBillingTargetCode;
                            //_dotbt_MoneyCollectionInfo.ReceiptAmount = (decimal?)Convert.ToDecimal(RegisterData.Detail1[i].txtReceiptAmount);
                            //_dotbt_MoneyCollectionInfo.CollectionArea = RegisterData.Detail1[i].txtCollectionArea;
                            //_dotbt_MoneyCollectionInfo.ExpectedCollectDate = (DateTime)RegisterData.Detail1[i].dtpExpectedCollectDate;
                            //_dotbt_MoneyCollectionInfo.Memo = RegisterData.Detail1[i].txtMemo;

                            if (incomeHandler.CreateTbt_MoneyCollectionInfo(_dotbt_MoneyCollectionInfo) == 0)
                            {
                                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7122, null);
                            }
                        }
                        #endregion

                        scope.Complete();
                    }
                    catch (Exception ex)
                    {
                        // Fail rollback all
                        scope.Dispose();
                        res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                        res.AddErrorMessage(ex);
                        return(Json(res));
                    }
                }

                // return "1" to js is every thing OK
                if (res.MessageList == null || res.MessageList.Count == 0)
                {
                    res.ResultData = "1";
                }
                else
                {
                    res.ResultData = "0";
                }

                return(Json(res));
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }
            return(Json(res));
        }