Exemplo n.º 1
0
        /// <summary>
        /// Insert billing temp data
        /// </summary>
        /// <param name="billing"></param>
        /// <returns></returns>
        public List <tbt_BillingTemp> InsertBillingTemp(tbt_BillingTemp billing)
        {
            List <tbt_BillingTemp> insertedList = null;

            try
            {
                //Validate data input
                //1.1	ContractCode and OCC are required.
                //1.3   BillingType, BillingAmount, PaymentMethod are required.
                #region validate input
                ApplicationErrorException.CheckMandatoryField <tbt_BillingTemp, doBillingTempData_Insert>(billing);

                //1.2	At least one of (BillingOCC, BillingTargetCode, BillingClientCode and BillingOfficeCode)
                bool          bBillingOCC              = true;
                bool          bBillingTargetCode       = true;
                bool          bBillingClientOfficeCode = true;
                List <String> fieldList = new List <string>();

                //BillingOCC
                if (CommonUtil.IsNullOrEmpty(billing.BillingOCC))
                {
                    bBillingOCC = false;
                    //fieldList.Add("BillingOCC");
                }

                //BillingTargetCode
                if (CommonUtil.IsNullOrEmpty(billing.BillingTargetCode))
                {
                    bBillingTargetCode = false;
                    //fieldList.Add("BillingTargetCode");
                }

                //BillingClientCode and BillingOfficeCode
                try
                {
                    doBillingBasicCheckBillingClientOfficeCode bClientOfficeCode = new doBillingBasicCheckBillingClientOfficeCode();
                    bClientOfficeCode.ContractCode      = billing.ContractCode;
                    bClientOfficeCode.BillingOfficeCode = billing.BillingOfficeCode;
                    bClientOfficeCode.BillingClientCode = billing.BillingClientCode;
                    ApplicationErrorException.CheckMandatoryField(bClientOfficeCode);
                }
                catch (Exception)
                {
                    bBillingClientOfficeCode = false;
                    //fieldList.Add("BillingOfficeCode");
                    //fieldList.Add("BillingClientCode");
                }

                bool bResult = bBillingOCC || bBillingTargetCode || bBillingClientOfficeCode;
                if (!bResult)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, "At least one of BillingOCC, BillingTargetCode, BillingClientCode and BillingOfficeCode");
                }
                #endregion

                //Insert billing temp data to DB
                insertedList = base.InsertTbt_BillingTemp(billing.ContractCode
                                                          , billing.OCC
                                                          , billing.BillingOCC
                                                          , billing.BillingTargetRunningNo
                                                          , billing.BillingClientCode
                                                          , billing.BillingTargetCode
                                                          , billing.BillingOfficeCode
                                                          , billing.BillingType
                                                          , billing.CreditTerm
                                                          , billing.BillingTiming
                                                          , billing.BillingAmt
                                                          , billing.PayMethod
                                                          , billing.BillingCycle
                                                          , billing.CalDailyFeeStatus
                                                          , billing.SendFlag
                                                          , CommonUtil.dsTransData.dtOperationData.ProcessDateTime
                                                          , CommonUtil.dsTransData.dtUserData.EmpNo
                                                          , billing.DocLanguage
                                                          , billing.BillingAmtUsd
                                                          , billing.BillingAmtCurrencyType); //Add by Jutarat A. on 18122013

                //Insert Log
                if (insertedList.Count > 0)
                {
                    doTransactionLog logData = new doTransactionLog();
                    logData.TransactionType = doTransactionLog.eTransactionType.Insert;
                    logData.TableName       = TableName.C_TBL_NAME_BILLING_TEMP;
                    logData.TableData       = CommonUtil.ConvertToXml(insertedList);
                    ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                    hand.WriteTransactionLog(logData);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(insertedList);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Update billing temp data by key
        /// </summary>
        /// <param name="billing"></param>
        /// <returns></returns>
        public List <tbt_BillingTemp> UpdateBillingTempByKey(tbt_BillingTemp billing)
        {
            try
            {
                //Validate data input
                //1.1	ContractCode, OCC and SequenceNo are required
                //1.3	BillingType, BillingAmount, PaymentMethod are required.
                #region validate input
                ApplicationErrorException.CheckMandatoryField <tbt_BillingTemp, doBillingTempData_Update>(billing);

                //1.2	At least one of (BllingOCC, BillingTargetCode, BillingClientCode)
                List <String> fieldList = new List <string>();

                if (CommonUtil.IsNullOrEmpty(billing.BillingOCC))
                {
                    fieldList.Add("BillingOCC");
                }

                if (CommonUtil.IsNullOrEmpty(billing.BillingTargetCode))
                {
                    fieldList.Add("BillingTargetCode");
                }

                //Modify by Jutarat A. on 13112013

                /*if (CommonUtil.IsNullOrEmpty(billing.BillingClientCode))
                 * {
                 *  //fieldList.Add("BillingClientCode");
                 * }*/
                if (CommonUtil.IsNullOrEmpty(billing.BillingClientCode) && CommonUtil.IsNullOrEmpty(billing.BillingOfficeCode))
                {
                    if (CommonUtil.IsNullOrEmpty(billing.BillingClientCode))
                    {
                        fieldList.Add("BillingClientCode");
                    }

                    if (CommonUtil.IsNullOrEmpty(billing.BillingOfficeCode))
                    {
                        fieldList.Add("BillingOfficeCode");
                    }
                }
                //End Modify

                if (fieldList.Count >= 3) //== 3 //Modify by Jutarat A. on 13112013
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, fieldList.ToArray <String>());
                }
                #endregion

                //Update data to DB
                List <tbt_BillingTemp> updatedList
                    = base.UpdateTbt_BillingTemp_ByKey(billing.BillingOCC
                                                       , billing.BillingTargetRunningNo
                                                       , billing.BillingClientCode
                                                       , billing.BillingTargetCode
                                                       , billing.BillingOfficeCode
                                                       , billing.BillingType
                                                       , billing.CreditTerm
                                                       , billing.BillingTiming
                                                       , billing.BillingAmt
                                                       , billing.PayMethod
                                                       , billing.BillingCycle
                                                       , billing.CalDailyFeeStatus
                                                       , billing.SendFlag
                                                       , billing.ContractCode
                                                       , billing.OCC
                                                       , billing.SequenceNo
                                                       , CommonUtil.dsTransData.dtOperationData.ProcessDateTime
                                                       , CommonUtil.dsTransData.dtUserData.EmpNo
                                                       , billing.BillingAmtCurrencyType
                                                       , billing.BillingAmtUsd);

                //Insert Log
                if (updatedList.Count > 0)
                {
                    doTransactionLog logData = new doTransactionLog();
                    logData.TransactionType = doTransactionLog.eTransactionType.Update;
                    logData.TableName       = TableName.C_TBL_NAME_BILLING_TEMP;
                    logData.TableData       = CommonUtil.ConvertToXml(updatedList);
                    ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                    hand.WriteTransactionLog(logData);
                }

                return(updatedList);
            }
            catch (Exception)
            {
                throw;
            }
        }