Доработаны формы
This commit is contained in:
parent
743d2e7174
commit
16cb8fe33f
@ -42,6 +42,7 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCancel.Location = new Point(297, 216);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
@ -52,6 +53,7 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonSave.Location = new Point(216, 216);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(75, 23);
|
||||
|
@ -64,6 +64,7 @@
|
||||
buttonUpdate.Size = new Size(65, 65);
|
||||
buttonUpdate.TabIndex = 1;
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
@ -74,6 +75,7 @@
|
||||
buttonDelete.Size = new Size(65, 65);
|
||||
buttonDelete.TabIndex = 1;
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
@ -84,6 +86,7 @@
|
||||
buttonAdd.Size = new Size(65, 65);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
@ -106,6 +109,7 @@
|
||||
Name = "FormClients";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Клиенты";
|
||||
Load += FormClients_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
|
@ -96,6 +96,7 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonSave.Location = new Point(211, 200);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(75, 23);
|
||||
@ -106,6 +107,7 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCancel.Location = new Point(292, 200);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
|
@ -35,7 +35,13 @@
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
label2 = new Label();
|
||||
dateTimePicker1 = new DateTimePicker();
|
||||
dateTimePickerOrderDate = new DateTimePicker();
|
||||
groupBox1 = new GroupBox();
|
||||
dataGridViewProducts = new DataGridView();
|
||||
ColumnProductName = new DataGridViewComboBoxColumn();
|
||||
ColumnProductCount = new DataGridViewTextBoxColumn();
|
||||
groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewProducts).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label4
|
||||
@ -76,21 +82,25 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(297, 150);
|
||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCancel.Location = new Point(297, 416);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
buttonCancel.TabIndex = 22;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(216, 150);
|
||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonSave.Location = new Point(216, 416);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(75, 23);
|
||||
buttonSave.TabIndex = 21;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
@ -101,20 +111,58 @@
|
||||
label2.TabIndex = 23;
|
||||
label2.Text = "Дата:";
|
||||
//
|
||||
// dateTimePicker1
|
||||
// dateTimePickerOrderDate
|
||||
//
|
||||
dateTimePicker1.Enabled = false;
|
||||
dateTimePicker1.Location = new Point(122, 98);
|
||||
dateTimePicker1.Name = "dateTimePicker1";
|
||||
dateTimePicker1.Size = new Size(200, 23);
|
||||
dateTimePicker1.TabIndex = 24;
|
||||
dateTimePickerOrderDate.Enabled = false;
|
||||
dateTimePickerOrderDate.Location = new Point(122, 98);
|
||||
dateTimePickerOrderDate.Name = "dateTimePickerOrderDate";
|
||||
dateTimePickerOrderDate.Size = new Size(200, 23);
|
||||
dateTimePickerOrderDate.TabIndex = 24;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
groupBox1.Controls.Add(dataGridViewProducts);
|
||||
groupBox1.Location = new Point(12, 137);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(360, 263);
|
||||
groupBox1.TabIndex = 25;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Продукты";
|
||||
//
|
||||
// dataGridViewProducts
|
||||
//
|
||||
dataGridViewProducts.AllowUserToResizeColumns = false;
|
||||
dataGridViewProducts.AllowUserToResizeRows = false;
|
||||
dataGridViewProducts.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
dataGridViewProducts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewProducts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewProducts.Columns.AddRange(new DataGridViewColumn[] { ColumnProductName, ColumnProductCount });
|
||||
dataGridViewProducts.Location = new Point(6, 22);
|
||||
dataGridViewProducts.MultiSelect = false;
|
||||
dataGridViewProducts.Name = "dataGridViewProducts";
|
||||
dataGridViewProducts.RowHeadersVisible = false;
|
||||
dataGridViewProducts.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewProducts.Size = new Size(354, 242);
|
||||
dataGridViewProducts.TabIndex = 0;
|
||||
//
|
||||
// ColumnProductName
|
||||
//
|
||||
ColumnProductName.HeaderText = "Продукт";
|
||||
ColumnProductName.Name = "ColumnProductName";
|
||||
//
|
||||
// ColumnProductCount
|
||||
//
|
||||
ColumnProductCount.HeaderText = "Количество";
|
||||
ColumnProductCount.Name = "ColumnProductCount";
|
||||
//
|
||||
// FormOrder
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(384, 185);
|
||||
Controls.Add(dateTimePicker1);
|
||||
ClientSize = new Size(384, 451);
|
||||
Controls.Add(groupBox1);
|
||||
Controls.Add(dateTimePickerOrderDate);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
@ -125,6 +173,8 @@
|
||||
Name = "FormOrder";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Заказ";
|
||||
groupBox1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewProducts).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -138,6 +188,10 @@
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private Label label2;
|
||||
private DateTimePicker dateTimePicker1;
|
||||
private DateTimePicker dateTimePickerOrderDate;
|
||||
private GroupBox groupBox1;
|
||||
private DataGridView dataGridViewProducts;
|
||||
private DataGridViewComboBoxColumn ColumnProductName;
|
||||
private DataGridViewTextBoxColumn ColumnProductCount;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using ProjectConfectionaryFactory.Entities;
|
||||
using ProjectConfectionaryFactory.Repositories;
|
||||
using ProjectConfectionaryFactory.Repositories.Implementations;
|
||||
|
||||
namespace ProjectConfectionaryFactory.Forms
|
||||
{
|
||||
@ -27,20 +28,24 @@ namespace ProjectConfectionaryFactory.Forms
|
||||
}
|
||||
}
|
||||
|
||||
public FormOrder(IOrderRepository orderRepository, IClientRepository clientRepository)
|
||||
public FormOrder(IOrderRepository orderRepository, IClientRepository clientRepository, IProductRepository productRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
||||
comboBoxClient.DataSource = clientRepository.ReadClients();
|
||||
comboBoxClient.DisplayMember = "FirstName";
|
||||
comboBoxClient.ValueMember = "Id";
|
||||
|
||||
ColumnProductName.DataSource = productRepository.ReadProducts();
|
||||
ColumnProductName.DisplayMember = "Name";
|
||||
ColumnProductName.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (comboBoxClient.SelectedIndex < 0 || !checkBoxCompleted.Checked)
|
||||
if (dataGridViewProducts.RowCount < 1 || comboBoxClient.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
@ -56,15 +61,34 @@ namespace ProjectConfectionaryFactory.Forms
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private Order CreateOrder(int id) => Order.CreateEntity(
|
||||
id,
|
||||
(int)comboBoxClient.SelectedValue!,
|
||||
checkBoxCompleted.Checked);
|
||||
private List<OrderProduct>CreateListOrderProductFromDataGrid()
|
||||
{
|
||||
var list = new List<OrderProduct>();
|
||||
foreach (DataGridViewRow row in dataGridViewProducts.Rows)
|
||||
{
|
||||
if (row.Cells["ColumnProductsName"].Value == null ||
|
||||
row.Cells["ColumnProductCount"].Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list.Add(OrderProduct.CreateEntity(0,
|
||||
Convert.ToInt32(row.Cells["ColumnProductsName"].Value),
|
||||
Convert.ToInt32(row.Cells["ColumnProductCount"].Value)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private Order CreateOrder(int id) => Order.CreateOperation(0,
|
||||
(int)comboBoxClient.SelectedValue!,
|
||||
checkBoxCompleted.Checked,
|
||||
CreateListOrderProductFromDataGrid());
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
@ -117,4 +117,16 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="ColumnProductName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnProductCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnProductName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnProductCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -46,6 +46,7 @@
|
||||
buttonAdd.Size = new Size(65, 65);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// dataGridViewData
|
||||
//
|
||||
@ -74,6 +75,7 @@
|
||||
buttonUpdate.Size = new Size(65, 65);
|
||||
buttonUpdate.TabIndex = 1;
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
@ -84,6 +86,7 @@
|
||||
buttonDelete.Size = new Size(65, 65);
|
||||
buttonDelete.TabIndex = 1;
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
@ -106,6 +109,7 @@
|
||||
Name = "FormOrders";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "FormOrders";
|
||||
Load += FormOrders_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
|
@ -36,13 +36,19 @@
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
checkedListBoxConfectionaryType = new CheckedListBox();
|
||||
groupBox1 = new GroupBox();
|
||||
dataGridViewComponents = new DataGridView();
|
||||
ColumnComponent = new DataGridViewComboBoxColumn();
|
||||
ColumnWeight = new DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||
groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewComponents).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// numericUpDownPrice
|
||||
//
|
||||
numericUpDownPrice.DecimalPlaces = 2;
|
||||
numericUpDownPrice.Location = new Point(150, 208);
|
||||
numericUpDownPrice.Location = new Point(150, 201);
|
||||
numericUpDownPrice.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
|
||||
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||
numericUpDownPrice.Size = new Size(96, 23);
|
||||
@ -59,7 +65,7 @@
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(106, 210);
|
||||
label2.Location = new Point(106, 203);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(38, 15);
|
||||
label2.TabIndex = 6;
|
||||
@ -85,7 +91,8 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(297, 286);
|
||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCancel.Location = new Point(297, 544);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
buttonCancel.TabIndex = 11;
|
||||
@ -95,7 +102,8 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(216, 286);
|
||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonSave.Location = new Point(216, 544);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(75, 23);
|
||||
buttonSave.TabIndex = 10;
|
||||
@ -111,11 +119,50 @@
|
||||
checkedListBoxConfectionaryType.Size = new Size(207, 112);
|
||||
checkedListBoxConfectionaryType.TabIndex = 12;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
groupBox1.Controls.Add(dataGridViewComponents);
|
||||
groupBox1.Location = new Point(12, 241);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(360, 273);
|
||||
groupBox1.TabIndex = 26;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Компоненты";
|
||||
//
|
||||
// dataGridViewComponents
|
||||
//
|
||||
dataGridViewComponents.AllowUserToResizeColumns = false;
|
||||
dataGridViewComponents.AllowUserToResizeRows = false;
|
||||
dataGridViewComponents.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewComponents.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewComponents.Columns.AddRange(new DataGridViewColumn[] { ColumnComponent, ColumnWeight });
|
||||
dataGridViewComponents.Dock = DockStyle.Fill;
|
||||
dataGridViewComponents.Location = new Point(3, 19);
|
||||
dataGridViewComponents.MultiSelect = false;
|
||||
dataGridViewComponents.Name = "dataGridViewComponents";
|
||||
dataGridViewComponents.RowHeadersVisible = false;
|
||||
dataGridViewComponents.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewComponents.Size = new Size(354, 251);
|
||||
dataGridViewComponents.TabIndex = 0;
|
||||
//
|
||||
// ColumnComponent
|
||||
//
|
||||
ColumnComponent.HeaderText = "Компонент";
|
||||
ColumnComponent.Name = "ColumnComponent";
|
||||
//
|
||||
// ColumnWeight
|
||||
//
|
||||
ColumnWeight.HeaderText = "Вес";
|
||||
ColumnWeight.MaxInputLength = 7;
|
||||
ColumnWeight.Name = "ColumnWeight";
|
||||
//
|
||||
// FormProduct
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(384, 321);
|
||||
ClientSize = new Size(384, 579);
|
||||
Controls.Add(groupBox1);
|
||||
Controls.Add(checkedListBoxConfectionaryType);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
@ -128,6 +175,8 @@
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "FormProduct";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||
groupBox1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewComponents).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -141,5 +190,9 @@
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private CheckedListBox checkedListBoxConfectionaryType;
|
||||
private GroupBox groupBox1;
|
||||
private DataGridView dataGridViewComponents;
|
||||
private DataGridViewComboBoxColumn ColumnComponent;
|
||||
private DataGridViewTextBoxColumn ColumnWeight;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using ProjectConfectionaryFactory.Entities;
|
||||
using ProjectConfectionaryFactory.Entities.Enums;
|
||||
using ProjectConfectionaryFactory.Repositories;
|
||||
using ProjectConfectionaryFactory.Repositories.Implementations;
|
||||
|
||||
namespace ProjectConfectionaryFactory.Forms
|
||||
{
|
||||
@ -41,21 +42,26 @@ namespace ProjectConfectionaryFactory.Forms
|
||||
}
|
||||
}
|
||||
|
||||
public FormProduct(IProductRepository productRepository)
|
||||
public FormProduct(IProductRepository productRepository, IComponentRepository componentRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
||||
|
||||
foreach (var elem in Enum.GetValues(typeof(ConfectionaryType)))
|
||||
{
|
||||
checkedListBoxConfectionaryType.Items.Add(elem);
|
||||
}
|
||||
|
||||
ColumnComponent.DataSource = componentRepository.ReadComponents();
|
||||
ColumnComponent.DisplayMember = "Name";
|
||||
ColumnComponent.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (checkedListBoxConfectionaryType.CheckedItems.Count == 0 || string.IsNullOrWhiteSpace(textBoxProductName.Text))
|
||||
if (checkedListBoxConfectionaryType.CheckedItems.Count == 0 || string.IsNullOrWhiteSpace(textBoxProductName.Text) || dataGridViewComponents.RowCount < 1)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
@ -77,6 +83,23 @@ namespace ProjectConfectionaryFactory.Forms
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private List<ProductComponent> CreateListProductComponentFromDataGrid()
|
||||
{
|
||||
var list = new List<ProductComponent>();
|
||||
foreach (DataGridViewRow row in dataGridViewComponents.Rows)
|
||||
{
|
||||
if (row.Cells["ColumnComponent"].Value == null ||
|
||||
row.Cells["ColumnWeight"].Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list.Add(ProductComponent.CreateEntity(0,
|
||||
Convert.ToInt32(row.Cells["ColumnComponent"].Value),
|
||||
Convert.ToInt32(row.Cells["ColumnWeight"].Value)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private Product CreateProduct(int id)
|
||||
{
|
||||
ConfectionaryType confectionaryType = ConfectionaryType.None;
|
||||
@ -88,7 +111,8 @@ namespace ProjectConfectionaryFactory.Forms
|
||||
id,
|
||||
confectionaryType,
|
||||
textBoxProductName.Text,
|
||||
(double)numericUpDownPrice.Value);
|
||||
(double)numericUpDownPrice.Value,
|
||||
CreateListProductComponentFromDataGrid());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,4 +117,10 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="ColumnComponent.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnWeight.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -46,6 +46,7 @@
|
||||
buttonUpdate.Size = new Size(65, 65);
|
||||
buttonUpdate.TabIndex = 1;
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
@ -56,6 +57,7 @@
|
||||
buttonDelete.Size = new Size(65, 65);
|
||||
buttonDelete.TabIndex = 1;
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
@ -66,6 +68,7 @@
|
||||
buttonAdd.Size = new Size(65, 65);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// dataGridViewData
|
||||
//
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
|
@ -55,6 +55,7 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCancel.Location = new Point(297, 156);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
@ -65,6 +66,7 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonSave.Location = new Point(216, 156);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(75, 23);
|
||||
|
@ -64,6 +64,7 @@
|
||||
buttonUpdate.Size = new Size(65, 65);
|
||||
buttonUpdate.TabIndex = 1;
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
@ -74,6 +75,7 @@
|
||||
buttonDelete.Size = new Size(65, 65);
|
||||
buttonDelete.TabIndex = 1;
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
@ -84,6 +86,7 @@
|
||||
buttonAdd.Size = new Size(65, 65);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
@ -106,6 +109,7 @@
|
||||
Name = "FormSuppliers";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "FormSuppliers";
|
||||
Load += FormSuppliers_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
|
@ -62,6 +62,7 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCancel.Location = new Point(297, 251);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
@ -72,6 +73,7 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonSave.Location = new Point(216, 251);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(75, 23);
|
||||
|
@ -66,7 +66,7 @@ namespace ProjectConfectionaryFactory.Forms
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private Supply CreateSupply(int id) => Supply.CreateEntity(
|
||||
private Supply CreateSupply(int id) => Supply.CreateOperation(
|
||||
id,
|
||||
(int)comboBoxSupplier.SelectedValue!,
|
||||
(int)comboBoxComponent.SelectedValue!,
|
||||
|
@ -64,6 +64,7 @@
|
||||
buttonUpdate.Size = new Size(65, 65);
|
||||
buttonUpdate.TabIndex = 1;
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
@ -74,6 +75,7 @@
|
||||
buttonDelete.Size = new Size(65, 65);
|
||||
buttonDelete.TabIndex = 1;
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
@ -84,6 +86,7 @@
|
||||
buttonAdd.Size = new Size(65, 65);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
@ -106,6 +109,7 @@
|
||||
Name = "FormSupplys";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "FormSupplys";
|
||||
Load += FormSupplys_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
|
Loading…
x
Reference in New Issue
Block a user