This commit is contained in:
Glliza 2024-12-21 21:15:47 +04:00
parent 5fc338cc39
commit dc2a6f8486
10 changed files with 51 additions and 36 deletions

View File

@ -13,12 +13,12 @@ public class Employee
public int NumberStorage { get; private set; }
public int StorageSize { get; private set; }
public static Employee CreateEntity(int id, int numberStorage, int storageSize)
public static Employee CreateEntity(int id, DateTime date,int numberStorage, int storageSize)
{
return new Employee
{
Id = id,
Date = DateTime.Now,
Date = date,
NumberStorage = numberStorage,
StorageSize = storageSize
};

View File

@ -10,14 +10,14 @@ public class ProductSale
{
public int ProductId { get; private set; }
public int SaleId { get; private set; }
public int Amount { get; private set; }
public int SalesNumber { get; private set; }
public static ProductSale CreateEntities(int productId, int saleId, int amount)
public static ProductSale CreateOperation(int productId, int saleId, int salesNumber)
{
return new ProductSale {
ProductId = productId,
SaleId = saleId,
Amount = amount
SalesNumber = salesNumber
};
}
}

View File

@ -10,25 +10,19 @@ namespace ShoeStore.Entities;
public class Receipt
{
public int Id { get; private set; }
//public int ProductId { get; private set; }
//public int StorageProductId { get; private set; }
//public int ReceiptNumber {get; private set; }
public ProductType ProductType { get; private set; }
public DateTime DateOfReceipt { get; private set; }
public int NumberOfPairsReceived { get; private set; }
//public int StorageSize { get; private set; }
public static Receipt CreateOperation(int id, ProductType productType, int numberOfPairsReceived)
public static Receipt CreateOperation(int id,ProductType productType, DateTime date,int numberOfPairsReceived)
{
return new Receipt
{
Id = id,
ProductType = productType,
//StorageProductId = storageProductId,
//ReceiptNumber = receiptNumber,
DateOfReceipt = DateTime.Now,
DateOfReceipt = date,
NumberOfPairsReceived = numberOfPairsReceived,
//StorageSize = storageSize
};
}

View File

@ -19,14 +19,14 @@ public class Sale
private set;
} = [];
public static Sale CreateOperation (int id, int salesNumber)
public static Sale CreateOperation(int id, int salesNumber, DateTime date, IEnumerable<ProductSale> product)
{
return new Sale
{
Id = id,
DateOfSale = DateTime.Now,
DateOfSale = date,
SalesNumber = salesNumber,
//StorageSize = storageSize
Product = product
};
}

View File

@ -17,6 +17,7 @@ public partial class FormEmployee : Form
{
private readonly IEmployeeRepository _employeeRepository;
private int? _employeeId;
private DateTime _originalDate;
public int Id
{
@ -31,6 +32,7 @@ public partial class FormEmployee : Form
}
numericUpDownNumStorage.Value = employee.NumberStorage;
numericUpDownStorageSize.Value = (decimal)employee.StorageSize;
dateTimePickerDate.Value = employee.Date;
_employeeId = value;
}
catch (Exception ex)
@ -77,6 +79,6 @@ public partial class FormEmployee : Form
private void ButtonCancel_Click_1(object sender, EventArgs e) => Close();
private Employee CreateEmployee(int id) => Employee.CreateEntity(id, Convert.ToInt32(numericUpDownNumStorage.Value),
private Employee CreateEmployee(int id) => Employee.CreateEntity(id, dateTimePickerDate.Value,Convert.ToInt32(numericUpDownNumStorage.Value),
Convert.ToInt32(numericUpDownStorageSize.Value));
}

View File

@ -51,7 +51,8 @@ namespace ShoeStore.Froms
}
_receiptRepository.CreateReceipt(Receipt.CreateOperation(
0,
productType,
productType,
dateTimePickerDate.Value,
Convert.ToInt32(numericUpDownNumOfPairs.Value)));
Close();

View File

