// // CUSTOM FUNCTION HERE // public override object GetInitData(int userID, out Notification notification) { notification = new Notification() { Type = NotificationType.Success }; Module.Framework.DAL.DataFactory fwFactory = new Module.Framework.DAL.DataFactory(); int?companyID = fwFactory.GetCompanyID(userID); SupportFormData data = new SupportFormData(); data.EmployeeDTOs = new List <EmployeeDTO>(); data.CompanyDTOs = new List <CompanyDTO>(); try { using (AnnualLeaveRptEntities context = CreateContext()) { data.EmployeeDTOs = converter.DB2DTO_EmployeeDTO(context.AnnualLeaveRpt_Employee_View.ToList()); data.CompanyDTOs = converter.DB2DTO_CompanyDTO(context.AnnualLeaveRpt_Company_View.Where(s => s.CompanyID == companyID).ToList()); } return(data); } catch (Exception ex) { notification.Type = NotificationType.Error; notification.Message = ex.Message; return(data); } }
public List <DetailTotalDTO> GetDetailTotal(int employeeID, int affectedYear, int type, out Notification notification) { notification = new Notification() { Type = NotificationType.Success }; List <DetailTotalDTO> data = new List <DetailTotalDTO>(); try { using (AnnualLeaveRptEntities context = CreateContext()) { data = converter.DB2DTO_DetailTotalDTO(context.AnnualLeaveRpt_function_GetDetailTotal(employeeID, type, affectedYear).ToList()); } return(data); } catch (Exception ex) { notification.Type = NotificationType.Error; notification.Message = ex.Message; return(data); } }
public override DTO.SearchFormData GetDataWithFilter(int userID, System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; DTO.SearchFormData data = new DTO.SearchFormData(); data.Data = new List <AnnualLeaveSearchResultDTO>(); totalRows = 0; string EmployeeNM = null; int? CompanyID = null; int? AffectedYear = null; bool? HasLeft = false; if (filters.ContainsKey("employeeNM") && filters["employeeNM"] != null && !string.IsNullOrEmpty(filters["employeeNM"].ToString())) { EmployeeNM = filters["employeeNM"].ToString(); } if (filters.ContainsKey("companyID") && filters["companyID"] != null && !string.IsNullOrEmpty(filters["companyID"].ToString())) { CompanyID = Convert.ToInt32(filters["companyID"].ToString()); } if (filters.ContainsKey("affectedYear") && filters["affectedYear"] != null && !string.IsNullOrEmpty(filters["affectedYear"].ToString())) { AffectedYear = Convert.ToInt32(filters["affectedYear"].ToString()); } if (filters.ContainsKey("HasLeft") && filters["HasLeft"] != null && !string.IsNullOrEmpty(filters["HasLeft"].ToString())) { HasLeft = (filters["HasLeft"].ToString() == "true") ? true : false; } //try to get data try { using (AnnualLeaveRptEntities context = CreateContext()) { int?companyID = fwFactory.GetCompanyID(userID); var result = context.AnnualLeaveRpt_function_SearchAnnualLeave(EmployeeNM, CompanyID, AffectedYear, HasLeft, orderBy, orderDirection).Where(o => o.CompanyID == companyID).ToList(); totalRows = result.Count(); data.Data = converter.DB2DTO_AnnualLeaveSearchResultDTO(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }