Итог
This commit is contained in:
parent
5fc338cc39
commit
dc2a6f8486
@ -13,12 +13,12 @@ public class Employee
|
|||||||
public int NumberStorage { get; private set; }
|
public int NumberStorage { get; private set; }
|
||||||
public int StorageSize { 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
|
return new Employee
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
Date = DateTime.Now,
|
Date = date,
|
||||||
NumberStorage = numberStorage,
|
NumberStorage = numberStorage,
|
||||||
StorageSize = storageSize
|
StorageSize = storageSize
|
||||||
};
|
};
|
||||||
|
@ -10,14 +10,14 @@ public class ProductSale
|
|||||||
{
|
{
|
||||||
public int ProductId { get; private set; }
|
public int ProductId { get; private set; }
|
||||||
public int SaleId { 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 {
|
return new ProductSale {
|
||||||
ProductId = productId,
|
ProductId = productId,
|
||||||
SaleId = saleId,
|
SaleId = saleId,
|
||||||
Amount = amount
|
SalesNumber = salesNumber
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,25 +10,19 @@ namespace ShoeStore.Entities;
|
|||||||
public class Receipt
|
public class Receipt
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
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 ProductType ProductType { get; private set; }
|
||||||
public DateTime DateOfReceipt { get; private set; }
|
public DateTime DateOfReceipt { get; private set; }
|
||||||
public int NumberOfPairsReceived { get; private set; }
|
public int NumberOfPairsReceived { get; private set; }
|
||||||
//public int StorageSize { 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
|
return new Receipt
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
ProductType = productType,
|
ProductType = productType,
|
||||||
//StorageProductId = storageProductId,
|
DateOfReceipt = date,
|
||||||
//ReceiptNumber = receiptNumber,
|
|
||||||
DateOfReceipt = DateTime.Now,
|
|
||||||
NumberOfPairsReceived = numberOfPairsReceived,
|
NumberOfPairsReceived = numberOfPairsReceived,
|
||||||
//StorageSize = storageSize
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,14 +19,14 @@ public class Sale
|
|||||||
private set;
|
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
|
return new Sale
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
DateOfSale = DateTime.Now,
|
DateOfSale = date,
|
||||||
SalesNumber = salesNumber,
|
SalesNumber = salesNumber,
|
||||||
//StorageSize = storageSize
|
Product = product
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ public partial class FormEmployee : Form
|
|||||||
{
|
{
|
||||||
private readonly IEmployeeRepository _employeeRepository;
|
private readonly IEmployeeRepository _employeeRepository;
|
||||||
private int? _employeeId;
|
private int? _employeeId;
|
||||||
|
private DateTime _originalDate;
|
||||||
|
|
||||||
public int Id
|
public int Id
|
||||||
{
|
{
|
||||||
@ -31,6 +32,7 @@ public partial class FormEmployee : Form
|
|||||||
}
|
}
|
||||||
numericUpDownNumStorage.Value = employee.NumberStorage;
|
numericUpDownNumStorage.Value = employee.NumberStorage;
|
||||||
numericUpDownStorageSize.Value = (decimal)employee.StorageSize;
|
numericUpDownStorageSize.Value = (decimal)employee.StorageSize;
|
||||||
|
dateTimePickerDate.Value = employee.Date;
|
||||||
_employeeId = value;
|
_employeeId = value;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -77,6 +79,6 @@ public partial class FormEmployee : Form
|
|||||||
|
|
||||||
private void ButtonCancel_Click_1(object sender, EventArgs e) => Close();
|
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));
|
Convert.ToInt32(numericUpDownStorageSize.Value));
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,7 @@ namespace ShoeStore.Froms
|
|||||||
_receiptRepository.CreateReceipt(Receipt.CreateOperation(
|
_receiptRepository.CreateReceipt(Receipt.CreateOperation(
|
||||||
0,
|
0,
|
||||||
productType,
|
productType,
|
||||||
|
dateTimePickerDate.Value,
|
||||||
Convert.ToInt32(numericUpDownNumOfPairs.Value)));
|
Convert.ToInt32(numericUpDownNumOfPairs.Value)));
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
|
26
ShoeStore/Forms/FormSale.Designer.cs
generated
26
ShoeStore/Forms/FormSale.Designer.cs
generated
@ -33,14 +33,14 @@
|
|||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
panel1 = new Panel();
|
panel1 = new Panel();
|
||||||
dataGridView1 = new DataGridView();
|
dataGridViewSale = new DataGridView();
|
||||||
ColumnProduct = new DataGridViewComboBoxColumn();
|
ColumnProduct = new DataGridViewComboBoxColumn();
|
||||||
ColumnAmount = new DataGridViewTextBoxColumn();
|
ColumnAmount = new DataGridViewTextBoxColumn();
|
||||||
label1 = new Label();
|
label1 = new Label();
|
||||||
dateTimePickerDate = new DateTimePicker();
|
dateTimePickerDate = new DateTimePicker();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownStorageSize).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownStorageSize).BeginInit();
|
||||||
panel1.SuspendLayout();
|
panel1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewSale).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// label5
|
// label5
|
||||||
@ -81,21 +81,21 @@
|
|||||||
//
|
//
|
||||||
// panel1
|
// panel1
|
||||||
//
|
//
|
||||||
panel1.Controls.Add(dataGridView1);
|
panel1.Controls.Add(dataGridViewSale);
|
||||||
panel1.Location = new Point(38, 200);
|
panel1.Location = new Point(38, 200);
|
||||||
panel1.Name = "panel1";
|
panel1.Name = "panel1";
|
||||||
panel1.Size = new Size(289, 249);
|
panel1.Size = new Size(289, 249);
|
||||||
panel1.TabIndex = 14;
|
panel1.TabIndex = 14;
|
||||||
//
|
//
|
||||||
// dataGridView1
|
// dataGridViewSale
|
||||||
//
|
//
|
||||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridViewSale.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView1.Columns.AddRange(new DataGridViewColumn[] { ColumnProduct, ColumnAmount });
|
dataGridViewSale.Columns.AddRange(new DataGridViewColumn[] { ColumnProduct, ColumnAmount });
|
||||||
dataGridView1.Dock = DockStyle.Fill;
|
dataGridViewSale.Dock = DockStyle.Fill;
|
||||||
dataGridView1.Location = new Point(0, 0);
|
dataGridViewSale.Location = new Point(0, 0);
|
||||||
dataGridView1.Name = "dataGridView1";
|
dataGridViewSale.Name = "dataGridViewSale";
|
||||||
dataGridView1.Size = new Size(289, 249);
|
dataGridViewSale.Size = new Size(289, 249);
|
||||||
dataGridView1.TabIndex = 13;
|
dataGridViewSale.TabIndex = 13;
|
||||||
//
|
//
|
||||||
// ColumnProduct
|
// ColumnProduct
|
||||||
//
|
//
|
||||||
@ -139,7 +139,7 @@
|
|||||||
Text = "FormSale";
|
Text = "FormSale";
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownStorageSize).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownStorageSize).EndInit();
|
||||||
panel1.ResumeLayout(false);
|
panel1.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewSale).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@
|
|||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Panel panel1;
|
private Panel panel1;
|
||||||
private DataGridView dataGridView1;
|
private DataGridView dataGridViewSale;
|
||||||
private DataGridViewComboBoxColumn ColumnProduct;
|
private DataGridViewComboBoxColumn ColumnProduct;
|
||||||
private DataGridViewTextBoxColumn ColumnAmount;
|
private DataGridViewTextBoxColumn ColumnAmount;
|
||||||
private Label label1;
|
private Label label1;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using ShoeStore.Entities;
|
using ShoeStore.Entities;
|
||||||
|
using ShoeStore.Entities.Enums;
|
||||||
using ShoeStore.Repositories;
|
using ShoeStore.Repositories;
|
||||||
using ShoeStore.Repositories.Implementations;
|
using ShoeStore.Repositories.Implementations;
|
||||||
using System;
|
using System;
|
||||||
@ -10,6 +11,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
namespace ShoeStore.Froms;
|
namespace ShoeStore.Froms;
|
||||||
|
|
||||||
@ -37,10 +39,10 @@ public partial class FormSale : Form
|
|||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_saleRepository.CreateSale(Sale.CreateOperation(0, Convert.ToInt32(numericUpDownStorageSize.Value), dateTimePickerDate.Value, CreateListProductSaleFromDataGrid()));
|
||||||
|
|
||||||
MessageBox.Show("Данные успешно добавлены!", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("Данные успешно добавлены!", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
|
||||||
_saleRepository.CreateSale(Sale.CreateOperation(0, Convert.ToInt32(numericUpDownStorageSize.Value)));
|
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -52,4 +54,20 @@ public partial class FormSale : Form
|
|||||||
|
|
||||||
private void ButtonCancel_Click_1(object sender, EventArgs e) => Close();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -50,7 +50,7 @@ public class ProductRepository : IProductRepository
|
|||||||
{
|
{
|
||||||
ProductID,
|
ProductID,
|
||||||
elem.SaleId,
|
elem.SaleId,
|
||||||
elem.Amount
|
elem.SalesNumber
|
||||||
}, transaction);
|
}, transaction);
|
||||||
}
|
}
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
|
@ -48,7 +48,7 @@ public class SaleRepository : ISaleRepository
|
|||||||
{
|
{
|
||||||
elem.ProductId,
|
elem.ProductId,
|
||||||
elem.SaleId,
|
elem.SaleId,
|
||||||
elem.Amount
|
elem.SalesNumber
|
||||||
}, transaction);
|
}, transaction);
|
||||||
}
|
}
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user