я ненавижу связи многие ко многим я ненавижу связи многие ко многим я ненавижу связи многие ко многим я ненавижу связи многие ко многим я ненавижу связи многие ко многим я ненавижу связи многие ко многим я ненавижу связи многие ко многим я ненавижу связи многие ко многим я ненавижу связи многие ко многим я ненавижу связи многие ко многим я ненавижу связи многие ко многим я ненавижу связи многие ко многим я ненавижу связи многие ко многим
This commit is contained in:
parent
abe9f95aae
commit
a42202f627
@ -56,7 +56,7 @@ namespace DatabaseImplement.Models
|
|||||||
public void Update(Database context, SupplierBindingModel model)
|
public void Update(Database context, SupplierBindingModel model)
|
||||||
{
|
{
|
||||||
Name = model.Name;
|
Name = model.Name;
|
||||||
|
Deals = model.Deals;
|
||||||
Debug.WriteLine(model.AvailibleProducts.Keys);
|
Debug.WriteLine(model.AvailibleProducts.Keys);
|
||||||
Products = model.AvailibleProducts.Select(x => new
|
Products = model.AvailibleProducts.Select(x => new
|
||||||
SupplierProduct
|
SupplierProduct
|
||||||
@ -86,7 +86,7 @@ namespace DatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
var newList = new List<SupplierProduct>();
|
var newList = new List<SupplierProduct>();
|
||||||
var trueCount = model.AvailibleProducts.Count;
|
var trueCount = model.AvailibleProducts.Count;
|
||||||
for (int i = 0; i < trueCount; i++)
|
for (int i = 0; i < trueCount; i++)
|
||||||
{
|
{
|
||||||
newList.Add(supplierProducts[i]);
|
newList.Add(supplierProducts[i]);
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ namespace DatabaseImplement.Models
|
|||||||
foreach (var item in supplierProducts)
|
foreach (var item in supplierProducts)
|
||||||
{
|
{
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
foreach(var product in model.AvailibleProducts)
|
foreach (var product in model.AvailibleProducts)
|
||||||
{
|
{
|
||||||
if (product.Value.Item1.Id == item.ProductId)
|
if (product.Value.Item1.Id == item.ProductId)
|
||||||
{
|
{
|
||||||
|
66
WinFormsApp/FormSuppliers.Designer.cs
generated
66
WinFormsApp/FormSuppliers.Designer.cs
generated
@ -33,7 +33,7 @@
|
|||||||
label3 = new Label();
|
label3 = new Label();
|
||||||
numericUpDownDeals = new NumericUpDown();
|
numericUpDownDeals = new NumericUpDown();
|
||||||
groupBoxSupplierProducts = new GroupBox();
|
groupBoxSupplierProducts = new GroupBox();
|
||||||
buttonRefresh = new Button();
|
buttonDeleteProduct = new Button();
|
||||||
label2 = new Label();
|
label2 = new Label();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
label1 = new Label();
|
label1 = new Label();
|
||||||
@ -41,8 +41,6 @@
|
|||||||
numericUpDownCount = new NumericUpDown();
|
numericUpDownCount = new NumericUpDown();
|
||||||
comboBoxProducts = new ComboBox();
|
comboBoxProducts = new ComboBox();
|
||||||
dataGridViewProducts = new DataGridView();
|
dataGridViewProducts = new DataGridView();
|
||||||
Column = new DataGridViewTextBoxColumn();
|
|
||||||
Column2 = new DataGridViewTextBoxColumn();
|
|
||||||
buttonAddSupplierProduct = new Button();
|
buttonAddSupplierProduct = new Button();
|
||||||
textBoxName = new TextBox();
|
textBoxName = new TextBox();
|
||||||
groupBoxControls = new GroupBox();
|
groupBoxControls = new GroupBox();
|
||||||
@ -50,6 +48,9 @@
|
|||||||
buttonUpdateSupplier = new Button();
|
buttonUpdateSupplier = new Button();
|
||||||
buttonCreateSupplier = new Button();
|
buttonCreateSupplier = new Button();
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
|
ColumnId = new DataGridViewTextBoxColumn();
|
||||||
|
Column = new DataGridViewTextBoxColumn();
|
||||||
|
Column2 = new DataGridViewTextBoxColumn();
|
||||||
groupBoxCreateSupplier.SuspendLayout();
|
groupBoxCreateSupplier.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownDeals).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownDeals).BeginInit();
|
||||||
groupBoxSupplierProducts.SuspendLayout();
|
groupBoxSupplierProducts.SuspendLayout();
|
||||||
@ -103,7 +104,7 @@
|
|||||||
//
|
//
|
||||||
// groupBoxSupplierProducts
|
// groupBoxSupplierProducts
|
||||||
//
|
//
|
||||||
groupBoxSupplierProducts.Controls.Add(buttonRefresh);
|
groupBoxSupplierProducts.Controls.Add(buttonDeleteProduct);
|
||||||
groupBoxSupplierProducts.Controls.Add(label2);
|
groupBoxSupplierProducts.Controls.Add(label2);
|
||||||
groupBoxSupplierProducts.Controls.Add(buttonCancel);
|
groupBoxSupplierProducts.Controls.Add(buttonCancel);
|
||||||
groupBoxSupplierProducts.Controls.Add(label1);
|
groupBoxSupplierProducts.Controls.Add(label1);
|
||||||
@ -119,15 +120,15 @@
|
|||||||
groupBoxSupplierProducts.TabStop = false;
|
groupBoxSupplierProducts.TabStop = false;
|
||||||
groupBoxSupplierProducts.Text = "Доступные товары поставщика";
|
groupBoxSupplierProducts.Text = "Доступные товары поставщика";
|
||||||
//
|
//
|
||||||
// buttonRefresh
|
// buttonDeleteProduct
|
||||||
//
|
//
|
||||||
buttonRefresh.Location = new Point(58, 307);
|
buttonDeleteProduct.Location = new Point(58, 307);
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
buttonDeleteProduct.Name = "buttonDeleteProduct";
|
||||||
buttonRefresh.Size = new Size(81, 23);
|
buttonDeleteProduct.Size = new Size(81, 23);
|
||||||
buttonRefresh.TabIndex = 14;
|
buttonDeleteProduct.TabIndex = 15;
|
||||||
buttonRefresh.Text = "Обновить";
|
buttonDeleteProduct.Text = "Удалить";
|
||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
buttonDeleteProduct.UseVisualStyleBackColor = true;
|
||||||
buttonRefresh.Click += buttonRefresh_Click;
|
buttonDeleteProduct.Click += buttonDeleteProduct_Click;
|
||||||
//
|
//
|
||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
@ -186,26 +187,13 @@
|
|||||||
// dataGridViewProducts
|
// dataGridViewProducts
|
||||||
//
|
//
|
||||||
dataGridViewProducts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridViewProducts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridViewProducts.Columns.AddRange(new DataGridViewColumn[] { Column, Column2 });
|
dataGridViewProducts.Columns.AddRange(new DataGridViewColumn[] { ColumnId, Column, Column2 });
|
||||||
dataGridViewProducts.Dock = DockStyle.Top;
|
dataGridViewProducts.Dock = DockStyle.Top;
|
||||||
dataGridViewProducts.Location = new Point(3, 19);
|
dataGridViewProducts.Location = new Point(3, 19);
|
||||||
dataGridViewProducts.Name = "dataGridViewProducts";
|
dataGridViewProducts.Name = "dataGridViewProducts";
|
||||||
dataGridViewProducts.Size = new Size(355, 195);
|
dataGridViewProducts.Size = new Size(355, 195);
|
||||||
dataGridViewProducts.TabIndex = 8;
|
dataGridViewProducts.TabIndex = 8;
|
||||||
//
|
//
|
||||||
// Column
|
|
||||||
//
|
|
||||||
Column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
Column.HeaderText = "Продукт";
|
|
||||||
Column.Name = "Column";
|
|
||||||
Column.ReadOnly = true;
|
|
||||||
//
|
|
||||||
// Column2
|
|
||||||
//
|
|
||||||
Column2.HeaderText = "Кол-во";
|
|
||||||
Column2.Name = "Column2";
|
|
||||||
Column2.ReadOnly = true;
|
|
||||||
//
|
|
||||||
// buttonAddSupplierProduct
|
// buttonAddSupplierProduct
|
||||||
//
|
//
|
||||||
buttonAddSupplierProduct.Location = new Point(58, 278);
|
buttonAddSupplierProduct.Location = new Point(58, 278);
|
||||||
@ -276,6 +264,25 @@
|
|||||||
dataGridView.Size = new Size(392, 637);
|
dataGridView.Size = new Size(392, 637);
|
||||||
dataGridView.TabIndex = 4;
|
dataGridView.TabIndex = 4;
|
||||||
//
|
//
|
||||||
|
// ColumnId
|
||||||
|
//
|
||||||
|
ColumnId.HeaderText = "Id";
|
||||||
|
ColumnId.Name = "ColumnId";
|
||||||
|
ColumnId.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// Column
|
||||||
|
//
|
||||||
|
Column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
Column.HeaderText = "Продукт";
|
||||||
|
Column.Name = "Column";
|
||||||
|
Column.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// Column2
|
||||||
|
//
|
||||||
|
Column2.HeaderText = "Кол-во";
|
||||||
|
Column2.Name = "Column2";
|
||||||
|
Column2.ReadOnly = true;
|
||||||
|
//
|
||||||
// FormSuppliers
|
// FormSuppliers
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
@ -317,11 +324,12 @@
|
|||||||
private Label label2;
|
private Label label2;
|
||||||
private Label label1;
|
private Label label1;
|
||||||
private NumericUpDown numericUpDownCount;
|
private NumericUpDown numericUpDownCount;
|
||||||
private DataGridViewTextBoxColumn Column;
|
|
||||||
private DataGridViewTextBoxColumn Column2;
|
|
||||||
private Label label4;
|
private Label label4;
|
||||||
private Label label3;
|
private Label label3;
|
||||||
private NumericUpDown numericUpDownDeals;
|
private NumericUpDown numericUpDownDeals;
|
||||||
private Button buttonRefresh;
|
private Button buttonDeleteProduct;
|
||||||
|
private DataGridViewTextBoxColumn ColumnId;
|
||||||
|
private DataGridViewTextBoxColumn Column;
|
||||||
|
private DataGridViewTextBoxColumn Column2;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -57,7 +57,7 @@ namespace WinFormsApp
|
|||||||
dataGridViewProducts.Rows.Clear();
|
dataGridViewProducts.Rows.Clear();
|
||||||
foreach (var pc in _supplierProducts)
|
foreach (var pc in _supplierProducts)
|
||||||
{
|
{
|
||||||
dataGridViewProducts.Rows.Add(new object[] { pc.Value.Item1.Name, pc.Value.Item2 });
|
dataGridViewProducts.Rows.Add(new object[] { pc.Key, pc.Value.Item1.Name, pc.Value.Item2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ namespace WinFormsApp
|
|||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
_id = null;
|
_id = null;
|
||||||
_supplierProducts = new Dictionary<Guid, (IProduct, int)>;
|
_supplierProducts = new Dictionary<Guid, (IProduct, int)>();
|
||||||
textBoxName.Text = string.Empty;
|
textBoxName.Text = string.Empty;
|
||||||
numericUpDownDeals.Value = 0;
|
numericUpDownDeals.Value = 0;
|
||||||
//groupBoxControls.Enabled = true;
|
//groupBoxControls.Enabled = true;
|
||||||
@ -241,9 +241,28 @@ namespace WinFormsApp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonRefresh_Click(object sender, EventArgs e)
|
private void buttonDeleteProduct_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
LoadSupplierData();
|
if (dataGridViewProducts.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||||
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Удаление продукта из списка доступных продуктов поставщика");
|
||||||
|
Debug.WriteLine(_supplierProducts.Keys);
|
||||||
|
Debug.WriteLine(_supplierProducts.Values);
|
||||||
|
Debug.WriteLine((Guid)dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
_supplierProducts?.Remove((Guid)dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
LoadSupplierData();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,9 @@
|
|||||||
<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="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
<metadata name="Column.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Column.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
Loading…
Reference in New Issue
Block a user