예제 #1
0
        /// <summary>
        /// Retrieve dept target information list of specific screen mode and search criteria information
        /// </summary>
        /// <param name="data">Search criteria</param>
        /// <returns></returns>
        public ActionResult ICS031_SearchData(ICS031_RegisterData data)
        {
            ICS031_ScreenParameter param        = GetScreenObject <ICS031_ScreenParameter>();
            ICS031_RegisterData    RegisterData = new ICS031_RegisterData();
            CommonUtil             comUtil      = new CommonUtil();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            List <doGetDebtTarget> _doGetDebtTargetList = new List <doGetDebtTarget>();

            try
            {
                // Common Check Sequence

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

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

                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                ICS031_ScreenParameter sParam = GetScreenObject <ICS031_ScreenParameter>();

                _doGetDebtTargetList = iincomeHandler.GetDebtTarget();


                // add by Jirawat Jannet @ 2016-10-13
                #region Initial detail input datas for  bindinh to data grid

                string currencyLocal = MiscellaneousTypeCommon.getCurrencyName(CurrencyUtil.C_CURRENCY_LOCAL);
                string currencyUs    = MiscellaneousTypeCommon.getCurrencyName(CurrencyUtil.C_CURRENCY_US);

                List <ICS031_DetailData> _detailInputDatas = new List <ICS031_DetailData>();
                int no = 1;
                if (_doGetDebtTargetList != null)
                {
                    foreach (var item in _doGetDebtTargetList)
                    {
                        // local currency
                        _detailInputDatas.Add(new ICS031_DetailData()
                        {
                            No = no,
                            BillingOfficeCode            = item.BillingOfficeCode,
                            BillingOfficeName            = item.OfficeName,
                            AllUnpaidTargetAmount        = item.AmountAll,
                            AllUnpaidTargetBillingDetail = item.DetailAll,
                            UnpaidOverTargetAmount       = item.Amount2Month,
                            UnpaidOverBillingDetail      = item.Detail2Month,
                            CurrencyType     = CurrencyUtil.C_CURRENCY_LOCAL,
                            CurrencyTypeName = currencyLocal
                        });
                        // us currency
                        _detailInputDatas.Add(new ICS031_DetailData()
                        {
                            No = no,
                            BillingOfficeCode            = item.BillingOfficeCode,
                            BillingOfficeName            = item.OfficeName,
                            AllUnpaidTargetAmount        = item.AmountAllUsd,
                            AllUnpaidTargetBillingDetail = item.DetailAllUsd,
                            UnpaidOverTargetAmount       = item.Amount2MonthUsd,
                            UnpaidOverBillingDetail      = item.Detail2MonthUsd,
                            CurrencyType     = CurrencyUtil.C_CURRENCY_US,
                            CurrencyTypeName = currencyUs
                        });
                        no++;
                    }
                }

                #endregion

                param.RegisterData        = data;
                param.doGetDebtTargetList = _doGetDebtTargetList;
                param.detailInputDatas    = _detailInputDatas;

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

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

            return(Json(res));
        }