Лабораторная работа 2 (доработаны формы)
This commit is contained in:
parent
a5a1099be9
commit
b0e19ce372
@ -21,7 +21,7 @@ namespace ProjectConfectioneryFactory.Forms
|
||||
{
|
||||
throw new InvalidDataException(nameof(order));
|
||||
}
|
||||
checkBoxCompleted.Enabled = order.Completed;
|
||||
checkBoxCompleted.Checked = order.Completed;
|
||||
_orderId = value;
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
|
||||
@ -33,7 +33,7 @@ namespace ProjectConfectioneryFactory.Forms
|
||||
InitializeComponent();
|
||||
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
||||
comboBoxClient.DataSource = clientRepository.ReadClients();
|
||||
comboBoxClient.DisplayMember = "FirstName";
|
||||
comboBoxClient.DisplayMember = "Phone";
|
||||
comboBoxClient.ValueMember = "Id";
|
||||
|
||||
ColumnProductName.DataSource = productRepository.ReadProducts();
|
||||
@ -45,7 +45,7 @@ namespace ProjectConfectioneryFactory.Forms
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dataGridViewProducts.RowCount < 1 || comboBoxClient.SelectedIndex < 0)
|
||||
if (dataGridViewProducts.RowCount <= 1 || comboBoxClient.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
@ -74,14 +74,14 @@ namespace ProjectConfectioneryFactory.Forms
|
||||
var list = new List<OrderProduct>();
|
||||
foreach (DataGridViewRow row in dataGridViewProducts.Rows)
|
||||
{
|
||||
if (row.Cells["ColumnComponent"].Value == null ||
|
||||
row.Cells["ColumnWeight"].Value == null)
|
||||
if (row.Cells["ColumnProductName"].Value == null ||
|
||||
row.Cells["ColumnProductCount"].Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list.Add(OrderProduct.CreateEntity(0,
|
||||
Convert.ToInt32(row.Cells["ColumnComponent"].Value),
|
||||
Convert.ToInt32(row.Cells["ColumnWeight"].Value)));
|
||||
Convert.ToInt32(row.Cells["ColumnProductName"].Value),
|
||||
Convert.ToInt32(row.Cells["ColumnProductCount"].Value)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
using ProjectConfectioneryFactory.Entities;
|
||||
using ProjectConfectioneryFactory.Entities;
|
||||
using ProjectConfectioneryFactory.Entities.Enums;
|
||||
using ProjectConfectioneryFactory.Repositories;
|
||||
using ProjectConfectioneryFactory.Repositories.Implementations;
|
||||
|
||||
namespace ProjectConfectioneryFactory.Forms
|
||||
{
|
||||
@ -61,7 +59,7 @@ namespace ProjectConfectioneryFactory.Forms
|
||||
{
|
||||
try
|
||||
{
|
||||
if (checkedListBoxConfectioneryType.CheckedItems.Count == 0 || string.IsNullOrWhiteSpace(textBoxProductName.Text) || dataGridViewComponents.RowCount < 1)
|
||||
if (checkedListBoxConfectioneryType.CheckedItems.Count == 0 || string.IsNullOrWhiteSpace(textBoxProductName.Text) || dataGridViewComponents.RowCount <= 1)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace ProjectConfectioneryFactory.Forms
|
||||
throw new InvalidDataException(nameof(supply));
|
||||
}
|
||||
numericUpDownWeight.Value = (decimal)supply.Weight;
|
||||
checkBoxCompleted.Enabled = supply.Completed;
|
||||
checkBoxCompleted.Checked = supply.Completed;
|
||||
_supplyId = value;
|
||||
}
|
||||
catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
|
||||
@ -32,11 +32,13 @@ namespace ProjectConfectioneryFactory.Forms
|
||||
{
|
||||
InitializeComponent();
|
||||
_supplyRepository = supplyRepository ?? throw new ArgumentNullException(nameof(supplyRepository));
|
||||
|
||||
comboBoxSupplier.DataSource = supplierRepository.ReadSuppliers();
|
||||
comboBoxSupplier.DisplayMember = "Name";
|
||||
comboBoxSupplier.ValueMember = "Id";
|
||||
|
||||
comboBoxComponent.DataSource = componentRepository.ReadComponents();
|
||||
comboBoxComponent.DisplayMember = "ComponentName";
|
||||
comboBoxComponent.DisplayMember = "Name";
|
||||
comboBoxComponent.ValueMember = "Id";
|
||||
}
|
||||
|
||||
@ -44,7 +46,7 @@ namespace ProjectConfectioneryFactory.Forms
|
||||
{
|
||||
try
|
||||
{
|
||||
if (comboBoxSupplier.SelectedIndex < 0 || comboBoxComponent.SelectedIndex < 0 || !checkBoxCompleted.Checked)
|
||||
if (comboBoxSupplier.SelectedIndex < 0 || comboBoxComponent.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class ProductRepository : IProductRepository
|
||||
var queryUpdate = @"
|
||||
UPDATE Products
|
||||
SET
|
||||
сonfectioneryType=@сonfectioneryType,
|
||||
ConfectioneryType=@ConfectioneryType,
|
||||
Name=@Name,
|
||||
Price=@Price
|
||||
WHERE Id=@Id";
|
||||
@ -117,7 +117,7 @@ public class ProductRepository : IProductRepository
|
||||
var querySelect = @"
|
||||
SELECT *
|
||||
FROM Products
|
||||
WHERE Id=@id";
|
||||
WHERE Id=@Id";
|
||||
var product = connection.QueryFirst<Product>(querySelect, new { id });
|
||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(product));
|
||||
return product;
|
||||
@ -135,7 +135,7 @@ public class ProductRepository : IProductRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Products";
|
||||
var querySelect = @"SELECT * FROM Products";
|
||||
var products = connection.Query<Product>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(products));
|
||||
return products;
|
||||
|
Loading…
x
Reference in New Issue
Block a user