public DocumentsAlternateList() { InitializeComponent(); manager = new ContextManager(); bool allowed = Compas.Logic.Security.CurrentSecurityContext.Principal.OpperationAllowed("StaffShiftsList"); if (allowed == true) { documentFilterUC1.Fill(); universalFilter1.Fill(); documentsLogic = new DocumentsLogic(manager); WareCategoriesLogic categoriesLogic = new WareCategoriesLogic(manager); BindingList <ItemIntValue> categories = categoriesLogic.GetCategoriesHierarchy(); ViewCategoriesLUE.Properties.ValueMember = "ID"; ViewCategoriesLUE.Properties.DisplayMember = "Name"; ViewCategoriesLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Name", 0, "Назва категорії")); ViewCategoriesLUE.Properties.DataSource = categories; Fill(); } else { MessageBox.Show("Дія заборонена. Зверніться до адміністратора."); this.Close(); } }
private void FillCategories() { ItemIntValue none = new ItemIntValue(); none.ID = -1; none.Name = " - не вибрано - "; List <ItemIntValue> items0 = new List <ItemIntValue>(); WareCategoriesLogic categories = new WareCategoriesLogic(manager); items0.Clear(); //items0.Add(none); foreach (var a in categories.GetCategoriesHierarchy().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items0.Add(i); } CategoriesCB.DataSource = items0; if ((mode == "new") & (defaultCategoryId != null)) { foreach (ItemIntValue i in CategoriesCB.Items) { if (i.ID == Convert.ToInt32(defaultCategoryId)) { CategoriesCB.SelectedItem = i; } } } CategoriesCB.ValueMember = "ID"; CategoriesCB.DisplayMember = "Name"; CategoriesCB.Update(); }
private void Fill() { WareCategoriesLogic cl = new WareCategoriesLogic(manager); FillCategoriesHierarchy(null, ""); CategoriesCB.DataSource = items; if (mode == "edit") { WareCategory category = cl.Get(Convert.ToInt32(id)); if (category != null) { NameTB.Text = category.Name; foreach (ItemIntValue i in items) { if (category.ParentCategoryID == i.ID) { CategoriesCB.SelectedItem = i; } } ImagePB.SizeMode = PictureBoxSizeMode.Zoom; _image = Helpers.ImageOperations.ByteArrayToImage(category.Image); image = category.Image; ImagePB.Image = _image; } } }
/// <summary> /// /// </summary> /// <param name="category">батьківська категорія</param> private void FillCategoriesHierarchy(WareCategory category, string prefix, bool start) { if (start == true) { items.Clear(); } WareCategoriesLogic categoriesLogic = new WareCategoriesLogic(manager); List <WareCategory> categories = new List <WareCategory>(); if (category == null) { categories = categoriesLogic.GetAllRoot(); } else { categories = categoriesLogic.GetAll(category.ID); } foreach (WareCategory a in categories) { ItemIntValue item = new ItemIntValue(); item.ID = a.ID; item.Name = prefix + a.Name; item.Image = a.Image; items.Add(item); FillCategoriesHierarchy(a, prefix + @" ", false); } }
public DocumentsAlternateList() { InitializeComponent(); manager = new ContextManager(); bool allowed = Compas.Logic.Security.CurrentSecurityContext.Principal.OpperationAllowed("StaffShiftsList"); if (allowed == true) { documentFilterUC1.Fill(); universalFilter1.Fill(); documentsLogic = new DocumentsLogic(manager); WareCategoriesLogic categoriesLogic = new WareCategoriesLogic(manager); BindingList<ItemIntValue> categories = categoriesLogic.GetCategoriesHierarchy(); ViewCategoriesLUE.Properties.ValueMember = "ID"; ViewCategoriesLUE.Properties.DisplayMember = "Name"; ViewCategoriesLUE.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Name", 0, "Назва категорії")); ViewCategoriesLUE.Properties.DataSource = categories; Fill(); } else { MessageBox.Show("Дія заборонена. Зверніться до адміністратора."); this.Close(); } }
//public string WareName //{ // get // { // string result = null; // if (NameTB.Text.Length > 0) // { // result = NameTB.Text; // } // return result; // } //} public void Fill() { ItemIntValue none = new ItemIntValue(); none.ID = -1; none.Name = " - не вибрано - "; List <ItemIntValue> items0 = new List <ItemIntValue>(); WareCategoriesLogic categories = new WareCategoriesLogic(manager); items0.Clear(); //items0.Add(none); foreach (var a in categories.GetCategoriesHierarchy().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items0.Add(i); } CategoriesCB.DataSource = items0; CategoriesCB.ValueMember = "ID"; CategoriesCB.DisplayMember = "Name"; CategoriesCB.Update(); WareManufacturersLogic manufacturers = new WareManufacturersLogic(manager); List <ItemIntValue> items1 = new List <ItemIntValue>(); items1.Clear(); items1.Add(none); foreach (var a in manufacturers.GetAll().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items1.Add(i); } //ManufacturersCB.DataSource = manufacturers.GetAll(); ManufacturersCB.DataSource = items1; ManufacturersCB.ValueMember = "ID"; ManufacturersCB.DisplayMember = "Name"; ManufacturersCB.Update(); WareUnitsLogic units = new WareUnitsLogic(manager); List <ItemIntValue> items2 = new List <ItemIntValue>(); items2.Clear(); items2.Add(none); foreach (var a in units.GetAll().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items2.Add(i); } UnitsCB.DataSource = items2; UnitsCB.ValueMember = "ID"; UnitsCB.DisplayMember = "Name"; UnitsCB.Update(); }
private void DeleteCategorySB_Click(object sender, EventArgs e) { if (categoriesFilterUC1.SelectedCategoryID != null) { WareCategoriesLogic cl = new WareCategoriesLogic(manager); cl.Delete(Convert.ToInt32(categoriesFilterUC1.SelectedCategoryID)); manager.Save(); categoriesFilterUC1.Fill(); } }
private void DeleteSB_Click(object sender, EventArgs e) { WareCategoriesLogic cl = new WareCategoriesLogic(manager); cl.Delete(Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value)); manager.Save(); manager.CloseContext(); manager = new ContextManager(); Fill(); }
private void Fill() { DataGV.Rows.Clear(); DataGV.ClearSelection(); FillCategoriesHierarchy(null, "", true); WareCategoriesLogic cl = new WareCategoriesLogic(manager); DataGV.AutoGenerateColumns = false; DataGV.DataSource = items;//cl.GetAll(); DataGV.Update(); }
public List <WareDocumentDetail> GetAllByWareCategory(DateTime StartDate, DateTime?EndDate, int WareCategoryID, int DocumentID) { List <WareDocumentDetail> result; WareCategoriesLogic categoriesLogic = new WareCategoriesLogic(manager); List <WareCategory> categories = categoriesLogic.GetAllChilds(WareCategoryID); List <int?> c = new List <int?>(); foreach (WareCategory category in categories) { c.Add(category.ID); } result = (from a in context.WareDocumentDetails where a.WareDocument.Date >= StartDate & (EndDate == null || a.WareDocument.Date <= EndDate) & (a.Ware.CategoryID == WareCategoryID || c.Contains(a.Ware.CategoryID)) & a.DocumentID == DocumentID select a).ToList().OrderBy(a => a.ID).ToList(); return(result); }
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 FillCategories() { ItemIntValue none = new ItemIntValue(); none.ID = -1; none.Name = " - не вибрано - "; List <ItemIntValue> items0 = new List <ItemIntValue>(); WareCategoriesLogic categories = new WareCategoriesLogic(manager); items0.Clear(); //items0.Add(none); foreach (var a in categories.GetCategoriesHierarchy().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items0.Add(i); } CategoriesCB.DataSource = items0; CategoriesCB.ValueMember = "ID"; CategoriesCB.DisplayMember = "Name"; CategoriesCB.Update(); }
private void SaveBt_Click(object sender, EventArgs e) { WareCategoriesLogic cl = new WareCategoriesLogic(manager); int?parentCategoryId = null; if (CategoriesCB.SelectedValue != null & CategoriesCB.SelectedIndex > 0) { parentCategoryId = Convert.ToInt32(((ItemIntValue)CategoriesCB.SelectedItem).ID); } if (mode == "new") { if (openFileDialog1.CheckPathExists == true) { image = Helpers.ImageOperations.ConvertImageToByteArray(openFileDialog1.FileName); } cl.Create(NameTB.Text, parentCategoryId, image); } if (mode == "edit") { if (_image != null) { image = Helpers.ImageOperations.ImageToByteArray(_image); } else { image = null; } cl.Update(Convert.ToInt32(id), NameTB.Text, parentCategoryId, image); } manager.Save(); Fill(); this.Close(); }
/// <summary> /// /// </summary> /// <param name="category">батьківська категорія</param> private void FillCategoriesHierarchy(WareCategory category, string prefix) { if (items.Count == 0) { ItemIntValue none = new ItemIntValue(); none.Name = " - не вибрано -"; items.Add(none); } WareCategoriesLogic categoriesLogic = new WareCategoriesLogic(manager); List <WareCategory> categories = new List <WareCategory>(); if (category == null) { categories = categoriesLogic.GetAllRoot(); } else { categories = categoriesLogic.GetAll(category.ID); } foreach (WareCategory a in categories) { //TreeNode node = new TreeNode(; //node.Text = a.Name; //node. ItemIntValue item = new ItemIntValue(); item.ID = a.ID; item.Name = prefix + a.Name; items.Add(item); //CategoriesTV.Nodes.Add(a.ID.ToString(), a.Name); FillCategoriesHierarchy(a, prefix + @" "); } }
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 FillCategories() { ItemIntValue none = new ItemIntValue(); none.ID = -1; none.Name = " - не вибрано - "; List<ItemIntValue> items0 = new List<ItemIntValue>(); WareCategoriesLogic categories = new WareCategoriesLogic(manager); items0.Clear(); //items0.Add(none); foreach (var a in categories.GetCategoriesHierarchy().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items0.Add(i); } CategoriesCB.DataSource = items0; if ((mode == "new") & (defaultCategoryId != null)) { foreach (ItemIntValue i in CategoriesCB.Items) { if (i.ID == Convert.ToInt32(defaultCategoryId)) { CategoriesCB.SelectedItem = i; } } } CategoriesCB.ValueMember = "ID"; CategoriesCB.DisplayMember = "Name"; CategoriesCB.Update(); }
/// <summary> /// /// </summary> /// <param name="category">батьківська категорія</param> private void FillCategoriesHierarchy(WareCategory category, string prefix, bool start) { if (start == true) items.Clear(); WareCategoriesLogic categoriesLogic = new WareCategoriesLogic(manager); List<WareCategory> categories = new List<WareCategory>(); if (category == null) categories = categoriesLogic.GetAllRoot(); else categories = categoriesLogic.GetAll(category.ID); foreach (WareCategory a in categories) { ItemIntValue item = new ItemIntValue(); item.ID = a.ID; item.Name = prefix + a.Name; item.Image = a.Image; items.Add(item); FillCategoriesHierarchy(a, prefix + @" ", false); } }
//public string WareName //{ // get // { // string result = null; // if (NameTB.Text.Length > 0) // { // result = NameTB.Text; // } // return result; // } //} public void Fill() { ItemIntValue none = new ItemIntValue(); none.ID = -1; none.Name = " - не вибрано - "; List<ItemIntValue> items0 = new List<ItemIntValue>(); WareCategoriesLogic categories = new WareCategoriesLogic(manager); items0.Clear(); //items0.Add(none); foreach (var a in categories.GetCategoriesHierarchy().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items0.Add(i); } CategoriesCB.DataSource = items0; CategoriesCB.ValueMember = "ID"; CategoriesCB.DisplayMember = "Name"; CategoriesCB.Update(); WareManufacturersLogic manufacturers = new WareManufacturersLogic(manager); List<ItemIntValue> items1 = new List<ItemIntValue>(); items1.Clear(); items1.Add(none); foreach (var a in manufacturers.GetAll().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items1.Add(i); } //ManufacturersCB.DataSource = manufacturers.GetAll(); ManufacturersCB.DataSource = items1; ManufacturersCB.ValueMember = "ID"; ManufacturersCB.DisplayMember = "Name"; ManufacturersCB.Update(); WareUnitsLogic units = new WareUnitsLogic(manager); List<ItemIntValue> items2 = new List<ItemIntValue>(); items2.Clear(); items2.Add(none); foreach (var a in units.GetAll().OrderBy(a => a.Name)) { ItemIntValue i = new ItemIntValue(); i.ID = a.ID; i.Name = a.Name; items2.Add(i); } UnitsCB.DataSource = items2; UnitsCB.ValueMember = "ID"; UnitsCB.DisplayMember = "Name"; UnitsCB.Update(); }
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 SaveBt_Click(object sender, EventArgs e) { WareCategoriesLogic cl = new WareCategoriesLogic(manager); int? parentCategoryId = null; if (CategoriesCB.SelectedValue != null & CategoriesCB.SelectedIndex > 0) { parentCategoryId = Convert.ToInt32(((ItemIntValue)CategoriesCB.SelectedItem).ID); } if (mode == "new") { if (openFileDialog1.CheckPathExists == true) image = Helpers.ImageOperations.ConvertImageToByteArray(openFileDialog1.FileName); cl.Create(NameTB.Text, parentCategoryId, image); } if (mode == "edit") { if (_image != null) image = Helpers.ImageOperations.ImageToByteArray(_image); else image = null; cl.Update(Convert.ToInt32(id), NameTB.Text, parentCategoryId, image); } manager.Save(); Fill(); this.Close(); }
/// <summary> /// /// </summary> /// <param name="category">батьківська категорія</param> private void FillCategoriesHierarchy(WareCategory category, string prefix) { if (items.Count == 0) { ItemIntValue none = new ItemIntValue(); none.Name = " - не вибрано -"; items.Add(none); } WareCategoriesLogic categoriesLogic = new WareCategoriesLogic(manager); List<WareCategory> categories = new List<WareCategory>(); if(category == null) categories = categoriesLogic.GetAllRoot(); else categories = categoriesLogic.GetAll(category.ID); foreach (WareCategory a in categories) { //TreeNode node = new TreeNode(; //node.Text = a.Name; //node. ItemIntValue item = new ItemIntValue(); item.ID = a.ID; item.Name = prefix + a.Name; items.Add(item); //CategoriesTV.Nodes.Add(a.ID.ToString(), a.Name); FillCategoriesHierarchy(a, prefix+@" "); } }