ф
This commit is contained in:
parent
ac8ab62ae9
commit
0689ebe5b9
@ -9,7 +9,7 @@ namespace ShoeStore.Entities;
|
|||||||
public class ShoesReplenishment
|
public class ShoesReplenishment
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public int FactoryId { get; private set; }
|
public int FactorysId { get; private set; }
|
||||||
public DateTime DateReceipt { get; private set; }
|
public DateTime DateReceipt { get; private set; }
|
||||||
public IEnumerable<ShoesShoesReplenishment> ShoesShoesReplenishments
|
public IEnumerable<ShoesShoesReplenishment> ShoesShoesReplenishments
|
||||||
{
|
{
|
||||||
@ -22,7 +22,7 @@ public class ShoesReplenishment
|
|||||||
return new ShoesReplenishment
|
return new ShoesReplenishment
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
FactoryId = factoryId,
|
FactorysId = factoryId,
|
||||||
DateReceipt = DateTime.Now,
|
DateReceipt = DateTime.Now,
|
||||||
ShoesShoesReplenishments = shoesShoesReplenishments
|
ShoesShoesReplenishments = shoesShoesReplenishments
|
||||||
};
|
};
|
||||||
|
@ -9,17 +9,15 @@ namespace ShoeStore.Entities;
|
|||||||
public class Store
|
public class Store
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public string StoreType { get; private set; } = string.Empty;
|
|
||||||
public string StoreName { get; private set; } = string.Empty;
|
public string StoreName { get; private set; } = string.Empty;
|
||||||
public int Employees { get; private set; }
|
public int Employees { get; private set; }
|
||||||
public double Visitors { get; private set; }
|
public double Visitors { get; private set; }
|
||||||
public static Store CreateEntity(int id, string storeType, string
|
public static Store CreateEntity(int id, string
|
||||||
storeName, int employees, double visitors)
|
storeName, int employees, double visitors)
|
||||||
{
|
{
|
||||||
return new Store
|
return new Store
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
StoreType = storeType ?? string.Empty,
|
|
||||||
StoreName = storeName ?? string.Empty,
|
StoreName = storeName ?? string.Empty,
|
||||||
Employees = employees,
|
Employees = employees,
|
||||||
Visitors = visitors
|
Visitors = visitors
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
ButtonDel.Size = new Size(85, 78);
|
ButtonDel.Size = new Size(85, 78);
|
||||||
ButtonDel.TabIndex = 2;
|
ButtonDel.TabIndex = 2;
|
||||||
ButtonDel.UseVisualStyleBackColor = true;
|
ButtonDel.UseVisualStyleBackColor = true;
|
||||||
|
ButtonDel.Click += ButtonDel_Click;
|
||||||
//
|
//
|
||||||
// ButtonUpd
|
// ButtonUpd
|
||||||
//
|
//
|
||||||
@ -67,6 +68,7 @@
|
|||||||
ButtonUpd.Size = new Size(85, 77);
|
ButtonUpd.Size = new Size(85, 77);
|
||||||
ButtonUpd.TabIndex = 1;
|
ButtonUpd.TabIndex = 1;
|
||||||
ButtonUpd.UseVisualStyleBackColor = true;
|
ButtonUpd.UseVisualStyleBackColor = true;
|
||||||
|
ButtonUpd.Click += ButtonUpd_Click;
|
||||||
//
|
//
|
||||||
// ButtonAdd
|
// ButtonAdd
|
||||||
//
|
//
|
||||||
|
@ -32,10 +32,10 @@
|
|||||||
comboBoxFactory = new ComboBox();
|
comboBoxFactory = new ComboBox();
|
||||||
groupBox1 = new GroupBox();
|
groupBox1 = new GroupBox();
|
||||||
dataGridViewShoess = new DataGridView();
|
dataGridViewShoess = new DataGridView();
|
||||||
ColumnShoes = new DataGridViewComboBoxColumn();
|
|
||||||
Column2 = new DataGridViewTextBoxColumn();
|
|
||||||
ButtonSave = new Button();
|
ButtonSave = new Button();
|
||||||
ButtonCancel = new Button();
|
ButtonCancel = new Button();
|
||||||
|
ColumnShoes = new DataGridViewComboBoxColumn();
|
||||||
|
ColumnCount = new DataGridViewTextBoxColumn();
|
||||||
groupBox1.SuspendLayout();
|
groupBox1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewShoess).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewShoess).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -74,7 +74,7 @@
|
|||||||
dataGridViewShoess.AllowUserToResizeColumns = false;
|
dataGridViewShoess.AllowUserToResizeColumns = false;
|
||||||
dataGridViewShoess.AllowUserToResizeRows = false;
|
dataGridViewShoess.AllowUserToResizeRows = false;
|
||||||
dataGridViewShoess.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridViewShoess.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridViewShoess.Columns.AddRange(new DataGridViewColumn[] { ColumnShoes, Column2 });
|
dataGridViewShoess.Columns.AddRange(new DataGridViewColumn[] { ColumnShoes, ColumnCount });
|
||||||
dataGridViewShoess.Dock = DockStyle.Fill;
|
dataGridViewShoess.Dock = DockStyle.Fill;
|
||||||
dataGridViewShoess.Location = new Point(3, 19);
|
dataGridViewShoess.Location = new Point(3, 19);
|
||||||
dataGridViewShoess.MultiSelect = false;
|
dataGridViewShoess.MultiSelect = false;
|
||||||
@ -85,18 +85,6 @@
|
|||||||
dataGridViewShoess.TabIndex = 8;
|
dataGridViewShoess.TabIndex = 8;
|
||||||
dataGridViewShoess.CellContentClick += dataGridViewShoess_CellContentClick;
|
dataGridViewShoess.CellContentClick += dataGridViewShoess_CellContentClick;
|
||||||
//
|
//
|
||||||
// ColumnShoes
|
|
||||||
//
|
|
||||||
ColumnShoes.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
ColumnShoes.HeaderText = "Обувь";
|
|
||||||
ColumnShoes.Name = "ColumnShoes";
|
|
||||||
//
|
|
||||||
// Column2
|
|
||||||
//
|
|
||||||
Column2.HeaderText = "Количество";
|
|
||||||
Column2.Name = "Column2";
|
|
||||||
Column2.Width = 114;
|
|
||||||
//
|
|
||||||
// ButtonSave
|
// ButtonSave
|
||||||
//
|
//
|
||||||
ButtonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
ButtonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
@ -119,6 +107,18 @@
|
|||||||
ButtonCancel.UseVisualStyleBackColor = true;
|
ButtonCancel.UseVisualStyleBackColor = true;
|
||||||
ButtonCancel.Click += ButtonCancel_Click;
|
ButtonCancel.Click += ButtonCancel_Click;
|
||||||
//
|
//
|
||||||
|
// ColumnShoes
|
||||||
|
//
|
||||||
|
ColumnShoes.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
ColumnShoes.HeaderText = "Обувь";
|
||||||
|
ColumnShoes.Name = "ColumnShoes";
|
||||||
|
//
|
||||||
|
// ColumnCount
|
||||||
|
//
|
||||||
|
ColumnCount.HeaderText = "Количество";
|
||||||
|
ColumnCount.Name = "ColumnCount";
|
||||||
|
ColumnCount.Width = 114;
|
||||||
|
//
|
||||||
// FormShoesReplenishment
|
// FormShoesReplenishment
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
@ -147,6 +147,6 @@
|
|||||||
private Button ButtonSave;
|
private Button ButtonSave;
|
||||||
private Button ButtonCancel;
|
private Button ButtonCancel;
|
||||||
private DataGridViewComboBoxColumn ColumnShoes;
|
private DataGridViewComboBoxColumn ColumnShoes;
|
||||||
private DataGridViewTextBoxColumn Column2;
|
private DataGridViewTextBoxColumn ColumnCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -117,7 +117,7 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
</root>
|
</root>
|
27
ShoeStore/ShoeStore/Forms/FormStore.Designer.cs
generated
27
ShoeStore/ShoeStore/Forms/FormStore.Designer.cs
generated
@ -28,8 +28,6 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
textBoxStoreType = new TextBox();
|
|
||||||
label1 = new Label();
|
|
||||||
label2 = new Label();
|
label2 = new Label();
|
||||||
textBoxStoreName = new TextBox();
|
textBoxStoreName = new TextBox();
|
||||||
label3 = new Label();
|
label3 = new Label();
|
||||||
@ -43,26 +41,10 @@
|
|||||||
((System.ComponentModel.ISupportInitialize)numericUpDownVisitors).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownVisitors).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// textBoxStoreType
|
|
||||||
//
|
|
||||||
textBoxStoreType.Location = new Point(161, 47);
|
|
||||||
textBoxStoreType.Name = "textBoxStoreType";
|
|
||||||
textBoxStoreType.Size = new Size(178, 23);
|
|
||||||
textBoxStoreType.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(39, 50);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(84, 15);
|
|
||||||
label1.TabIndex = 1;
|
|
||||||
label1.Text = "Тип магазина:";
|
|
||||||
//
|
|
||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
label2.AutoSize = true;
|
label2.AutoSize = true;
|
||||||
label2.Location = new Point(39, 94);
|
label2.Location = new Point(39, 61);
|
||||||
label2.Name = "label2";
|
label2.Name = "label2";
|
||||||
label2.Size = new Size(116, 15);
|
label2.Size = new Size(116, 15);
|
||||||
label2.TabIndex = 2;
|
label2.TabIndex = 2;
|
||||||
@ -70,7 +52,7 @@
|
|||||||
//
|
//
|
||||||
// textBoxStoreName
|
// textBoxStoreName
|
||||||
//
|
//
|
||||||
textBoxStoreName.Location = new Point(161, 91);
|
textBoxStoreName.Location = new Point(161, 58);
|
||||||
textBoxStoreName.Name = "textBoxStoreName";
|
textBoxStoreName.Name = "textBoxStoreName";
|
||||||
textBoxStoreName.Size = new Size(178, 23);
|
textBoxStoreName.Size = new Size(178, 23);
|
||||||
textBoxStoreName.TabIndex = 3;
|
textBoxStoreName.TabIndex = 3;
|
||||||
@ -153,8 +135,6 @@
|
|||||||
Controls.Add(label3);
|
Controls.Add(label3);
|
||||||
Controls.Add(textBoxStoreName);
|
Controls.Add(textBoxStoreName);
|
||||||
Controls.Add(label2);
|
Controls.Add(label2);
|
||||||
Controls.Add(label1);
|
|
||||||
Controls.Add(textBoxStoreType);
|
|
||||||
Name = "FormStore";
|
Name = "FormStore";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "Магазин";
|
Text = "Магазин";
|
||||||
@ -166,9 +146,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private TextBox textBoxStoreType;
|
|
||||||
private Label label1;
|
|
||||||
private Label label2;
|
private Label label2;
|
||||||
private TextBox textBoxStoreName;
|
private TextBox textBoxStoreName;
|
||||||
private Label label3;
|
private Label label3;
|
||||||
|
@ -28,7 +28,6 @@ public partial class FormStore : Form
|
|||||||
throw new InvalidDataException(nameof(store));
|
throw new InvalidDataException(nameof(store));
|
||||||
}
|
}
|
||||||
|
|
||||||
textBoxStoreType.Text = store.StoreType;
|
|
||||||
textBoxStoreName.Text = store.StoreName;
|
textBoxStoreName.Text = store.StoreName;
|
||||||
numericUpDownEmployees.Value = store.Employees;
|
numericUpDownEmployees.Value = store.Employees;
|
||||||
numericUpDownVisitors.Value = (decimal)store.Visitors;
|
numericUpDownVisitors.Value = (decimal)store.Visitors;
|
||||||
@ -51,9 +50,7 @@ public partial class FormStore : Form
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(textBoxStoreType.Text)
|
if (string.IsNullOrWhiteSpace(textBoxStoreName.Text))
|
||||||
||
|
|
||||||
string.IsNullOrWhiteSpace(textBoxStoreName.Text))
|
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
@ -75,7 +72,6 @@ public partial class FormStore : Form
|
|||||||
}
|
}
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
private Store CreateStore(int id) => Store.CreateEntity(id,
|
private Store CreateStore(int id) => Store.CreateEntity(id,
|
||||||
textBoxStoreType.Text,
|
|
||||||
textBoxStoreName.Text,
|
textBoxStoreName.Text,
|
||||||
Convert.ToInt32(numericUpDownEmployees.Value),
|
Convert.ToInt32(numericUpDownEmployees.Value),
|
||||||
Convert.ToDouble(numericUpDownVisitors.Value));
|
Convert.ToDouble(numericUpDownVisitors.Value));
|
||||||
@ -84,6 +80,4 @@ public partial class FormStore : Form
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
2
ShoeStore/ShoeStore/Forms/FormStores.Designer.cs
generated
2
ShoeStore/ShoeStore/Forms/FormStores.Designer.cs
generated
@ -58,6 +58,7 @@
|
|||||||
ButtonDel.Size = new Size(85, 78);
|
ButtonDel.Size = new Size(85, 78);
|
||||||
ButtonDel.TabIndex = 2;
|
ButtonDel.TabIndex = 2;
|
||||||
ButtonDel.UseVisualStyleBackColor = true;
|
ButtonDel.UseVisualStyleBackColor = true;
|
||||||
|
ButtonDel.Click += ButtonDel_Click;
|
||||||
//
|
//
|
||||||
// ButtonUpd
|
// ButtonUpd
|
||||||
//
|
//
|
||||||
@ -68,6 +69,7 @@
|
|||||||
ButtonUpd.Size = new Size(85, 77);
|
ButtonUpd.Size = new Size(85, 77);
|
||||||
ButtonUpd.TabIndex = 1;
|
ButtonUpd.TabIndex = 1;
|
||||||
ButtonUpd.UseVisualStyleBackColor = true;
|
ButtonUpd.UseVisualStyleBackColor = true;
|
||||||
|
ButtonUpd.Click += ButtonUpd_Click;
|
||||||
//
|
//
|
||||||
// ButtonAdd
|
// ButtonAdd
|
||||||
//
|
//
|
||||||
|
@ -8,6 +8,6 @@ namespace ShoeStore.Repositories.Implementations;
|
|||||||
|
|
||||||
internal class ConnectionString : IConnectionString
|
internal class ConnectionString : IConnectionString
|
||||||
{
|
{
|
||||||
string IConnectionString.ConnectionString => "Server=localhost;Port=5432;Database=Shoe_store;User Id=postgres;Password=326452ND;";
|
string IConnectionString.ConnectionString => "Server=localhost;Port=5432;Database=postgres;Username=postgres;Password=326452ND;";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ UPDATE Factorys
|
|||||||
SET
|
SET
|
||||||
FactoryName=@FactoryName,
|
FactoryName=@FactoryName,
|
||||||
Manufacturer=@Manufacturer
|
Manufacturer=@Manufacturer
|
||||||
WHERE [Id]=@Id";
|
WHERE Id=@Id";
|
||||||
connection.Execute(queryUpdate, factory);
|
connection.Execute(queryUpdate, factory);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -35,13 +35,13 @@ internal class ShoesReplenishmentRepository : IShoesReplenishmentRepository
|
|||||||
connection.Open();
|
connection.Open();
|
||||||
using var transaction = connection.BeginTransaction();
|
using var transaction = connection.BeginTransaction();
|
||||||
var queryInsert = @"
|
var queryInsert = @"
|
||||||
INSERT INTO ShoesReplenishments (FactorysId, DateReceipt)
|
INSERT INTO ShoesReplenishments (factorysid, DateReceipt)
|
||||||
VALUES (@FactorysId, @DateReceipt);
|
VALUES (@factorysid, @DateReceipt);
|
||||||
SELECT MAX(Id) FROM ShoesReplenishments";
|
SELECT MAX(Id) FROM ShoesReplenishments";
|
||||||
var shoesReplenishmentId =
|
var shoesReplenishmentId =
|
||||||
connection.QueryFirst<int>(queryInsert, shoesReplenishment, transaction);
|
connection.QueryFirst<int>(queryInsert, shoesReplenishment, transaction);
|
||||||
var querySubInsert = @"
|
var querySubInsert = @"
|
||||||
INSERT INTO ShoesShoesReplenishments (ShoesReplenishmentId, ShoesId, Count)
|
INSERT INTO ShoesShoesReplenishments (shoesreplenishmentsid, ShoesId, Count)
|
||||||
VALUES (@ShoesReplenishmentId,@ShoesId, @Count)";
|
VALUES (@ShoesReplenishmentId,@ShoesId, @Count)";
|
||||||
foreach (var elem in shoesReplenishment.ShoesShoesReplenishments)
|
foreach (var elem in shoesReplenishment.ShoesShoesReplenishments)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@ internal class ShoesRepository : IShoesRepository
|
|||||||
using var connection = new
|
using var connection = new
|
||||||
NpgsqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryInsert = @"
|
var queryInsert = @"
|
||||||
INSERT INTO Shoess (ShoesType, Name, Description)
|
INSERT INTO Shoes (ShoesType, Name, Description)
|
||||||
VALUES (@ShoesType, @Name, @Description)";
|
VALUES (@ShoesType, @Name, @Description)";
|
||||||
connection.Execute(queryInsert, shoes);
|
connection.Execute(queryInsert, shoes);
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ VALUES (@ShoesType, @Name, @Description)";
|
|||||||
using var connection = new
|
using var connection = new
|
||||||
NpgsqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryUpdate = @"
|
var queryUpdate = @"
|
||||||
UPDATE Shoess
|
UPDATE Shoes
|
||||||
SET
|
SET
|
||||||
ShoesType=@ShoesType,
|
ShoesType=@ShoesType,
|
||||||
Name=@Name,
|
Name=@Name,
|
||||||
@ -77,7 +77,7 @@ WHERE Id=@Id";
|
|||||||
using var connection = new
|
using var connection = new
|
||||||
NpgsqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryDelete = @"
|
var queryDelete = @"
|
||||||
DELETE FROM Shoess
|
DELETE FROM Shoes
|
||||||
WHERE Id=@id";
|
WHERE Id=@id";
|
||||||
connection.Execute(queryDelete, new { id });
|
connection.Execute(queryDelete, new { id });
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ WHERE Id=@id";
|
|||||||
using var connection = new
|
using var connection = new
|
||||||
NpgsqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = @"
|
||||||
SELECT * FROM Shoess
|
SELECT * FROM Shoes
|
||||||
WHERE Id=@id";
|
WHERE Id=@id";
|
||||||
var shoes = connection.QueryFirst<Shoes>(querySelect, new
|
var shoes = connection.QueryFirst<Shoes>(querySelect, new
|
||||||
{
|
{
|
||||||
@ -119,7 +119,7 @@ WHERE Id=@id";
|
|||||||
{
|
{
|
||||||
using var connection = new
|
using var connection = new
|
||||||
NpgsqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM Shoess";
|
var querySelect = "SELECT * FROM Shoes";
|
||||||
var shoess = connection.Query<Shoes>(querySelect);
|
var shoess = connection.Query<Shoes>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}",
|
_logger.LogDebug("Полученные объекты: {json}",
|
||||||
JsonConvert.SerializeObject(shoess));
|
JsonConvert.SerializeObject(shoess));
|
||||||
|
@ -33,8 +33,8 @@ internal class StoreRepository : IStoreRepository
|
|||||||
using var connection = new
|
using var connection = new
|
||||||
NpgsqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryInsert = @"
|
var queryInsert = @"
|
||||||
INSERT INTO Stores (StoreType, StoreName, Employees, Visitors)
|
INSERT INTO Stores (StoreName, Employees, Visitors)
|
||||||
VALUES (@StoreType, @StoreName, @Employees, @Visitors)";
|
VALUES (@StoreName, @Employees, @Visitors)";
|
||||||
connection.Execute(queryInsert, store);
|
connection.Execute(queryInsert, store);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -52,9 +52,8 @@ VALUES (@StoreType, @StoreName, @Employees, @Visitors)";
|
|||||||
using var connection = new
|
using var connection = new
|
||||||
NpgsqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryUpdate = @"
|
var queryUpdate = @"
|
||||||
UPDATE Store
|
UPDATE Stores
|
||||||
SET
|
SET
|
||||||
StoreType=@StoreType,
|
|
||||||
StoreName=@StoreName,
|
StoreName=@StoreName,
|
||||||
Employees=@Employees,
|
Employees=@Employees,
|
||||||
Visitors=@Visitors
|
Visitors=@Visitors
|
||||||
@ -77,7 +76,7 @@ WHERE Id=@Id";
|
|||||||
using var connection = new
|
using var connection = new
|
||||||
NpgsqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var queryDelete = @"
|
var queryDelete = @"
|
||||||
DELETE FROM Store
|
DELETE FROM Stores
|
||||||
WHERE Id=@id";
|
WHERE Id=@id";
|
||||||
connection.Execute(queryDelete, new { id });
|
connection.Execute(queryDelete, new { id });
|
||||||
}
|
}
|
||||||
@ -97,8 +96,8 @@ WHERE Id=@id";
|
|||||||
using var connection = new
|
using var connection = new
|
||||||
NpgsqlConnection(_connectionString.ConnectionString);
|
NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = @"
|
||||||
SELECT * FROM Store
|
SELECT * FROM Stores
|
||||||
WHERE [Id]=@id";
|
WHERE Id=@id";
|
||||||
var store = connection.QueryFirst<Store>(querySelect, new
|
var store = connection.QueryFirst<Store>(querySelect, new
|
||||||
{
|
{
|
||||||
id
|
id
|
||||||
|
Loading…
Reference in New Issue
Block a user