public object GetWorkOrderWithFilter(int userID, System.Collections.Hashtable filters, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification(); notification.Type = Library.DTO.NotificationType.Success; List <DTO.SupportWorkOrderData> data = new List <DTO.SupportWorkOrderData>(); try { Framework.DAL.DataFactory fwFactory = new Framework.DAL.DataFactory(); int?companyID = fwFactory.GetCompanyID(userID); string searchString = filters.ContainsKey("searchString") && filters["searchString"] != null && !string.IsNullOrEmpty(filters["searchString"].ToString().Trim()) ? filters["searchString"].ToString().Trim() : null; int? clientID = filters.ContainsKey("clientID") && filters["clientID"] != null && !string.IsNullOrEmpty(filters["clientID"].ToString().Trim()) ? (int?)Convert.ToInt32(filters["clientID"].ToString().Trim()) : null; using (var context = CreateContext()) { var dbItem = context.PurchaseOrderTrackingRpt_function_SupportWorkOrder(searchString, clientID, companyID); data = converter.DB2DTO_SupportWorkOrder(dbItem.ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = Library.Helper.GetInnerException(ex).Message; } return(data); }
public string ExportExcelReportData(int userId, int id, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; ProductionItemObjectData ds = new ProductionItemObjectData(); Framework.DAL.DataFactory fwFactory = new Framework.DAL.DataFactory(); int?companyID = fwFactory.GetCompanyID(userId); try { SqlDataAdapter adap = new SqlDataAdapter(); adap.SelectCommand = new SqlCommand("ProductionItemMng_function_GetExcelData", new SqlConnection(Library.Helper.GetSQLConnectionString())); adap.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure; adap.SelectCommand.Parameters.AddWithValue("@ProductionItemID", id); adap.SelectCommand.Parameters.AddWithValue("@CompanyID", companyID); adap.TableMappings.Add("Table", "ProductionItemExportToExcel"); adap.Fill(ds); return(Library.Helper.CreateReportFileWithEPPlus2(ds, "ProductionItem")); } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message)) { notification.DetailMessage.Add(ex.InnerException.Message); } return(string.Empty); } }
public List <DTO.ProductionItemDefaultPriceDTO> GetProductionItemDefaultPrice(int userId, string searchString, out Notification notification) { notification = new Notification(); notification.Type = NotificationType.Success; List <DTO.ProductionItemDefaultPriceDTO> data = new List <DTO.ProductionItemDefaultPriceDTO>(); try { Framework.DAL.DataFactory fwFactory = new Framework.DAL.DataFactory(); int?companyID = fwFactory.GetCompanyID(userId); using (var context = CreatContext()) { var dbItem = context.PurchaseQuotationMng_ProductionItemDefaultPrice_View.Where(o => o.CompanyID == companyID && (o.Value.Contains(searchString) || o.ProductionItemUD.Contains(searchString))); data = converter.DB2DTO_ProductionItemDefaultPrice(dbItem.ToList()); foreach (var item in data) { if (item != null && item.FrameWeight.HasValue) { item.IsHasWeight = true; } } } } catch (Exception ex) { notification.Type = NotificationType.Error; notification.Message = Library.Helper.GetInnerException(ex).Message; } return(data); }
public DTO.InitForm GetInitData(int iRequesterID, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification(); notification.Type = Library.DTO.NotificationType.Success; DTO.InitForm initForm = new DTO.InitForm(); initForm.FactoryWarehouses = new List <Support.DTO.FactoryWarehouseDto>(); try { Framework.DAL.DataFactory fwFactory = new Framework.DAL.DataFactory(); int?companyID = fwFactory.GetCompanyID(iRequesterID); Support.DAL.DataFactory supportFactory = new Support.DAL.DataFactory(); initForm.FactoryWarehouses = supportFactory.GetFactoryWarehouse(companyID); } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message.Trim())) { notification.DetailMessage.Add(ex.InnerException.Message); } } return(initForm); }
public DTO.SearchForm GetDataWithFilters(int userId, int?month, int?year, string workOrderStatusNM, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification(); notification.Type = Library.DTO.NotificationType.Success; DTO.SearchForm data = new DTO.SearchForm(); data.SummaryOutWardReportDatas = new List <DTO.SummaryOutWardReportData>(); try { Framework.DAL.DataFactory fwFactory = new Framework.DAL.DataFactory(); int?companyID = fwFactory.GetCompanyID(userId); using (var context = CreateContext()) { var results = context.SummaryOutWardRpt_function_GetReportData(companyID, month, year, workOrderStatusNM); data.SummaryOutWardReportDatas = converter.DB2DTO_GetSummaryOutWardReportData(results.ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message)) { notification.DetailMessage.Add(ex.InnerException.Message); } } return(data); }
// get filter Factory Quotation public List <DTO.FactorySaleOrder> GetFilterOrder(int userID, string searchQuery, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification(); notification.Type = Library.DTO.NotificationType.Success; List <DTO.FactorySaleOrder> data = new List <DTO.FactorySaleOrder>(); try { using (var context = CreateContext()) { Framework.DAL.DataFactory frameworkFactory = new Framework.DAL.DataFactory(); int?companyID = frameworkFactory.GetCompanyID(userID); data = converter.GetFilterFactorySaleOrder(context.FactorySaleOrderMng_FilterSaleOrder_View.Where(o => o.FactorySaleOrderUD.Contains(searchQuery)).ToList()); if (data != null && data.Count > 0) { data = data.Where(x => !string.IsNullOrEmpty(x.FactorySaleOrderUD)).ToList(); } } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }
public object GetProductionItemWithFilters(int userID, System.Collections.Hashtable filters, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification(); notification.Type = Library.DTO.NotificationType.Success; System.Collections.Generic.List <DTO.SupportProductBreakDownPALProductionItemData> data = new System.Collections.Generic.List <DTO.SupportProductBreakDownPALProductionItemData>(); try { Framework.DAL.DataFactory fwFactory = new Framework.DAL.DataFactory(); int?companyID = fwFactory.GetCompanyID(userID); string searchQuery = (filters.ContainsKey("searchQuery") && filters["searchQuery"] != null && !string.IsNullOrEmpty(filters["searchQuery"].ToString())) ? filters["searchQuery"].ToString() : null; string priceDate = (filters.ContainsKey("priceDate") && filters["priceDate"] != null && !string.IsNullOrEmpty(filters["priceDate"].ToString())) ? filters["priceDate"].ToString() : null; using (var context = CreateContext()) { data = converter.DB2DTO_ProductionItemPAL(context.ProductBreakDownPAL_function_SupportProductionItemPAL(searchQuery, priceDate, companyID).ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = Library.Helper.GetInnerException(ex).Message; } return(data); }
public DTO.InitFormDTO GetInitData(int userId, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification(); notification.Type = Library.DTO.NotificationType.Success; DTO.InitFormDTO data = new DTO.InitFormDTO(); try { Framework.DAL.DataFactory frameworkFactory = new Framework.DAL.DataFactory(); int?companyId = frameworkFactory.GetCompanyID(userId); using (var context = CreateContext()) { var dbFactoryWarehouses = context.ShowroomTransferMng_FactoryWarehouse_View.Where(o => o.CompanyID == companyId); data.FactoryWarehouses = dataConverter.DB2DTO_SupportFactoryWarehouse(dbFactoryWarehouses.ToList()); var dbFactoryWarehousePallets = context.ShowroomTransferMng_FactoryWarehousePallet_View.Where(o => o.CompanyID == companyId); data.FactoryWarehousePallets = dataConverter.DB2DTO_SupportFactoryWarehousePallet(dbFactoryWarehousePallets.ToList()); } } catch (System.Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = Helper.GetInnerException(ex).Message; } return(data); }
public DTO.InitFormData GetInitData(int userId, out Notification notification) { notification = new Notification(); notification.Type = NotificationType.Success; DTO.InitFormData data = new InitFormData(); data.SubSupplier = new List <FactoryRawMaterialDto>(); data.Seasons = new List <Support.DTO.Season>(); try { Framework.DAL.DataFactory fwFactory = new Framework.DAL.DataFactory(); int?companyID = fwFactory.GetCompanyID(userId); Module.Support.DAL.DataFactory supportFactory = new Support.DAL.DataFactory(); data.Seasons = supportFactory.GetSeason(); using (var context = CreateContext()) { data.SubSupplier = converter.DB2DTO_GetFactoryRawMaterial(context.PurchaseOrderMng_FactoryRawMaterial_View.ToList()); } } catch (Exception ex) { Exception ex_1 = Library.Helper.GetInnerException(ex); notification.Type = NotificationType.Error; notification.Message = ex_1.Message; } return(data); }
public List <DTO.SystemSetting2> CoppySeassions(string Seassion, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification { Type = Library.DTO.NotificationType.Success }; List <DTO.SystemSetting2> data = new List <DTO.SystemSetting2>(); try { // Pre data param to get data ProductionItem Framework.DAL.DataFactory fwFactory = new Framework.DAL.DataFactory(); //int? companyID = fwFactory.GetCompanyID(userID); using (var context = CreateContext()) { context.FW_function_ApplySystemSettingFromLastSeason(Seassion); var dbItem = context.SystemSetting2Mng_SystemSetting_View.ToList(); data = AutoMapper.Mapper.Map <List <SystemSetting2Mng_SystemSetting_View>, List <DTO.SystemSetting2> >(dbItem.ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = Library.Helper.GetInnerException(ex).Message; } return(data); }
// get filter list client contact public List <DTO.ClientContact> GetFilterClientcontact(int userID, string searchQuery, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification(); notification.Type = Library.DTO.NotificationType.Success; List <DTO.ClientContact> data = new List <DTO.ClientContact>(); Framework.DAL.DataFactory frameworkFactory = new Framework.DAL.DataFactory(); try { using (var context = CreateContext()) { data = converter.GetListClientContact(context.FactorySaleQuotationMng_FactorySaleQuotation_ClientContact_View.Where(o => (o.FullName.Contains(searchQuery))).ToList()); if (data != null && data.Count > 0) { data = data.Where(x => !string.IsNullOrEmpty(x.FullName)).ToList(); } } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }
public object QuickSearchProductionItem(int userID, Hashtable filters, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification(); notification.Type = Library.DTO.NotificationType.Success; DTO.QuickSearchProductionItemDTO data = new DTO.QuickSearchProductionItemDTO(); try { Framework.DAL.DataFactory fwFactory = new Framework.DAL.DataFactory(); int?companyID = fwFactory.GetCompanyID(userID); string searchString = (filters.ContainsKey("searchString") && filters["searchString"] != null && !string.IsNullOrEmpty(filters["searchString"].ToString()) ? filters["searchString"].ToString() : null); int? fromBranch = (filters.ContainsKey("fromBranch") && filters["fromBranch"] != null && !string.IsNullOrEmpty(filters["fromBranch"].ToString()) ? (int?)Convert.ToInt32(filters["fromBranch"].ToString()) : null); int? toBranch = (filters.ContainsKey("toBranch") && filters["toBranch"] != null && !string.IsNullOrEmpty(filters["toBranch"].ToString()) ? (int?)Convert.ToInt32(filters["toBranch"].ToString()) : null); using (WarehouseTransferMngEntities context = CreateContext()) { var dbProductionItem = context.WarehouseTransferMng_function_ProductionItemQuickSearchResult(searchString, fromBranch, toBranch, companyID); data.ProductionItems = converter.DB2DTO_ProductionItem(dbProductionItem.ToList()); //data.ProductionItemUnits = converter.DB2DTO_ProductionItemUnit(context.WarehouseTransferMng_ProductionItemUnit_View.Where(o => o.ProductionItemUD.Contains(searchString) || o.ProductionItemNM.Contains(searchString)).ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = Library.Helper.GetInnerException(ex).Message; } return(data); }
public DTO.InitFormDTO GetInitData(int userID, out Notification notification) { notification = new Notification(); notification.Type = NotificationType.Success; DTO.InitFormDTO data = new DTO.InitFormDTO(); try { Framework.DAL.DataFactory fwFactory = new Framework.DAL.DataFactory(); int?companyID = fwFactory.GetCompanyID(userID); using (var context = CreateContext()) { data.ProductionTeam = AutoMapper.Mapper.Map <List <OutsourceRpt_ProductionTeam_View>, List <DTO.OutsourceProductionTeamDTO> >(context.OutsourceRpt_ProductionTeam_View.Where(o => o.CompanyID == companyID).ToList()); } } catch (Exception ex) { notification.Type = NotificationType.Error; notification.Message = Library.Helper.GetInnerException(ex).Message; } return(data); }
// get filter product item public List <DTO.ProductionItem> GetFilterProductItem(int userID, string searchQuery, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification(); notification.Type = Library.DTO.NotificationType.Success; List <DTO.ProductionItem> data = new List <DTO.ProductionItem>(); try { Framework.DAL.DataFactory frameworkFactory = new Framework.DAL.DataFactory(); int?companyID = frameworkFactory.GetCompanyID(userID); using (var context = CreateContext()) { data = converter.GetListListProductionItem(context.FactorySaleQuotationMng_FactorySaleQuotation_ListProductionItem_View.Where(o => o.ProductionItemNM.Contains(searchQuery) || o.ProductionItemUD.Contains(searchQuery)).ToList()); if (data != null && data.Count > 0) { data = data.Where(x => !string.IsNullOrEmpty(x.ProductionItemNM)).ToList(); } } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }
public DTO.InitFormDTO GetInitForm(int userID, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification(); notification.Type = Library.DTO.NotificationType.Success; DTO.InitFormDTO data = new DTO.InitFormDTO(); try { Framework.DAL.DataFactory frameworkFactory = new Framework.DAL.DataFactory(); int?companyID = frameworkFactory.GetCompanyID(userID); using (WarehouseTransferMngEntities context = CreateContext()) { data.Branches = AutoMapper.Mapper.Map <List <WarehouseTransferMng_Branch_View>, List <DTO.BranchDTO> >(context.WarehouseTransferMng_Branch_View.Where(o => o.CompanyID == companyID).ToList()); data.FactoryWarehouses = AutoMapper.Mapper.Map <List <WarehouseTransferMng_FactoryWarehouse_View>, List <DTO.FactoryWarehouseDTO> >(context.WarehouseTransferMng_FactoryWarehouse_View.Where(o => o.CompanyID == companyID).ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = Library.Helper.GetInnerException(ex).Message; } return(data); }
public List <DTO.FactorySaleQuotationDTO> GetFactorySalesQuotation(int userId, string factorySalesQuotationUD, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; List <DTO.FactorySaleQuotationDTO> data = new List <DTO.FactorySaleQuotationDTO>(); try { Module.Framework.DAL.DataFactory fw_factory = new Framework.DAL.DataFactory(); int?companyID = fw_factory.GetCompanyID(userId); using (FactorySalesOrderMngEntities context = CreateContext()) { var x = context.FactorySaleOrderMng_QuickSearchFactorySaleQuotation_View.Where(o => o.CompanyID == companyID && o.FactorySaleQuotationUD.Contains(factorySalesQuotationUD)).ToList(); data = AutoMapper.Mapper.Map <List <FactorySaleOrderMng_QuickSearchFactorySaleQuotation_View>, List <DTO.FactorySaleQuotationDTO> >(x); return(data); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = Library.Helper.GetInnerException(ex).Message; return(new List <DTO.FactorySaleQuotationDTO>()); } }
// filter list raw material public List <DTO.RawMaterial> GetFilterRawMaterial(int userID, string searchQuery, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification(); notification.Type = Library.DTO.NotificationType.Success; List <DTO.RawMaterial> data = new List <DTO.RawMaterial>(); try { Framework.DAL.DataFactory frameworkFactory = new Framework.DAL.DataFactory(); int?companyID = frameworkFactory.GetCompanyID(userID); using (var context = CreateContext()) { var userInformation = _AccountMngFactory.GetUserInformation(userID, out notification); data = converter.GetListRawMaterial(context.FactorySaleQuotationMng_FactorySaleQuotation_ListRawMaterial_View.Where(o => (o.FactoryRawMaterialShortNM.Contains(searchQuery) || o.FactoryRawMaterialOfficialNM.Contains(searchQuery))).ToList()); if (data != null && data.Count > 0) { data = data.Where(x => !string.IsNullOrEmpty(x.FactoryRawMaterialUD)).ToList(); //if (userInformation != null) //{ // data = data.Where(x => x.CompanyID == userInformation.CompanyID).ToList(); //} } } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }
public DTO.ReportData GetProductionSchedule(int userId, Hashtable filters, out Notification notification) { DTO.ReportData data = new DTO.ReportData(); notification = new Library.DTO.Notification { Type = Library.DTO.NotificationType.Success }; try { int? workOrderID = null; string workOrderUD = null; int? workCenterID = null;; int? productionTeamID = null; if (filters["workOrderID"] != null) { workOrderID = Convert.ToInt32(filters["workOrderID"]); } if (filters["workOrderUD"] != null) { workOrderUD = filters["workOrderUD"].ToString(); } if (filters["workCenterID"] != null) { workCenterID = Convert.ToInt32(filters["workCenterID"]); } if (filters["productionTeamID"] != null) { productionTeamID = Convert.ToInt32(filters["productionTeamID"]); } Module.Support.DAL.DataFactory support_factory = new Support.DAL.DataFactory(); Module.Framework.DAL.DataFactory fw_factory = new Framework.DAL.DataFactory(); int?companyID = fw_factory.GetCompanyID(userId); data.WorkCenters = support_factory.GetWorkCenter(); data.ProductionTeams = support_factory.GetProductionTeam(companyID); data.FactoryWarehouseDtos = support_factory.GetFactoryWarehouse(companyID); using (ProductionScheduleRptEntities context = CreateContext()) { var x = context.ProductionScheduleRpt_ProductionSchedule_View.Where(o => o.WorkOrderUD.Contains(workOrderUD == null || workOrderUD == "" ? o.WorkOrderUD : workOrderUD) && o.WorkCenterID == (workCenterID.HasValue ? workCenterID.Value : o.WorkCenterID) && o.ProductionTeamID == (productionTeamID.HasValue ? productionTeamID.Value : o.ProductionTeamID) ); data.ProductionSchedules = converter.DB2DTO_ProductionSchedule(x.ToList()); return(data); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; notification.DetailMessage.Add(ex.Message); if (ex.GetBaseException() != null) { notification.DetailMessage.Add(ex.GetBaseException().Message); } return(new DTO.ReportData()); } }
// // CUSTOM // public DTO.SearchFilterData GetSearchFilter(int userId, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; DTO.SearchFilterData data = new DTO.SearchFilterData(); //data.Companies = new List<Support.DTO.InternalCompany>(); try { Framework.DAL.DataFactory frameworkFactory = new Framework.DAL.DataFactory(); int?companyID = frameworkFactory.GetCompanyID(userId); Support.DAL.DataFactory supportFactory = new Support.DAL.DataFactory(); data.Employees = supportFactory.GetEmployee(); using (FactoryWarehouseEntities context = CreateContext()) { data.Branches = AutoMapper.Mapper.Map <List <FactoryWarehouseMng_Branch_View>, List <DTO.BranchDTO> >(context.FactoryWarehouseMng_Branch_View.Where(o => o.CompanyID == companyID).ToList()); } //data.Companies = supportFactory.GetInternalCompany().ToList(); } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }
public DTO.InitForm GetInitData(int userId, out Library.DTO.Notification notification) { DTO.InitForm initData = new DTO.InitForm(); Support.DAL.DataFactory supportFactory = new Support.DAL.DataFactory(); Framework.DAL.DataFactory frameworkFactory = new Framework.DAL.DataFactory(); notification = new Library.DTO.Notification(); notification.Type = Library.DTO.NotificationType.Success; try { initData.WorkCenters = supportFactory.GetWorkCenter(); int?companyID = frameworkFactory.GetCompanyID(userId); initData.ProductionTeams = supportFactory.GetProductionTeam(companyID); initData.FactoryWarehouses = supportFactory.GetFactoryWarehouse(companyID); } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(initData); }
public List <DTO.WorkOrder> GetWorkOrder(int userID, string searchQuery, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification(); notification.Type = Library.DTO.NotificationType.Success; List <DTO.WorkOrder> data = new List <DTO.WorkOrder>(); Framework.DAL.DataFactory frameworkFactory = new Framework.DAL.DataFactory(); int?companyID = frameworkFactory.GetCompanyID(userID); try { using (var context = CreatedContext()) { data = converter.DB2DTO_WorkOrder(context.SupportMng_WorkOrder_View.Where(o => o.Label.Contains(searchQuery) && o.CompanyID == companyID).ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }
public List <DTO.MaterialPriceProductItemSeach> GetProductionItem(string searchProductionItem, string searchProductionItemUD, int userID, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification { Type = Library.DTO.NotificationType.Success }; List <DTO.MaterialPriceProductItemSeach> data = new List <DTO.MaterialPriceProductItemSeach>(); try { // Pre data param to get data ProductionItem Framework.DAL.DataFactory fwFactory = new Framework.DAL.DataFactory(); int?companyID = fwFactory.GetCompanyID(userID); using (var context = CreateContext()) { var dbItem = context.FactoryRawMaterial_function_GetProductionItemMaterial(searchProductionItem, searchProductionItemUD); data = AutoMapper.Mapper.Map <List <FactoryRawMaterialMng_SearchProductionItem_View>, List <DTO.MaterialPriceProductItemSeach> >(dbItem.ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = Library.Helper.GetInnerException(ex).Message; } return(data); }
public DTO.EditFormData GetData(int userId, int id, out Library.DTO.Notification notification) { DTO.EditFormData editFormData = new DTO.EditFormData(); notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; try { //get companyID Module.Framework.DAL.DataFactory fw_factory = new Framework.DAL.DataFactory(); int?companyID = fw_factory.GetCompanyID(userId); using (WarehouseTransferMngEntities context = CreateContext()) { if (id > 0) { WarehouseTransferMng_WarehouseTransfer_View dbItem; dbItem = context.WarehouseTransferMng_WarehouseTransfer_View.FirstOrDefault(o => o.WarehouseTransferID == id); editFormData.Data = converter.DB2DTO_WarehouseTransfer(dbItem); editFormData.Data.WarehouseTransferProductDTOs = new List <DTO.WarehouseTransferProductDTO>(); //get item from List <WarehouseTransferMng_WarehouseTransferProduct_View> transferItem = context.WarehouseTransferMng_WarehouseTransferProduct_View.Where(o => o.WarehouseTransferID == id).ToList(); DTO.WarehouseTransferProductDTO dtoTransferItem; foreach (var item in transferItem) { dtoTransferItem = new DTO.WarehouseTransferProductDTO(); dtoTransferItem.WarehouseTransferProductID = item.WarehouseTransferProductID; dtoTransferItem.ProductionItemID = item.ProductionItemID; dtoTransferItem.Quantity = item.Quantity; dtoTransferItem.QNTBarCode = item.QNTBarCode; dtoTransferItem.ProductionItemUD = item.ProductionItemUD; dtoTransferItem.ProductionItemNM = item.ProductionItemNM; dtoTransferItem.ProductionItemTypeNM = item.ProductionItemTypeNM; editFormData.Data.WarehouseTransferProductDTOs.Add(dtoTransferItem); } } else { editFormData.Data = new DTO.WarehouseTransferDTO(); editFormData.Data.WarehouseTransferProductDTOs = new List <DTO.WarehouseTransferProductDTO>(); editFormData.Data.WarehouseTransferDetails = new List <DTO.WarehouseTransferDetailDTO>(); editFormData.Data.ReceiptDate = DateTime.Now.ToString("dd/MM/yyyy"); } } //get support list Module.Support.DAL.DataFactory support_factory = new Support.DAL.DataFactory(); editFormData.FactoryWarehouses = support_factory.GetFactoryWarehouse(companyID); return(editFormData); } catch (Exception ex) { Exception iEx = Library.Helper.GetInnerException(ex); notification.Type = Library.DTO.NotificationType.Error; notification.Message = iEx.Message; return(editFormData); } }
private bool CheckIsFactory(PriceQuotationMngEntities context, int userId) { Framework.DAL.DataFactory factory = new Framework.DAL.DataFactory(); int? companyLogin = factory.GetCompanyID(userId); List <int?> companyInternals = context.SupportMng_InternalCompany2_View.Select(o => o.InternalCompanyID).ToList(); return(!companyInternals.Contains(companyLogin)); }
public DTO.SearchForm GetDataWithFilters(int userId, Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification) { DTO.SearchForm data = new DTO.SearchForm(); data.CustomerDatas = new List <DTO.CustomerData>(); data.ProductionItemDatas = new List <DTO.ProductionItemData>(); notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; totalRows = 0; try { string salesOrderNo = ""; int? factoryRawMaterialID = null; string startDate = ""; string endDate = ""; if (filters.ContainsKey("salesOrderNo") && !string.IsNullOrEmpty(filters["salesOrderNo"].ToString())) { salesOrderNo = filters["salesOrderNo"].ToString().Replace("'", "''"); } if (filters.ContainsKey("factoryRawMaterialID") && filters["factoryRawMaterialID"] != null && !string.IsNullOrEmpty(filters["factoryRawMaterialID"].ToString())) { factoryRawMaterialID = Convert.ToInt32(filters["factoryRawMaterialID"]); } if (filters.ContainsKey("startDate") && !string.IsNullOrEmpty(filters["startDate"].ToString())) { startDate = filters["startDate"].ToString().Replace("'", "''"); } if (filters.ContainsKey("endDate") && !string.IsNullOrEmpty(filters["endDate"].ToString())) { endDate = filters["endDate"].ToString().Replace("'", "''"); } Framework.DAL.DataFactory fwFactory = new Framework.DAL.DataFactory(); int?companyID = fwFactory.GetCompanyID(userId); using (var context = CreateContext()) { var results = context.SummarySalesRpt_function_CustomerReport(factoryRawMaterialID, salesOrderNo, companyID, startDate, endDate); data.CustomerDatas = converter.DB2DTO_GetCustomerDatas(results.ToList()); data.ProductionItemDatas = converter.DB2DTO_GetProductionItemDatas(context.SummarySalesRpt_function_ProductionItemReport(factoryRawMaterialID, salesOrderNo, companyID, startDate, endDate).ToList()); } return(data); } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; notification.DetailMessage.Add(ex.Message); if (ex.GetBaseException() != null) { notification.DetailMessage.Add(ex.GetBaseException().Message); } return(data); } }
public List <DTO.ProductionItem> getProductionItemTypeCost(int userId, Hashtable filters) { List <DTO.ProductionItem> result = new List <DTO.ProductionItem>(); using (WorkOrderCostMngEntities context = this.CreateContext()) { Module.Framework.DAL.DataFactory fw_factory = new Framework.DAL.DataFactory(); int? companyID = fw_factory.GetCompanyID(userId); string searchQuery = filters["searchQuery"].ToString(); var dbItems = context.SupportMng_ProductionItem_View.Where(o => o.CompanyID == companyID && o.ProductionItemTypeID == 7 && (o.ProductionItemNM.Contains(searchQuery) || o.ProductionItemUD.Contains(searchQuery))).ToList(); return(AutoMapper.Mapper.Map <List <SupportMng_ProductionItem_View>, List <DTO.ProductionItem> >(dbItems)); } }
public DTO.SearchFormData GetDataWithFilter(int userId, Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification) { DTO.SearchFormData searchFormData = new DTO.SearchFormData(); notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; totalRows = 0; try { int? companyID = null; string purchaseRequestUD = null; string purchaseRequestDate = null; int? purchaseRequestStatusID = null; Module.Framework.DAL.DataFactory fw_factory = new Framework.DAL.DataFactory(); companyID = fw_factory.GetCompanyID(userId); if (filters.ContainsKey("purchaseRequestUD") && !string.IsNullOrEmpty(filters["purchaseRequestUD"].ToString())) { purchaseRequestUD = filters["purchaseRequestUD"].ToString().Replace("'", "''"); } if (filters.ContainsKey("purchaseRequestDate") && !string.IsNullOrEmpty(filters["purchaseRequestDate"].ToString())) { purchaseRequestDate = filters["purchaseRequestDate"].ToString().Replace("'", "''"); } if (filters.ContainsKey("purchaseRequestStatusID") && filters["purchaseRequestStatusID"] != null) { purchaseRequestStatusID = Convert.ToInt32(filters["purchaseRequestStatusID"]); } using (PurchaseRequestMngEntities context = CreateContext()) { totalRows = context.PurchaseRequestMng_function_SearchPurchaseRequest(orderBy, orderDirection, companyID, purchaseRequestUD, purchaseRequestDate, purchaseRequestStatusID).Count(); var result = context.PurchaseRequestMng_function_SearchPurchaseRequest(orderBy, orderDirection, companyID, purchaseRequestUD, purchaseRequestDate, purchaseRequestStatusID); searchFormData.Data = converter.DB2DTO_PurchaseRequestSearch(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList()); } return(searchFormData); } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; notification.DetailMessage.Add(ex.Message); if (ex.GetBaseException() != null) { notification.DetailMessage.Add(ex.GetBaseException().Message); } return(searchFormData); } }
public bool UpdateData(int userId, int id, ref object dtoItem, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; List <WorkOrderCost> dataItem = ((Newtonsoft.Json.Linq.JArray)dtoItem).ToObject <List <WorkOrderCost> >(); try { //get companyID Module.Framework.DAL.DataFactory fw_factory = new Framework.DAL.DataFactory(); int?companyID = fw_factory.GetCompanyID(userId); using (WorkOrderCostMngEntities context = CreateContext()) { List <WorkOrderCost> dbWorkOrderCosts = context.WorkOrderCost.Where(x => x.WorkOrderID == id).ToList(); List <int> dbWorkOrderCostsDelete = dbWorkOrderCosts.Select(y => y.WorkOrderCostID).Where(x => !dataItem.Select(z => z.WorkOrderCostID).Contains(x)).ToList(); foreach (WorkOrderCost item in dataItem) { if (!dbWorkOrderCosts.Select(x => x.WorkOrderCostID).ToList().Contains(item.WorkOrderCostID)) { context.WorkOrderCost.Add(item); } else { WorkOrderCost dbWorkOrderCost = dbWorkOrderCosts.Where(x => x.WorkOrderCostID == item.WorkOrderCostID).FirstOrDefault(); dbWorkOrderCost.Qty = item.Qty; dbWorkOrderCost.CostPrice = item.CostPrice; } } foreach (int iddelete in dbWorkOrderCostsDelete) { WorkOrderCost itemdelete = context.WorkOrderCost.Where(x => x.WorkOrderCostID == iddelete).FirstOrDefault(); if (itemdelete != null) { context.WorkOrderCost.Remove(itemdelete); } } context.SaveChanges(); return(true); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; Exception iEx = Library.Helper.GetInnerException(ex); notification.Message = iEx.Message; return(false); } }
public string GetExcelReportData(int userID, int?factoryWarsehouseID, int?productionItemTypeID, string validDate, out Notification notification) { notification = new Notification(); notification.Type = NotificationType.Success; ReportDataObject ds = new ReportDataObject(); Framework.DAL.DataFactory frameFactory = new Framework.DAL.DataFactory(); int?companyID = frameFactory.GetCompanyID(userID); DateTime?currentDate = validDate.ConvertStringToDateTime(); if (!currentDate.HasValue) { throw new Exception("Please input valid date!"); } string startDate = currentDate.Value.ToString("dd/MM/yyyy"); string endDate = currentDate.Value.AddMonths(1).AddDays(-1).ToString("dd/MM/yyyy"); int?currentMonth = currentDate.Value.Month; int?currentYear = currentDate.Value.Year; try { SqlDataAdapter adap = new SqlDataAdapter(); adap.SelectCommand = new SqlCommand("InventoryCostRpt_function_InventoryCostSearchResult", new SqlConnection(Library.Helper.GetSQLConnectionString())); adap.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure; adap.SelectCommand.Parameters.AddWithValue("@FactoryWarehouseID", factoryWarsehouseID); adap.SelectCommand.Parameters.AddWithValue("@StartDate", startDate); adap.SelectCommand.Parameters.AddWithValue("@EndDate", DBNull.Value); adap.SelectCommand.Parameters.AddWithValue("@BranchID", DBNull.Value); adap.SelectCommand.Parameters.AddWithValue("@ProductionItemTypeID", productionItemTypeID); adap.TableMappings.Add("Table", "InventoryCostReportDataView"); adap.Fill(ds); return(Library.Helper.CreateReportFileWithEPPlus2(ds, "InventoryCostRpt")); } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message)) { notification.DetailMessage.Add(ex.InnerException.Message); } return(string.Empty); } }
public SearchFormData GetDataWithFilter(int userID, Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Notification notification) { SearchFormData data = new SearchFormData { Data = new List <PriceQuotationSearchResultData>() }; notification = new Notification { Type = NotificationType.Success }; totalRows = 0; try { string season = (filters.ContainsKey("Season") && filters["Season"] != null && !string.IsNullOrEmpty(filters["Season"].ToString().Replace("'", "''"))) ? filters["Season"].ToString().Trim() : null; string clientUD = (filters.ContainsKey("ClientUD") && filters["ClientUD"] != null && !string.IsNullOrEmpty(filters["ClientUD"].ToString().Replace("'", "''"))) ? filters["ClientUD"].ToString().Trim() : null; string factoryUD = (filters.ContainsKey("FactoryUD") && filters["FactoryUD"] != null && !string.IsNullOrEmpty(filters["FactoryUD"].ToString().Replace("'", "''"))) ? filters["FactoryUD"].ToString().Trim() : null; string articleCode = (filters.ContainsKey("ArticleCode") && filters["ArticleCode"] != null && !string.IsNullOrEmpty(filters["ArticleCode"].ToString().Replace("'", "''"))) ? filters["ArticleCode"].ToString().Trim() : null; string description = (filters.ContainsKey("Description") && filters["Description"] != null && !string.IsNullOrEmpty(filters["Description"].ToString().Replace("'", "''"))) ? filters["Description"].ToString().Trim() : null; string priceDifferenceCode = (filters.ContainsKey("PriceDifferenceCode") && filters["PriceDifferenceCode"] != null && !string.IsNullOrEmpty(filters["PriceDifferenceCode"].ToString().Replace("'", "''"))) ? filters["PriceDifferenceCode"].ToString().Trim() : null; int? quotationStatusID = (filters.ContainsKey("QuotationStatusID") && filters["QuotationStatusID"] != null && !string.IsNullOrEmpty(filters["QuotationStatusID"].ToString().Replace("'", "''"))) ? (int?)Convert.ToInt32(filters["QuotationStatusID"].ToString().Trim()) : null; string orderNo = (filters.ContainsKey("OrderNumber") && filters["OrderNumber"] != null && !string.IsNullOrEmpty(filters["OrderNumber"].ToString().Replace("'", "''"))) ? filters["OrderNumber"].ToString().Trim() : null; using (var context = CreateContext()) { if (!string.IsNullOrEmpty(season)) { context.PriceQuotationMng_AddAllItemToQuotation(season); } Framework.DAL.DataFactory factory = new Framework.DAL.DataFactory(); data.IsCompany = context.SupportMng_InternalCompany2_View.Select(o => o.InternalCompanyID).Contains(factory.GetCompanyID(userID)) ? null : (int?)1; totalRows = context.PriceQuotationMng_function_PriceQuotationSearchResult(clientUD, factoryUD, articleCode, description, priceDifferenceCode, quotationStatusID, season, orderBy, orderDirection, userID, data.IsCompany, orderNo).Count(); data.Data = converter.DB2DTO_PriceQuotationSearchResult(context.PriceQuotationMng_function_PriceQuotationSearchResult(clientUD, factoryUD, articleCode, description, priceDifferenceCode, quotationStatusID, season, orderBy, orderDirection, userID, data.IsCompany, orderNo).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList()); } return(data); } catch (Exception ex) { notification.Type = NotificationType.Error; notification.Message = ex.Message; return(null); } }