@ -33,14 +33,14 @@
buttonSave = new Button();
buttonCancel = new Button();
panel1 = new Panel();
dataGridView1 = new DataGridView();
dataGridViewSale = new DataGridView();
ColumnProduct = new DataGridViewComboBoxColumn();
ColumnAmount = new DataGridViewTextBoxColumn();
label1 = new Label();
dateTimePickerDate = new DateTimePicker();
((System.ComponentModel.ISupportInitialize)numericUpDownStorageSize).BeginInit();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
((System.ComponentModel.ISupportInitialize)dataGridViewSale).BeginInit();
SuspendLayout();
//
// label5
@ -81,21 +81,21 @@
//
// panel1
//
panel1.Controls.Add(dataGridView1);
panel1.Controls.Add(dataGridViewSale);
panel1.Location = new Point(38, 200);
panel1.Name = "panel1";
panel1.Size = new Size(289, 249);
panel1.TabIndex = 14;
//
// dataGridView1
// dataGridViewSale
//
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Columns.AddRange(new DataGridViewColumn[] { ColumnProduct, ColumnAmount });
dataGridView1.Dock = DockStyle.Fill;
dataGridView1.Location = new Point(0, 0);
dataGridView1.Name = "dataGridView1";
dataGridView1.Size = new Size(289, 249);
dataGridView1.TabIndex = 13;
dataGridViewSale.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewSale.Columns.AddRange(new DataGridViewColumn[] { ColumnProduct, ColumnAmount });
dataGridViewSale.Dock = DockStyle.Fill;
dataGridViewSale.Location = new Point(0, 0);
dataGridViewSale.Name = "dataGridViewSale";
dataGridViewSale.Size = new Size(289, 249);
dataGridViewSale.TabIndex = 13;
//
// ColumnProduct
//
@ -139,7 +139,7 @@
Text = "FormSale";
((System.ComponentModel.ISupportInitialize)numericUpDownStorageSize).EndInit();
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
((System.ComponentModel.ISupportInitialize)dataGridViewSale).EndInit();
ResumeLayout(false);
PerformLayout();
}
@ -150,7 +150,7 @@
private Button buttonSave;
private Button buttonCancel;
private Panel panel1;
private DataGridView dataGridView1;
private DataGridView dataGridViewSale;
private DataGridViewComboBoxColumn ColumnProduct;
private DataGridViewTextBoxColumn ColumnAmount;
private Label label1;

View File

@ -1,4 +1,5 @@
using ShoeStore.Entities;
using ShoeStore.Entities.Enums;
using ShoeStore.Repositories;
using ShoeStore.Repositories.Implementations;
using System;
@ -10,6 +11,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ShoeStore.Froms;
@ -37,10 +39,10 @@ public partial class FormSale : Form
throw new Exception("Имеются незаполненные поля");
}
_saleRepository.CreateSale(Sale.CreateOperation(0, Convert.ToInt32(numericUpDownStorageSize.Value), dateTimePickerDate.Value, CreateListProductSaleFromDataGrid()));
MessageBox.Show("Данные успешно добавлены!", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
_saleRepository.CreateSale(Sale.CreateOperation(0, Convert.ToInt32(numericUpDownStorageSize.Value)));
Close();
}
catch (Exception ex)
@ -52,4 +54,20 @@ public partial class FormSale : Form
private void ButtonCancel_Click_1(object sender, EventArgs e) => Close();
private List<ProductSale> CreateListProductSaleFromDataGrid()
{
var list = new List<ProductSale>();
foreach (DataGridViewRow row in dataGridViewSale.Rows)
{
if (row.Cells["ColumnProduct"].Value == null ||
row.Cells["ColumnAmount"].Value == null)
{
continue;
}
list.Add(ProductSale.CreateOperation(Convert.ToInt32(row.Cells["ColumnProduct"].Value), 0,
Convert.ToInt32(row.Cells["ColumnAmount"].Value)));
}
return list;
}
}

View File

@ -50,7 +50,7 @@ public class ProductRepository : IProductRepository
{
ProductID,
elem.SaleId,
elem.Amount
elem.SalesNumber
}, transaction);
}
transaction.Commit();

View File

@ -48,7 +48,7 @@ public class SaleRepository : ISaleRepository
{
elem.ProductId,
elem.SaleId,
elem.Amount
elem.SalesNumber
}, transaction);
}
transaction.Commit();