//ICS060
        /// <summary>
        /// Function for cancel receipt information. (sp_IC_CancelReceipt)
        /// </summary>
        /// <param name="doReceipt">receipt information</param>
        /// <returns></returns>
        public bool CancelReceipt(doReceipt doReceipt)
        {
            //Validate
            if (doReceipt == null || string.IsNullOrEmpty(doReceipt.ReceiptNo))
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG0007, null);
            }
            doReceipt doReceiptDB = this.GetReceipt(doReceipt.ReceiptNo);

            if (doReceipt.UpdateDate != doReceiptDB.UpdateDate)
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG0019, null);
            }

            //Cancel receipt
            List <tbt_Receipt> result = base.CancelReceipt(doReceipt.ReceiptNo
                                                           , CommonUtil.dsTransData.dtUserData.EmpNo
                                                           , CommonUtil.dsTransData.dtOperationData.ProcessDateTime);

            if (result != null && result.Count > 0)
            {
                ILogHandler      logHand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                doTransactionLog logData = new doTransactionLog()
                {
                    TransactionType = doTransactionLog.eTransactionType.Update,
                    TableName       = TableName.C_TBL_NAME_RECEIPT,
                    TableData       = null
                };
                logData.TableData = CommonUtil.ConvertToXml(result);
                logHand.WriteTransactionLog(logData);
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Check customer code whether be used in draft contract, contract , AR, incident or Project
        /// </summary>
        /// <param name="custCode"></param>
        /// <returns></returns>
        public bool IsUsedCustomerData(string custCode)
        {
            try
            {
                if (CommonUtil.IsNullOrEmpty(custCode))
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, new string[] { "CustCode" });
                }

                List <int?> list = base.IsUsedCustomer(custCode);

                bool result = false;
                if (list.Count > 0)
                {
                    if (list[0].Value == 1)
                    {
                        result = true;
                    }
                }

                return(result);
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Update employee data
        /// </summary>
        /// <param name="employee"></param>
        /// <returns></returns>
        public List <tbm_Employee> UpdateEmployee(tbm_Employee employee)
        {
            List <DateTime?> updateDateList = base.GetEmployeeUpdateDate(employee.EmpNo);

            //if (updateDateList == null || updateDateList.Count == 0 || updateDateList[0] == null
            //    || employee.UpdateDate == null || !employee.UpdateDate.HasValue)
            //{
            //    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, new string[] { "UpdateDate" });
            //}

            if (CommonUtil.IsNullOrEmpty(employee.UpdateDate) && updateDateList[0].Value.CompareTo(employee.UpdateDate.Value) != 0)
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019, new string[] { employee.EmpNo });
            }

            employee.UpdateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
            employee.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;

            List <tbm_Employee> updateList = new List <tbm_Employee>();

            updateList.Add(employee);
            string xml = CommonUtil.ConvertToXml_Store(updateList);

            return(base.UpdateEmployee(xml));
        }
Beispiel #4
0
        public List <tbm_Site> DeleteSite(doSite site)
        {
            try
            {
                ApplicationErrorException.CheckMandatoryField <doSite, tbm_SiteCondition>(site);

                //Check whether this record is the most updated data
                List <doGetTbm_Site> sList = this.GetTbm_Site(site.SiteCode);
                if (DateTime.Compare(sList[0].UpdateDate.Value, site.UpdateDate.Value) != 0)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019);
                }

                List <tbm_Site> lst = this.DeleteSite(site.SiteCode);

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

                return(lst);
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Get Site Information and Contract with same site.
        /// </summary>
        /// <param name="strSiteCode"></param>
        /// <returns></returns>
        public dsSiteInfoForView GetSiteInfoForView(string strSiteCode)
        {
            try
            {
                dsSiteInfoForView     SiteInfoForView = new dsSiteInfoForView();
                ISiteMasterHandler    handSite        = ServiceContainer.GetService <ISiteMasterHandler>() as ISiteMasterHandler;
                doSiteSearchCondition doSiteSeachCond = new doSiteSearchCondition();
                doSiteSeachCond.SiteCode = strSiteCode;
                List <dtSiteData> dtSiteData = handSite.GetSiteDataForSearch(doSiteSeachCond);

                CommonUtil.MappingObjectLanguage <dtSiteData>(dtSiteData);


                if (dtSiteData.Count <= 0)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                }
                else
                {
                    SiteInfoForView.dtSiteData = dtSiteData;
                }

                IViewContractHandler       handView       = ServiceContainer.GetService <IViewContractHandler>() as IViewContractHandler;
                List <dtContractsSameSite> dtContSameSite = handView.GetContractsListForViewSite(strSiteCode);

                SiteInfoForView.dtContractsSameSite = dtContSameSite;
                return(SiteInfoForView);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #6
0
        /// <summary>
        /// Check duplicate customer
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public bool CheckDuplicateCustomer(doCustomer customer)
        {
            try
            {
                doCustomer cust = CommonUtil.CloneObject <doCustomer, doCustomer>(customer);
                if (cust != null)
                {
                    if (CommonUtil.IsNullOrEmpty(cust.CustCode) == false ||
                        CommonUtil.IsNullOrEmpty(cust.CustNameLC) == false)
                    {
                        for (int i = 32; i <= 125; i++)
                        {
                            string key = null;
                            if ((i >= 32 && i <= 46) ||
                                (i >= 58 && i <= 64) ||
                                (i >= 91 && i <= 96) ||
                                (i >= 123 && i <= 125))
                            {
                                key = Char.ConvertFromUtf32(i);
                            }
                            if (CommonUtil.IsNullOrEmpty(key) == false)
                            {
                                if (CommonUtil.IsNullOrEmpty(cust.CustCode) == false)
                                {
                                    cust.CustCode = cust.CustCode.Replace(key, "");
                                }
                                if (CommonUtil.IsNullOrEmpty(cust.CustNameLC) == false)
                                {
                                    cust.CustNameLC = cust.CustNameLC.Replace(key, "");
                                }
                            }
                        }
                    }

                    List <int?> lst = base.CheckDuplicateCustomer(CustomerStatus.C_CUST_STATUS_EXIST,
                                                                  cust.CustCode,
                                                                  cust.IDNo,
                                                                  cust.CustNameLC);
                    if (lst.Count > 0)
                    {
                        if (lst[0] == 1)
                        {
                            throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1003);
                        }
                        else if (lst[0] == 2)
                        {
                            throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1004);
                        }
                    }
                }

                return(false);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public List <tbm_PermissionDetail> DeletePermissionTypeIndividual(string permissionGroupCode, string permissionIndividualCode, DateTime updateDate)
        {
            List <DateTime?> updateDateList = base.GetPermissionIndividualUpdateDate(permissionGroupCode, permissionIndividualCode);

            if (updateDateList == null || updateDateList.Count == 0 || updateDateList[0] == null ||
                updateDate == null)
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, new string[] { "UpdateDate" });
            }

            if (updateDateList[0].Value.CompareTo(updateDate) != 0)
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019, new string[] { permissionIndividualCode });
            }

            List <tbm_PermissionDetail> result = null;

            using (TransactionScope scope = new TransactionScope()) {
                try {
                    ILogHandler      hand    = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                    doTransactionLog logData = new doTransactionLog()
                    {
                        TransactionType = doTransactionLog.eTransactionType.Delete,
                        TableName       = null,
                        TableData       = null
                    };

                    List <tbm_PermissionIndividualDetail> listIndDetail = base.DeletePermissionIndividualDetail(permissionGroupCode, permissionIndividualCode);
                    if (listIndDetail.Count != 0)
                    {
                        logData.TableData = CommonUtil.ConvertToXml(listIndDetail);
                        logData.TableName = TableName.C_TBL_NAME_PERMISSION_IND_DETAIL;
                        hand.WriteTransactionLog(logData);
                    }

                    List <tbm_PermissionIndividual> listInd = base.DeletePermissionIndividual(permissionGroupCode, permissionIndividualCode);
                    if (listInd.Count != 0)
                    {
                        logData.TableData = CommonUtil.ConvertToXml(listInd);
                        logData.TableName = TableName.C_TBL_NAME_PERMISSION_IND;
                        hand.WriteTransactionLog(logData);
                    }

                    result = base.DeletePermissionDetail(permissionGroupCode, permissionIndividualCode);
                    if (result.Count != 0)
                    {
                        logData.TableData = CommonUtil.ConvertToXml(result);
                        logData.TableName = TableName.C_TBL_NAME_PERMISSION_DETAIL;
                        hand.WriteTransactionLog(logData);
                    }
                } catch (Exception ex) {
                    throw ex;
                }

                scope.Complete();
            }
            return(result);
        }
