public ActionResult GetReportContractExpired([DataSourceRequest] DataSourceRequest request, Hre_ReportContractExpiredSearchModel model) { #region Validate string message = string.Empty; var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Hre_ReportContractExpiredSearchModel>(model, "Hre_ReportGeneral", ref message); if (!checkValidate) { var ls = new object[] { "error", message }; return Json(ls); } #endregion var Services = new Hre_ReportServices(); var actionService = new ActionService(UserLogin); #region Getdata //List<Hre_ProfileEntity> listProfileByOrg = new List<Hre_ProfileEntity>(); //if (!model.IsCreateTemplate) //{ // //Lọc theo phòng ban // List<object> listObj = new List<object>(); // listObj.Add(model.OrgStructureID); // listObj.Add(model.ProfileName); // listObj.Add(model.CodeEmp); // listProfileByOrg = Services.GetData<Hre_ProfileEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, ref status); //} #endregion #region lay nhan vien theo dieu kien loc string status = string.Empty; List<Hre_ProfileEntity> lstProfileForRptContractEXP = new List<Hre_ProfileEntity>(); if (!model.IsCreateTemplate) { //Lọc theo phòng ban List<object> listObj = new List<object>(); listObj.AddRange(new object[14]); listObj[0] = model.ProfileName; listObj[1] = model.CodeEmp; listObj[2] = model.OrgStructureID; listObj[3] = model.JobTitleID; listObj[4] = model.PositionID; listObj[5] = model.DateHireFrom; listObj[6] = model.DateHireTo; listObj[7] = model.EmpTypeID; listObj[8] = model.Gender; listObj[9] = model.WorkPlaceID; listObj[10] = model.SalaryClassID; listObj[11] = model.IDNo; listObj[12] = 1; listObj[13] = int.MaxValue - 1; lstProfileForRptContractEXP = actionService.GetData<Hre_ProfileEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileForRptContractExpired, ref status); } #endregion string NameTable = "ReportContractExpired"; DataTable Table = Services.GetReportContractExpired(lstProfileForRptContractEXP, model.DateSignedStart, model.DateSignedEnd, model.ContractNo, model.ContractTypeID, model.IsCreateTemplate, NameTable); #region Xử lý cách export mới var isDataTable = false; DataTable obj = null; if (model.IsCreateTemplateForDynamicGrid) { var col = Table.Columns.Count; Table.Columns.RemoveAt(col - 1); obj = Table; isDataTable = true; } HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateStart", Value = model.DateHireFrom }; HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateEnd", Value = model.DateHireTo }; 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 = obj, FileName = NameTable, OutPutPath = path, HeaderInfo = listHeaderInfo, DownloadPath = Hrm_Main_Web + "Templates", IsDataTable = isDataTable }; var str = exportService.CreateTemplate(cfgExport); return Json(str); } if (model.ExportId != Guid.Empty) { var fullPath = ExportService.Export(model.ExportId, Table, listHeaderInfo, ExportFileType.Excel); return Json(fullPath); } #endregion return new JsonResult() { Data = Table.ToDataSourceResult(request), MaxJsonLength = Int32.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }