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