private void FillWares() { WaresLogic wares = new WaresLogic(manager); int?categoryId = null; int?manufacturerId = null; int?unitId = null; //string name = wareFilterUC1.WareName; categoryId = wareFilterUC1.CategoryID; manufacturerId = wareFilterUC1.ManufacturerID; unitId = wareFilterUC1.UnitID; BindingSource bs = new BindingSource(); var waresList = wares.GetAll("", categoryId, manufacturerId, unitId).Select(a => new { a.ID, Name = a.Name, UnitName = a.WareUnit != null ? a.WareUnit.Name : "", ManufacturerName = a.WareManufacturer != null ? a.WareManufacturer.Name : "", CategoryName = a.WareCategory != null ? a.WareCategory.Name : "", SecondaryUnitID = a.SecondaryUnitID != null ? a.SecondaryUnitID : null, SecondaryUnitName = a.WareUnit1 != null ? a.WareUnit1.Name : "", SecondaryUnitQuantity = a.SecondaryUnitQuantity != null ? a.SecondaryUnitQuantity : null });//.OrderBy(a => a.CategoryName).ThenBy(a=> a.Name).ToList(); if (wareId != null) { waresList = waresList.Where(a => a.ID == wareId); } List <WareView> viewList = new List <WareView>(); foreach (var a in waresList) { WareView wv = new WareView(); wv.ID = a.ID; wv.Name = a.Name; wv.CategoryName = a.CategoryName; wv.ManufacturerName = a.ManufacturerName; wv.UnitName = a.UnitName; wv.SecondaryUnitID = a.SecondaryUnitID; wv.SecondaryUnitName = a.SecondaryUnitName; wv.SecondaryUnitQuantity = a.SecondaryUnitQuantity; viewList.Add(wv); } //BindingListView<WareView> view = new BindingListView<WareView>(viewList); //bs.DataSource = view; //bs.Sort = columnName; view = new SortableBindingList <WareView>(viewList); WareCB.DataSource = view; WareCB.ValueMember = "ID"; WareCB.DisplayMember = "Name"; }
private void FillFilteredWares(string columnName) { WaresLogic wares = new WaresLogic(manager); int?categoryId = null; int?manufacturerId = null; int?unitId = null; //string name = wareFilterUC1.WareName; if (categoriesUC1.SelectedCategoryID >= 0) { categoryId = categoriesUC1.SelectedCategoryID; } //manufacturerId = wareFilterUC1.ManufacturerID; //unitId = wareFilterUC1.UnitID; BindingSource bs = new BindingSource(); var waresList = wares.GetAll("", categoryId, manufacturerId, unitId).Select(a => new { a.ID, Name = a.Name, UnitName = a.WareUnit != null ? a.WareUnit.Name : "", ManufacturerName = a.WareManufacturer != null ? a.WareManufacturer.Name : "", CategoryName = a.WareCategory != null ? a.WareCategory.Name : "", SecondaryUnitID = a.SecondaryUnitID != null ? a.SecondaryUnitID : null, SecondaryUnitName = a.WareUnit1 != null ? a.WareUnit1.Name : "", SecondaryUnitQuantity = a.SecondaryUnitQuantity != null ? a.SecondaryUnitQuantity : null, a.WareCodes });//.OrderBy(a => a.CategoryName).ThenBy(a=> a.Name).ToList(); List <WareView> viewList = new List <WareView>(); foreach (var a in waresList) { WareView wv = new WareView(); wv.ID = a.ID; wv.Name = a.Name; wv.CategoryName = a.CategoryName; wv.ManufacturerName = a.ManufacturerName; wv.UnitName = a.UnitName; wv.SecondaryUnitID = a.SecondaryUnitID; wv.SecondaryUnitName = a.SecondaryUnitName; wv.SecondaryUnitQuantity = a.SecondaryUnitQuantity; wv.WareCodes = a.WareCodes.ToList(); viewList.Add(wv); } //BindingListView<WareView> view = new BindingListView<WareView>(viewList); //bs.DataSource = view; //bs.Sort = columnName; view = new SortableBindingList <WareView>(viewList); WareLUE.Properties.DataSource = view; }
private void FillWares() { WaresLogic wares = new WaresLogic(manager); int?categoryId = null; int?manufacturerId = null; int?unitId = null; //string name = wareFilterUC1.WareName; categoryId = wareFilterUC1.CategoryID; manufacturerId = wareFilterUC1.ManufacturerID; unitId = wareFilterUC1.UnitID; BindingSource bs = new BindingSource(); var waresList = mode == "new" ? wares.GetAll("", categoryId, manufacturerId, unitId).Select(a => new { a.ID, Name = a.Name, UnitName = a.WareUnit != null ? a.WareUnit.Name : "", ManufacturerName = a.WareManufacturer != null ? a.WareManufacturer.Name : "", CategoryName = a.WareCategory != null ? a.WareCategory.Name : "", SecondaryUnitID = a.SecondaryUnitID != null ? a.SecondaryUnitID : null, SecondaryUnitName = a.WareUnit1 != null ? a.WareUnit1.Name : "", SecondaryUnitQuantity = a.SecondaryUnitQuantity != null ? a.SecondaryUnitQuantity : null, a.WareCodes }) : wares.GetAllByWareID(DocumentDetail.WareID).Select(a => new { a.ID, Name = a.Name, UnitName = a.WareUnit != null ? a.WareUnit.Name : "", ManufacturerName = a.WareManufacturer != null ? a.WareManufacturer.Name : "", CategoryName = a.WareCategory != null ? a.WareCategory.Name : "", SecondaryUnitID = a.SecondaryUnitID != null ? a.SecondaryUnitID : null, SecondaryUnitName = a.WareUnit1 != null ? a.WareUnit1.Name : "", SecondaryUnitQuantity = a.SecondaryUnitQuantity != null ? a.SecondaryUnitQuantity : null, a.WareCodes }) ;//.OrderBy(a => a.CategoryName).ThenBy(a=> a.Name).ToList(); List <WareView> viewList = new List <WareView>(); foreach (var a in waresList) { WareView wv = new WareView(); wv.ID = a.ID; wv.Name = a.Name; wv.CategoryName = a.CategoryName; wv.ManufacturerName = a.ManufacturerName; wv.UnitName = a.UnitName; wv.SecondaryUnitID = a.SecondaryUnitID; wv.SecondaryUnitName = a.SecondaryUnitName; wv.SecondaryUnitQuantity = a.SecondaryUnitQuantity; wv.WareCodes = a.WareCodes.ToList(); viewList.Add(wv); } //BindingListView<WareView> view = new BindingListView<WareView>(viewList); //bs.DataSource = view; //bs.Sort = columnName; view = new SortableBindingList <WareView>(viewList); WareLUE.Properties.DataSource = view; WareLUE.Properties.ValueMember = "ID"; WareLUE.Properties.DisplayMember = "Name"; WareLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("WareCodesString", 0, "Код")); WareLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Name", 0, "Назва")); WareLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("ManufacturerName", 0, "Виробник")); WareLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("UnitName", 0, "Осн. од. вим.")); WareLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("SecondUnitName", 0, "втор. од. вим.")); WareLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("CategoryName", 0, "Категорія")); }
private void Fill() { int? selectedIndex = null; if (DataGV.SelectedRows.Count > 0) { selectedIndex = DataGV.SelectedRows[0].Index; } int? documentTypeId = null; string documentNumber = ""; DateTime startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); DateTime? endDate = null; decimal? documentSum = null; if(documentFilterUC1.DocumentTypeID >= 0) documentTypeId = documentFilterUC1.DocumentTypeID; documentNumber = documentFilterUC1.DocumentNumber; startDate = universalFilter1.StartDate == null ? startDate : Convert.ToDateTime(universalFilter1.StartDate); endDate = universalFilter1.EndDate; documentSum = documentFilterUC1.DocumentSum; SortableBindingList<DocumentView> view = new SortableBindingList<DocumentView>(documentsLogic.GetAllView(documentTypeId, documentNumber, startDate, endDate, documentSum)); //if (selectedIndex != null) // if(DataGV.RowCount > selectedIndex) // DataGV.Rows[Convert.ToInt32(selectedIndex)].Selected = true; DataTable table = new DataTable(); table.Columns.Add("Дата", typeof(DateTime)); table.Columns.Add("Адреса", typeof(string)); WareCategoriesLogic categoriesLogic = new WareCategoriesLogic(manager); Compas.Logic.Documents.DocumentDetailsLogic detailsLogic = new DocumentDetailsLogic(manager); DocumentStaffDetailsLogic staffLogic = new DocumentStaffDetailsLogic(manager); WaresLogic waresLogic = new WaresLogic(manager); //Спочатку визначаємо яку категорію номенклатури нам необхідно проаналізувати int viewCategoryId = Convert.ToInt32(ViewCategoriesLUE.EditValue); List<WareCategory> categories = categoriesLogic.GetAllRoot().Where(a => a.ID != viewCategoryId).ToList(); foreach (WareCategory category in categories) { table.Columns.Add(category.Name, typeof(string)); } table.Columns.Add("Акт №", typeof(string)); table.Columns.Add("Сума", typeof(decimal)); table.Columns.Add("К-ть робіт", typeof(decimal)); table.Columns.Add("К-ть виконавців", typeof(int)); table.Columns.Add("К-ть на вик.", typeof(int)); table.Columns.Add("Виконавець1", typeof(string)); table.Columns.Add("Виконавець2", typeof(string)); table.Columns.Add("Виконавець3", typeof(string)); table.Columns.Add("Виконавець4", typeof(string)); //Основні матеріали(номенклатура, включена в документ) List<WareCategory> viewCategories = categoriesLogic.GetAllChilds(viewCategoryId); //спочатку вкладені підкатегорії foreach (WareCategory category in viewCategories) { table.Columns.Add(category.Name, typeof(string)); } //тоді номенклатурні одиниці даної категорії(без підкатегорій) List<Ware> wares = waresLogic.GetAll(viewCategoryId); //кожна номенклатурна одиниця - окрема колонка foreach (Ware ware in wares) { table.Columns.Add(ware.Name, typeof(decimal)); } table.Columns.Add("Коментарі", typeof(string)); categories = categoriesLogic.GetAllRoot().Where(a => a.ID != viewCategoryId).ToList(); foreach (DocumentView document in view) { DataRow row = table.NewRow(); row["Дата"] = document.Date; row["Адреса"] = "Адреса надання послуги"; row["Акт №"] = document.Number; row["Сума"] = document.DocumentSum; row["К-ть виконавців"] = 0; row["К-ть на вик."] = 0; int counter = 0; //виводимо категорії по колонкам foreach (WareCategory category in categories) { string detailsList = ""; List<WareDocumentDetail> details = detailsLogic.GetAllByWareCategory(startDate, endDate, category.ID, document.ID).Where(a => a.Ware.CategoryID != viewCategoryId).ToList(); foreach (WareDocumentDetail detail in details) { if (detailsList.Length > 0) detailsList = detailsList + ";\n"; //стрічка містить перелік номенклатурних одиниць в межах категорії detailsList = detailsList + detail.Ware.Name; counter++; } if (row[category.Name] != null) { row[category.Name] = detailsList; } } row["К-ть робіт"] = counter; //Працівники повязані з даним документом List<StaffEmployee> staffEmployees = staffLogic.GetStaffEmployeesByDocumentID(document.ID); counter = 1; string fullName = ""; foreach (StaffEmployee employee in staffEmployees) { fullName = employee.LastName + " " + employee.FirstName + " " + employee.MiddleName; if (counter < 4) row["Виконавець" + counter.ToString()] = fullName; else row["Виконавець" + counter.ToString()] = row["Виконавець" + counter.ToString()] + "; " + fullName; counter = counter + 1; } //номенклатурні одиниці, пов'язані з документом string viewCategoryDetailsList = ""; decimal startViewCounter = 0; List<WareDocumentDetail> viewCategoryDetailsAll = detailsLogic.GetAllByWareCategory(startDate, endDate, viewCategoryId, document.ID); List<WareDocumentDetail> viewCategoryDetails = viewCategoryDetailsAll.Where(a => a.Ware.CategoryID == viewCategoryId).ToList(); foreach (WareDocumentDetail detail in viewCategoryDetails) { row[detail.Ware.Name] = startViewCounter + detail.UnitQuantity; } //тепер заповнюємо перелік по підкатегоріям List<WareDocumentDetail> viewNotCategoryDetails = viewCategoryDetailsAll.Where(a => a.Ware.CategoryID != viewCategoryId).ToList(); foreach (WareCategory category in viewCategories) { string waresList = ""; List<WareDocumentDetail> details = detailsLogic.GetAllByWareCategory(startDate, endDate, category.ID, document.ID); foreach (WareDocumentDetail detail in details) { waresList = waresList + detail.Ware.Name + ";\n"; } row[category.Name] = waresList; } row["Коментарі"] = document.Description; table.Rows.Add(row); } DataGV.DefaultCellStyle.WrapMode = DataGridViewTriState.True; DataGV.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells; DataGV.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; DataGV.AllowUserToResizeColumns = true; DataGV.AutoGenerateColumns = true; DataGV.DataSource = table; DataGV.Columns["Коментарі"].DisplayIndex = DataGV.Columns.Count - 1; DataGV.Columns[0].DefaultCellStyle.WrapMode = DataGridViewTriState.False; DataGV.Update(); exportTable = table; }
private void Fill() { int?selectedIndex = null; if (DataGV.SelectedRows.Count > 0) { selectedIndex = DataGV.SelectedRows[0].Index; } int? documentTypeId = null; string documentNumber = ""; DateTime startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); DateTime?endDate = null; decimal? documentSum = null; if (documentFilterUC1.DocumentTypeID >= 0) { documentTypeId = documentFilterUC1.DocumentTypeID; } documentNumber = documentFilterUC1.DocumentNumber; startDate = universalFilter1.StartDate == null ? startDate : Convert.ToDateTime(universalFilter1.StartDate); endDate = universalFilter1.EndDate; documentSum = documentFilterUC1.DocumentSum; SortableBindingList <DocumentView> view = new SortableBindingList <DocumentView>(documentsLogic.GetAllView(documentTypeId, documentNumber, startDate, endDate, documentSum)); //if (selectedIndex != null) // if(DataGV.RowCount > selectedIndex) // DataGV.Rows[Convert.ToInt32(selectedIndex)].Selected = true; DataTable table = new DataTable(); table.Columns.Add("Дата", typeof(DateTime)); table.Columns.Add("Адреса", typeof(string)); WareCategoriesLogic categoriesLogic = new WareCategoriesLogic(manager); Compas.Logic.Documents.DocumentDetailsLogic detailsLogic = new DocumentDetailsLogic(manager); DocumentStaffDetailsLogic staffLogic = new DocumentStaffDetailsLogic(manager); WaresLogic waresLogic = new WaresLogic(manager); //Спочатку визначаємо яку категорію номенклатури нам необхідно проаналізувати int viewCategoryId = Convert.ToInt32(ViewCategoriesLUE.EditValue); List <WareCategory> categories = categoriesLogic.GetAllRoot().Where(a => a.ID != viewCategoryId).ToList(); foreach (WareCategory category in categories) { table.Columns.Add(category.Name, typeof(string)); } table.Columns.Add("Акт №", typeof(string)); table.Columns.Add("Сума", typeof(decimal)); table.Columns.Add("К-ть робіт", typeof(decimal)); table.Columns.Add("К-ть виконавців", typeof(int)); table.Columns.Add("К-ть на вик.", typeof(int)); table.Columns.Add("Виконавець1", typeof(string)); table.Columns.Add("Виконавець2", typeof(string)); table.Columns.Add("Виконавець3", typeof(string)); table.Columns.Add("Виконавець4", typeof(string)); //Основні матеріали(номенклатура, включена в документ) List <WareCategory> viewCategories = categoriesLogic.GetAllChilds(viewCategoryId); //спочатку вкладені підкатегорії foreach (WareCategory category in viewCategories) { table.Columns.Add(category.Name, typeof(string)); } //тоді номенклатурні одиниці даної категорії(без підкатегорій) List <Ware> wares = waresLogic.GetAll(viewCategoryId); //кожна номенклатурна одиниця - окрема колонка foreach (Ware ware in wares) { table.Columns.Add(ware.Name, typeof(decimal)); } table.Columns.Add("Коментарі", typeof(string)); categories = categoriesLogic.GetAllRoot().Where(a => a.ID != viewCategoryId).ToList(); foreach (DocumentView document in view) { DataRow row = table.NewRow(); row["Дата"] = document.Date; row["Адреса"] = "Адреса надання послуги"; row["Акт №"] = document.Number; row["Сума"] = document.DocumentSum; row["К-ть виконавців"] = 0; row["К-ть на вик."] = 0; int counter = 0; //виводимо категорії по колонкам foreach (WareCategory category in categories) { string detailsList = ""; List <WareDocumentDetail> details = detailsLogic.GetAllByWareCategory(startDate, endDate, category.ID, document.ID).Where(a => a.Ware.CategoryID != viewCategoryId).ToList(); foreach (WareDocumentDetail detail in details) { if (detailsList.Length > 0) { detailsList = detailsList + ";\n"; } //стрічка містить перелік номенклатурних одиниць в межах категорії detailsList = detailsList + detail.Ware.Name; counter++; } if (row[category.Name] != null) { row[category.Name] = detailsList; } } row["К-ть робіт"] = counter; //Працівники повязані з даним документом List <StaffEmployee> staffEmployees = staffLogic.GetStaffEmployeesByDocumentID(document.ID); counter = 1; string fullName = ""; foreach (StaffEmployee employee in staffEmployees) { fullName = employee.LastName + " " + employee.FirstName + " " + employee.MiddleName; if (counter < 4) { row["Виконавець" + counter.ToString()] = fullName; } else { row["Виконавець" + counter.ToString()] = row["Виконавець" + counter.ToString()] + "; " + fullName; } counter = counter + 1; } //номенклатурні одиниці, пов'язані з документом string viewCategoryDetailsList = ""; decimal startViewCounter = 0; List <WareDocumentDetail> viewCategoryDetailsAll = detailsLogic.GetAllByWareCategory(startDate, endDate, viewCategoryId, document.ID); List <WareDocumentDetail> viewCategoryDetails = viewCategoryDetailsAll.Where(a => a.Ware.CategoryID == viewCategoryId).ToList(); foreach (WareDocumentDetail detail in viewCategoryDetails) { row[detail.Ware.Name] = startViewCounter + detail.UnitQuantity; } //тепер заповнюємо перелік по підкатегоріям List <WareDocumentDetail> viewNotCategoryDetails = viewCategoryDetailsAll.Where(a => a.Ware.CategoryID != viewCategoryId).ToList(); foreach (WareCategory category in viewCategories) { string waresList = ""; List <WareDocumentDetail> details = detailsLogic.GetAllByWareCategory(startDate, endDate, category.ID, document.ID); foreach (WareDocumentDetail detail in details) { waresList = waresList + detail.Ware.Name + ";\n"; } row[category.Name] = waresList; } row["Коментарі"] = document.Description; table.Rows.Add(row); } DataGV.DefaultCellStyle.WrapMode = DataGridViewTriState.True; DataGV.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells; DataGV.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; DataGV.AllowUserToResizeColumns = true; DataGV.AutoGenerateColumns = true; DataGV.DataSource = table; DataGV.Columns["Коментарі"].DisplayIndex = DataGV.Columns.Count - 1; DataGV.Columns[0].DefaultCellStyle.WrapMode = DataGridViewTriState.False; DataGV.Update(); exportTable = table; }
private void FillWares() { WaresLogic wares = new WaresLogic(manager); int? categoryId = null; int? manufacturerId = null; int? unitId = null; //string name = wareFilterUC1.WareName; categoryId = wareFilterUC1.CategoryID; manufacturerId = wareFilterUC1.ManufacturerID; unitId = wareFilterUC1.UnitID; BindingSource bs = new BindingSource(); var waresList = wares.GetAll("", categoryId, manufacturerId, unitId).Select(a => new { a.ID, Name = a.Name, UnitName = a.WareUnit != null ? a.WareUnit.Name : "", ManufacturerName = a.WareManufacturer != null ? a.WareManufacturer.Name : "", CategoryName = a.WareCategory != null ? a.WareCategory.Name : "", SecondaryUnitID = a.SecondaryUnitID != null ? a.SecondaryUnitID : null, SecondaryUnitName = a.WareUnit1 != null ? a.WareUnit1.Name : "", SecondaryUnitQuantity = a.SecondaryUnitQuantity != null ? a.SecondaryUnitQuantity : null });//.OrderBy(a => a.CategoryName).ThenBy(a=> a.Name).ToList(); if (wareId != null) { waresList = waresList.Where(a => a.ID == wareId); } List<WareView> viewList = new List<WareView>(); foreach (var a in waresList) { WareView wv = new WareView(); wv.ID = a.ID; wv.Name = a.Name; wv.CategoryName = a.CategoryName; wv.ManufacturerName = a.ManufacturerName; wv.UnitName = a.UnitName; wv.SecondaryUnitID = a.SecondaryUnitID; wv.SecondaryUnitName = a.SecondaryUnitName; wv.SecondaryUnitQuantity = a.SecondaryUnitQuantity; viewList.Add(wv); } //BindingListView<WareView> view = new BindingListView<WareView>(viewList); //bs.DataSource = view; //bs.Sort = columnName; view = new SortableBindingList<WareView>(viewList); WareCB.DataSource = view; WareCB.ValueMember = "ID"; WareCB.DisplayMember = "Name"; }
private void FillWares() { WaresLogic wares = new WaresLogic(manager); int? categoryId = null; int? manufacturerId = null; int? unitId = null; //string name = wareFilterUC1.WareName; categoryId = wareFilterUC1.CategoryID; manufacturerId = wareFilterUC1.ManufacturerID; unitId = wareFilterUC1.UnitID; BindingSource bs = new BindingSource(); var waresList = mode == "new" ? wares.GetAll("", categoryId, manufacturerId, unitId).Select(a => new { a.ID, Name = a.Name, UnitName = a.WareUnit != null ? a.WareUnit.Name : "", ManufacturerName = a.WareManufacturer != null ? a.WareManufacturer.Name : "", CategoryName = a.WareCategory != null ? a.WareCategory.Name : "", SecondaryUnitID = a.SecondaryUnitID != null ? a.SecondaryUnitID : null, SecondaryUnitName = a.WareUnit1 != null ? a.WareUnit1.Name : "", SecondaryUnitQuantity = a.SecondaryUnitQuantity != null ? a.SecondaryUnitQuantity : null, a.WareCodes }) : wares.GetAllByWareID(DocumentDetail.WareID).Select(a => new { a.ID, Name = a.Name, UnitName = a.WareUnit != null ? a.WareUnit.Name : "", ManufacturerName = a.WareManufacturer != null ? a.WareManufacturer.Name : "", CategoryName = a.WareCategory != null ? a.WareCategory.Name : "", SecondaryUnitID = a.SecondaryUnitID != null ? a.SecondaryUnitID : null, SecondaryUnitName = a.WareUnit1 != null ? a.WareUnit1.Name : "", SecondaryUnitQuantity = a.SecondaryUnitQuantity != null ? a.SecondaryUnitQuantity : null, a.WareCodes }) ;//.OrderBy(a => a.CategoryName).ThenBy(a=> a.Name).ToList(); List<WareView> viewList = new List<WareView>(); foreach (var a in waresList) { WareView wv = new WareView(); wv.ID = a.ID; wv.Name = a.Name; wv.CategoryName = a.CategoryName; wv.ManufacturerName = a.ManufacturerName; wv.UnitName = a.UnitName; wv.SecondaryUnitID = a.SecondaryUnitID; wv.SecondaryUnitName = a.SecondaryUnitName; wv.SecondaryUnitQuantity = a.SecondaryUnitQuantity; wv.WareCodes = a.WareCodes.ToList(); viewList.Add(wv); } //BindingListView<WareView> view = new BindingListView<WareView>(viewList); //bs.DataSource = view; //bs.Sort = columnName; view = new SortableBindingList<WareView>(viewList); WareLUE.Properties.DataSource = view; WareLUE.Properties.ValueMember = "ID"; WareLUE.Properties.DisplayMember = "Name"; WareLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("WareCodesString", 0, "Код")); WareLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Name", 0, "Назва")); WareLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("ManufacturerName", 0, "Виробник")); WareLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("UnitName", 0, "Осн. од. вим.")); WareLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("SecondUnitName", 0, "втор. од. вим.")); WareLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("CategoryName", 0, "Категорія")); }
private void FillFilteredWares(string columnName) { WaresLogic wares = new WaresLogic(manager); int? categoryId = null; int? manufacturerId = null; int? unitId = null; //string name = wareFilterUC1.WareName; if(categoriesUC1.SelectedCategoryID >= 0) categoryId = categoriesUC1.SelectedCategoryID; //manufacturerId = wareFilterUC1.ManufacturerID; //unitId = wareFilterUC1.UnitID; BindingSource bs = new BindingSource(); var waresList = wares.GetAll("", categoryId, manufacturerId, unitId).Select(a => new { a.ID, Name = a.Name, UnitName = a.WareUnit != null ? a.WareUnit.Name : "", ManufacturerName = a.WareManufacturer != null ? a.WareManufacturer.Name : "", CategoryName = a.WareCategory != null ? a.WareCategory.Name : "", SecondaryUnitID = a.SecondaryUnitID != null ? a.SecondaryUnitID : null, SecondaryUnitName = a.WareUnit1 != null ? a.WareUnit1.Name : "", SecondaryUnitQuantity = a.SecondaryUnitQuantity != null ? a.SecondaryUnitQuantity : null, a.WareCodes });//.OrderBy(a => a.CategoryName).ThenBy(a=> a.Name).ToList(); List<WareView> viewList = new List<WareView>(); foreach (var a in waresList) { WareView wv = new WareView(); wv.ID = a.ID; wv.Name = a.Name; wv.CategoryName = a.CategoryName; wv.ManufacturerName = a.ManufacturerName; wv.UnitName = a.UnitName; wv.SecondaryUnitID = a.SecondaryUnitID; wv.SecondaryUnitName = a.SecondaryUnitName; wv.SecondaryUnitQuantity = a.SecondaryUnitQuantity; wv.WareCodes = a.WareCodes.ToList(); viewList.Add(wv); } //BindingListView<WareView> view = new BindingListView<WareView>(viewList); //bs.DataSource = view; //bs.Sort = columnName; view = new SortableBindingList<WareView>(viewList); WareLUE.Properties.DataSource = view; }