Лабораторная 4(отредактированная теперь точно)
This commit is contained in:
parent
16d9bd2048
commit
ad9ce78231
@ -43,8 +43,11 @@ namespace ProjectSellPC.Forms.Receipt
|
||||
{
|
||||
try
|
||||
{
|
||||
// Получаем все чеки
|
||||
var cheques = _ChequeRepository.ReadAll();
|
||||
// Получаем все чеки и удаляем дубликаты по ID
|
||||
var cheques = _ChequeRepository.ReadAll()
|
||||
.GroupBy(c => c.Id)
|
||||
.Select(g => g.First())
|
||||
.ToList();
|
||||
|
||||
// Загружаем информацию о клиентах
|
||||
foreach (var cheque in cheques)
|
||||
@ -55,14 +58,7 @@ namespace ProjectSellPC.Forms.Receipt
|
||||
foreach (var productInCheque in cheque.Products)
|
||||
{
|
||||
var product = _productRepository.Read(productInCheque.ProductID);
|
||||
if (product != null)
|
||||
{
|
||||
productInCheque.ProductName = product.Name; // Добавляем название товара
|
||||
}
|
||||
else
|
||||
{
|
||||
productInCheque.ProductName = "Неизвестный товар";
|
||||
}
|
||||
productInCheque.ProductName = product?.Name ?? "Неизвестный товар";
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,7 +68,8 @@ namespace ProjectSellPC.Forms.Receipt
|
||||
Id = c.Id,
|
||||
ClientName = c.Client?.Name ?? "Неизвестно",
|
||||
PurchaseDate = c.PurchaseDate,
|
||||
Products = string.Join(", ", c.Products.Select(p => p.ProductName)) // Отображаем названия товаров
|
||||
Products = string.Join(", ", c.Products.Select(p => p.ProductName)), // Названия товаров через запятую
|
||||
Quantities = string.Join(", ", c.Products.Select(p => p.Count.ToString())) // Количество товаров через запятую
|
||||
}).ToList();
|
||||
|
||||
// Настройка столбцов DataGridView
|
||||
@ -80,6 +77,7 @@ namespace ProjectSellPC.Forms.Receipt
|
||||
ChequesDataGridView.Columns["ClientName"].HeaderText = "Клиент";
|
||||
ChequesDataGridView.Columns["PurchaseDate"].HeaderText = "Дата покупки";
|
||||
ChequesDataGridView.Columns["Products"].HeaderText = "Товары";
|
||||
ChequesDataGridView.Columns["Quantities"].HeaderText = "Количество";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -30,7 +30,6 @@
|
||||
{
|
||||
addButton = new Button();
|
||||
productsDataGridView = new DataGridView();
|
||||
editButton = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)productsDataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -54,14 +53,12 @@
|
||||
productsDataGridView.RowHeadersWidth = 51;
|
||||
productsDataGridView.Size = new Size(851, 400);
|
||||
productsDataGridView.TabIndex = 8;
|
||||
|
||||
//
|
||||
// ProductsOnWarehouseForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1064, 450);
|
||||
Controls.Add(editButton);
|
||||
Controls.Add(addButton);
|
||||
Controls.Add(productsDataGridView);
|
||||
Name = "ProductsOnWarehouseForm";
|
||||
@ -76,6 +73,5 @@
|
||||
|
||||
private Button addButton;
|
||||
private DataGridView productsDataGridView;
|
||||
private Button editButton;
|
||||
}
|
||||
}
|
@ -82,7 +82,7 @@ namespace ProjectSellPC.Forms.ProductsOnWarehouse
|
||||
|
||||
WarehouseCombobox.DataSource = _WarehouseRepository.ReadAll().ToList();
|
||||
WarehouseCombobox.DisplayMember = "Adress";
|
||||
WarehouseCombobox.ValueMember = "Id";
|
||||
//WarehouseCombobox.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void saveButton_Click(object sender, EventArgs e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user