Beispiel #8
0
        /// <summary>
        /// Update contract email
        /// </summary>
        /// <param name="doUpdate"></param>
        /// <returns></returns>
        public List <tbt_ContractEmail> UpdateTbt_ContractEmail(tbt_ContractEmail doUpdate)
        {
            bool isBatch = false;

            try
            {
                //Check whether this record is the most updated data
                List <tbt_ContractEmail> rList = this.GetTbt_ContractEmail(doUpdate.ContractEmailID);
                //if (rList[0].UpdateDate != doUpdate.UpdateDate)
                if (DateTime.Compare(rList[0].UpdateDate.Value, doUpdate.UpdateDate.Value) != 0)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019);
                }

                //set updateDate and updateBy

                try
                {
                    doUpdate.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                    doUpdate.UpdateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
                }
                catch (Exception) //Call by Batch
                {
                    isBatch             = true;
                    doUpdate.UpdateDate = DateTime.Now;
                }


                List <tbt_ContractEmail> doUpdateList = new List <tbt_ContractEmail>();
                doUpdateList.Add(doUpdate);
                List <tbt_ContractEmail> updatedList = base.UpdateTbt_ContractEmail(CommonUtil.ConvertToXml_Store <tbt_ContractEmail>(doUpdateList));

                //Insert Log
                if (updatedList.Count > 0)
                {
                    doTransactionLog logData = new doTransactionLog();
                    logData.TransactionType = doTransactionLog.eTransactionType.Update;
                    logData.TableName       = TableName.C_TBL_NAME_CON_EMAIL;
                    logData.TableData       = CommonUtil.ConvertToXml(updatedList);
                    ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                    if (isBatch)
                    {
                        hand.WriteTransactionLog(logData, doUpdate.UpdateBy, "CMS050");
                    }
                    else
                    {
                        hand.WriteTransactionLog(logData);
                    }
                }

                return(updatedList);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #9
0
        /// <summary>
        /// Get Rental Basic information from tbt_RentalBasic
        /// </summary>
        /// <param name="strLongContratCode"></param>
        /// <returns></returns>
        public dsRentalBasicForHistDigestView GetRentalBasicForHistoryDigestView(string strLongContratCode)
        {
            try
            {
                dsRentalBasicForHistDigestView          dsRentBasicForHDView = new dsRentalBasicForHistDigestView();
                IRentralContractHandler                 handRen = ServiceContainer.GetService <IRentralContractHandler>() as IRentralContractHandler;
                List <dtTbt_RentalContractBasicForView> lstTbt_RentalContractBasicForView = handRen.GetTbt_RentalContractBasicForView(strLongContratCode);
                if (lstTbt_RentalContractBasicForView.Count <= 0)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                }
                dsRentBasicForHDView.dtTbt_RentalContractBasicForView = lstTbt_RentalContractBasicForView;

                //2.3
                ICommonHandler handCom = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                //List<doMiscTypeCode> MiscTypeCode = new List<doMiscTypeCode>();
                //for (int i = 0; i < 3; i++)
                //    MiscTypeCode.Add(new doMiscTypeCode());

                //MiscTypeCode[0].FieldName = MiscType.C_RENTAL_CHANGE_TYPE;
                //MiscTypeCode[0].ValueCode = "%";
                //MiscTypeCode[1].FieldName = MiscType.C_INCIDENT_TYPE;
                //MiscTypeCode[1].ValueCode = "%";
                //MiscTypeCode[2].FieldName = MiscType.C_AR_TYPE;
                //MiscTypeCode[2].ValueCode = "%";

                //List<doMiscTypeCode> MiscTypeResult = handCom.GetMiscTypeCodeList(MiscTypeCode);
                //dsRentBasicForHDView.dtMiscellaneousType = MiscTypeResult;

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

                List <dtRentalHistoryDigest> dtRentalHistoryDigest = handView.GetRentalHistoryDigestList(dsRentBasicForHDView.dtTbt_RentalContractBasicForView[0].ContractCode, null, null);

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

                dsRentBasicForHDView.dtRentalHistoryDigest = dtRentalHistoryDigest;
                return(dsRentBasicForHDView);
            }
            catch (Exception) { throw; }
        }
Beispiel #10
0
        /// <summary>
        /// Process - transaction log
        /// </summary>
        /// <param name="doTrans"></param>
        /// <param name="empNo"></param>
        /// <param name="screenID"></param>
        /// <returns></returns>
        public bool WriteTransactionLog(doTransactionLog doTrans, string empNo = null, string screenID = null)
        {
            // Akat K. 2011-10-27 : add mandatory check
            List <string> messageParam = new List <string>();

            if (doTrans.TableData == null)
            {
                messageParam.Add("TableData");
            }
            if (doTrans.TableName == null)
            {
                messageParam.Add("TableName");
            }
            if (doTrans.TransactionType == null)
            {
                messageParam.Add("TransactionType");
            }
            if (messageParam.Count > 0)
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, messageParam.ToArray <string>());
            }

            string xml = toXmlString(doTrans.TableData, doTrans.TransactionType.ToString().Substring(0, 1));



            List <int?> tmp;

            if (empNo == null)
            {
                tmp = base.WriteTransactionLog(CommonUtil.dsTransData.dtOperationData.GUID, CommonUtil.dsTransData.dtTransHeader.ScreenID, doTrans.TableName, xml, CommonUtil.dsTransData.dtOperationData.ProcessDateTime, CommonUtil.dsTransData.dtUserData.EmpNo);
            }
            else
            {
                //using in Batch Process CMS050
                Guid g;
                g   = Guid.NewGuid();
                tmp = base.WriteTransactionLog(g.ToString()
                                               , screenID
                                               , doTrans.TableName
                                               , xml
                                               , DateTime.Now
                                               , empNo);
            }

            return(tmp[0] > 0 ? true : false);
        }
