public DTO.SearchFormData GetDataWithFilter(int userID, Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Notification notification) { totalRows = 0; notification = new Notification(); notification.Type = NotificationType.Success; DTO.SearchFormData data = new DTO.SearchFormData(0); try { int? factoryWarehouseID = filters.ContainsKey("factoryWarhouseID") && filters["factoryWarhouseID"] != null && !string.IsNullOrEmpty(filters["factoryWarhouseID"].ToString().Trim()) ? (int?)Convert.ToInt32(filters["factoryWarhouseID"].ToString()) : null; int? productionTeamID = filters.ContainsKey("productionTeamID") && filters["productionTeamID"] != null && !string.IsNullOrEmpty(filters["productionTeamID"].ToString().Trim()) ? (int?)Convert.ToInt32(filters["productionTeamID"].ToString()) : null; string startDate = filters.ContainsKey("startDate") && filters["startDate"] != null ? filters["startDate"].ToString() : null; string endDate = filters.ContainsKey("endDate") && filters["endDate"] != null ? filters["endDate"].ToString() : null; int?companyID = null; using (InventoryRptEntities context = CreateContext()) { if (factoryWarehouseID.HasValue) { if (factoryWarehouseID.Value == 46) { totalRows = context.InventoryRpt_function_InventoryFinishProduct(companyID, factoryWarehouseID, productionTeamID, startDate, endDate).Count(); } else { totalRows = 0; } } else { if (productionTeamID.HasValue) { } } data.InventoryOverviewClient = converter.DB2DTO_InventoryOverviewClient(context.InventoryRpt_InventoryOverviewWithClient_View.ToList()); } } catch (Exception ex) { notification.Type = NotificationType.Error; notification.Message = Library.Helper.GetInnerException(ex).Message; } return(data); }
public DTO.InitFormData GetInitData(int userID, int?branchID, out Notification notification) { DTO.InitFormData initData = new DTO.InitFormData(); initData.FactoryWarehouse = new List <DTO.FactoryWarehouseDTO>(); initData.ProductionTeam = new List <Support.DTO.ProductionTeam>(); notification = new Notification(); notification.Type = NotificationType.Success; try { // Declare data factory of support to get data. Support.DAL.DataFactory supportFactory = new Support.DAL.DataFactory(); // Get company of end-user. Framework.DAL.DataFactory frameworkFactory = new Framework.DAL.DataFactory(); int?companyID = frameworkFactory.GetCompanyID(userID); //initData.FactoryWarehouse = supportFactory.GetFactoryWarehouse(companyID); initData.ProductionTeam = supportFactory.GetProductionTeam(companyID); using (InventoryRptEntities context = CreateContext()) { initData.FactoryWarehouse = AutoMapper.Mapper.Map <List <InventoryRpt_FactoryWarehouse_View>, List <DTO.FactoryWarehouseDTO> >(context.InventoryRpt_FactoryWarehouse_View.Where(o => o.CompanyID == companyID).ToList()); if (branchID.HasValue) // Has branch with end-user { initData.FactoryWarehouse = initData.FactoryWarehouse.Where(o => o.BranchID == branchID).ToList(); } } } catch (Exception ex) { notification.Type = NotificationType.Error; notification.Message = ex.Message; if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message)) { notification.DetailMessage.Add(ex.InnerException.Message); } } return(initData); }