Example #1
0
        public ActionResult GetReportSummaryDependantDeduction([DataSourceRequest] DataSourceRequest request, Hre_ReportSummaryDependantDeductionModel model)
        {
            HeaderInfo headerInfo1 = new HeaderInfo() { Name = "MonthFrom", Value = model.MonthFrom ?? DateTime.Now };
            HeaderInfo headerInfo2 = new HeaderInfo() { Name = "MonthTo", Value = model.MonthTo ?? DateTime.Now };
            List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1, headerInfo2 };
            if (model != null && model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();
                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = new Hre_ReportSummaryDependantDeductionModel(),
                    FileName = "Hre_ReportSummaryDependantDeductionModel",
                    OutPutPath = path,
                    HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = false
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }
            #region Validate
            string message = string.Empty;
            var checkValidate = ValidatorService.OnValidateData<Hre_ReportSummaryDependantDeductionModel>(model, "Hre_ReportSummaryDependantDeduction", ref message);
            if (!checkValidate)
            {
                return Json(message, JsonRequestBehavior.AllowGet);
            }
            #endregion
            string status = string.Empty;
            var actionService = new ActionService(UserLogin);
            List<object> paraDependant = new List<object>();
            paraDependant.AddRange(new object[11]);
            paraDependant[9] = 1;
            paraDependant[10] = int.MaxValue;
            var lstDependant = actionService.GetData<Hre_DependantEntity>(paraDependant, ConstantSql.hrm_hr_sp_get_Dependant, ref status);
            var ReportServices = new Hre_ReportServices();

            if (model.MonthFrom != null && model.MonthTo != null && lstDependant != null)
            {
                lstDependant = lstDependant.Where(s =>
                    ((model.MonthFrom <= s.MonthOfExpiry && s.MonthOfExpiry <= model.MonthTo) || (s.MonthOfExpiry == null))
                    && (s.MonthOfEffect <= model.MonthTo)).ToList();
            }
            var result = ReportServices.GetReportSummaryDependantDeduction(lstDependant, model.IsCreateTemplate);

            if (model.ExportId != Guid.Empty)
            {
                if (model.MonthFrom != null && model.MonthTo != null)
                {
                    var fullPath = ExportService.Export(model.ExportId, result, listHeaderInfo, model.ExportType);
                    return Json(fullPath);
                }
                else
                {
                    var fullPath = ExportService.Export(model.ExportId, result, null, model.ExportType);
                    return Json(fullPath);
                }
            }
            return Json(result.ToDataSourceResult(request));
        }
Example #2
0
 public ActionResult GetReportSummaryDependantDeductionValidate(Hre_ReportSummaryDependantDeductionModel model)
 {
     #region Validate
     string message = string.Empty;
     var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Hre_ReportSummaryDependantDeductionModel>(model, "Hre_ReportSummaryDependantDeduction", ref message);
     if (!checkValidate)
     {
         var ls = new object[] { "error", message };
         return Json(ls);
     }
     #endregion
     return Json(message);
 }