Beispiel #11
0
        /// <summary>
        /// To generate project code
        /// </summary>
        /// <returns></returns>
        public string GenerateProjectCode()
        {
            try
            {
                ICommonHandler hand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

                //1.	Call method for get next running code
                List <doRunningNo> doRunningNo = null;
                try
                {
                    doRunningNo = hand.GetNextRunningCode(NameCode.C_NAME_CODE_PROJECT_CODE, true);
                }
                catch
                {
                }

                bool isFound = false;
                if (doRunningNo != null)
                {
                    if (doRunningNo.Count > 0)
                    {
                        if (CommonUtil.IsNullOrEmpty(doRunningNo[0].RunningNo) == false)
                        {
                            isFound = true;
                        }
                    }
                }
                if (isFound == false)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3131);
                }

                //2.	Call method for get the check digit
                string strCheckDigit = hand.GenerateCheckDigit(doRunningNo[0].RunningNo);

                //3.	Create project code
                string strProjectCode = ProjectCode.C_PROJECT_CODE_PREFIX + doRunningNo[0].RunningNo + strCheckDigit;

                //4.	Return strProjectCode
                return(strProjectCode);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #12
0
 public tbm_Supplier GetSupplier(string strSupplierCode, string strSupplierName)
 {
     try
     {
         List <tbm_Supplier> obj = base.GetSupplier(strSupplierCode, strSupplierName);
         if (obj.Count > 0)
         {
             CommonUtil.MappingObjectLanguage(obj);
             return(obj[0]);
         }
         return(new tbm_Supplier());
     }
     catch (Exception)
     {
         throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
     }
 }
        /// <summary>
        /// Update contract email data
        /// </summary>
        /// <param name="listEmail"></param>
        /// <returns></returns>
        public int UpdateTbt_ContractEmail(List <tbt_ContractEmail> listEmail) //Add by Jutarat A. on 14012014
        {
            try
            {
                if (listEmail != null)
                {
                    List <tbt_ContractEmail> rList;
                    dsTransDataModel         dsTrans = CommonUtil.dsTransData;
                    foreach (tbt_ContractEmail data in listEmail)
                    {
                        rList = this.GetTbt_ContractEmail(data.ContractEmailID);
                        if (DateTime.Compare(rList[0].UpdateDate.Value, data.UpdateDate.Value) != 0)
                        {
                            throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019);
                        }

                        data.UpdateDate = dsTrans.dtOperationData.ProcessDateTime;
                        data.UpdateBy   = dsTrans.dtUserData.EmpNo;
                    }
                }

                List <tbt_ContractEmail> res = this.UpdateTbt_ContractEmail(CommonUtil.ConvertToXml_Store <tbt_ContractEmail>(listEmail));

                #region Log

                doTransactionLog logData = new doTransactionLog()
                {
                    TransactionType = doTransactionLog.eTransactionType.Update,
                    TableName       = TableName.C_TBL_NAME_CON_EMAIL,
                    TableData       = CommonUtil.ConvertToXml(res)
                };

                ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                hand.WriteTransactionLog(logData);

                #endregion

                return(res.Count);
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Update group data.<br />
        /// - Check update date.<br />
        /// - Call UpdateGroup stored procedure.<br />
        /// - Write transaction log.
        /// </summary>
        /// <param name="doUpdate"></param>
        /// <returns></returns>
        public List <tbm_Group> UpdateGroup(doGroup doUpdate)
        {
            try
            {
                //Check whether this record is the most updated data
                List <tbm_Group> rList = this.GetTbm_Group(doUpdate.GroupCode);
                if (DateTime.Compare(rList[0].UpdateDate.Value, doUpdate.UpdateDate.Value) != 0)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019);
                }

                //set updateDate and updateBy
                doUpdate.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                doUpdate.UpdateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;

                List <tbm_Group> updatedList = base.UpdateGroup(
                    doUpdate.GroupCode
                    , doUpdate.GroupNameEN
                    , doUpdate.GroupNameLC
                    , doUpdate.Memo
                    , doUpdate.GroupOfficeCode
                    , doUpdate.GroupEmpNo
                    , doUpdate.DeleteFlag
                    , doUpdate.UpdateDate
                    , doUpdate.UpdateBy);

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

                return(updatedList);
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Delete employee data
        /// </summary>
        /// <param name="employee"></param>
        /// <returns></returns>
        public List <tbm_Employee> DeleteEmployee(tbm_Employee employee)
        {
            List <DateTime?> updateDateList = base.GetEmployeeUpdateDate(employee.EmpNo);

            if (updateDateList == null || updateDateList.Count == 0 || updateDateList[0] == null ||
                employee.UpdateDate == null || !employee.UpdateDate.HasValue)
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, new string[] { "UpdateDate" });
            }

            if (updateDateList[0].Value.CompareTo(employee.UpdateDate.Value) != 0)
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019, new string[] { employee.EmpNo });
            }

            employee.UpdateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
            employee.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
            return(base.DeleteEmployee(employee.EmpNo, employee.DeleteFlag, employee.UpdateBy, employee.UpdateDate));
        }
        public List <tbm_InstrumentExpansion> DeleteInstrumentExpansion(tbm_InstrumentExpansion doDelete)
        {
            try
            {
                //Check whether this record is the most updated data
                List <tbm_InstrumentExpansion> rList = this.GetTbm_InstrumentExpansion(doDelete.InstrumentCode, doDelete.ChildInstrumentCode);
                if (rList == null || rList.Count == 0 || rList[0] == null ||
                    rList[0].UpdateDate == null || !rList[0].UpdateDate.HasValue ||
                    doDelete.UpdateDate == null || !doDelete.UpdateDate.HasValue)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, new string[] { "UpdateDate" });
                }
                if (DateTime.Compare(rList[0].UpdateDate.Value, doDelete.UpdateDate.Value) != 0)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019, new string[] { doDelete.InstrumentCode });
                }

                //set updateDate and updateBy
                //doDelete.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                //doDelete.UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo;

                List <tbm_InstrumentExpansion> deletedList = base.DeleteInstrumentExpansion(doDelete.ChildInstrumentCode
                                                                                            , doDelete.InstrumentCode);

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

                return(deletedList);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public List <tbm_Instrument> UpdateInstrument(tbm_Instrument instrument)
        {
            List <DateTime?> updateDateList = base.GetInstrumentUpdateDate(instrument.InstrumentCode);

            if (updateDateList == null || updateDateList.Count == 0 || updateDateList[0] == null ||
                instrument.UpdateDate == null || !instrument.UpdateDate.HasValue)
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, new string[] { "UpdateDate" });
            }
            if (updateDateList[0].Value.CompareTo(instrument.UpdateDate.Value) != 0)
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019, new string[] { instrument.InstrumentCode });
            }

            instrument.UpdateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
            instrument.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;

            //8.5	Update instrument data
            List <tbm_Instrument> updateList = new List <tbm_Instrument>();

            updateList.Add(instrument);
            string xml = CommonUtil.ConvertToXml_Store(updateList);
            List <tbm_Instrument> listUpdated = base.UpdateInstrument(xml);

            if (listUpdated == null || listUpdated.Count == 0)
            {
                return(null);
            }
            else
            {
                doTransactionLog logData = new doTransactionLog()
                {
                    TransactionType = doTransactionLog.eTransactionType.Update,
                    TableName       = TableName.C_TBL_NAME_INSTRUMENT,
                    TableData       = CommonUtil.ConvertToXml(listUpdated)
                };
                ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                hand.WriteTransactionLog(logData);
            }

            return(listUpdated);
        }
        /// <summary>
        /// Check and update date  belonging data
        /// </summary>
        /// <param name="checkList"></param>
        public void checkBelongingUpdateDate(List <View_tbm_Belonging> checkList)
        {
            foreach (var belonging in checkList)
            {
                List <DateTime?> updateDateList = base.GetBelongingUpdateDate(belonging.BelongingID);
                if (updateDateList == null || updateDateList.Count == 0 || updateDateList[0] == null ||
                    belonging.UpdateDate == null || !belonging.UpdateDate.HasValue)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, new string[] { "UpdateDate" });
                }

                if (updateDateList[0].Value.CompareTo(belonging.UpdateDate.Value) != 0)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019, new string[] { belonging.EmpNo });
                }

                belonging.UpdateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
                belonging.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
            }
        }
        private List <tbm_PermissionIndividual> updatePermissionIndividual(doPermission permission)
        {
            List <DateTime?> updateDateList = base.GetPermissionIndividualUpdateDate(permission.PermissionGroupCode, permission.PermissionIndividualCode);

            if (updateDateList == null || updateDateList.Count == 0 || updateDateList[0] == null ||
                permission.UpdateDate == null || !permission.UpdateDate.HasValue)
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, new string[] { "UpdateDate" });
            }

            if (updateDateList[0].Value.CompareTo(permission.UpdateDate.Value) != 0)
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019, new string[] { permission.PermissionIndividualCode });
            }

            return(base.UpdatePermissionIndividual(permission.PermissionGroupCode,
                                                   permission.PermissionIndividualCode,
                                                   permission.PermissionIndividualName,
                                                   CommonUtil.dsTransData.dtOperationData.ProcessDateTime,
                                                   CommonUtil.dsTransData.dtUserData.EmpNo));
        }
