Доработаны формы
This commit is contained in:
parent
31dd4aa11f
commit
3912a9cfd3
@ -42,6 +42,7 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonCancel.Location = new Point(297, 216);
|
buttonCancel.Location = new Point(297, 216);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(75, 23);
|
buttonCancel.Size = new Size(75, 23);
|
||||||
@ -52,6 +53,7 @@
|
|||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonSave.Location = new Point(216, 216);
|
buttonSave.Location = new Point(216, 216);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(75, 23);
|
buttonSave.Size = new Size(75, 23);
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
buttonUpdate.Size = new Size(65, 65);
|
buttonUpdate.Size = new Size(65, 65);
|
||||||
buttonUpdate.TabIndex = 1;
|
buttonUpdate.TabIndex = 1;
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpdate.Click += ButtonUpdate_Click;
|
||||||
//
|
//
|
||||||
// buttonDelete
|
// buttonDelete
|
||||||
//
|
//
|
||||||
@ -74,6 +75,7 @@
|
|||||||
buttonDelete.Size = new Size(65, 65);
|
buttonDelete.Size = new Size(65, 65);
|
||||||
buttonDelete.TabIndex = 1;
|
buttonDelete.TabIndex = 1;
|
||||||
buttonDelete.UseVisualStyleBackColor = true;
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
|
buttonDelete.Click += ButtonDelete_Click;
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
@ -84,6 +86,7 @@
|
|||||||
buttonAdd.Size = new Size(65, 65);
|
buttonAdd.Size = new Size(65, 65);
|
||||||
buttonAdd.TabIndex = 0;
|
buttonAdd.TabIndex = 0;
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
//
|
//
|
||||||
// panel1
|
// panel1
|
||||||
//
|
//
|
||||||
@ -106,6 +109,7 @@
|
|||||||
Name = "FormClients";
|
Name = "FormClients";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "Клиенты";
|
Text = "Клиенты";
|
||||||
|
Load += FormClients_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||||
panel1.ResumeLayout(false);
|
panel1.ResumeLayout(false);
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
@ -96,6 +96,7 @@
|
|||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonSave.Location = new Point(211, 200);
|
buttonSave.Location = new Point(211, 200);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(75, 23);
|
buttonSave.Size = new Size(75, 23);
|
||||||
@ -106,6 +107,7 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonCancel.Location = new Point(292, 200);
|
buttonCancel.Location = new Point(292, 200);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(75, 23);
|
buttonCancel.Size = new Size(75, 23);
|
||||||
|
@ -35,7 +35,13 @@
|
|||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
label2 = new Label();
|
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();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// label4
|
// label4
|
||||||
@ -76,21 +82,25 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(297, 150);
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonCancel.Location = new Point(297, 416);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(75, 23);
|
buttonCancel.Size = new Size(75, 23);
|
||||||
buttonCancel.TabIndex = 22;
|
buttonCancel.TabIndex = 22;
|
||||||
buttonCancel.Text = "Отмена";
|
buttonCancel.Text = "Отмена";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
buttonSave.Location = new Point(216, 150);
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonSave.Location = new Point(216, 416);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(75, 23);
|
buttonSave.Size = new Size(75, 23);
|
||||||
buttonSave.TabIndex = 21;
|
buttonSave.TabIndex = 21;
|
||||||
buttonSave.Text = "Сохранить";
|
buttonSave.Text = "Сохранить";
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += ButtonSave_Click;
|
||||||
//
|
//
|
||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
@ -101,20 +111,58 @@
|
|||||||
label2.TabIndex = 23;
|
label2.TabIndex = 23;
|
||||||
label2.Text = "Дата:";
|
label2.Text = "Дата:";
|
||||||
//
|
//
|
||||||
// dateTimePicker1
|
// dateTimePickerOrderDate
|
||||||
//
|
//
|
||||||
dateTimePicker1.Enabled = false;
|
dateTimePickerOrderDate.Enabled = false;
|
||||||
dateTimePicker1.Location = new Point(122, 98);
|
dateTimePickerOrderDate.Location = new Point(122, 98);
|
||||||
dateTimePicker1.Name = "dateTimePicker1";
|
dateTimePickerOrderDate.Name = "dateTimePickerOrderDate";
|
||||||
dateTimePicker1.Size = new Size(200, 23);
|
dateTimePickerOrderDate.Size = new Size(200, 23);
|
||||||
dateTimePicker1.TabIndex = 24;
|
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
|
// FormOrder
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(384, 185);
|
ClientSize = new Size(384, 451);
|
||||||
Controls.Add(dateTimePicker1);
|
Controls.Add(groupBox1);
|
||||||
|
Controls.Add(dateTimePickerOrderDate);
|
||||||
Controls.Add(label2);
|
Controls.Add(label2);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
@ -125,6 +173,8 @@
|
|||||||
Name = "FormOrder";
|
Name = "FormOrder";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "Заказ";
|
Text = "Заказ";
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewProducts).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -138,6 +188,10 @@
|
|||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private Label label2;
|
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.Entities;
|
||||||
using ProjectConfectionaryFactory.Repositories;
|
using ProjectConfectionaryFactory.Repositories;
|
||||||
|
using ProjectConfectionaryFactory.Repositories.Implementations;
|
||||||
|
|
||||||
namespace ProjectConfectionaryFactory.Forms
|
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();
|
InitializeComponent();
|
||||||
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
||||||
comboBoxClient.DataSource = clientRepository.ReadClients();
|
comboBoxClient.DataSource = clientRepository.ReadClients();
|
||||||
comboBoxClient.DisplayMember = "FirstName";
|
comboBoxClient.DisplayMember = "FirstName";
|
||||||
comboBoxClient.ValueMember = "Id";
|
comboBoxClient.ValueMember = "Id";
|
||||||
|
|
||||||
|
ColumnProductName.DataSource = productRepository.ReadProducts();
|
||||||
|
ColumnProductName.DisplayMember = "Name";
|
||||||
|
ColumnProductName.ValueMember = "Id";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (comboBoxClient.SelectedIndex < 0 || !checkBoxCompleted.Checked)
|
if (dataGridViewProducts.RowCount < 1 || comboBoxClient.SelectedIndex < 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
@ -56,15 +61,34 @@ namespace ProjectConfectionaryFactory.Forms
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
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 void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
private Order CreateOrder(int id) => Order.CreateEntity(
|
private List<OrderProduct>CreateListOrderProductFromDataGrid()
|
||||||
id,
|
{
|
||||||
(int)comboBoxClient.SelectedValue!,
|
var list = new List<OrderProduct>();
|
||||||
checkBoxCompleted.Checked);
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,4 +117,16 @@
|
|||||||
<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="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>
|
</root>
|
@ -46,6 +46,7 @@
|
|||||||
buttonAdd.Size = new Size(65, 65);
|
buttonAdd.Size = new Size(65, 65);
|
||||||
buttonAdd.TabIndex = 0;
|
buttonAdd.TabIndex = 0;
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
//
|
//
|
||||||
// dataGridViewData
|
// dataGridViewData
|
||||||
//
|
//
|
||||||
@ -74,6 +75,7 @@
|
|||||||
buttonUpdate.Size = new Size(65, 65);
|
buttonUpdate.Size = new Size(65, 65);
|
||||||
buttonUpdate.TabIndex = 1;
|
buttonUpdate.TabIndex = 1;
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpdate.Click += ButtonUpdate_Click;
|
||||||
//
|
//
|
||||||
// buttonDelete
|
// buttonDelete
|
||||||
//
|
//
|
||||||
@ -84,6 +86,7 @@
|
|||||||
buttonDelete.Size = new Size(65, 65);
|
buttonDelete.Size = new Size(65, 65);
|
||||||
buttonDelete.TabIndex = 1;
|
buttonDelete.TabIndex = 1;
|
||||||
buttonDelete.UseVisualStyleBackColor = true;
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
|
buttonDelete.Click += ButtonDelete_Click;
|
||||||
//
|
//
|
||||||
// panel1
|
// panel1
|
||||||
//
|
//
|
||||||
@ -106,6 +109,7 @@
|
|||||||
Name = "FormOrders";
|
Name = "FormOrders";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "FormOrders";
|
Text = "FormOrders";
|
||||||
|
Load += FormOrders_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||||
panel1.ResumeLayout(false);
|
panel1.ResumeLayout(false);
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
@ -36,13 +36,19 @@
|
|||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
checkedListBoxConfectionaryType = new CheckedListBox();
|
checkedListBoxConfectionaryType = new CheckedListBox();
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
dataGridViewComponents = new DataGridView();
|
||||||
|
ColumnComponent = new DataGridViewComboBoxColumn();
|
||||||
|
ColumnWeight = new DataGridViewTextBoxColumn();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewComponents).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// numericUpDownPrice
|
// numericUpDownPrice
|
||||||
//
|
//
|
||||||
numericUpDownPrice.DecimalPlaces = 2;
|
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.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
|
||||||
numericUpDownPrice.Name = "numericUpDownPrice";
|
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||||
numericUpDownPrice.Size = new Size(96, 23);
|
numericUpDownPrice.Size = new Size(96, 23);
|
||||||
@ -59,7 +65,7 @@
|
|||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
label2.AutoSize = true;
|
label2.AutoSize = true;
|
||||||
label2.Location = new Point(106, 210);
|
label2.Location = new Point(106, 203);
|
||||||
label2.Name = "label2";
|
label2.Name = "label2";
|
||||||
label2.Size = new Size(38, 15);
|
label2.Size = new Size(38, 15);
|
||||||
label2.TabIndex = 6;
|
label2.TabIndex = 6;
|
||||||
@ -85,7 +91,8 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(297, 286);
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonCancel.Location = new Point(297, 544);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(75, 23);
|
buttonCancel.Size = new Size(75, 23);
|
||||||
buttonCancel.TabIndex = 11;
|
buttonCancel.TabIndex = 11;
|
||||||
@ -95,7 +102,8 @@
|
|||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
buttonSave.Location = new Point(216, 286);
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonSave.Location = new Point(216, 544);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(75, 23);
|
buttonSave.Size = new Size(75, 23);
|
||||||
buttonSave.TabIndex = 10;
|
buttonSave.TabIndex = 10;
|
||||||
@ -111,11 +119,50 @@
|
|||||||
checkedListBoxConfectionaryType.Size = new Size(207, 112);
|
checkedListBoxConfectionaryType.Size = new Size(207, 112);
|
||||||
checkedListBoxConfectionaryType.TabIndex = 12;
|
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
|
// FormProduct
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(384, 321);
|
ClientSize = new Size(384, 579);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
Controls.Add(checkedListBoxConfectionaryType);
|
Controls.Add(checkedListBoxConfectionaryType);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
@ -128,6 +175,8 @@
|
|||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "FormProduct";
|
Text = "FormProduct";
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewComponents).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -141,5 +190,9 @@
|
|||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private CheckedListBox checkedListBoxConfectionaryType;
|
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;
|
||||||
using ProjectConfectionaryFactory.Entities.Enums;
|
using ProjectConfectionaryFactory.Entities.Enums;
|
||||||
using ProjectConfectionaryFactory.Repositories;
|
using ProjectConfectionaryFactory.Repositories;
|
||||||
|
using ProjectConfectionaryFactory.Repositories.Implementations;
|
||||||
|
|
||||||
namespace ProjectConfectionaryFactory.Forms
|
namespace ProjectConfectionaryFactory.Forms
|
||||||
{
|
{
|
||||||
@ -41,21 +42,26 @@ namespace ProjectConfectionaryFactory.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FormProduct(IProductRepository productRepository)
|
public FormProduct(IProductRepository productRepository, IComponentRepository componentRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
||||||
|
|
||||||
foreach (var elem in Enum.GetValues(typeof(ConfectionaryType)))
|
foreach (var elem in Enum.GetValues(typeof(ConfectionaryType)))
|
||||||
{
|
{
|
||||||
checkedListBoxConfectionaryType.Items.Add(elem);
|
checkedListBoxConfectionaryType.Items.Add(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ColumnComponent.DataSource = componentRepository.ReadComponents();
|
||||||
|
ColumnComponent.DisplayMember = "Name";
|
||||||
|
ColumnComponent.ValueMember = "Id";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
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("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
@ -77,6 +83,23 @@ namespace ProjectConfectionaryFactory.Forms
|
|||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
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)
|
private Product CreateProduct(int id)
|
||||||
{
|
{
|
||||||
ConfectionaryType confectionaryType = ConfectionaryType.None;
|
ConfectionaryType confectionaryType = ConfectionaryType.None;
|
||||||
@ -88,7 +111,8 @@ namespace ProjectConfectionaryFactory.Forms
|
|||||||
id,
|
id,
|
||||||
confectionaryType,
|
confectionaryType,
|
||||||
textBoxProductName.Text,
|
textBoxProductName.Text,
|
||||||
(double)numericUpDownPrice.Value);
|
(double)numericUpDownPrice.Value,
|
||||||
|
CreateListProductComponentFromDataGrid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,4 +117,10 @@
|
|||||||
<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="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>
|
</root>
|
@ -46,6 +46,7 @@
|
|||||||
buttonUpdate.Size = new Size(65, 65);
|
buttonUpdate.Size = new Size(65, 65);
|
||||||
buttonUpdate.TabIndex = 1;
|
buttonUpdate.TabIndex = 1;
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpdate.Click += ButtonUpdate_Click;
|
||||||
//
|
//
|
||||||
// buttonDelete
|
// buttonDelete
|
||||||
//
|
//
|
||||||
@ -56,6 +57,7 @@
|
|||||||
buttonDelete.Size = new Size(65, 65);
|
buttonDelete.Size = new Size(65, 65);
|
||||||
buttonDelete.TabIndex = 1;
|
buttonDelete.TabIndex = 1;
|
||||||
buttonDelete.UseVisualStyleBackColor = true;
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
|
buttonDelete.Click += ButtonDelete_Click;
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
@ -66,6 +68,7 @@
|
|||||||
buttonAdd.Size = new Size(65, 65);
|
buttonAdd.Size = new Size(65, 65);
|
||||||
buttonAdd.TabIndex = 0;
|
buttonAdd.TabIndex = 0;
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
//
|
//
|
||||||
// dataGridViewData
|
// dataGridViewData
|
||||||
//
|
//
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonCancel.Location = new Point(297, 156);
|
buttonCancel.Location = new Point(297, 156);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(75, 23);
|
buttonCancel.Size = new Size(75, 23);
|
||||||
@ -65,6 +66,7 @@
|
|||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonSave.Location = new Point(216, 156);
|
buttonSave.Location = new Point(216, 156);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(75, 23);
|
buttonSave.Size = new Size(75, 23);
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
buttonUpdate.Size = new Size(65, 65);
|
buttonUpdate.Size = new Size(65, 65);
|
||||||
buttonUpdate.TabIndex = 1;
|
buttonUpdate.TabIndex = 1;
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpdate.Click += ButtonUpdate_Click;
|
||||||
//
|
//
|
||||||
// buttonDelete
|
// buttonDelete
|
||||||
//
|
//
|
||||||
@ -74,6 +75,7 @@
|
|||||||
buttonDelete.Size = new Size(65, 65);
|
buttonDelete.Size = new Size(65, 65);
|
||||||
buttonDelete.TabIndex = 1;
|
buttonDelete.TabIndex = 1;
|
||||||
buttonDelete.UseVisualStyleBackColor = true;
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
|
buttonDelete.Click += ButtonDelete_Click;
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
@ -84,6 +86,7 @@
|
|||||||
buttonAdd.Size = new Size(65, 65);
|
buttonAdd.Size = new Size(65, 65);
|
||||||
buttonAdd.TabIndex = 0;
|
buttonAdd.TabIndex = 0;
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
//
|
//
|
||||||
// panel1
|
// panel1
|
||||||
//
|
//
|
||||||
@ -106,6 +109,7 @@
|
|||||||
Name = "FormSuppliers";
|
Name = "FormSuppliers";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "FormSuppliers";
|
Text = "FormSuppliers";
|
||||||
|
Load += FormSuppliers_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||||
panel1.ResumeLayout(false);
|
panel1.ResumeLayout(false);
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
@ -62,6 +62,7 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonCancel.Location = new Point(297, 251);
|
buttonCancel.Location = new Point(297, 251);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(75, 23);
|
buttonCancel.Size = new Size(75, 23);
|
||||||
@ -72,6 +73,7 @@
|
|||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonSave.Location = new Point(216, 251);
|
buttonSave.Location = new Point(216, 251);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(75, 23);
|
buttonSave.Size = new Size(75, 23);
|
||||||
|
@ -66,7 +66,7 @@ namespace ProjectConfectionaryFactory.Forms
|
|||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
private Supply CreateSupply(int id) => Supply.CreateEntity(
|
private Supply CreateSupply(int id) => Supply.CreateOperation(
|
||||||
id,
|
id,
|
||||||
(int)comboBoxSupplier.SelectedValue!,
|
(int)comboBoxSupplier.SelectedValue!,
|
||||||
(int)comboBoxComponent.SelectedValue!,
|
(int)comboBoxComponent.SelectedValue!,
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
buttonUpdate.Size = new Size(65, 65);
|
buttonUpdate.Size = new Size(65, 65);
|
||||||
buttonUpdate.TabIndex = 1;
|
buttonUpdate.TabIndex = 1;
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpdate.Click += ButtonUpdate_Click;
|
||||||
//
|
//
|
||||||
// buttonDelete
|
// buttonDelete
|
||||||
//
|
//
|
||||||
@ -74,6 +75,7 @@
|
|||||||
buttonDelete.Size = new Size(65, 65);
|
buttonDelete.Size = new Size(65, 65);
|
||||||
buttonDelete.TabIndex = 1;
|
buttonDelete.TabIndex = 1;
|
||||||
buttonDelete.UseVisualStyleBackColor = true;
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
|
buttonDelete.Click += ButtonDelete_Click;
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
@ -84,6 +86,7 @@
|
|||||||
buttonAdd.Size = new Size(65, 65);
|
buttonAdd.Size = new Size(65, 65);
|
||||||
buttonAdd.TabIndex = 0;
|
buttonAdd.TabIndex = 0;
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
//
|
//
|
||||||
// panel1
|
// panel1
|
||||||
//
|
//
|
||||||
@ -106,6 +109,7 @@
|
|||||||
Name = "FormSupplys";
|
Name = "FormSupplys";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "FormSupplys";
|
Text = "FormSupplys";
|
||||||
|
Load += FormSupplys_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
||||||
panel1.ResumeLayout(false);
|
panel1.ResumeLayout(false);
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user