Exemple #1
0
        public ActionResult ICS150_ExportExcelData(doMatchRReport dtIncome)
        {
            ICS150_ScreenParameter param = GetScreenObject <ICS150_ScreenParameter>();

            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;


            try
            {
                ValidatorUtil validator = new ValidatorUtil();

                ICS150_ValidateBusiness(validator, dtIncome);
                ValidatorUtil.BuildErrorMessage(res, validator, null);
                if (res.IsError)
                {
                    return(Json(res));
                }

                if (dtIncome == null || CommonUtil.IsNullAllField(dtIncome))
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0006);
                }
                else
                {
                    IIncomeHandler handler  = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler;
                    ICommonHandler chandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                    if (string.IsNullOrEmpty(dtIncome.CreateBy) && CommonUtil.dsTransData != null)
                    {
                        dtIncome.CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo;
                    }
                    var lst = handler.GetListIRC050(dtIncome);

                    if (lst.Count != 0)
                    {
                        IIncomeDocumentHandler docService = ServiceContainer.GetService <IIncomeDocumentHandler>() as IIncomeDocumentHandler;
                        param.PendingDownloadFilePath = docService.GenerateICR050Report(lst, dtIncome);
                        param.PendingDownloadFileName = "ICR050Report.xlsx";
                        res.ResultData = true;
                    }
                    else
                    {
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                    }
                }
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }