Ejemplo n.º 1
0
        /// <summary>
        /// Check screen authority and permission
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult ICS031_Authority(ICS031_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();
            // System Suspend
            ICommonHandler handlerCommon = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

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

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

            return(InitialScreenEnvironment <ICS031_ScreenParameter>("ICS031", param, res));
        }
        /// <summary>
        /// Getting billing occ list for load to grid
        /// </summary>
        /// <returns></returns>
        public ActionResult CMS420_LoadGridBillingOCC()
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                CMS420_ScreenParameter param = GetScreenObject <CMS420_ScreenParameter>();
                CommonUtil             cm    = new CommonUtil();

                string strContractCode_short = param.ContractCode;
                string strContractCode       = cm.ConvertContractCode(strContractCode_short, CommonUtil.CONVERT_TYPE.TO_LONG);

                IViewBillingHandler   viewBillingHandler = ServiceContainer.GetService <IViewBillingHandler>() as IViewBillingHandler;
                ICommonHandler        comHand            = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doMiscTypeCode> tmpCurrencies      = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                {
                    new doMiscTypeCode()
                    {
                        FieldName = MiscType.C_CURRENCT,
                        ValueCode = "%"
                    }
                }).ToList();
                List <dtViewBillingOccList> viewBillingOccListData = viewBillingHandler.GetViewBillingOccList(strContractCode);
                for (int i = 0; i < viewBillingOccListData.Count(); i++)
                {
                    viewBillingOccListData[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                }

                CommonUtil.MappingObjectLanguage <dtViewBillingOccList>(viewBillingOccListData);

                string xml = CommonUtil.ConvertToXml <dtViewBillingOccList>(viewBillingOccListData, "Common\\CMS420_BillingOCC", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                res.ResultData = xml;
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get email of default department
        /// </summary>
        /// <returns></returns>
        private String getEmailsOfDefaultDepartment()
        {
            //1.1 Get default department to send email
            ICommonHandler        handCommon = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            List <doSystemConfig> doSystem   = handCommon.GetSystemConfig(ConfigName.C_CONFIG_DEPARTMENT_NOTIFY_CHANGE_FEE);
            String strDeptCode = doSystem[0].ConfigValue;

            //1.2 Get employee belonging to default department
            //1.2.1 Get belonging list
            IEmployeeMasterHandler handMaster  = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
            List <dtBelonging>     dtBelonging = handMaster.GetBelonging(null, strDeptCode, null, null);

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

            foreach (dtBelonging belonging in dtBelonging)
            {
                tbm_Employee employee = new tbm_Employee();
                employee.EmpNo = belonging.EmpNo;
                empList.Add(employee);
            }

            //1.2.2 Get employee list
            List <tbm_Employee> dtEmployee = handMaster.GetEmployeeList(empList);

            //1.3 Generate list of email
            //1.3.1 Set emailTo = Combine all dtEmployee.EmailAddrss with seperated by semi-colon
            StringBuilder sbEmailTo = new StringBuilder("");

            foreach (tbm_Employee employee in dtEmployee)
            {
                sbEmailTo.Append(employee.EmailAddress + ";");
            }

            if (sbEmailTo.Length > 0)
            {
                sbEmailTo = sbEmailTo.Remove(sbEmailTo.Length - 1, 1);
            }

            return(sbEmailTo.ToString());
        }
Ejemplo n.º 4
0
        private void LoadBatchQueue(DateTime nextRunFrom, DateTime nextRunTo)
        {
            ICommonHandler commonHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

            var lstAllQueue = commonHandler.GetTbs_BatchQueue(null, nextRunFrom, nextRunTo).OrderBy(q => q.NextRun).ThenBy(q => q.RunId).ToList();

            foreach (var queueProxy in lstAllQueue)
            {
                var queue = CommonUtil.CloneObject <tbs_BatchQueue, tbs_BatchQueue>(queueProxy);

                JobDetail jobDetail = SequentialProcessJob.CreateJobDetail(queue, new QueueStatusUpdate(this.QueueStatusUpdate));

                var scheduledQueue = _lstBatchQueue.Where(q => q.RunId == queue.RunId).FirstOrDefault();
                if (scheduledQueue != null)
                {
                    _lstBatchQueue.Remove(scheduledQueue);
                }

                if (queue.Status == "W")
                {
                    Trigger trg = new SimpleTrigger(jobDetail.Name, null, queue.NextRun.ToUniversalTime(), null, 0, TimeSpan.Zero);

                    if (_scheduler.GetJobDetail(jobDetail.Name, jobDetail.Group) != null)
                    {
                        _scheduler.DeleteJob(jobDetail.Name, jobDetail.Group);
                    }

                    _scheduler.ScheduleJob(jobDetail, trg);
                }

                _lstBatchQueue.Add(queue);
            }

            var lstCompleted = _lstBatchQueue.Where(q => q.Status == "C").ToList();

            foreach (var queue in lstCompleted)
            {
                _lstBatchQueue.Remove(queue);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Check screen authority and permission
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult ICS110_Authority(ICS110_ScreenParameter param)
        {
            ICommonHandler handlerCommon  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            IIncomeHandler iincomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;

            ObjectResultData res = new ObjectResultData();

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

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

            return(InitialScreenEnvironment <ICS110_ScreenParameter>("ICS110", param, res));
        }
Ejemplo n.º 6
0
        ///<summary>
        ///Purpose:
        ///     Get system status  - Resume system
        ///
        ///Pre-Condition
        ///     Current date: 04/08/2011
        ///     Current time: 15:00
        ///
        ///Expected:
        ///     SuspendFlag : 0
        ///     ResumeServiceDateTime: 04/08/2011  18:00:00
        ///     SuspendServiceDateTime: 05/08/2011  9:00:00
        ///
        ///</summary>
        public string Case2()
        {
            ICommonHandler        target   = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            List <doSystemStatus> expected = new List <doSystemStatus>();
            doSystemStatus        status   = new doSystemStatus();

            status.SuspendFlag            = false;
            status.ResumeServiceDateTime  = new DateTime(2011, 8, 4, 18, 0, 0);
            status.SuspendServiceDateTime = new DateTime(2011, 8, 5, 9, 0, 0);

            List <doSystemStatus> actual = null;

            try {
                actual = target.GetSystemStatus();
            } catch (ApplicationErrorException ex) {
                actual = null;
            } catch (Exception ex) {
                actual = null;
            }

            return(string.Format(RESULT_FORMAT, 2, expected, actual, CompareResult_Object(expected, actual)));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Mapping description for payment type of payment information List
        /// </summary>
        /// <param name="doPayments">payment information list</param>
        private void ICS010_FillPaymentType(List <tbt_Payment> doPayments)
        {
            if (doPayments != null)
            {
                ICommonHandler commonHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <string>  listFieldName = new List <string>();
                listFieldName.Add(MiscType.C_PAYMENT_TYPE);
                List <doMiscTypeCode> listMisc = commonHandler.GetMiscTypeCodeListByFieldName(listFieldName);

                foreach (var doPayment in doPayments)
                {
                    if (!string.IsNullOrEmpty(doPayment.PaymentType))
                    {
                        List <doMiscTypeCode> miscs = listMisc.Where(d => d.ValueCode == doPayment.PaymentType).ToList(); // This result has language mapping already
                        if (listMisc != null && listMisc.Count > 0)
                        {
                            doPayment.PaymentTypeDisplay = miscs[0].ValueDisplay;
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Check email suffix
        /// </summary>
        /// <param name="addr"></param>
        /// <returns></returns>
        public ActionResult CMS060_CheckEmailSuffix(List <dtEmailAddress> addr)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                #region Get Email suffix

                string emailSuffix = "";

                ICommonHandler        chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doSystemConfig> emlst    = chandler.GetSystemConfig(ConfigName.C_EMAIL_SUFFIX);
                if (emlst.Count > 0)
                {
                    emailSuffix = emlst[0].ConfigValue;
                }

                #endregion

                foreach (dtEmailAddress a in addr)
                {
                    //if (a.EmailAddress.IndexOf(emailSuffix) < 0)
                    if (String.IsNullOrEmpty(a.EmailAddress) == false &&
                        a.EmailAddress.ToUpper().IndexOf(emailSuffix.ToUpper()) < 0)    //Modify by Jutarat A. on 21112012
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0151);
                        return(Json(res));
                    }
                }

                res.ResultData = true;
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Debt tracing result
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="id"></param>
        /// <param name="attribute"></param>
        /// <returns></returns>
        public static MvcHtmlString DebtTracingResultCombo(this HtmlHelper helper, string id, object attribute = null)
        {
            ICommonHandler comh = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            List <string>  lst  = new List <string>();

            lst.Add(MiscType.C_DEBT_TRACING_RESULT);
            List <doMiscTypeCode> dtMisc = comh.GetMiscTypeCodeListByFieldName(lst);

            if (CommonUtil.dsTransData != null)
            {
                if (!CommonUtil.dsTransData.ContainsPermission(ScreenID.C_SCREEN_ID_DEBT_TRACING, FunctionID.C_FUNC_ID_TRANSFER_TO_BRANCH))
                {
                    dtMisc = dtMisc.Where(d =>
                                          d.ValueCode != DebtTracingResult.C_DEBT_TRACE_RESULT_TRANSFER_TO_BRANCH &&
                                          d.ValueCode != DebtTracingResult.C_DEBT_TRACE_RESULT_TRANSFER_TO_HQ
                                          ).ToList();
                }
            }

            CommonUtil.eFirstElementType idx0_type = CommonUtil.eFirstElementType.Select;
            return(CommonUtil.CommonComboBox <doMiscTypeCode>(id, dtMisc, "ValueCodeDisplay", "ValueCode", attribute, true, idx0_type));
        }
Ejemplo n.º 10
0
        /// <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;
            }
        }
Ejemplo n.º 11
0
        public bool SendEmailChangePlanBeforeStart(doChangePlanBeforeStartEmail templateObj)
        {
            try
            {
                if (templateObj == null)
                {
                    throw new ArgumentNullException("templateObj");
                }

                ICommonHandler common = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                var            config = common.GetSystemConfig(ConfigName.C_CONFIG_CHANGEPLAN_BEFORE_START_EMAIL).FirstOrDefault();

                if (config == null)
                {
                    throw new ApplicationException("Missing tbs_configuration : " + ConfigName.C_CONFIG_CHANGEPLAN_BEFORE_START_EMAIL);
                }

                EmailTemplateUtil mailUtil = new EmailTemplateUtil(EmailTemplateName.C_EMAIL_TEMPLATE_NAME_CHANGEPLAN_BEFORE_START);
                var mailTemplate           = mailUtil.LoadTemplate(templateObj);

                doEmailProcess mailMsg = new doEmailProcess();
                mailMsg.MailFrom      = CommonUtil.dsTransData.dtUserData.EmailAddress;
                mailMsg.MailFromAlias = null;
                mailMsg.MailTo        = config.ConfigValue;
                mailMsg.Subject       = mailTemplate.TemplateSubject;
                mailMsg.Message       = mailTemplate.TemplateContent;
                mailMsg.IsBodyHtml    = true;

                ICommonHandler comHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                comHandler.SendMail(mailMsg);

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Check permission for access screen BLS090
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult BLS090_Authority(BLS090_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            // Is suspend ?
            ICommonHandler handler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

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

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


            return(InitialScreenEnvironment <object>("BLS090", param, res));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Get office checking list.
        /// </summary>
        /// <returns></returns>
        public ActionResult IVS150_GetOfficeCheckingList()
        {
            ObjectResultData            res  = new ObjectResultData();
            List <dtOfficeCheckingList> list = new List <dtOfficeCheckingList>();

            try
            {
                IInventoryHandler handlerInventory = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler;
                ICommonHandler    handlerCommon    = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

                list = handlerInventory.GetOfficeCheckingList(MiscType.C_INV_LOC);

                // Language Mapping
                CommonUtil.MappingObjectLanguage <dtOfficeCheckingList>(list);
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            res.ResultData = CommonUtil.ConvertToXml <dtOfficeCheckingList>(list, "Inventory\\IVS150_OfficeChecking", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
            return(Json(res));
        }
Ejemplo n.º 14
0
        ///<summary>
        ///Purpose:
        ///     Mandatory check
        ///
        ///Parameters:
        ///     doMailProcess:
        ///         MailTo: [email protected]
        ///         MailFrom: [email protected]
        ///         MailFromAlias: SECOM-AJIS
        ///         Subject: test
        ///         Message: last case
        ///
        ///Expected:
        ///     From: [email protected]
        ///     From (Display name): SECOM-AJIS
        ///     Header (Subject): test
        ///     Body (Content): last case
        ///
        ///</summary>
        public string Case4()
        {
            ICommonHandler target = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            doEmailProcess param  = new doEmailProcess();

            param.MailTo        = "*****@*****.**";
            param.MailFrom      = "*****@*****.**";
            param.MailFromAlias = "SECOM-AJIS";
            param.Subject       = "test";
            param.Message       = "last case";
            string expected = null;
            string actual   = null;

            try {
                target.SendMail(param).ToString();
            } catch (ApplicationErrorException ex) {
                actual = ex.ErrorResult.Message.Code;
            } catch (Exception ex) {
                actual = ex.StackTrace;
            }

            return(string.Format(RESULT_FORMAT, 4, expected, actual, CompareResult_String(expected, actual)));
        }
Ejemplo n.º 15
0
        public static void SendMail(object o)
        {
            try
            {
                SendMailObject obj = o as SendMailObject;
                if (obj == null)
                {
                    return;
                }

                if (obj.EmailList != null)
                {
                    ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                    foreach (doEmailProcess mail in obj.EmailList)
                    {
                        chandler.SendMail(mail);
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 16
0
        public ActionResult CMS026()
        {
            try
            {
                CMS026_ScreenParameter param = GetScreenObject <CMS026_ScreenParameter>();

                ICommonHandler            chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doPopupSubMenuList> lst      = chandler.GetPopupSubMenuList(param.PopupSubMenuID);

                ViewBag.PopupSubMenuList = lst;

                if (lst.Count > 0)
                {
                    ViewBag.PopupSubmenuName = lst[0].PopupSubmenuName;
                }
            }
            catch (Exception)
            {
                ViewBag.PopupSubMenuList = new List <doPopupSubMenuList>();
            }

            return(View());
        }
        /// <summary>
        /// Checking user's permission.
        /// </summary>
        /// <param name="param">Screen's parameter</param>
        /// <returns>Return the ActionResult of the screen.</returns>
        public ActionResult IVS200_Authority(IVS200_ScreenParameter param)
        {
            ObjectResultData res           = new ObjectResultData();
            ICommonHandler   commonhandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

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

                if (!CheckUserPermission(ScreenID.C_INV_SCREEN_ID_INQUIRE_INSTRUMENT))
                {
                    res.AddErrorMessage("Common", MessageUtil.MessageList.MSG0053, null, null);
                    return(Json(res));
                }

                IInventoryHandler invenhandler = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler;

                var headOffice = invenhandler.GetInventoryHeadOffice();
                if (headOffice == null || headOffice.Count <= 0)
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4016);
                    //res.ResultData = MessageUtil.MessageList.MSG0049.ToString();
                    return(Json(res));
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(InitialScreenEnvironment <IVS200_ScreenParameter>("IVS200", param, res));
        }
        /// <summary>
        /// Check ics032 popup screen authority and permission
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        public ActionResult ICS030_CheckForICS032()
        {
            // 1 = ok
            // 2 = Suspending
            // 3 = no permission
            string           ResultDataFlag = "1";
            ObjectResultData res            = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
            try
            {
                // System Suspend
                ICommonHandler handlerCommon = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                if (handlerCommon.IsSystemSuspending())
                {
                    ResultDataFlag = "2";
                    res.ResultData = ResultDataFlag;
                    return(Json(res));
                }

                if (!CheckUserPermission(ScreenID.C_SCREEN_ID_DEBT_TRACING_INFO, FunctionID.C_FUNC_ID_OPERATE))
                {
                    ResultDataFlag = "3";
                    res.ResultData = ResultDataFlag;
                    return(Json(res));
                }

                res.ResultData = ResultDataFlag;
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }
            return(Json(res));
        }
        /// <summary>
        /// Check screen authority and permission
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult CTS190_Authority(CTS190_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            //doContractInfoCondition param = new doContractInfoCondition();


            // Check permission
            if (!CheckUserPermission(ScreenID.C_SCREEN_ID_CP32, FunctionID.C_FUNC_ID_OPERATE))
            {
                res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                return(Json(res));
            }



            // Check system is syspend ?
            try
            {
                ICommonHandler handler   = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                bool           isSuspend = handler.IsSystemSuspending();


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

            return(InitialScreenEnvironment <CTS190_ScreenParameter>("CTS190", param, res));
        }
        /// <summary>
        /// Generate Unit comboitem list
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        public ActionResult IVS250_GetUnit(string id)
        {
            try
            {
                ICommonHandler comh   = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                var            lstAll = comh.GetMiscTypeCodeListByFieldName(new List <string>()
                {
                    MiscType.C_UNIT
                });
                var lstFilter = lstAll.ToList <doMiscTypeCode>();
                CommonUtil.MappingObjectLanguage <doMiscTypeCode>(lstFilter);

                ComboBoxModel cboModel = new ComboBoxModel();
                cboModel.SetList <doMiscTypeCode>(lstFilter, "ValueDisplay", "ValueCode", true, CommonUtil.eFirstElementType.Select);

                return(Json(cboModel));
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
        /// <summary>
        /// - Check system suspending.<br />
        /// - Check user permission for screen IVS050.<br />
        /// - Get inventory head office.
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public ActionResult IVS050_Authority(IVS050_ScreenParameter param)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                ICommonHandler comh = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                if (comh.IsSystemSuspending())
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049);
                    return(Json(res));
                }
                if (!CheckUserPermission(ScreenID.C_INV_SCREEN_ID_ELIMINATION, FunctionID.C_FUNC_ID_OPERATE))
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                    return(Json(res));
                }

                IInventoryHandler handInven    = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler;
                List <doOffice>   IvHeadOffice = handInven.GetInventoryHeadOffice();

                if (IvHeadOffice.Count <= 0)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4016);
                    return(Json(res));
                }

                param.office = IvHeadOffice[0];
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(InitialScreenEnvironment <IVS050_ScreenParameter>("IVS050", param, res));
        }
        public ActionResult IVS050()
        {
            ViewBag.Eliminate    = InstrumentLocation.C_INV_LOC_ELIMINATION;
            ViewBag.PreEliminate = InstrumentLocation.C_INV_LOC_PRE_ELIMINATION;

            ICommonHandler        hand            = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            List <doMiscTypeCode> lstMiscTypeCode = new List <doMiscTypeCode>();
            doMiscTypeCode        MiscTypeCode    = new doMiscTypeCode();

            MiscTypeCode.FieldName = MiscType.C_INV_LOC;
            MiscTypeCode.ValueCode = InstrumentLocation.C_INV_LOC_ELIMINATION;
            lstMiscTypeCode.Add(MiscTypeCode);
            MiscTypeCode           = new doMiscTypeCode();
            MiscTypeCode.FieldName = MiscType.C_INV_LOC;
            MiscTypeCode.ValueCode = InstrumentLocation.C_INV_LOC_PRE_ELIMINATION;
            lstMiscTypeCode.Add(MiscTypeCode);
            List <doMiscTypeCode> MiscLock = hand.GetMiscTypeCodeList(lstMiscTypeCode);

            CommonUtil.MappingObjectLanguage <doMiscTypeCode>(MiscLock);

            foreach (var i in MiscLock)
            {
                if (i.ValueCode == InstrumentLocation.C_INV_LOC_ELIMINATION)
                {
                    ViewBag.LabelEliminate = i.ValueDisplay;
                }
                else if (i.ValueCode == InstrumentLocation.C_INV_LOC_PRE_ELIMINATION)
                {
                    ViewBag.LabelPreEliminate = i.ValueDisplay;
                }
            }

            ViewBag.Total = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_INVENTORY, ScreenID.C_INV_SCREEN_ID_PRE_ELIMINATION, "lblTotalAmountOfTransferAsset");

            return(View());
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Generate misc type combobox
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="id"></param>
        /// <param name="fieldName"></param>
        /// <param name="firstElement"></param>
        /// <param name="attribute"></param>
        /// <param name="display_field"></param>
        /// <param name="include_idx0"></param>
        /// <returns></returns>
        private static MvcHtmlString MiscTypeComboBoxWithFirstElement(this HtmlHelper helper, string id, string fieldName, string firstElement = null, object attribute = null, string display_field = null, bool include_idx0 = true)
        {
            List <doMiscTypeCode> lst = new List <doMiscTypeCode>();

            try
            {
                List <doMiscTypeCode> miscs = new List <doMiscTypeCode>()
                {
                    new doMiscTypeCode()
                    {
                        FieldName = fieldName,
                        ValueCode = "%"
                    }
                };

                ICommonHandler hand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                lst = hand.GetMiscTypeCodeList(miscs);
            }
            catch
            {
            }

            if (lst == null)
            {
                lst = new List <doMiscTypeCode>();
            }

            string display = "ValueCodeDisplay";

            if (display_field != null)
            {
                display = display_field;
            }

            return(CommonUtil.CommonComboBoxWithCustomFirstElement <doMiscTypeCode>(id, lst, display, "ValueCode", firstElement, attribute, include_idx0));
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Download attach file
        /// </summary>
        /// <param name="AttachID"></param>
        /// <returns></returns>
        public ActionResult CMS180_DownloadAttach(string attachID, string installationSlipNo)
        {
            ObjectResultData res           = new ObjectResultData();
            ICommonHandler   commonhandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

            try
            {
                var downloadFileStream = commonhandler.GetAttachFileForDownload(int.Parse(attachID), installationSlipNo);
                var downloadFileName   = commonhandler.GetTbt_AttachFile(installationSlipNo, int.Parse(attachID), null);

                string fileName = downloadFileName[0].FileName;
                if (!string.IsNullOrEmpty(fileName))
                {
                    fileName = Uri.EscapeDataString(fileName);
                }
                return(File(downloadFileStream, "application/octet-stream", fileName));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Get group summary for view customer group data
        /// </summary>
        /// <param name="strGroupCode"></param>
        /// <returns></returns>
        public List <dtGroupSummaryForShow> GetGroupSummaryForViewCustGrpData(string strGroupCode)
        {
            List <dtGroupSummaryForShow> result = new List <dtGroupSummaryForShow>();

            try
            {
                ICommonHandler        comHand       = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>()
                {
                    new doMiscTypeCode()
                    {
                        FieldName = MiscType.C_CURRENCT,
                        ValueCode = "%"
                    }
                }).ToList();
                List <dtGroupSummary> lst = base.GetGroupSummaryForViewCustGrp(strGroupCode, ContractStatus.C_CONTRACT_STATUS_CANCEL, ContractStatus.C_CONTRACT_STATUS_END, ContractStatus.C_CONTRACT_STATUS_FIXED_CANCEL, SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_LOCAL, SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_US);
                //Add Currency
                for (int i = 0; i < lst.Count(); i++)
                {
                    lst[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies);
                }

                if (lst.Count > 0)
                {
                    //set data to match grid
                    dtGroupSummaryForShow custGrp     = new dtGroupSummaryForShow();
                    dtGroupSummaryForShow siteGrp     = new dtGroupSummaryForShow();
                    dtGroupSummaryForShow contractGrp = new dtGroupSummaryForShow();
                    dtGroupSummaryForShow amountGrp   = new dtGroupSummaryForShow();
                    dtGroupSummaryForShow contractAmt = new dtGroupSummaryForShow();

                    //Contract Prefix 'N' => Alarm
                    dtGroupSummary dtGroupAlarm = lst.Find(grp => grp.ContractPrefix == ContractPrefix.C_CONTRACT_PREFIX_ALARM);
                    if (!CommonUtil.IsNullOrEmpty(dtGroupAlarm))
                    {
                        custGrp.ContractAlarm     = ConvertFromIntToStringFormat(dtGroupAlarm.CountCustCode_CT);
                        siteGrp.ContractAlarm     = ConvertFromIntToStringFormat(dtGroupAlarm.CountSiteCode_CT);
                        contractGrp.ContractAlarm = ConvertFromIntToStringFormat(dtGroupAlarm.CountContractCode_CT);
                        amountGrp.ContractAlarm   = dtGroupAlarm.TextTransferSumContractAmount_CT_LOCAL + "<br>" + dtGroupAlarm.TextTransferSumContractAmount_CT_US;
                        //amountGrp.ContractAlarm = ConvertFromDecimalToStringFormat(dtGroupAlarm.SumContractAmount_CT);
                        custGrp.CustomerAlarm     = ConvertFromIntToStringFormat(dtGroupAlarm.CountCustCode_R);
                        siteGrp.CustomerAlarm     = ConvertFromIntToStringFormat(dtGroupAlarm.CountSiteCode_R);
                        contractGrp.CustomerAlarm = ConvertFromIntToStringFormat(dtGroupAlarm.CountContractCode_R);
                        amountGrp.CustomerAlarm   = dtGroupAlarm.TextTransferSumContractAmount_R_LOCAL + "<br>" + dtGroupAlarm.TextTransferSumContractAmount_R_US;
                        //amountGrp.CustomerAlarm = ConvertFromDecimalToStringFormat(dtGroupAlarm.SumContractAmount_R);
                    }

                    //Contract Prefix 'MA' => Maintainence
                    dtGroupSummary dtGroupMaint = lst.Find(grp => grp.ContractPrefix == ContractPrefix.C_CONTRACT_PREFIX_MAINTAINENCE);
                    if (!CommonUtil.IsNullOrEmpty(dtGroupMaint))
                    {
                        custGrp.ContractMaintenance     = ConvertFromIntToStringFormat(dtGroupMaint.CountCustCode_CT);
                        siteGrp.ContractMaintenance     = ConvertFromIntToStringFormat(dtGroupMaint.CountSiteCode_CT);
                        contractGrp.ContractMaintenance = ConvertFromIntToStringFormat(dtGroupMaint.CountContractCode_CT);
                        amountGrp.ContractMaintenance   = dtGroupMaint.TextTransferSumContractAmount_CT_LOCAL + "<br>" + dtGroupMaint.TextTransferSumContractAmount_CT_US;
                        //amountGrp.ContractMaintenance = ConvertFromDecimalToStringFormat(dtGroupMaint.SumContractAmount_CT);
                        custGrp.CustomerMaintenance     = ConvertFromIntToStringFormat(dtGroupMaint.CountCustCode_R);
                        siteGrp.CustomerMaintenance     = ConvertFromIntToStringFormat(dtGroupMaint.CountSiteCode_R);
                        contractGrp.CustomerMaintenance = ConvertFromIntToStringFormat(dtGroupMaint.CountContractCode_R);
                        amountGrp.CustomerMaintenance   = dtGroupMaint.TextTransferSumContractAmount_R_LOCAL + "<br>" + dtGroupMaint.TextTransferSumContractAmount_R_US;
                        //amountGrp.CustomerMaintenance = ConvertFromDecimalToStringFormat(dtGroupMaint.SumContractAmount_R);
                    }

                    //Contract Prefix 'SG' => Maintainence
                    dtGroupSummary dtGroupGuard = lst.Find(grp => grp.ContractPrefix == ContractPrefix.C_CONTRACT_PREFIX_GUARD);
                    if (!CommonUtil.IsNullOrEmpty(dtGroupGuard))
                    {
                        custGrp.ContractGuard     = ConvertFromIntToStringFormat(dtGroupGuard.CountCustCode_CT);
                        siteGrp.ContractGuard     = ConvertFromIntToStringFormat(dtGroupGuard.CountSiteCode_CT);
                        contractGrp.ContractGuard = ConvertFromIntToStringFormat(dtGroupGuard.CountContractCode_CT);
                        amountGrp.ContractGuard   = dtGroupGuard.TextTransferSumContractAmount_CT_LOCAL + "<br>" + dtGroupGuard.TextTransferSumContractAmount_CT_US;
                        //amountGrp.ContractGuard = ConvertFromDecimalToStringFormat(dtGroupGuard.SumContractAmount_CT);
                        custGrp.CustomerGuard     = ConvertFromIntToStringFormat(dtGroupGuard.CountCustCode_R);
                        siteGrp.CustomerGuard     = ConvertFromIntToStringFormat(dtGroupGuard.CountSiteCode_R);
                        contractGrp.CustomerGuard = ConvertFromIntToStringFormat(dtGroupGuard.CountContractCode_R);
                        amountGrp.CustomerGuard   = dtGroupGuard.TextTransferSumContractAmount_R_LOCAL + "<br>" + dtGroupGuard.TextTransferSumContractAmount_R_US;
                        //amountGrp.CustomerGuard = ConvertFromDecimalToStringFormat(dtGroupGuard.SumContractAmount_R);
                    }

                    //Contract Prefix 'Q' => Sale
                    dtGroupSummary dtGroupSale = lst.Find(grp => grp.ContractPrefix == ContractPrefix.C_CONTRACT_PREFIX_SALE);
                    if (!CommonUtil.IsNullOrEmpty(dtGroupSale))
                    {
                        //custGrp.ContractSale = (dtGroupSale.CountCustCode_CT.HasValue) ? dtGroupSale.CountCustCode_CT.Value.ToString("#,###") : "-";
                        //siteGrp.ContractSale = (dtGroupSale.CountSiteCode_CT.HasValue) ? dtGroupSale.CountSiteCode_CT.Value.ToString("#,###") : "-";
                        //contractGrp.ContractSale = (dtGroupSale.CountContractCode_CT.HasValue) ? dtGroupSale.CountContractCode_CT.Value.ToString("#,###") : "-";
                        //amountGrp.ContractSale = (dtGroupSale.SumContractAmount_CT.HasValue) ? dtGroupSale.SumContractAmount_CT.Value.ToString("#,###,0000") : "-";
                        //custGrp.CustomerSale = (dtGroupSale.CountCustCode_R.HasValue) ? dtGroupSale.CountCustCode_R.Value.ToString("#,###") : "-";
                        //siteGrp.CustomerSale = (dtGroupSale.CountSiteCode_R.HasValue) ? dtGroupSale.CountSiteCode_R.Value.ToString("#,###") : "-";
                        //contractGrp.CustomerSale = (dtGroupSale.CountContractCode_R.HasValue) ? dtGroupSale.CountContractCode_R.Value.ToString("#,###") : "-";
                        //amountGrp.CustomerSale = (dtGroupSale.SumContractAmount_R.HasValue) ? dtGroupSale.SumContractAmount_R.Value.ToString("#,###,0000") : "-";
                        custGrp.ContractSale     = ConvertFromIntToStringFormat(dtGroupSale.CountCustCode_CT);
                        siteGrp.ContractSale     = ConvertFromIntToStringFormat(dtGroupSale.CountSiteCode_CT);
                        contractGrp.ContractSale = ConvertFromIntToStringFormat(dtGroupSale.CountContractCode_CT);
                        amountGrp.ContractSale   = dtGroupSale.TextTransferSumContractAmount_CT_LOCAL + "<br>" + dtGroupSale.TextTransferSumContractAmount_CT_US;
                        //amountGrp.ContractSale = ConvertFromDecimalToStringFormat(dtGroupSale.SumContractAmount_CT);
                        contractAmt.ContractSale = dtGroupSale.FinalTextContractAmount_CT;
                        custGrp.CustomerSale     = ConvertFromIntToStringFormat(dtGroupSale.CountCustCode_R);
                        siteGrp.CustomerSale     = ConvertFromIntToStringFormat(dtGroupSale.CountSiteCode_R);
                        contractGrp.CustomerSale = ConvertFromIntToStringFormat(dtGroupSale.CountContractCode_R);
                        amountGrp.CustomerSale   = dtGroupSale.TextTransferSumContractAmount_R_LOCAL + "<br>" + dtGroupSale.TextTransferSumContractAmount_R_US;
                        //amountGrp.CustomerSale = ConvertFromDecimalToStringFormat(dtGroupSale.SumContractAmount_R);
                        contractAmt.CustomerSale = dtGroupSale.FinalTextContractAmount_R;
                    }

                    custGrp.RowHeader     = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_COMMON, ScreenID.C_SCREEN_ID_VIEW_CUSTOMER_GROUP, "colNumberOfCustomer");
                    custGrp.RowPrefix     = "customer";
                    siteGrp.RowHeader     = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_COMMON, ScreenID.C_SCREEN_ID_VIEW_CUSTOMER_GROUP, "colNumberOfSite");
                    siteGrp.RowPrefix     = "site";
                    contractGrp.RowHeader = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_COMMON, ScreenID.C_SCREEN_ID_VIEW_CUSTOMER_GROUP, "colNumberOfContract");
                    contractGrp.RowPrefix = "contract";
                    amountGrp.RowHeader   = CommonUtil.GetLabelFromResource(MessageUtil.MODULE_COMMON, ScreenID.C_SCREEN_ID_VIEW_CUSTOMER_GROUP, "colAmountOfContract");
                    amountGrp.RowPrefix   = "amount";
                    result.Add(custGrp);
                    result.Add(siteGrp);
                    result.Add(contractGrp);
                    result.Add(amountGrp);
                    result.Add(contractAmt);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Validate customer data
        /// </summary>
        /// <param name="cust"></param>
        /// <param name="isFullValidate"></param>
        public void ValidateCustomerData(doCustomer cust, bool isFullValidate = false)
        {
            IMasterHandler mhandler = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler;
            ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

            doCompanyType cType = null;

            cust.ValidateCustomerData = true;
            try
            {
                #region Set Misc Data

                MiscTypeMappingList miscList = new MiscTypeMappingList();
                miscList.AddMiscType(cust);
                chandler.MiscTypeMappingList(miscList);

                #endregion
                #region Company Type

                List <doCompanyType> clst = mhandler.GetCompanyType(cust.CompanyTypeCode);
                if (clst.Count > 0)
                {
                    cType = clst[0];
                    cust.CompanyTypeName = clst[0].CompanyTypeName;
                }

                #endregion
                #region Nationality Data

                if (CommonUtil.IsNullOrEmpty(cust.RegionCode) == false)
                {
                    List <tbm_Region> nlst = mhandler.GetTbm_Region();
                    if (nlst.Count > 0)
                    {
                        foreach (tbm_Region r in nlst)
                        {
                            if (cust.RegionCode == r.RegionCode)
                            {
                                cust.Nationality = r.Nationality;
                                break;
                            }
                        }
                    }
                }

                #endregion
                #region BusinessType Data

                if (CommonUtil.IsNullOrEmpty(cust.BusinessTypeCode) == false)
                {
                    List <tbm_BusinessType> blst = mhandler.GetTbm_BusinessType();
                    if (blst.Count > 0)
                    {
                        foreach (tbm_BusinessType b in blst)
                        {
                            if (cust.BusinessTypeCode == b.BusinessTypeCode)
                            {
                                cust.BusinessTypeName = b.BusinessTypeName;
                                break;
                            }
                        }
                    }
                }

                #endregion
                #region Province Data

                if (CommonUtil.IsNullOrEmpty(cust.ProvinceCode) == false)
                {
                    List <tbm_Province> plst = mhandler.GetTbm_Province();
                    if (plst.Count > 0)
                    {
                        foreach (tbm_Province pv in plst)
                        {
                            if (cust.ProvinceCode == pv.ProvinceCode)
                            {
                                cust.ProvinceNameEN = pv.ProvinceNameEN;
                                cust.ProvinceNameLC = pv.ProvinceNameLC;
                                break;
                            }
                        }
                    }
                }

                #endregion
                #region District

                if (CommonUtil.IsNullOrEmpty(cust.DistrictCode) == false)
                {
                    List <tbm_District> dlst = mhandler.GetTbm_District(cust.ProvinceCode);
                    if (dlst.Count > 0)
                    {
                        foreach (tbm_District d in dlst)
                        {
                            if (cust.ProvinceCode == d.ProvinceCode &&
                                cust.DistrictCode == d.DistrictCode)
                            {
                                cust.DistrictNameEN = d.DistrictNameEN;
                                cust.DistrictNameLC = d.DistrictNameLC;
                                break;
                            }
                        }
                    }
                }

                #endregion

                if (CommonUtil.IsNullOrEmpty(cust.CustTypeName) || cust.CustTypeCode != CustomerType.C_CUST_TYPE_JURISTIC)
                {
                    cust.CompanyTypeName = null;
                }
                if (CommonUtil.IsNullOrEmpty(cust.CompanyTypeName) || cust.CompanyTypeCode != CompanyType.C_COMPANY_TYPE_PUBLIC_CO_LTD)
                {
                    cust.FinancialMaketTypeName = null;
                }

                if (CommonUtil.IsNullOrEmpty(cust.CustCode))
                {
                    if (isFullValidate)
                    {
                        ApplicationErrorException.CheckMandatoryField <doCustomer, ValidateCustomer_Full>(cust);
                    }
                    else if (CommonUtil.IsNullOrEmpty(cust.CustCode) == true)
                    {
                        ApplicationErrorException.CheckMandatoryField <doCustomer, ValidateCustomer_CodeNull>(cust);
                    }
                    else
                    {
                        ApplicationErrorException.CheckMandatoryField <doCustomer, ValidateCustomer>(cust);
                    }
                }
            }
            catch
            {
                cust.ValidateCustomerData = false;
            }
            try
            {
                if (cType == null)
                {
                    cType = new doCompanyType();
                }

                cust.CustFullNameEN =
                    CommonUtil.TextList(new string[] { cType.CustNamePrefixEN,
                                                       cust.CustNameEN,
                                                       cType.CustNameSuffixEN }, " ");
                cust.CustFullNameLC =
                    CommonUtil.TextList(new string[] { cType.CustNamePrefixLC,
                                                       cust.CustNameLC,
                                                       cType.CustNameSuffixLC }, " ");

                mhandler.CreateAddressFull(cust);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 27
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;
            }
        }
        /// <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)); }
            }
        }
        /// <summary>
        /// Search inventory slip detail.
        /// </summary>
        /// <param name="Cond"></param>
        /// <returns></returns>
        public ActionResult RetrieveStockInSlip(IVS012_SearchCond Cond)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {      //Valid Cond
                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                ValidatorUtil.BuildErrorMessage(res, this, null);
                if (res.IsError)
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    return(Json(res));
                }

                IVS012_ScreenParameter param = GetScreenObject <IVS012_ScreenParameter>();
                if (param.lstInventorySlipDetail == null)
                {
                    param.lstInventorySlipDetail = new List <doInventorySlipDetailList>();
                }

                IInventoryHandler InvH          = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler;
                ICommonHandler    commonHandler = CSI.WindsorHelper.ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <doInventorySlipDetailList> lstSlipDetail = InvH.GetInventorySlipDetailForRegister(Cond.SlipNo);

                if (lstSlipDetail.Count <= 0)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                    return(Json(res));
                }

                for (int i = 0; i < lstSlipDetail.Count; i++)
                {
                    //Default Currency
                    if (lstSlipDetail[i].InstrumentAmountCurrencyType == null)
                    {
                        lstSlipDetail[i].InstrumentAmountCurrencyType = SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_LOCAL;
                    }

                    //Exchange Rate Currency
                    if (lstSlipDetail[i].InstrumentAmountCurrencyType == SECOM_AJIS.Common.Util.ConstantValue.CurrencyUtil.C_CURRENCY_LOCAL)
                    {
                        decimal amt       = lstSlipDetail[i].InstrumentAmount ?? 0;
                        double  errorCode = 0;

                        decimal localAmt = commonHandler.ConvertCurrencyPrice(amt, lstSlipDetail[i].InstrumentAmountCurrencyType, CurrencyUtil.C_CURRENCY_LOCAL, DateTime.Now, ref errorCode);

                        lstSlipDetail[i].InstrumentAmount = localAmt;
                    }
                    else
                    {
                        decimal amt       = lstSlipDetail[i].InstrumentAmount ?? 0;
                        double  errorCode = 0;

                        decimal usdAmt = commonHandler.ConvertCurrencyPrice(amt, lstSlipDetail[i].InstrumentAmountCurrencyType, CurrencyUtil.C_CURRENCY_US, DateTime.Now, ref errorCode);

                        lstSlipDetail[i].InstrumentAmount = usdAmt;
                    }
                }

                // Monthly Price @ 2015 : Allow to register asset anytime until LockFlag = true
                //if (lstSlipDetail.FirstOrDefault().RegisterAssetFlag == "1")
                //{
                //    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4146);
                //    return Json(res);
                //}

                param.lstInventorySlipDetail = lstSlipDetail;

                //Add by Jutarat A. on 30052013
                List <tbt_InventorySlip> lstInventorySlip = InvH.GetTbt_InventorySlip(Cond.SlipNo);

                // Monthly Price @ 2015 : Allow to register asset anytime until LockFlag = true
                if (lstInventorySlip.Count > 0 && lstInventorySlip[0].LockFlag == true)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4148);
                    return(Json(res));
                }

                param.lstInventorySlip = lstInventorySlip;
                //End Add

                res.ResultData = CommonUtil.ConvertToXml <doInventorySlipDetailList>(lstSlipDetail, "Inventory\\IVS012_Instrument", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
                return(Json(res));
            }
            catch (Exception ex) { res.AddErrorMessage(ex); return(Json(res)); }
        }
        /// <summary>
        /// Confirming picking list registration.
        /// </summary>
        /// <param name="lstInstallationSlipNo">List of installation slip no. for registering.</param>
        /// <returns>Return ActionResult of confirmation process result.</returns>
        public ActionResult IVS240_ConfirmPickingList(List <string> lstInstallationSlipNo)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION; //All message during confirmation process must be information dialog box.

            try
            {
                IVS240_ScreenParameter sParam = GetScreenObject <IVS240_ScreenParameter>(); //Add by Jutarat A. on 04122012

                ICommonHandler srvCommon = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                if (srvCommon.IsSystemSuspending())
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0049);
                    res.ResultData = this.IVS240_ConfirmPickingList_CreateResult(false, null, null);
                    return(Json(res));
                }

                if (!CheckUserPermission(ScreenID.C_INV_SCREEN_ID_PICKING_LIST, FunctionID.C_FUNC_ID_OPERATE))
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053);
                    res.ResultData = this.IVS240_ConfirmPickingList_CreateResult(false, null, null);
                    return(Json(res));
                }

                if (lstInstallationSlipNo == null || lstInstallationSlipNo.Count <= 0)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4063);
                    res.ResultData = this.IVS240_ConfirmPickingList_CreateResult(false, null, null);
                    return(Json(res));
                }

                IInventoryHandler srvInv   = ServiceContainer.GetService <IInventoryHandler>() as IInventoryHandler;
                List <string>     lstError = new List <string>();

                List <tbt_InventorySlip> lstInvSlip = new List <tbt_InventorySlip>();
                foreach (var strInstallationSlipNo in lstInstallationSlipNo)
                {
                    var lstTempInvSlip = srvInv.GetTbt_InventorySlip(null, strInstallationSlipNo);
                    //if (lstInvSlip.Count > 0 && lstInvSlip[0].PickingListNo != null)
                    //{
                    //    res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4064
                    //        , new string[] { strInstallationSlipNo });
                    //    lstError.Add(strInstallationSlipNo);
                    //}

                    if (lstTempInvSlip.Any(p => p.PickingListNo != null))
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_INVENTORY, MessageUtil.MessageList.MSG4064
                                            , new string[] { strInstallationSlipNo });
                        lstError.Add(strInstallationSlipNo);
                        res.ResultData = this.IVS240_ConfirmPickingList_CreateResult(false, lstError, null);
                        return(Json(res));
                    }

                    lstInvSlip.AddRange(lstTempInvSlip);
                }

                //if (lstError.Count > 0)
                //{
                //    res.ResultData = this.IVS240_ConfirmPickingList_CreateResult(false, lstError, null);
                //    return Json(res);
                //}

                string strPickingListNo = srvInv.GeneratePickingListNo();

                #region //R2
                foreach (var slip in lstInvSlip)
                {
                    slip.PickingListNo = strPickingListNo;

                    //Comment by Jutarat A. on 30052013 (Set at UpdateTbt_InventorySlip())
                    //slip.UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo;
                    //slip.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                    //End Comment
                }
                #endregion

                srvInv.UpdateTbt_InventorySlip(lstInvSlip);

                IInventoryDocumentHandler srvInvDoc = ServiceContainer.GetService <IInventoryDocumentHandler>() as IInventoryDocumentHandler;

                //srvInvDoc.GenerateIVR170FilePath(strPickingListNo, CommonUtil.dsTransData.dtUserData.EmpNo, CommonUtil.dsTransData.dtOperationData.ProcessDateTime);
                sParam.ResultStream = srvInvDoc.GenerateIVR170(strPickingListNo, CommonUtil.dsTransData.dtUserData.EmpNo, CommonUtil.dsTransData.dtOperationData.ProcessDateTime); //Modify by Jutarat A. on 04122012

                res.ResultData = this.IVS240_ConfirmPickingList_CreateResult(true, null, strPickingListNo);
                return(Json(res));
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
                res.ResultData = this.IVS240_ConfirmPickingList_CreateResult(false, null, null);;
                return(Json(res));
            }
        }