Итог
This commit is contained in:
parent
4896424633
commit
5fc338cc39
@ -13,12 +13,12 @@ public class Receipt
|
|||||||
//public int ProductId { get; private set; }
|
//public int ProductId { get; private set; }
|
||||||
//public int StorageProductId { get; private set; }
|
//public int StorageProductId { get; private set; }
|
||||||
//public int ReceiptNumber {get; private set; }
|
//public int ReceiptNumber {get; private set; }
|
||||||
public int 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, int productType, int numberOfPairsReceived)
|
public static Receipt CreateOperation(int id, ProductType productType, int numberOfPairsReceived)
|
||||||
{
|
{
|
||||||
return new Receipt
|
return new Receipt
|
||||||
{
|
{
|
||||||
|
42
ShoeStore/Forms/FormReceipt.Designer.cs
generated
42
ShoeStore/Forms/FormReceipt.Designer.cs
generated
@ -33,7 +33,9 @@
|
|||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
label = new Label();
|
label = new Label();
|
||||||
comboBox1 = new ComboBox();
|
comboBoxProdctType = new ComboBox();
|
||||||
|
label1 = new Label();
|
||||||
|
dateTimePickerDate = new DateTimePicker();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownNumOfPairs).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownNumOfPairs).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -76,26 +78,44 @@
|
|||||||
// label
|
// label
|
||||||
//
|
//
|
||||||
label.AutoSize = true;
|
label.AutoSize = true;
|
||||||
label.Location = new Point(27, 69);
|
label.Location = new Point(27, 96);
|
||||||
label.Name = "label";
|
label.Name = "label";
|
||||||
label.Size = new Size(70, 15);
|
label.Size = new Size(70, 15);
|
||||||
label.TabIndex = 19;
|
label.TabIndex = 19;
|
||||||
label.Text = "Тип товара:";
|
label.Text = "Тип товара:";
|
||||||
//
|
//
|
||||||
// comboBox1
|
// comboBoxProdctType
|
||||||
//
|
//
|
||||||
comboBox1.FormattingEnabled = true;
|
comboBoxProdctType.FormattingEnabled = true;
|
||||||
comboBox1.Location = new Point(246, 69);
|
comboBoxProdctType.Location = new Point(246, 96);
|
||||||
comboBox1.Name = "comboBox1";
|
comboBoxProdctType.Name = "comboBoxProdctType";
|
||||||
comboBox1.Size = new Size(121, 23);
|
comboBoxProdctType.Size = new Size(121, 23);
|
||||||
comboBox1.TabIndex = 20;
|
comboBoxProdctType.TabIndex = 20;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(27, 36);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(35, 15);
|
||||||
|
label1.TabIndex = 22;
|
||||||
|
label1.Text = "Дата:";
|
||||||
|
//
|
||||||
|
// dateTimePickerDate
|
||||||
|
//
|
||||||
|
dateTimePickerDate.Location = new Point(246, 36);
|
||||||
|
dateTimePickerDate.Name = "dateTimePickerDate";
|
||||||
|
dateTimePickerDate.Size = new Size(132, 23);
|
||||||
|
dateTimePickerDate.TabIndex = 21;
|
||||||
//
|
//
|
||||||
// FormReceipt
|
// FormReceipt
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(398, 330);
|
ClientSize = new Size(398, 330);
|
||||||
Controls.Add(comboBox1);
|
Controls.Add(label1);
|
||||||
|
Controls.Add(dateTimePickerDate);
|
||||||
|
Controls.Add(comboBoxProdctType);
|
||||||
Controls.Add(label);
|
Controls.Add(label);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
@ -114,6 +134,8 @@
|
|||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private Label label;
|
private Label label;
|
||||||
private ComboBox comboBox1;
|
private ComboBox comboBoxProdctType;
|
||||||
|
private Label label1;
|
||||||
|
private DateTimePicker dateTimePickerDate;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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;
|
||||||
@ -24,21 +25,36 @@ namespace ShoeStore.Froms
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_receiptRepository = receiptRepository ?? throw new ArgumentNullException(nameof(receiptRepository));
|
_receiptRepository = receiptRepository ?? throw new ArgumentNullException(nameof(receiptRepository));
|
||||||
|
|
||||||
|
foreach (var elem in Enum.GetValues(typeof(ProductType)))
|
||||||
|
{
|
||||||
|
comboBoxProdctType.Items.Add(elem);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonSave_Click(object sender, EventArgs e)
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
ProductType productType = ProductType.None;
|
||||||
|
if (comboBoxProdctType.SelectedItem != null)
|
||||||
|
{
|
||||||
|
productType = (ProductType)Enum.Parse(typeof(ProductType), comboBoxProdctType.SelectedItem.ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Не выбран тип продукта");
|
||||||
|
}
|
||||||
if (numericUpDownNumOfPairs.Value < 0)
|
if (numericUpDownNumOfPairs.Value < 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
_receiptRepository.CreateReceipt(Receipt.CreateOperation(
|
_receiptRepository.CreateReceipt(Receipt.CreateOperation(
|
||||||
0,
|
0,
|
||||||
(int)comboBox1.SelectedValue!,
|
productType,
|
||||||
Convert.ToInt32(numericUpDownNumOfPairs.Value)));
|
Convert.ToInt32(numericUpDownNumOfPairs.Value)));
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,7 @@ public partial class FormSale : Form
|
|||||||
ColumnProduct.DataSource = productRepository.ReadProducts();
|
ColumnProduct.DataSource = productRepository.ReadProducts();
|
||||||
ColumnProduct.DisplayMember = "NameOfShoes";
|
ColumnProduct.DisplayMember = "NameOfShoes";
|
||||||
ColumnProduct.ValueMember = "Id";
|
ColumnProduct.ValueMember = "Id";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSave_Click_1(object sender, EventArgs e)
|
private void ButtonSave_Click_1(object sender, EventArgs e)
|
||||||
|
@ -33,8 +33,8 @@ public class ReceiptRepository : IReceiptRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryInsert = @"INSERT INTO Receipts (ProductType, NumberOfPairsReceived, Date)
|
var queryInsert = @"INSERT INTO Receipts (ProductType, NumberOfPairsReceived, DateOfReceipt)
|
||||||
VALUES (@ProductType, @NumberOfPairsReceived, @Date)";
|
VALUES (@ProductType, @NumberOfPairsReceived, @DateOfReceipt)";
|
||||||
connection.Execute(queryInsert, receipt);
|
connection.Execute(queryInsert, receipt);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -35,8 +35,8 @@ public class SaleRepository : ISaleRepository
|
|||||||
connection.Open();
|
connection.Open();
|
||||||
using var transaction = connection.BeginTransaction();
|
using var transaction = connection.BeginTransaction();
|
||||||
var queryInsert = @"
|
var queryInsert = @"
|
||||||
INSERT INTO Sales (SalesNumber, Date)
|
INSERT INTO Sales (SalesNumber, DateOfSale)
|
||||||
VALUES (@SalesNumber, @Date);
|
VALUES (@SalesNumber, @DateOfSale);
|
||||||
SELECT MAX(Id) FROM Sales";
|
SELECT MAX(Id) FROM Sales";
|
||||||
var visitingId = connection.QueryFirst<int>(queryInsert, sale, transaction);
|
var visitingId = connection.QueryFirst<int>(queryInsert, sale, transaction);
|
||||||
var querySubInsert = @"
|
var querySubInsert = @"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user