// // CUSTOM FUNCTION HERE // public DTO.SupportFormData GetInitData(out Library.DTO.Notification notification) { notification = new Library.DTO.Notification { Type = Library.DTO.NotificationType.Success }; DTO.SupportFormData data = new DTO.SupportFormData(); data.WorkCenterDTOs = new List <DTO.WorkCenterDTO>(); try { using (MasterGrantChartRptEntities context = CreateContext()) { data.WorkCenterDTOs = converter.DB2DTO_WorkCenterList(context.WorkCenter.ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = Library.Helper.GetInnerException(ex).Message; } return(data); }
public List <DTO.WorkOrderProductionDetailDTO> GetWorkOrderProductionDetail(int workOrderID, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification { Type = Library.DTO.NotificationType.Success }; List <DTO.WorkOrderProductionDetailDTO> data = new List <DTO.WorkOrderProductionDetailDTO>(); try { using (MasterGrantChartRptEntities context = CreateContext()) { var x = context.MasterGrantChartRpt_WorkOrderProductionDetail_View.Where(o => o.WorkOrderID == workOrderID).ToList(); data = AutoMapper.Mapper.Map <List <MasterGrantChartRpt_WorkOrderProductionDetail_View>, List <DTO.WorkOrderProductionDetailDTO> >(x); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = Library.Helper.GetInnerException(ex).Message; } return(data); }
public override DTO.SearchFormData GetDataWithFilter(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 <DTO.WorkOrderDTO>(); data.WeekInfoDTOs = new List <DTO.WeekInfoDTO>(); totalRows = 0; DateTime?StartDateFrom = null; DateTime?StartDateTo = null; DateTime?FinishedDateFrom = null; DateTime?FinishedDateTo = null; string WorkOrderUD = null; string ClientUD = null; string ProformaInvoiceNo = null; string WorkOrderStatus = null; int? WorkCenterID = null; int? UserID = null; int CompanyID = 0; if (filters.ContainsKey("StartDateFrom") && filters["StartDateFrom"] != null && !string.IsNullOrEmpty(filters["StartDateFrom"].ToString())) { StartDateFrom = filters["StartDateFrom"].ToString().Replace("'", "''").ConvertStringToDateTime(); } if (filters.ContainsKey("StartDateTo") && filters["StartDateTo"] != null && !string.IsNullOrEmpty(filters["StartDateTo"].ToString())) { StartDateTo = filters["StartDateTo"].ToString().Replace("'", "''").ConvertStringToDateTime(); } if (filters.ContainsKey("FinishedDateFrom") && filters["FinishedDateFrom"] != null && !string.IsNullOrEmpty(filters["FinishedDateFrom"].ToString())) { FinishedDateFrom = filters["FinishedDateFrom"].ToString().Replace("'", "''").ConvertStringToDateTime(); } if (filters.ContainsKey("FinishedDateTo") && filters["FinishedDateTo"] != null && !string.IsNullOrEmpty(filters["FinishedDateTo"].ToString())) { FinishedDateTo = filters["FinishedDateTo"].ToString().Replace("'", "''").ConvertStringToDateTime(); } if (filters.ContainsKey("WorkOrderUD") && filters["WorkOrderUD"] != null && !string.IsNullOrEmpty(filters["WorkOrderUD"].ToString())) { WorkOrderUD = filters["WorkOrderUD"].ToString().Replace("'", "''"); } if (filters.ContainsKey("ClientUD") && filters["ClientUD"] != null && !string.IsNullOrEmpty(filters["ClientUD"].ToString())) { ClientUD = filters["ClientUD"].ToString().Replace("'", "''"); } if (filters.ContainsKey("ProformaInvoiceNo") && filters["ProformaInvoiceNo"] != null && !string.IsNullOrEmpty(filters["ProformaInvoiceNo"].ToString())) { ProformaInvoiceNo = filters["ProformaInvoiceNo"].ToString().Replace("'", "''"); } if (filters.ContainsKey("WorkOrderStatus") && filters["WorkOrderStatus"] != null && !string.IsNullOrEmpty(filters["WorkOrderStatus"].ToString())) { WorkOrderStatus = filters["WorkOrderStatus"].ToString().Replace("'", "''"); } if (filters.ContainsKey("WorkCenterID") && filters["WorkCenterID"] != null && !string.IsNullOrEmpty(filters["WorkCenterID"].ToString())) { WorkCenterID = Convert.ToInt32(filters["WorkCenterID"]); } if (filters.ContainsKey("UserID") && filters["UserID"] != null && !string.IsNullOrEmpty(filters["UserID"].ToString())) { UserID = Convert.ToInt32(filters["UserID"]); } //try to get data try { try { CompanyID = fwFactory.GetCompanyID(UserID.Value).Value; } catch { CompanyID = 0; } using (MasterGrantChartRptEntities context = CreateContext()) { var dbWorkOrders = context.MasterGrantChartRpt_function_SearchWorkOrder(StartDateFrom, StartDateTo, FinishedDateFrom, FinishedDateTo, WorkOrderUD, ClientUD, ProformaInvoiceNo, WorkOrderStatus, WorkCenterID, CompanyID).OrderBy(o => o.StartDate).ToList(); DateTime?FromDate = dbWorkOrders.Min(o => o.WeekStart); DateTime?ToDate = dbWorkOrders.Max(o => o.WeekEnd); data.Data = converter.DB2DTO_WorkOrderList(dbWorkOrders); data.WeekInfoDTOs = converter.DB2DTO_WeekInfoList(context.WeekInfo.Where(o => o.WeekEnd >= FromDate && o.WeekEnd <= ToDate).OrderBy(o => o.WeekStart).ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }