/// <summary>
 /// [Chuc.Nguyen] - Lấy dữ liệu bảng Tai Nạn(Hre_Accident) theo Id
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public FIN_TravelRequestItemModel GetById(Guid id)
 {
     string status = string.Empty;
     var model = new FIN_TravelRequestItemModel();
     ActionService service = new ActionService(UserLogin);
     var entity = service.GetByIdUseStore<FIN_TravelRequestItemEntity>(id, ConstantSql.hrm_hr_sp_get_TravelRequestItemById, ref status);
     if (entity != null)
     {
         model = entity.CopyData<FIN_TravelRequestItemModel>();
     }
     model.ActionStatus = status;
     return model;
 }
Exemple #2
0
        public ActionResult ExportTravelRequestByTemplate([DataSourceRequest] DataSourceRequest request, FIN_TravelRequestSearchModel model)
        {
            string status = string.Empty;
            var isDataTable = false;
            object obj = new FIN_TravelRequestItemModel();
            var lstModel = new List<FIN_TravelRequestItemModel>();
            request.Page = 1;
            request.PageSize = int.MaxValue - 1;
            var result = GetListData<FIN_TravelRequestModel, FIN_TravelRequestEntity, FIN_TravelRequestSearchModel>(request, model, ConstantSql.hrm_hr_sp_get_TravelRequest, ref status);
            //string _ProfileName = "";
            //string _PositionName = "";
            if (result != null)
            {
                //_ProfileName = result[0].ProfileName;
                //_PositionName = result[0].PositionName;
                var actionService = new ActionService(UserLogin);
                var objs = new List<object>();
                objs.Add(result[0].ID);
                lstModel = actionService.GetData<FIN_TravelRequestItemModel>(objs, ConstantSql.hrm_hr_sp_get_TravelRequestItemByTravelRequestID, ref status);
            }
            //HeaderInfo headerInfo1 = new HeaderInfo() { Name = "ProfileName", Value = _ProfileName };
            //HeaderInfo headerInfo2 = new HeaderInfo() { Name = "PositionName", Value = _PositionName };
            //List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1, headerInfo2 };
            if (model.IsCreateTemplateForDynamicGrid)
            {
                obj = lstModel;
                isDataTable = false;
            }
            if (model != null && model.IsCreateTemplate)
            {

                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = obj,
                    FileName = "FIN_TravelRequestItemModel",
                    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, lstModel, null, model.ExportType);
                return Json(fullPath);
            }
            return Json(result.ToDataSourceResult(request));
        }