public void FillWare() { WaresLogic waresLogic = new WaresLogic(manager); Compas.Model.Ware ware = waresLogic.Get(wareId); WareNameL.Text = ware.Name; }
private void FillFields() { _unitQuantity = detail.UnitQuantity; _secondaryUnitQuantity = detail.SecondaryUnitQuantity; _priceForUnit = detail.PriceForUnit; _endPriceForUnit = detail.EndPriceForUnit; _endPrice = detail.EndPrice; _currencyName = (detail.WareDocument == null ? "" : detail.WareDocument.Currency.Name); if (detail.Ware != null) { _wareName = detail.Ware.Name; _unitName = detail.Ware.WareUnit == null ? "" : detail.Ware.WareUnit.Name; _secondaryUnitName = detail.Ware.WareUnit1 == null ? "" : detail.Ware.WareUnit1.Name; _unit = _unitQuantity + " " + (detail.Ware.WareUnit == null ? "" : detail.Ware.WareUnit.Name); _secondaryUnit = detail.SecondaryUnitQuantity.ToString() + " " + (detail.Ware.WareUnit1 == null ? "" : detail.Ware.WareUnit1.Name); } else { WaresLogic waresLogic = new WaresLogic(manager); Ware ware = waresLogic.Get(detail.WareID); if (ware != null) { _wareName = ware.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 = 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 DeleteSB_Click(object sender, EventArgs e) { WaresLogic wares = new WaresLogic(manager); wares.Delete(Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value)); manager.Save(); Fill("Name"); }
private void Fill() { if (mode == "edit") { WaresLogic waresLogic = new WaresLogic(manager); Model.Ware ware = waresLogic.Get(Convert.ToInt32(id)); WareNameL.Text = ware.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 SaveBt_Click(object sender, EventArgs e) { WaresLogic wares = new WaresLogic(manager); WareCodesLogic codes = new WareCodesLogic(manager); string name = NameTB.Text; int? categoryId = null; if (CategoriesCB.SelectedIndex > 0) { categoryId = Convert.ToInt32(CategoriesCB.SelectedValue); } int?manufacturerId = null; if (ManufacturersCB.SelectedIndex > 0) { manufacturerId = Convert.ToInt32(ManufacturersCB.SelectedValue); } int unitId = Convert.ToInt32(UnitsCB.SelectedValue); int? secondaryUnitId = null; decimal?secondaryUnitQuantity = null; if (SecondaryUnitsCB.SelectedIndex > 0) { secondaryUnitId = Convert.ToInt32(SecondaryUnitsCB.SelectedValue); secondaryUnitQuantity = Convert.ToDecimal(SecondaryQuantityNUD.Value); } Model.Ware ware = null; if (mode == "new") { ware = wares.Create(NameTB.Text, unitId, 0, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity); } if (mode == "edit") { ware = wares.Update(Convert.ToInt32(id), NameTB.Text, unitId, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity); foreach (string code in codesListForDelete) { codes.Delete(Convert.ToInt32(id), code); } } foreach (string code in codesList) { codes.Create(ware, code); } manager.Save(); this.Close(); }
private void Fill() { WareUnitsLogic units = new WareUnitsLogic(manager); WaresLogic wares = new WaresLogic(manager); StaffStructureObjectsLogic objects = new StaffStructureObjectsLogic(manager); if (DocumentDetail != null) { WareLUE.EditValue = DocumentDetail.WareID; UnitQuantityTB.EditValue = DocumentDetail.UnitQuantity; SecondaryUnitQuantityTB.EditValue = DocumentDetail.SecondaryUnitQuantity; SalePriceForUnitTB.EditValue = DocumentDetail.PriceForUnit; DiscountForUnitTB.EditValue = DocumentDetail.DiscountForUnit; EndSalePriceForUnitTB.Text = Convert.ToDecimal(DocumentDetail.EndPriceForUnit).ToString("n2"); SalePriceTB.Text = Convert.ToDecimal(DocumentDetail.EndPrice).ToString("n2"); } }
private void FillWares() { WaresLogic wares = new WaresLogic(manager); int?categoryId = null; int?manufacturerId = null; int?unitId = null; //string name = wareFilterUC1.WareName; categoryId = categoriesUC2.SelectedCategoryID; if (categoryId < 0) { categoryId = null; } BindingSource bs = new BindingSource(); List <ViewWare> waresList = wares.GetAllView("", categoryId, manufacturerId, unitId); view = new SortableBindingList <ViewWare>(waresList); WaresGV.Visible = false; WaresFLP.Visible = false; switch (this.WaresViewMode) { case WaresViewModes.GridView: { WaresGV.AutoGenerateColumns = false; WaresGV.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; WaresGV.DataSource = view; WaresGV.Visible = true; break; } case WaresViewModes.Button: { WaresFLP.Controls.Clear(); WaresFLP.Dock = DockStyle.Fill; foreach (var ware in view) { this.CreateButton(ware.ID.ToString(), ware.Name.ToString() + "\n" + "1" + ware.UnitName, Helpers.ImageOperations.ByteArrayToImage(ware.Image)); } WaresFLP.Visible = true; break; } } }
public void FillFilters() { WareCategoriesLogic categoriesLogic = new WareCategoriesLogic(manager); StaffStructureObjectsLogic structureObjectsLogic = new StaffStructureObjectsLogic(manager); WaresLogic waresLogic = new WaresLogic(manager); DocumentTypesLogic documentTypesLogic = new DocumentTypesLogic(manager); StructureObjectsLUE.Properties.DisplayMember = "Name"; StructureObjectsLUE.Properties.ValueMember = "ID"; StructureObjectsLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Name", "Назва")); StructureObjectsLUE.Properties.DataSource = structureObjectsLogic.GetHeirarchyView(); WareCategoriesLUE.Properties.DisplayMember = "Name"; WareCategoriesLUE.Properties.ValueMember = "ID"; WareCategoriesLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Name", "Назва")); WareCategoriesLUE.Properties.DataSource = categoriesLogic.GetCategoriesHierarchy(); StartDateDE.EditValue = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); }
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; if (WareCategoriesLUE.EditValue != null) { categoryId = Convert.ToInt32(WareCategoriesLUE.EditValue); } if (UnitLUE.EditValue != null) { unitId = Convert.ToInt32(UnitLUE.EditValue); } var waresList = wares.GetAllView("", categoryId, manufacturerId, unitId); //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.WareCategoryName; wv.ManufacturerName = a.ManufacturerName; wv.UnitName = a.UnitName; wv.SecondaryUnitID = a.SecondaryUnitID; wv.SecondaryUnitName = a.SecondaryUnitName; wv.SecondaryUnitQuantity = a.SecondaryUnitQuantity; wv.WareCode = a.WareCode == null ? "": a.WareCode; //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); WaresLUE.Properties.DataSource = view; WaresLUE.Properties.ValueMember = "ID"; WaresLUE.Properties.DisplayMember = "Name"; WaresLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("WareCode", 0, "Код")); WaresLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Name", 0, "Назва")); WaresLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("ManufacturerName", 0, "Виробник")); WaresLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("UnitName", 0, "Осн. од. вим.")); WaresLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("SecondUnitName", 0, "втор. од. вим.")); WaresLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("CategoryName", 0, "Категорія")); }
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 FillWares() { WaresLogic wares = new WaresLogic(manager); int? categoryId = null; int? manufacturerId = null; int? unitId = null; //string name = wareFilterUC1.WareName; if( WareCategoriesLUE.EditValue != null) categoryId =Convert.ToInt32(WareCategoriesLUE.EditValue); if(UnitLUE.EditValue != null) unitId =Convert.ToInt32(UnitLUE.EditValue); var waresList = wares.GetAllView("", categoryId, manufacturerId, unitId); //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.WareCategoryName; wv.ManufacturerName = a.ManufacturerName; wv.UnitName = a.UnitName; wv.SecondaryUnitID = a.SecondaryUnitID; wv.SecondaryUnitName = a.SecondaryUnitName; wv.SecondaryUnitQuantity = a.SecondaryUnitQuantity; wv.WareCode = a.WareCode == null ? "": a.WareCode; //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); WaresLUE.Properties.DataSource = view; WaresLUE.Properties.ValueMember = "ID"; WaresLUE.Properties.DisplayMember = "Name"; WaresLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("WareCode", 0, "Код")); WaresLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Name", 0, "Назва")); WaresLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("ManufacturerName", 0, "Виробник")); WaresLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("UnitName", 0, "Осн. од. вим.")); WaresLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("SecondUnitName", 0, "втор. од. вим.")); WaresLUE.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; }
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(string columnName) { DateTime start = DateTime.Now; WaresLogic wares = new WaresLogic(manager); DataGV.AutoGenerateColumns = false; int?categoryId = null; int?manufacturerId = null; int?unitId = null; //string name = wareFilterUC1.WareName; if (categoriesFilterUC1.SelectedCategoryID >= 0) { categoryId = categoriesFilterUC1.SelectedCategoryID; } //manufacturerId = wareFilterUC1.ManufacturerID; //unitId = wareFilterUC1.UnitID; BindingSource bs = new BindingSource(); var waresList = wares.GetAllView("", 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 : "", // CategoryID = a.CategoryID, // SecondaryUnitID = a.SecondaryUnitID != null ? a.SecondaryUnitID : null, // SecondaryUnitName = a.WareUnit1 != null ? a.WareUnit1.Name : "", // SecondaryUnitQuantity = a.SecondaryUnitQuantity != null ? a.SecondaryUnitQuantity : null, // a.WareCodes, // a.WareTimeLimits //});//.OrderBy(a => a.CategoryName).ThenBy(a=> a.Name).ToList(); //List<WareView> viewList = new List<WareView>(); DateTime start0 = DateTime.Now; //foreach (var a in waresList) //{ // WareView wv = new WareView(); // wv.ID = a.ID; // wv.CategoryID = a.CategoryID; // 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(); // //var lastTimeLimit = (from aa in a.WareTimeLimits // // where aa.Active == true // // select aa).FirstOrDefault(); // //if (lastTimeLimit != null) // // wv.TimeLimit = lastTimeLimit.TimeLimit; // //else // // wv.TimeLimit = 0; // viewList.Add(wv); //} DateTime start1 = DateTime.Now; //BindingListView<WareView> view = new BindingListView<WareView>(viewList); //bs.DataSource = view; //bs.Sort = columnName; view = new SortableBindingList <ViewWare>(waresList); ListToDataTable listToDataTable = new ListToDataTable(); DataGV.DataSource = listToDataTable.ToDataTable <ViewWare>(waresList); //DataGV.DataSource = view; DataGV.Update(); DgvFilterManager filterManager = new DgvFilterManager(DataGV); DateTime start2 = DateTime.Now; //MessageBox.Show(start.ToString() + " " + start0.ToString() + " " + start1.ToString() + " " + start2.ToString()); }
private void SaveBt_Click(object sender, EventArgs e) { WaresLogic wares = new WaresLogic(manager); WareCodesLogic codes = new WareCodesLogic(manager); string name = NameTB.Text; int? categoryId = null; if (CategoriesCB.SelectedIndex > 0) { categoryId = Convert.ToInt32(CategoriesCB.SelectedValue); } int?manufacturerId = null; if (ManufacturersCB.SelectedIndex > 0) { manufacturerId = Convert.ToInt32(ManufacturersCB.SelectedValue); } int unitId = Convert.ToInt32(UnitsCB.SelectedValue); int? secondaryUnitId = null; decimal?secondaryUnitQuantity = null; decimal timeLimit = 0; timeLimit = TimeLimitNUD.Value; if (SecondaryUnitsCB.SelectedIndex > 0) { secondaryUnitId = Convert.ToInt32(SecondaryUnitsCB.SelectedValue); secondaryUnitQuantity = Convert.ToDecimal(SecondaryQuantityNUD.Value); } Model.Ware ware = null; //зберігаємо код якщо він введений в текстове поле, а інших кодів немає if ((codesList.Count == 0) & (CodeTB.Text.Trim().Length > 0)) { codesList.Add(CodeTB.Text.Trim()); codesListForDelete.Remove(CodeTB.Text.Trim()); } if (mode == "new") { if (openFileDialog1.CheckPathExists == true) { image = Helpers.ImageOperations.ConvertImageToByteArray(openFileDialog1.FileName); } ware = wares.Create(NameTB.Text, unitId, 0, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity, image); } if (mode == "edit") { if (_image != null) { image = Helpers.ImageOperations.ImageToByteArray(_image); } else { image = null; } ware = wares.Update(Convert.ToInt32(id), NameTB.Text, unitId, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity, image); foreach (string code in codesListForDelete) { codes.Delete(Convert.ToInt32(id), code); } } foreach (string code in codesList) { if (codes.CodeForOtherWareExists(id, code) == false) { codes.Create(ware, code); } else { MessageBox.Show("Введений код " + code + " вже існує і не був збережений"); } } WareTimeLimitsLogic timeLimits = new WareTimeLimitsLogic(manager); timeLimits.Create(ware, Convert.ToDecimal(TimeLimitNUD.Value), true); manager.Save(); if (AddComponentsCB.Checked == true) { Wares.Ware.WareComponentData form = new Wares.Ware.WareComponentData("edit", Convert.ToInt32(ware.ID)); form.ShowDialog(); } this.Close(); }
private void Fill() { ItemIntValue none = new ItemIntValue(); none.ID = -1; none.Name = " - не вибрано - "; FillCategories(); FillManufacturers(); FillUnits(); FillSecondaryUnits(); FillCodes(); FillTimeLimits(); if (mode == "edit") { WaresLogic wares = new WaresLogic(manager); var ware = wares.Get(Convert.ToInt32(id)); if (ware != null) { NameTB.Text = ware.Name; int? categoryId = ware.CategoryID; int? manufacturerId = ware.ManufacturerID; int? unitId = ware.UnitID; int? secondaryUnitId = ware.SecondaryUnitID; decimal?secondaryUnitQuantity = ware.SecondaryUnitQuantity; if (secondaryUnitQuantity != null) { SecondaryQuantityNUD.Value = Convert.ToDecimal(secondaryUnitQuantity); } if (categoryId != null) { int i = 0; foreach (ItemIntValue a in CategoriesCB.Items) { if (a.ID == categoryId) { CategoriesCB.SelectedIndex = i; } i++; } } if (unitId != null) { int i = 0; foreach (ItemIntValue a in UnitsCB.Items) { if (a.ID == unitId) { UnitsCB.SelectedIndex = i; } i++; } } if (secondaryUnitId != null) { int i = 0; foreach (ItemIntValue a in SecondaryUnitsCB.Items) { if (a.ID == secondaryUnitId) { SecondaryUnitsCB.SelectedIndex = i; } i++; } } if (manufacturerId != null) { int i = 0; foreach (ItemIntValue a in ManufacturersCB.Items) { if (a.ID == manufacturerId) { ManufacturersCB.SelectedIndex = i; } i++; } } ImagePB.SizeMode = PictureBoxSizeMode.Zoom; _image = Helpers.ImageOperations.ByteArrayToImage(ware.Image); image = ware.Image; ImagePB.Image = _image; } } }
private void SaveBt_Click(object sender, EventArgs e) { WaresLogic wares = new WaresLogic(manager); WareCodesLogic codes = new WareCodesLogic(manager); string name = NameTB.Text; int? categoryId = null; if (CategoriesCB.SelectedIndex > 0) categoryId = Convert.ToInt32(CategoriesCB.SelectedValue); int? manufacturerId = null; if (ManufacturersCB.SelectedIndex > 0) manufacturerId = Convert.ToInt32(ManufacturersCB.SelectedValue); int unitId = Convert.ToInt32(UnitsCB.SelectedValue); int? secondaryUnitId = null; decimal? secondaryUnitQuantity = null; decimal timeLimit = 0; timeLimit = TimeLimitNUD.Value; if (SecondaryUnitsCB.SelectedIndex > 0) { secondaryUnitId = Convert.ToInt32(SecondaryUnitsCB.SelectedValue); secondaryUnitQuantity = Convert.ToDecimal(SecondaryQuantityNUD.Value); } Model.Ware ware = null; //зберігаємо код якщо він введений в текстове поле, а інших кодів немає if ((codesList.Count == 0) & (CodeTB.Text.Trim().Length > 0)) { codesList.Add(CodeTB.Text.Trim()); codesListForDelete.Remove(CodeTB.Text.Trim()); } if (mode == "new") { if (openFileDialog1.CheckPathExists == true) image = Helpers.ImageOperations.ConvertImageToByteArray(openFileDialog1.FileName); ware = wares.Create(NameTB.Text, unitId, 0, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity,image); } if (mode == "edit") { if (_image != null) image = Helpers.ImageOperations.ImageToByteArray(_image); else image = null; ware = wares.Update(Convert.ToInt32(id), NameTB.Text, unitId, manufacturerId, categoryId, secondaryUnitId, secondaryUnitQuantity, image); foreach (string code in codesListForDelete) { codes.Delete(Convert.ToInt32(id), code); } } foreach (string code in codesList) { if (codes.CodeForOtherWareExists(id, code) == false) codes.Create(ware, code); else MessageBox.Show("Введений код " + code + " вже існує і не був збережений"); } WareTimeLimitsLogic timeLimits = new WareTimeLimitsLogic(manager); timeLimits.Create(ware, Convert.ToDecimal(TimeLimitNUD.Value), true); manager.Save(); if (AddComponentsCB.Checked == true) { Wares.Ware.WareComponentData form = new Wares.Ware.WareComponentData("edit", Convert.ToInt32(ware.ID)); form.ShowDialog(); } this.Close(); }
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() { ItemIntValue none = new ItemIntValue(); none.ID = -1; none.Name = " - не вибрано - "; FillCategories(); FillManufacturers(); FillUnits(); FillSecondaryUnits(); FillCodes(); FillTimeLimits(); if (mode == "edit") { WaresLogic wares = new WaresLogic(manager); var ware = wares.Get(Convert.ToInt32(id)); if (ware != null) { NameTB.Text = ware.Name; int? categoryId = ware.CategoryID; int? manufacturerId = ware.ManufacturerID; int? unitId = ware.UnitID; int? secondaryUnitId = ware.SecondaryUnitID; decimal? secondaryUnitQuantity = ware.SecondaryUnitQuantity; if (secondaryUnitQuantity != null) SecondaryQuantityNUD.Value = Convert.ToDecimal(secondaryUnitQuantity); if (categoryId != null) { int i = 0; foreach (ItemIntValue a in CategoriesCB.Items) { if (a.ID == categoryId) { CategoriesCB.SelectedIndex = i; } i++; } } if (unitId != null) { int i = 0; foreach (ItemIntValue a in UnitsCB.Items) { if (a.ID == unitId) { UnitsCB.SelectedIndex = i; } i++; } } if (secondaryUnitId != null) { int i = 0; foreach (ItemIntValue a in SecondaryUnitsCB.Items) { if (a.ID == secondaryUnitId) { SecondaryUnitsCB.SelectedIndex = i; } i++; } } if (manufacturerId != null) { int i = 0; foreach (ItemIntValue a in ManufacturersCB.Items) { if (a.ID == manufacturerId) { ManufacturersCB.SelectedIndex = i; } i++; } } ImagePB.SizeMode = PictureBoxSizeMode.Zoom; _image = Helpers.ImageOperations.ByteArrayToImage(ware.Image); image = ware.Image; ImagePB.Image = _image; } } }
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(string columnName) { DateTime start = DateTime.Now; WaresLogic wares = new WaresLogic(manager); DataGV.AutoGenerateColumns = false; int? categoryId = null; int? manufacturerId = null; int? unitId = null; //string name = wareFilterUC1.WareName; if(categoriesFilterUC1.SelectedCategoryID >= 0) categoryId = categoriesFilterUC1.SelectedCategoryID; //manufacturerId = wareFilterUC1.ManufacturerID; //unitId = wareFilterUC1.UnitID; BindingSource bs = new BindingSource(); var waresList = wares.GetAllView("", 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 : "", // CategoryID = a.CategoryID, // SecondaryUnitID = a.SecondaryUnitID != null ? a.SecondaryUnitID : null, // SecondaryUnitName = a.WareUnit1 != null ? a.WareUnit1.Name : "", // SecondaryUnitQuantity = a.SecondaryUnitQuantity != null ? a.SecondaryUnitQuantity : null, // a.WareCodes, // a.WareTimeLimits //});//.OrderBy(a => a.CategoryName).ThenBy(a=> a.Name).ToList(); //List<WareView> viewList = new List<WareView>(); DateTime start0 = DateTime.Now; //foreach (var a in waresList) //{ // WareView wv = new WareView(); // wv.ID = a.ID; // wv.CategoryID = a.CategoryID; // 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(); // //var lastTimeLimit = (from aa in a.WareTimeLimits // // where aa.Active == true // // select aa).FirstOrDefault(); // //if (lastTimeLimit != null) // // wv.TimeLimit = lastTimeLimit.TimeLimit; // //else // // wv.TimeLimit = 0; // viewList.Add(wv); //} DateTime start1 = DateTime.Now; //BindingListView<WareView> view = new BindingListView<WareView>(viewList); //bs.DataSource = view; //bs.Sort = columnName; view = new SortableBindingList<ViewWare>(waresList); ListToDataTable listToDataTable = new ListToDataTable(); DataGV.DataSource = listToDataTable.ToDataTable<ViewWare>(waresList); //DataGV.DataSource = view; DataGV.Update(); DgvFilterManager filterManager = new DgvFilterManager(DataGV); DateTime start2 = DateTime.Now; //MessageBox.Show(start.ToString() + " " + start0.ToString() + " " + start1.ToString() + " " + start2.ToString()); }