Beispiel #20
0
        /// <summary>
        /// Manage Customer Information
        /// </summary>
        /// <param name="strCustCode"></param>
        public void ManageCustomerInformation(string strCustCode)
        {
            // Akat K. 2011-10-27 : add mandatory check
            if (strCustCode == null)
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, "strCustCode");
            }

            try
            {
                List <dtManageCustomerInformation> info = base.ManageCustomerInformation(strCustCode, CustomerStatus.C_CUST_STATUS_NEW);
                if (info.Count > 0)
                {
                    UpdateCustomerStatus(CustomerStatus.C_CUST_STATUS_EXIST, CustomerStatus.C_CUST_STATUS_NEW, strCustCode,
                                         CommonUtil.dsTransData.dtUserData.EmpNo, CommonUtil.dsTransData.dtOperationData.ProcessDateTime);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #21
0
        /// <summary>
        /// Update project stockout instrument
        /// </summary>
        /// <param name="doUpdate"></param>
        /// <returns></returns>
        public List <tbt_ProjectStockoutInstrument> UpdateTbt_ProjectStockoutInstrument(tbt_ProjectStockoutInstrument doUpdate)
        {
            try
            {
                //Check whether this record is the most updated data
                List <tbt_ProjectStockoutInstrument> rList = this.GetTbt_ProjectStockoutInstrument(doUpdate.ProjectCode, doUpdate.InstrumentCode);
                //if (rList[0].UpdateDate != doUpdate.UpdateDate)
                if (rList[0].UpdateDate != null && doUpdate.UpdateDate != null && DateTime.Compare(rList[0].UpdateDate.Value, doUpdate.UpdateDate.Value) != 0)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019);
                }

                //set updateDate and updateBy
                doUpdate.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                doUpdate.UpdateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;

                List <tbt_ProjectStockoutInstrument> doUpdateList = new List <tbt_ProjectStockoutInstrument>();
                doUpdateList.Add(doUpdate);
                List <tbt_ProjectStockoutInstrument> updatedList = base.UpdateTbt_ProjectStockoutInstrument(CommonUtil.ConvertToXml_Store <tbt_ProjectStockoutInstrument>(doUpdateList));

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

                return(updatedList);
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// To generate contract code
        /// </summary>
        /// <param name="strProductTypeCode"></param>
        /// <returns></returns>
        public string GenerateContractCode(string strProductTypeCode)
        {
            try
            {
                //1.	Get product type data
                ICommonHandler         hand            = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <tbs_ProductType> productTypeList = hand.GetTbs_ProductType(null, strProductTypeCode);

                //1.2.	Check existing of returned data
                if (productTypeList.Count <= 0 || productTypeList[0].ContractPrefix == null || productTypeList[0].ContractPrefix == string.Empty)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3022);
                }

                //2.	Call method for get next running code
                List <doRunningNo> runningNoList = hand.GetNextRunningCode(NameCode.C_NAME_CODE_CONTRACT_CODE);

                if (runningNoList.Count <= 0 || runningNoList[0].RunningNo == null || runningNoList[0].RunningNo == string.Empty)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_CONTRACT, MessageUtil.MessageList.MSG3130);
                }

                //3.	Call method for get the check digit
                //3.1.	Call		CommonHandler.GenerateCheckDigit
                string iCheckDigit = hand.GenerateCheckDigit(runningNoList[0].RunningNo);

                //4.	Create contract code
                //4.1.	Set strContractCode = dtTbs_ProductType[0].ContractPrefix + strRunningCode + iCheckDigit
                string strContractCode = productTypeList[0].ContractPrefix + runningNoList[0].RunningNo + iCheckDigit;

                //5.	Return strContractCode
                return(strContractCode);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #23
