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