0
        /// <summary>
        /// Insert billing client
        /// </summary>
        /// <param name="billingClientCode"></param>
        /// <returns></returns>
        public List <dtBillingClientData> GetBillingClient(string billingClientCode)
        {
            // Akat K. 2011-10-27 : add mandatory check
            if (billingClientCode == null)
            {
                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, "siteCode");
            }

            List <dtBillingClientData> listBillingClientData;

            try
            {
                listBillingClientData = base.GetBillingClient(MiscType.C_CUST_TYPE, billingClientCode);

                CommonUtil.MappingObjectLanguage <dtBillingClientData>(listBillingClientData);

                return(listBillingClientData);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #24
0
        /// <summary>
        ///  Refresh permission data of dsTrans object
        /// </summary>
        /// <param name="dsTrans"></param>
        public void RefreshPermissionData(dsTransDataModel dsTrans)
        {
            try
            {
                dsTrans.dtUserPermissionData = new Dictionary <string, UserPermissionDataDo>();

                string xmlDtBelonging = CommonUtil.ConvertToXml_Store <UserBelongingData>(dsTrans.dtUserBelongingData);
                List <dtUserPermission> dtUserPermiss = base.RefreshPermissionData(dsTrans.dtUserData.EmpNo, xmlDtBelonging);
                foreach (dtUserPermission i in dtUserPermiss)
                {
                    string key = dsTrans.GenerateKey(i.ObjectID, i.FuncionID.ToString());
                    dsTrans.dtUserPermissionData[key] = new UserPermissionDataDo(i.ObjectID, (int)i.FuncionID, i.ObjectTypeCode);
                }

                if (dsTrans.dtUserPermissionData.Count <= 0)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0033);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #25
0
        /// <summary>
        /// Manage customer target
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public doCustomerTarget ManageCustomerTarget(doCustomerTarget cond)
        {
            try
            {
                // Akat K. check mandatory field
                List <string> messageParam = new List <string>();
                if (cond.doCustomer.CustNameEN == null)
                {
                    messageParam.Add("CustNameEN");
                }
                //if (cond.doCustomer.CustNameLC == null)
                //{
                //    messageParam.Add("CustNameLC");
                //}
                if (cond.doCustomer.CustTypeCode == null)
                {
                    messageParam.Add("CustTypeCode");
                }
                if (cond.doCustomer.BusinessTypeCode == null)
                {
                    messageParam.Add("BusinessTypeCode");
                }
                if (cond.doCustomer.RegionCode == null)
                {
                    messageParam.Add("RegionCode");
                }
                if (cond.doCustomer.AddressEN == null)
                {
                    messageParam.Add("AddressEN");
                }
                //if (cond.doCustomer.RoadEN == null) {
                //    messageParam.Add("RoadEN");
                //}
                if (cond.doCustomer.SubDistrictEN == null)
                {
                    messageParam.Add("SubDistrictEN");
                }
                //if (cond.doCustomer.AddressLC == null)
                //{
                //    messageParam.Add("AddressLC");
                //}
                //if (cond.doCustomer.RoadLC == null) {
                //    messageParam.Add("RoadLC");
                //}
                //if (cond.doCustomer.SubDistrictLC == null)
                //{
                //    messageParam.Add("SubDistrictLC");
                //}
                if (cond.doCustomer.DistrictCode == null)
                {
                    messageParam.Add("DistrictCode");
                }
                if (cond.doCustomer.ProvinceCode == null)
                {
                    messageParam.Add("ProvinceCode");
                }
                if (messageParam.Count > 0)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, messageParam.ToArray <string>());
                }

                if (CommonUtil.IsNullOrEmpty(cond.doCustomer.CustCode))
                {
                    cond.doCustomer.CustCode = this.GenerateCustomerCode();
                    if (cond.doCustomer.DummyIDFlag == true)
                    {
                        cond.doCustomer.IDNo = this.GenerateDummyID();
                    }
                    List <tbm_Customer> nLst = this.InsertCustomer(cond.doCustomer);
                    if (nLst.Count > 0)
                    {
                        cond.doCustomer.CustStatus = nLst[0].CustStatus;

                        ICommonHandler        hand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                        List <doMiscTypeCode> mLst = hand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                        {
                            new doMiscTypeCode()
                            {
                                FieldName = MiscType.C_CUST_STATUS,
                                ValueCode = cond.doCustomer.CustStatus
                            }
                        });
                        if (mLst.Count > 0)
                        {
                            cond.doCustomer.CustStatusName = mLst[0].ValueDisplay;
                        }
                    }

                    if (cond.doSite != null)
                    {
                        cond.doSite.SiteCode = null;
                    }
                }
                else
                {
                    List <doCustomer> custLst = this.GetCustomerByLanguage(cond.doCustomer.CustCode);
                    if (custLst.Count > 0)
                    {
                        bool           isChanged = false;
                        PropertyInfo[] props     = cond.doCustomer.GetType().GetProperties();
                        foreach (PropertyInfo prop in props)
                        {
                            if (prop.CanWrite == false ||
                                prop.PropertyType != typeof(string))
                            {
                                continue;
                            }

                            string val1 = (string)prop.GetValue(cond.doCustomer, null);

                            PropertyInfo cprop = custLst[0].GetType().GetProperty(prop.Name);
                            if (cprop != null)
                            {
                                string val2 = (string)cprop.GetValue(custLst[0], null);
                                if (val1 != val2)
                                {
                                    isChanged = true;
                                    break;
                                }
                            }
                        }
                        if (isChanged)
                        {
                            if (cond.doCustomer.IDNo != custLst[0].IDNo)
                            {
                                // Akat K. : modify follow DDS
                                //if (cond.doCustomer.DummyIDFlag == true
                                //    && custLst[0].DummyIDFlag == false)
                                if (custLst[0].DummyIDFlag == true &&
                                    cond.doCustomer.DummyIDFlag == false)
                                {
                                    this.UpdateCustomer(cond.doCustomer);
                                }
                                else
                                {
                                    cond.doCustomer.CustCode = this.GenerateCustomerCode();
                                    List <tbm_Customer> nLst = this.InsertCustomer(cond.doCustomer);
                                    if (nLst.Count > 0)
                                    {
                                        cond.doCustomer.CustStatus = nLst[0].CustStatus;

                                        ICommonHandler        hand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                                        List <doMiscTypeCode> mLst = hand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                                        {
                                            new doMiscTypeCode()
                                            {
                                                FieldName = MiscType.C_CUST_STATUS,
                                                ValueCode = cond.doCustomer.CustStatus
                                            }
                                        });
                                        if (mLst.Count > 0)
                                        {
                                            cond.doCustomer.CustStatusName = mLst[0].ValueDisplay;
                                        }
                                    }

                                    if (cond.doSite != null)
                                    {
                                        cond.doSite.SiteCode = null;
                                    }
                                }
                            }
                            else
                            {
                                List <int?> lst = this.IsUsedCustomer(cond.doCustomer.CustCode);
                                if (lst.Count > 0)
                                {
                                    if (lst[0] > 0)
                                    {
                                        throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_MASTER, MessageUtil.MessageList.MSG1041);
                                    }
                                }

                                this.UpdateCustomer(cond.doCustomer);
                            }
                        }
                    }
                }
                if (cond.dtCustomerGroup != null)
                {
                    if (cond.dtCustomerGroup.Count > 0)
                    {
                        List <dtCustomeGroupData> lst = CommonUtil.ClonsObjectList <dtCustomerGroup, dtCustomeGroupData>(cond.dtCustomerGroup);
                        foreach (dtCustomeGroupData group in lst)
                        {
                            group.CustCode = cond.doCustomer.CustCode;
                        }

                        this.DeleteCustomerGroup(lst);
                        this.InsertCustomerGroup(lst);
                    }
                }
                // Akat K. : if input none of CustomerGroup > clear all remain CustomerGroup
                if (cond.dtCustomerGroup == null || cond.dtCustomerGroup.Count == 0)
                {
                    base.ClearAllCustomerGroup(cond.doCustomer.CustCode);
                }

                if (cond.doSite != null)
                {
                    cond.doSite.CustCode = cond.doCustomer.CustCode;

                    ISiteMasterHandler iHand = ServiceContainer.GetService <ISiteMasterHandler>() as ISiteMasterHandler;

                    if (CommonUtil.IsNullOrEmpty(cond.doSite.SiteCode))
                    {
                        if (GenerateSiteCode(cond.doCustomer.CustCode, cond.doSite))
                        {
                            iHand.InsertSite(cond.doSite);
                        }
                    }
                    //else
                    //    iHand.UpdateSite(cond.doSite);
                }

                return(cond);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #26
0
        /// <summary>
        /// Update customer
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public List <tbm_Customer> UpdateCustomer(doCustomer customer)
        {
            try
            {
                //Check whether this record is the most updated data
                List <tbm_Customer> sList = this.GetTbm_Customer(customer.CustCode);

                if (sList == null || sList.Count == 0 || sList[0] == null || sList[0].UpdateDate == null ||
                    customer.UpdateDate == null || !customer.UpdateDate.HasValue)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007, new string[] { "UpdateDate" });
                }

                if (DateTime.Compare(sList[0].UpdateDate.Value, customer.UpdateDate.Value) != 0)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0019);
                }

                dsTransDataModel dsTrans = CommonUtil.dsTransData;
                //customer.UpdateDate = dsTrans.dtOperationData.ProcessDateTime;
                //customer.UpdateBy = dsTrans.dtUserData.EmpNo;

                List <tbm_Customer> lst = this.UpdateCustomer(customer.CustCode,
                                                              customer.CustStatus,
                                                              customer.ImportantFlag,
                                                              customer.CustNameEN,
                                                              customer.CustNameLC,
                                                              customer.CustFullNameEN,
                                                              customer.CustFullNameLC,
                                                              customer.RepPersonName,
                                                              customer.ContactPersonName,
                                                              customer.SECOMContactPerson,
                                                              customer.CustTypeCode,
                                                              customer.CompanyTypeCode,
                                                              customer.FinancialMarketTypeCode,
                                                              customer.BusinessTypeCode,
                                                              customer.PhoneNo,
                                                              customer.FaxNo,
                                                              customer.IDNo,
                                                              customer.DummyIDFlag,
                                                              customer.RegionCode,
                                                              customer.URL,
                                                              customer.Memo,
                                                              customer.AlleyEN,
                                                              customer.AddressEN,
                                                              customer.RoadEN,
                                                              customer.SubDistrictEN,
                                                              customer.AddressFullEN,
                                                              customer.AddressLC,
                                                              customer.AlleyLC,
                                                              customer.RoadLC,
                                                              customer.SubDistrictLC,
                                                              customer.AddressFullLC,
                                                              customer.DistrictCode,
                                                              customer.ProvinceCode,
                                                              customer.ZipCode,
                                                              customer.DeleteFlag,
                                                              dsTrans.dtOperationData.ProcessDateTime,
                                                              dsTrans.dtUserData.EmpNo);

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

                return(lst);
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Register stock in asset.<br />
        /// - Update inventory current.<br />
        /// - Update inventory slip.<br />
        /// - Update account transfer sample/new instrument.
        /// </summary>
        /// <returns></returns>
        public ActionResult cmdConfirmIVS012()
        {
            IVS012_ScreenParameter   prm  = GetScreenObject <IVS012_ScreenParameter>();
            List <doIvs012Inventory> Cond = prm.lstIVS012Inventory;
            ObjectResultData         res  = new ObjectResultData();

            using (TransactionScope scope = new TransactionScope())
            {
                decimal decMovingAveragePrice = 0;
                try
                {
                    ICommonHandler    comh = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                    IInventoryHandler InvH = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler;
                    if (comh.IsSystemSuspending())
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049);
                        return(Json(res));
                    }


                    #region Monthly Price @ 2015 : C_INV_SHELF_NO_NOT_PRICE has no longer been used.
                    ////5.3
                    //List<tbt_InventoryCurrent> SourceCurrent = InvH.GetTbt_InventoryCurrent(prm.office.OfficeCode, InstrumentLocation.C_INV_LOC_INSTOCK, null, ShelfNo.C_INV_SHELF_NO_NOT_PRICE, null);
                    //
                    //foreach (doIvs012Inventory i in Cond)
                    //{
                    //    List<tbt_InventoryCurrent> OriginCurrent = (from c in SourceCurrent where i.InstrumentCode == c.InstrumentCode && i.InstrumentArea == c.AreaCode select c).ToList<tbt_InventoryCurrent>();
                    //
                    //    if (OriginCurrent.Count > 0)
                    //    {
                    //        OriginCurrent[0].InstrumentQty = OriginCurrent[0].InstrumentQty - i.StockInQty;
                    //        OriginCurrent[0].UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                    //        OriginCurrent[0].UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo;
                    //        InvH.UpdateTbt_InventoryCurrent(OriginCurrent);
                    //    }
                    //}
                    //
                    //List<tbt_InventoryCurrent> exCurrent = InvH.GetTbt_InventoryCurrent(prm.office.OfficeCode, InstrumentLocation.C_INV_LOC_INSTOCK, null, ShelfNo.C_INV_SHELF_NO_NOT_MOVE_SHELF, null);
                    //
                    //foreach (doIvs012Inventory i in Cond)
                    //{
                    //    var current = exCurrent.Where(c => i.InstrumentCode == c.InstrumentCode && i.InstrumentArea == c.AreaCode);
                    //    if (current.Count() > 0)
                    //    {
                    //        tbt_InventoryCurrent InvCurrent = current.First();
                    //        InvCurrent.InstrumentQty = (InvCurrent.InstrumentQty.HasValue ? InvCurrent.InstrumentQty : 0) + i.StockInQty;
                    //        InvCurrent.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                    //        InvCurrent.UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo;
                    //
                    //        InvH.UpdateTbt_InventoryCurrent(new List<tbt_InventoryCurrent>(new tbt_InventoryCurrent[] { InvCurrent }));
                    //    }
                    //    else
                    //    {
                    //        tbt_InventoryCurrent InvCurrent = new tbt_InventoryCurrent();
                    //        InvCurrent.OfficeCode = prm.office.OfficeCode;
                    //        InvCurrent.LocationCode = InstrumentLocation.C_INV_LOC_INSTOCK;
                    //        InvCurrent.AreaCode = i.InstrumentArea;
                    //        InvCurrent.ShelfNo = ShelfNo.C_INV_SHELF_NO_NOT_MOVE_SHELF;
                    //        InvCurrent.InstrumentCode = i.InstrumentCode;
                    //        InvCurrent.InstrumentQty = i.StockInQty;
                    //        InvCurrent.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                    //        InvCurrent.UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo;
                    //        InvCurrent.CreateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                    //        InvCurrent.CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo;
                    //
                    //        InvH.InsertTbt_InventoryCurrent(new List<tbt_InventoryCurrent>(new tbt_InventoryCurrent[] { InvCurrent }));
                    //    }
                    //}
                    #endregion

                    //Modify by Jutarat A. on 30052013
                    //List<tbt_InventorySlip> lstSlip = InvH.GetTbt_InventorySlip(prm.SlipNo);
                    //List<tbt_InventorySlip> lstSlip = prm.lstInventorySlip;
                    List <tbt_InventorySlip> lstSlip = CommonUtil.ClonsObjectList <tbt_InventorySlip, tbt_InventorySlip>(prm.lstInventorySlip); //Modify by Jutarat A. on 31102013
                    if (lstSlip == null || lstSlip.Count == 0)
                    {
                        lstSlip = InvH.GetTbt_InventorySlip(prm.SlipNo);
                    }
                    //End Modify

                    foreach (tbt_InventorySlip slip in lstSlip)
                    {
                        slip.RegisterAssetFlag = RegisterAssetFlag.C_INV_REGISTER_ASSET_REGISTERED;
                        slip.VoucherID         = prm.VoucherNo;
                        slip.VoucherDate       = prm.VoucherDate;
                        //Comment by Jutarat A. on 30052013 (Set at UpdateTbt_InventorySlip())
                        //slip.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                        //slip.UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo;
                        //End Comment
                    }
                    InvH.UpdateTbt_InventorySlip(lstSlip);

                    DateTime Stock_InDate = lstSlip[0].StockInDate.GetValueOrDefault(DateTime.Now);

                    //5.6
                    foreach (doIvs012Inventory i in Cond)
                    {
                        ICommonHandler commonHandler = CSI.WindsorHelper.ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                        List <tbt_InventorySlipDetail> lstSlipDetail = InvH.GetTbt_InventorySlipDetail(prm.SlipNo, i.RunningNo);

                        if (lstSlipDetail.Count > 0)
                        {
                            lstSlipDetail[0].InstrumentCode = i.InstrumentCode;
                            //lstSlipDetail[0].InstrumentAmount = Convert.ToDecimal(i.StockInUnitPrice * i.StockInQty);
                            double errorCode = 0;
                            if (i.InstrumentAmountCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US)
                            {
                                lstSlipDetail[0].InstrumentAmount             = null;
                                lstSlipDetail[0].InstrumentAmountUsd          = Convert.ToDecimal(i.InstrumentAmountUsd); //Modify by Jutarat A. on 09042013
                                lstSlipDetail[0].InstrumentAmountCurrencyType = i.InstrumentAmountCurrencyType;
                            }
                            else
                            {
                                lstSlipDetail[0].InstrumentAmount             = Convert.ToDecimal(i.InstrumentTotalPrice); //Modify by Jutarat A. on 09042013
                                lstSlipDetail[0].InstrumentAmountUsd          = commonHandler.ConvertCurrencyPrice(Convert.ToDecimal(i.InstrumentTotalPrice), CurrencyUtil.C_CURRENCY_LOCAL, CurrencyUtil.C_CURRENCY_US, Stock_InDate, ref errorCode);
                                lstSlipDetail[0].InstrumentAmountCurrencyType = i.InstrumentAmountCurrencyType;

                                if (errorCode == RateCalcCode.C_ERROR_NO_RATE)
                                {
                                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0334);
                                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING_DIALOG;
                                }
                            }
                        }

                        List <tbt_InventorySlipDetail> doInventorySlipDetail = InvH.UpdateTbt_InventorySlipDetail(lstSlipDetail);

                        if (doInventorySlipDetail.Count <= 0)
                        {
                            throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0148, new string[] { TableName.C_TBL_NAME_INV_SLIP_DETAIL });
                        }

                        #region Monthly Price @ 2015 : moved to stock-in process (IVS010)
                        //if (i.InstrumentArea == InstrumentArea.C_INV_AREA_NEW_SAMPLE)
                        //{

                        //    doGroupSampleInstrument GroupSample = new doGroupSampleInstrument();
                        //    GroupSample.SourceOfficeCode = prm.office.OfficeCode;
                        //    GroupSample.DestinationOfficeCode = prm.office.OfficeCode;
                        //    GroupSample.SourceLocationCode = InstrumentLocation.C_INV_LOC_INSTOCK;
                        //    GroupSample.DestinationLocationCode = InstrumentLocation.C_INV_LOC_INSTOCK;
                        //    GroupSample.ContractCode = null;
                        //    GroupSample.ProjectCode = null;
                        //    GroupSample.Instrumentcode = i.InstrumentCode;
                        //    GroupSample.TransferQty = i.StockInQty;
                        //    GroupSample.ObjectID = ScreenID.C_INV_SCREEN_ID_STOCKIN_ASSET;
                        //    InvH.UpdateAccountTransferSampleInstrument(GroupSample, null);
                        //}
                        //else
                        //{
                        //    doGroupNewInstrument GroupNew = new doGroupNewInstrument();
                        //    GroupNew.SourceOfficeCode = prm.office.OfficeCode;
                        //    GroupNew.DestinationOfficeCode = prm.office.OfficeCode;
                        //    GroupNew.SourceLocationCode = InstrumentLocation.C_INV_LOC_INSTOCK;
                        //    GroupNew.DestinationLocationCode = InstrumentLocation.C_INV_LOC_INSTOCK;
                        //    GroupNew.ProjectCode = null;
                        //    GroupNew.ContractCode = null;
                        //    GroupNew.Instrumentcode = i.InstrumentCode;
                        //    GroupNew.TransferQty = i.StockInQty;

                        //    //GroupNew.UnitPrice = Convert.ToDecimal(i.StockInUnitPrice);
                        //    GroupNew.UnitPrice = Convert.ToDecimal(i.InstrumentTotalPrice / i.StockInQty); //Modify by Jutarat A. on 09042013

                        //    GroupNew.ObjectID = ScreenID.C_INV_SCREEN_ID_STOCKIN_ASSET;

                        //    decMovingAveragePrice = InvH.CalculateMovingAveragePrice(GroupNew);

                        //    bool blnUpdate = InvH.UpdateAccountTransferNewInstrument(GroupNew, Convert.ToDecimal(decMovingAveragePrice));
                        //}
                        #endregion
                    }

                    scope.Complete();
                    res.ResultData = true;
                    return(Json(res));
                }
                catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); }
            }
        }
Beispiel #28
0
        /// <summary>
        /// Event when click confirm cancel button, this function will cancel the issued receipt information of specific receipt no. to the system.
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult ICS060_cmdConfirmCancel(ICS060_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            doReceipt doReceipt;

            try
            {
                if (IsSuspend(res))
                {
                    return(Json(res));
                }

                if (!ICS060_IsAllowOperate(res))
                {
                    return(Json(res));
                }


                //Validate receipt business
                doReceipt = ICS060_ValidateReceiptBusiness(param, res);
                if (res.IsError || doReceipt == null)
                {
                    return(Json(res));
                }


                //Connect db
                using (TransactionScope scope = new TransactionScope())
                {
                    try
                    {
                        //Cancel receipt
                        IIncomeHandler incomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;

                        bool isSuccess = incomeHandler.CancelReceipt(doReceipt);
                        if (!isSuccess)
                        {
                            throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7031, null);
                        }

                        IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
                        //Get Invoice
                        doInvoice doInvoice = billingHandler.GetInvoice(doReceipt.InvoiceNo);
                        if (doInvoice == null)
                        {
                            throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7031, null);
                        }

                        //string invoiceType = billingHandler.GetInvoiceType(doInvoice.BillingTypeCode);
                        //if ((invoiceType == InvoiceType.C_INVOICE_TYPE_DEPOSIT || invoiceType == InvoiceType.C_INVOICE_TYPE_SERVICE)
                        //    && (doInvoice.IssueReceiptTiming != IssueRecieptTime.C_ISSUE_REC_TIME_SAME_INV
                        //        || (doInvoice.IssueReceiptTiming == IssueRecieptTime.C_ISSUE_REC_TIME_SAME_INV
                        //             && doInvoice.PaymentMethod == PaymentMethod.C_PAYMENT_METHOD_MESSENGER_TRANSFER)))
                        bool isIssuedTaxInvoice = billingHandler.CheckInvoiceIssuedTaxInvoice(doReceipt.InvoiceNo, doReceipt.InvoiceOCC);
                        if (isIssuedTaxInvoice == true)
                        {
                            if (param.CancelMethod == CancelReceiptTarget.C_CANCEL_TAX_INVOICE_RECEIPT)
                            {
                                //Cancel tax invoice (Update cancel flag only)
                                isSuccess = billingHandler.CancelTaxInvoice(doReceipt.TaxInvoiceNo);
                                if (!isSuccess)
                                {
                                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7032, null);
                                }
                            }
                            else
                            {
                                //Clear receipt no.
                                isSuccess = billingHandler.UpdateReceiptNo(doReceipt.InvoiceNo, doReceipt.InvoiceOCC, null);
                                if (!isSuccess)
                                {
                                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7032, null);
                                }
                            }
                        }


                        //Clear receipt no, invoice no of deposit fee
                        if (doInvoice.BillingTypeCode == BillingType.C_BILLING_TYPE_DEPOSIT &&
                            (doReceipt.AdvanceReceiptStatus == AdvanceReceiptStatus.C_INC_ADVANCE_RECEIPT_STATUS_NOT ||
                             doReceipt.AdvanceReceiptStatus == AdvanceReceiptStatus.C_INC_ADVANCE_RECEIPT_STATUS_PAID))
                        {
                            isSuccess = billingHandler.UpdateReceiptNoDepositFeeCancelReceipt(doInvoice.InvoiceNo, doReceipt.ReceiptNo
                                                                                              , CommonUtil.dsTransData.dtUserData.EmpNo
                                                                                              , CommonUtil.dsTransData.dtOperationData.ProcessDateTime);

                            if (!isSuccess)
                            {
                                throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7032, null);
                            }
                        }


                        //Show attention in case of paid receipt
                        if (doReceipt.AdvanceReceiptStatus == SECOM_AJIS.Common.Util.ConstantValue.AdvanceReceiptStatus.C_INC_ADVANCE_RECEIPT_STATUS_NOT ||
                            doReceipt.AdvanceReceiptStatus == SECOM_AJIS.Common.Util.ConstantValue.AdvanceReceiptStatus.C_INC_ADVANCE_RECEIPT_STATUS_PAID)
                        {
                            res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION_OK;
                            res.AddErrorMessage(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7030);
                        }

                        //Success
                        scope.Complete();
                        res.ResultData = "1";
                    }
                    catch (Exception ex)
                    {
                        scope.Dispose();
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }
            return(Json(res));
        }
        /// <summary>
        /// validate input data confirm and register data into database
        /// </summary>
        /// <returns></returns>
        public ActionResult ICS032_Confirm()
        {
            string conModeRadio1rdo1Invoice       = "1";
            string conModeRadio1rdo1BillingTarget = "2";

            ICS032_ScreenParameter param        = GetScreenObject <ICS032_ScreenParameter>();
            ICS032_RegisterData    RegisterData = new ICS032_RegisterData();
            CommonUtil             comUtil      = new CommonUtil();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;

            try
            {
                // Common Check Sequence

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

                tbt_InvoiceDebtTracing       _dotbt_InvoiceDebtTracing       = new tbt_InvoiceDebtTracing();
                tbt_BillingTargetDebtTracing _dotbt_BillingTargetDebtTracing = new tbt_BillingTargetDebtTracing();

                //Already checked at ICS032_Register()
                //if (handlerCommon.IsSystemSuspending())
                //{
                //    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049);
                //    return Json(res);
                //}

                // Check User Permission

                //if (!CheckUserPermission(ScreenID.C_SCREEN_ID_REGISTER_CREDIT_NOTE, FunctionID.C_FUNC_ID_DEL) )
                //{
                //    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                //    return Json(res);
                //}

                string strBillingTargetCode = string.Empty;
                string strInvoiceNo         = string.Empty;
                int    intInvoiceOCC        = 0;

                if (param.doBillingTargetDebtSummaryList != null)
                {
                    if (param.doBillingTargetDebtSummaryList.Count != 0)
                    {
                        strBillingTargetCode = param.doBillingTargetDebtSummaryList[0].BillingTargetCode;
                    }
                }

                if (param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList != null)
                {
                    if (param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList.Count != 0)
                    {
                        strInvoiceNo  = param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList[0].InvoiceNo;
                        intInvoiceOCC = param.doGetUnpaidInvoiceDebtSummaryByBillingTargetList[0].InvoiceOCC;
                    }
                }

                using (TransactionScope scope = new TransactionScope())
                {
                    try
                    {
                        if (strInvoiceNo != string.Empty)
                        {
                            if (param.RegisterData.Header.rdoProcessType == conModeRadio1rdo1Invoice)
                            {
                                #region Tbt_InvoiceDebtTracing
                                _dotbt_InvoiceDebtTracing                   = new tbt_InvoiceDebtTracing();
                                _dotbt_InvoiceDebtTracing.InvoiceNo         = strInvoiceNo;
                                _dotbt_InvoiceDebtTracing.InvoiceOCC        = intInvoiceOCC;
                                _dotbt_InvoiceDebtTracing.TracingResult     = param.RegisterData.Header.cboTracingResault;
                                _dotbt_InvoiceDebtTracing.LastContactDate   = param.RegisterData.Header.dtpLastContractDate;
                                _dotbt_InvoiceDebtTracing.ExpectPaymentDate = param.RegisterData.Header.dtpExpectedPaymentdate;
                                _dotbt_InvoiceDebtTracing.PaymentMethod     = param.RegisterData.Header.cboPaymentMethods;
                                _dotbt_InvoiceDebtTracing.Memo              = param.RegisterData.Header.txtaMemo;

                                if (iincomeHandler.InsertTbt_InvoiceDebtTracing(_dotbt_InvoiceDebtTracing) <= 0)
                                {
                                    //res.AddErrorMessage(MessageUtil.MODULE_INCOME,
                                    //             "ICS032",
                                    //             MessageUtil.MODULE_INCOME,
                                    //             MessageUtil.MessageList.MSG7006,
                                    //             new string[] { },
                                    //             new string[] { });
                                    //return Json(res);

                                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7006, null);
                                }
                                #endregion
                            }
                        }
                        if (strBillingTargetCode != string.Empty)
                        {
                            if (param.RegisterData.Header.rdoProcessType == conModeRadio1rdo1BillingTarget)
                            {
                                #region Tbt_BillingTargetDebtTracing
                                _dotbt_BillingTargetDebtTracing = new tbt_BillingTargetDebtTracing();
                                _dotbt_BillingTargetDebtTracing.BillingTargetCode = strBillingTargetCode;
                                _dotbt_BillingTargetDebtTracing.TracingResult     = param.RegisterData.Header.cboTracingResault;
                                _dotbt_BillingTargetDebtTracing.LastContactDate   = param.RegisterData.Header.dtpLastContractDate;
                                _dotbt_BillingTargetDebtTracing.ExpectPaymentDate = param.RegisterData.Header.dtpExpectedPaymentdate;
                                _dotbt_BillingTargetDebtTracing.PaymentMethod     = param.RegisterData.Header.cboPaymentMethods;
                                _dotbt_BillingTargetDebtTracing.Memo = param.RegisterData.Header.txtaMemo;

                                if (iincomeHandler.InsertTbt_BillingTargetDebtTracing(_dotbt_BillingTargetDebtTracing) <= 0)
                                {
                                    //res.AddErrorMessage(MessageUtil.MODULE_INCOME,
                                    //             "ICS032",
                                    //             MessageUtil.MODULE_INCOME,
                                    //             MessageUtil.MessageList.MSG7006,
                                    //             new string[] { },
                                    //             new string[] { });
                                    //return Json(res);
                                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_INCOME, MessageUtil.MessageList.MSG7006, null);
                                }
                                #endregion
                            }
                        }
                        scope.Complete();
                    }
                    catch (Exception ex)
                    {
                        // Fail rollback all record
                        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 = null;
                }

                return(Json(res));
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }
            return(Json(res));
        }
Beispiel #30
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);
        }