materials fix + order rework
This commit is contained in:
parent
acdf703e9b
commit
0c8b33903b
@ -11,11 +11,13 @@ namespace ProjectPublishing.Entities
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public string Name { get; private set; }
|
||||
|
||||
public MaterialType MaterialType { get; private set; }
|
||||
|
||||
public static Material CreateMaterial(int id, MaterialType materialType)
|
||||
public static Material CreateMaterial(int id, string name, MaterialType materialType)
|
||||
{
|
||||
return new Material { Id = id, MaterialType = materialType };
|
||||
return new Material { Id = id, Name = name, MaterialType = materialType };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,11 +24,11 @@ namespace ProjectPublishing.Entities
|
||||
|
||||
public int PrintingId { get; private set; }
|
||||
|
||||
public int MaterialsId { get; private set; }
|
||||
public List<Material> Materials { get; private set; }
|
||||
|
||||
public static Order CreateOrder(int id, string description, ProductType productType, int amount, OrderStatus status, int customerId, int printingId, int materialsId)
|
||||
public static Order CreateOrder(int id, string description, ProductType productType, int amount, OrderStatus status, int customerId, int printingId, List<Material> materials)
|
||||
{
|
||||
return new Order { ProductType = productType, Id = id, Amount = amount, Status = status, CustomerId = customerId, PrintingId = printingId, MaterialsId = materialsId, OrderDate = DateTime.Now, Description = description ?? string.Empty };
|
||||
return new Order { ProductType = productType, Id = id, Amount = amount, Status = status, CustomerId = customerId, PrintingId = printingId, Materials = materials, OrderDate = DateTime.Now, Description = description ?? string.Empty };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,12 +32,12 @@
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
покупательToolStripMenuItem = new ToolStripMenuItem();
|
||||
контактнаяПерсонаToolStripMenuItem = new ToolStripMenuItem();
|
||||
заказToolStripMenuItem = new ToolStripMenuItem();
|
||||
материалыToolStripMenuItem = new ToolStripMenuItem();
|
||||
типографияToolStripMenuItem = new ToolStripMenuItem();
|
||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
||||
получениеМатериаловToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||
заказToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -53,7 +53,7 @@
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { покупательToolStripMenuItem, контактнаяПерсонаToolStripMenuItem, заказToolStripMenuItem, материалыToolStripMenuItem, типографияToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { покупательToolStripMenuItem, контактнаяПерсонаToolStripMenuItem, материалыToolStripMenuItem, типографияToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
@ -72,13 +72,6 @@
|
||||
контактнаяПерсонаToolStripMenuItem.Text = "Контактная персона";
|
||||
контактнаяПерсонаToolStripMenuItem.Click += контактнаяПерсонаToolStripMenuItem_Click;
|
||||
//
|
||||
// заказToolStripMenuItem
|
||||
//
|
||||
заказToolStripMenuItem.Name = "заказToolStripMenuItem";
|
||||
заказToolStripMenuItem.Size = new Size(234, 26);
|
||||
заказToolStripMenuItem.Text = "Заказ";
|
||||
заказToolStripMenuItem.Click += заказToolStripMenuItem_Click;
|
||||
//
|
||||
// материалыToolStripMenuItem
|
||||
//
|
||||
материалыToolStripMenuItem.Name = "материалыToolStripMenuItem";
|
||||
@ -95,7 +88,7 @@
|
||||
//
|
||||
// операцииToolStripMenuItem
|
||||
//
|
||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { получениеМатериаловToolStripMenuItem });
|
||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { получениеМатериаловToolStripMenuItem, заказToolStripMenuItem });
|
||||
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
||||
операцииToolStripMenuItem.Size = new Size(95, 24);
|
||||
операцииToolStripMenuItem.Text = "Операции";
|
||||
@ -113,6 +106,13 @@
|
||||
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||
//
|
||||
// заказToolStripMenuItem
|
||||
//
|
||||
заказToolStripMenuItem.Name = "заказToolStripMenuItem";
|
||||
заказToolStripMenuItem.Size = new Size(257, 26);
|
||||
заказToolStripMenuItem.Text = "Заказ";
|
||||
заказToolStripMenuItem.Click += заказToolStripMenuItem_Click;
|
||||
//
|
||||
// FormPublishing
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
@ -134,11 +134,11 @@
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem покупательToolStripMenuItem;
|
||||
private ToolStripMenuItem контактнаяПерсонаToolStripMenuItem;
|
||||
private ToolStripMenuItem заказToolStripMenuItem;
|
||||
private ToolStripMenuItem материалыToolStripMenuItem;
|
||||
private ToolStripMenuItem типографияToolStripMenuItem;
|
||||
private ToolStripMenuItem операцииToolStripMenuItem;
|
||||
private ToolStripMenuItem получениеМатериаловToolStripMenuItem;
|
||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||
private ToolStripMenuItem заказToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,7 @@
|
||||
buttonRemove.Size = new Size(115, 115);
|
||||
buttonRemove.TabIndex = 2;
|
||||
buttonRemove.UseVisualStyleBackColor = true;
|
||||
buttonRemove.Click += buttonRemove_Click;
|
||||
//
|
||||
// buttonEdit
|
||||
//
|
||||
@ -85,6 +86,7 @@
|
||||
buttonEdit.Size = new Size(115, 115);
|
||||
buttonEdit.TabIndex = 1;
|
||||
buttonEdit.UseVisualStyleBackColor = true;
|
||||
buttonEdit.Click += buttonEdit_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
@ -95,6 +97,7 @@
|
||||
buttonAdd.Size = new Size(115, 115);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// FormContactPeople
|
||||
//
|
||||
|
@ -170,7 +170,7 @@
|
||||
<data name="buttonEdit.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vQAADr0BR/uQrQAAA9dJREFUeF7tnS2QE0EQRuOQSCQSiUSeRCKRSCTy5LmTSOTJk0gkEolEIpHIs9Af
|
||||
vAAADrwBlbxySQAAA9dJREFUeF7tnS2QE0EQRuOQSCQSiUSeRCKRSCTy5LmTSOTJk0gkEolEIpHIs9Af
|
||||
VV0V0eSS7fnpSd6regJzlZrvY7IzO5vdAQAAAAAAAAAAAAAAAABAkivzxvxq/jL/mN/Ne/PafGrCGfLE
|
||||
vDUV+CFVitcmnBGvzB9mFPj/vDNVGlgc/W9+MKOQH/OLSQkWJhO+SwkWpUX4LiVYjJbhu5RgEXqE71KC
|
||||
4vQM36UERRkRvksJijEyfJcSFGFG+C4lmIz29WeF71KCiejGjW7kRMGM9JMJk6hSAs1GMIkKJfhp8lUw
|
||||
|
@ -32,11 +32,13 @@
|
||||
buttonSave = new Button();
|
||||
label2 = new Label();
|
||||
comboBoxMaterialType = new ComboBox();
|
||||
label1 = new Label();
|
||||
textBoxName = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(195, 74);
|
||||
buttonCancel.Location = new Point(202, 122);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 13;
|
||||
@ -46,7 +48,7 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(12, 74);
|
||||
buttonSave.Location = new Point(19, 122);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(94, 29);
|
||||
buttonSave.TabIndex = 12;
|
||||
@ -57,7 +59,7 @@
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(12, 15);
|
||||
label2.Location = new Point(19, 63);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(114, 20);
|
||||
label2.TabIndex = 9;
|
||||
@ -67,16 +69,34 @@
|
||||
//
|
||||
comboBoxMaterialType.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxMaterialType.FormattingEnabled = true;
|
||||
comboBoxMaterialType.Location = new Point(138, 12);
|
||||
comboBoxMaterialType.Location = new Point(145, 60);
|
||||
comboBoxMaterialType.Name = "comboBoxMaterialType";
|
||||
comboBoxMaterialType.Size = new Size(151, 28);
|
||||
comboBoxMaterialType.TabIndex = 14;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(19, 18);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(114, 20);
|
||||
label1.TabIndex = 15;
|
||||
label1.Text = "Тип материала";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(145, 15);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(151, 27);
|
||||
textBoxName.TabIndex = 16;
|
||||
//
|
||||
// FormMaterial
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(301, 124);
|
||||
ClientSize = new Size(308, 161);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(comboBoxMaterialType);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
@ -93,5 +113,7 @@
|
||||
private Button buttonSave;
|
||||
private Label label2;
|
||||
private ComboBox comboBoxMaterialType;
|
||||
private Label label1;
|
||||
private TextBox textBoxName;
|
||||
}
|
||||
}
|
@ -30,6 +30,7 @@ namespace ProjectPublishing.Forms
|
||||
{
|
||||
throw new InvalidDataException(nameof(material));
|
||||
}
|
||||
textBoxName.Text = material.Name;
|
||||
comboBoxMaterialType.SelectedItem = material.MaterialType;
|
||||
_materialId = value;
|
||||
}
|
||||
@ -52,7 +53,10 @@ namespace ProjectPublishing.Forms
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (string.IsNullOrWhiteSpace(textBoxName.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля!");
|
||||
}
|
||||
if (_materialId.HasValue)
|
||||
{
|
||||
_materialRepository.UpdateMaterial(CreateMaterial(_materialId.Value));
|
||||
@ -71,6 +75,6 @@ namespace ProjectPublishing.Forms
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private Material CreateMaterial(int id) => Material.CreateMaterial(id, (MaterialType)comboBoxMaterialType.SelectedItem!);
|
||||
private Material CreateMaterial(int id) => Material.CreateMaterial(id, textBoxName.Text, (MaterialType)comboBoxMaterialType.SelectedItem!);
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,7 @@
|
||||
Name = "FormMaterials";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "FormMaterials";
|
||||
Load += FormMaterials_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
panelButtons.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
|
@ -170,7 +170,7 @@
|
||||
<data name="buttonEdit.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vQAADr0BR/uQrQAAA9dJREFUeF7tnS2QE0EQRuOQSCQSiUSeRCKRSCTy5LmTSOTJk0gkEolEIpHIs9Af
|
||||
vAAADrwBlbxySQAAA9dJREFUeF7tnS2QE0EQRuOQSCQSiUSeRCKRSCTy5LmTSOTJk0gkEolEIpHIs9Af
|
||||
VV0V0eSS7fnpSd6regJzlZrvY7IzO5vdAQAAAAAAAAAAAAAAAABAkivzxvxq/jL/mN/Ne/PafGrCGfLE
|
||||
vDUV+CFVitcmnBGvzB9mFPj/vDNVGlgc/W9+MKOQH/OLSQkWJhO+SwkWpUX4LiVYjJbhu5RgEXqE71KC
|
||||
4vQM36UERRkRvksJijEyfJcSFGFG+C4lmIz29WeF71KCiejGjW7kRMGM9JMJk6hSAs1GMIkKJfhp8lUw
|
||||
|
@ -40,11 +40,15 @@
|
||||
label4 = new Label();
|
||||
label5 = new Label();
|
||||
label6 = new Label();
|
||||
label7 = new Label();
|
||||
comboBoxCustomerID = new ComboBox();
|
||||
comboBoxPrintingUD = new ComboBox();
|
||||
comboBoxMaterialsID = new ComboBox();
|
||||
groupBox1 = new GroupBox();
|
||||
dataGridViewMaterials = new DataGridView();
|
||||
columnMaterial = new DataGridViewTextBoxColumn();
|
||||
columnMaterialType = new DataGridViewComboBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownAmount).BeginInit();
|
||||
groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewMaterials).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
@ -157,15 +161,6 @@
|
||||
label6.TabIndex = 23;
|
||||
label6.Text = "ID типографии";
|
||||
//
|
||||
// label7
|
||||
//
|
||||
label7.AutoSize = true;
|
||||
label7.Location = new Point(12, 343);
|
||||
label7.Name = "label7";
|
||||
label7.Size = new Size(112, 20);
|
||||
label7.TabIndex = 25;
|
||||
label7.Text = "ID материалов";
|
||||
//
|
||||
// comboBoxCustomerID
|
||||
//
|
||||
comboBoxCustomerID.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
@ -184,24 +179,49 @@
|
||||
comboBoxPrintingUD.Size = new Size(161, 28);
|
||||
comboBoxPrintingUD.TabIndex = 27;
|
||||
//
|
||||
// comboBoxMaterialsID
|
||||
// groupBox1
|
||||
//
|
||||
comboBoxMaterialsID.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxMaterialsID.FormattingEnabled = true;
|
||||
comboBoxMaterialsID.Location = new Point(144, 340);
|
||||
comboBoxMaterialsID.Name = "comboBoxMaterialsID";
|
||||
comboBoxMaterialsID.Size = new Size(161, 28);
|
||||
comboBoxMaterialsID.TabIndex = 28;
|
||||
groupBox1.Controls.Add(dataGridViewMaterials);
|
||||
groupBox1.Location = new Point(311, 238);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(358, 192);
|
||||
groupBox1.TabIndex = 29;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "groupBox1";
|
||||
//
|
||||
// dataGridViewMaterials
|
||||
//
|
||||
dataGridViewMaterials.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewMaterials.Columns.AddRange(new DataGridViewColumn[] { columnMaterial, columnMaterialType });
|
||||
dataGridViewMaterials.Dock = DockStyle.Fill;
|
||||
dataGridViewMaterials.Location = new Point(3, 23);
|
||||
dataGridViewMaterials.Name = "dataGridViewMaterials";
|
||||
dataGridViewMaterials.RowHeadersWidth = 51;
|
||||
dataGridViewMaterials.Size = new Size(352, 166);
|
||||
dataGridViewMaterials.TabIndex = 0;
|
||||
//
|
||||
// columnMaterial
|
||||
//
|
||||
columnMaterial.HeaderText = "Материал";
|
||||
columnMaterial.MinimumWidth = 6;
|
||||
columnMaterial.Name = "columnMaterial";
|
||||
columnMaterial.Width = 125;
|
||||
//
|
||||
// columnMaterialType
|
||||
//
|
||||
columnMaterialType.HeaderText = "Тип";
|
||||
columnMaterialType.MinimumWidth = 6;
|
||||
columnMaterialType.Name = "columnMaterialType";
|
||||
columnMaterialType.Width = 125;
|
||||
//
|
||||
// FormOrder
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(317, 450);
|
||||
Controls.Add(comboBoxMaterialsID);
|
||||
ClientSize = new Size(674, 451);
|
||||
Controls.Add(groupBox1);
|
||||
Controls.Add(comboBoxPrintingUD);
|
||||
Controls.Add(comboBoxCustomerID);
|
||||
Controls.Add(label7);
|
||||
Controls.Add(label6);
|
||||
Controls.Add(label5);
|
||||
Controls.Add(comboBoxStatus);
|
||||
@ -218,6 +238,8 @@
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "FormOrder";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownAmount).EndInit();
|
||||
groupBox1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewMaterials).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -236,9 +258,11 @@
|
||||
private Label label4;
|
||||
private Label label5;
|
||||
private Label label6;
|
||||
private Label label7;
|
||||
private ComboBox comboBoxCustomerID;
|
||||
private ComboBox comboBoxPrintingUD;
|
||||
private ComboBox comboBoxMaterialsID;
|
||||
private GroupBox groupBox1;
|
||||
private DataGridView dataGridViewMaterials;
|
||||
private DataGridViewTextBoxColumn columnMaterial;
|
||||
private DataGridViewComboBoxColumn columnMaterialType;
|
||||
}
|
||||
}
|
@ -16,35 +16,34 @@ namespace ProjectPublishing.Forms
|
||||
public partial class FormOrder : Form
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private int? _orderId;
|
||||
//private int? _orderId;
|
||||
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var material = _orderRepository.ReadOrderById(value);
|
||||
if (material == null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(material));
|
||||
}
|
||||
textBoxDesc.Text = material.Description;
|
||||
numericUpDownAmount.Value = material.Amount;
|
||||
comboBoxOrderType.SelectedItem = material.ProductType;
|
||||
comboBoxStatus.SelectedItem = material.Status;
|
||||
comboBoxCustomerID.SelectedItem = material.CustomerId;
|
||||
comboBoxPrintingUD.SelectedItem = material.PrintingId;
|
||||
comboBoxMaterialsID.SelectedItem = material.MaterialsId;
|
||||
_orderId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
//public int Id
|
||||
//{
|
||||
// set
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var material = _orderRepository.ReadOrderById(value);
|
||||
// if (material == null)
|
||||
// {
|
||||
// throw new InvalidDataException(nameof(material));
|
||||
// }
|
||||
// textBoxDesc.Text = material.Description;
|
||||
// numericUpDownAmount.Value = material.Amount;
|
||||
// comboBoxOrderType.SelectedItem = material.ProductType;
|
||||
// comboBoxStatus.SelectedItem = material.Status;
|
||||
// comboBoxCustomerID.SelectedItem = material.CustomerId;
|
||||
// comboBoxPrintingUD.SelectedItem = material.PrintingId;
|
||||
// _orderId = value;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
public FormOrder(IOrderRepository orderRepository, ICustomerRepository customerRepository, IPrintingHouseRepository printingHouseRepository, IMaterialRepository materialRepository)
|
||||
{
|
||||
@ -54,7 +53,6 @@ namespace ProjectPublishing.Forms
|
||||
comboBoxStatus.DataSource = Enum.GetValues(typeof(OrderStatus));
|
||||
comboBoxCustomerID.DataSource = customerRepository.ReadCustomers();
|
||||
comboBoxPrintingUD.DataSource = printingHouseRepository.ReadPrintingHouses();
|
||||
comboBoxMaterialsID.DataSource = materialRepository.ReadMaterials();
|
||||
|
||||
comboBoxCustomerID.DisplayMember = "Name";
|
||||
comboBoxCustomerID.ValueMember = "Id";
|
||||
@ -62,23 +60,28 @@ namespace ProjectPublishing.Forms
|
||||
comboBoxPrintingUD.DisplayMember = "Name";
|
||||
comboBoxPrintingUD.ValueMember = "Id";
|
||||
|
||||
comboBoxMaterialsID.DisplayMember = "MaterialType";
|
||||
comboBoxMaterialsID.ValueMember= "Id";
|
||||
|
||||
columnMaterialType.DataSource = materialRepository.ReadMaterials();
|
||||
columnMaterialType.DisplayMember = "Name";
|
||||
columnMaterialType.ValueMember= "Id";
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (_orderId.HasValue)
|
||||
if (dataGridViewMaterials.RowCount < 1)
|
||||
{
|
||||
_orderRepository.UpdateOrder(CreateOrder(_orderId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_orderRepository.UpdateOrder(CreateOrder(0));
|
||||
throw new Exception("Имеются незаполненные поля!");
|
||||
}
|
||||
|
||||
_orderRepository.CreateOrder(Order.CreateOrder(0, textBoxDesc.Text,
|
||||
(ProductType)comboBoxOrderType.SelectedItem!,
|
||||
(int)numericUpDownAmount.Value,
|
||||
(OrderStatus)comboBoxStatus.SelectedItem!,
|
||||
(int)comboBoxCustomerID.SelectedValue!,
|
||||
(int)comboBoxPrintingUD.SelectedValue!,
|
||||
CreateListFromDataGrid()));
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -89,16 +92,30 @@ namespace ProjectPublishing.Forms
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private Order CreateOrder(int id) => Order.CreateOrder
|
||||
(
|
||||
id,
|
||||
textBoxDesc.Text,
|
||||
(ProductType)comboBoxOrderType.SelectedItem!,
|
||||
(int)numericUpDownAmount.Value,
|
||||
(OrderStatus)comboBoxStatus.SelectedItem!,
|
||||
(int)comboBoxCustomerID.SelectedValue!,
|
||||
(int)comboBoxPrintingUD.SelectedValue!,
|
||||
(int)comboBoxMaterialsID.SelectedValue!
|
||||
);
|
||||
//private Order CreateOrder(int id) => Order.CreateOrder
|
||||
// (
|
||||
// id,
|
||||
// textBoxDesc.Text,
|
||||
// (ProductType)comboBoxOrderType.SelectedItem!,
|
||||
// (int)numericUpDownAmount.Value,
|
||||
// (OrderStatus)comboBoxStatus.SelectedItem!,
|
||||
// (int)comboBoxCustomerID.SelectedValue!,
|
||||
// (int)comboBoxPrintingUD.SelectedValue!,
|
||||
// (int)comboBoxMaterialsID.SelectedValue!
|
||||
// );
|
||||
|
||||
private List<Material> CreateListFromDataGrid()
|
||||
{
|
||||
var list = new List<Material>();
|
||||
foreach (DataGridViewRow row in dataGridViewMaterials.Rows)
|
||||
{
|
||||
if (row.Cells["columnMaterial"].Value == null || row.Cells["columnMaterialType"].Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list.Add(Material.CreateMaterial(0, (string)row.Cells["columnMaterial"].Value, (MaterialType)row.Cells["columnMaterialType"].Value));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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="columnMaterial.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="columnMaterialType.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="columnMaterial.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="columnMaterialType.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -32,7 +32,6 @@
|
||||
dataGridView = new DataGridView();
|
||||
panelButtons = new Panel();
|
||||
buttonRemove = new Button();
|
||||
buttonEdit = new Button();
|
||||
buttonAdd = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
panelButtons.SuspendLayout();
|
||||
@ -59,7 +58,6 @@
|
||||
// panelButtons
|
||||
//
|
||||
panelButtons.Controls.Add(buttonRemove);
|
||||
panelButtons.Controls.Add(buttonEdit);
|
||||
panelButtons.Controls.Add(buttonAdd);
|
||||
panelButtons.Dock = DockStyle.Right;
|
||||
panelButtons.Location = new Point(648, 0);
|
||||
@ -77,17 +75,6 @@
|
||||
buttonRemove.UseVisualStyleBackColor = true;
|
||||
buttonRemove.Click += buttonRemove_Click;
|
||||
//
|
||||
// buttonEdit
|
||||
//
|
||||
buttonEdit.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonEdit.Image = (Image)resources.GetObject("buttonEdit.Image");
|
||||
buttonEdit.Location = new Point(23, 133);
|
||||
buttonEdit.Name = "buttonEdit";
|
||||
buttonEdit.Size = new Size(115, 115);
|
||||
buttonEdit.TabIndex = 1;
|
||||
buttonEdit.UseVisualStyleBackColor = true;
|
||||
buttonEdit.Click += buttonEdit_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.BackgroundImageLayout = ImageLayout.Center;
|
||||
@ -120,7 +107,6 @@
|
||||
private DataGridView dataGridView;
|
||||
private Panel panelButtons;
|
||||
private Button buttonRemove;
|
||||
private Button buttonEdit;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
@ -36,25 +36,6 @@ namespace ProjectPublishing.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonEdit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!tryGetIDFromRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<FormOrder>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
loadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonRemove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!tryGetIDFromRow(out var findId))
|
||||
|
@ -165,28 +165,6 @@
|
||||
QBnLZQtBF+NoSXfDm/2npGT+I+EJOTH6TpsQTAxpg9jWnL0TGfLzpl3MkdkhnlJ21yYPFZtjBEOCPibz
|
||||
seTNZBdOltfcL7lBRDIyqM+sD/PUyJ/5O/6Nn+Fn2dyRlLxMdVJWJ/utQRAEQRAEwaSMjf0DMjsRo5UV
|
||||
a8gAAAAASUVORK5CYII=
|
||||
</value>
|
||||
</data>
|
||||
<data name="buttonEdit.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vAAADrwBlbxySQAAA9dJREFUeF7tnS2QE0EQRuOQSCQSiUSeRCKRSCTy5LmTSOTJk0gkEolEIpHIs9Af
|
||||
VV0V0eSS7fnpSd6regJzlZrvY7IzO5vdAQAAAAAAAAAAAAAAAABAkivzxvxq/jL/mN/Ne/PafGrCGfLE
|
||||
vDUV+CFVitcmnBGvzB9mFPj/vDNVGlgc/W9+MKOQH/OLSQkWJhO+SwkWpUX4LiVYjJbhu5RgEXqE71KC
|
||||
4vQM36UERRkRvksJijEyfJcSFGFG+C4lmIz29WeF71KCiejGjW7kRMGM9JMJk6hSAs1GMIkKJfhp8lUw
|
||||
kQoleGvCRGaX4KMJHdBST/fzn//712FmlkArAmjM/jpf37OVS6DPBw2JNnkql0DnDKERh3b4qpaAa4BG
|
||||
HLO9W7EE70xowEvztxkN8r6VSqDTxM9MaMRqJWAPoAOrlEAPlUAnqpdAf0t/EzpStQSEn0RX+5/NY26i
|
||||
VCsB4SfZX+ode6iiSgkIP0m0zl+lBISf5NAmT/USEH6SY3b4qpaA8JMcE75brQSEn+SU8N0qJSD8JFvC
|
||||
d2eXgPCTZMJ3Z5aA8BO0CN+dVQLYSMvwXUqwCD3CdylBcXqG71KCoowI321dAt2QggQjw3dblYClXpIZ
|
||||
4bvZEhB+kpnhu1tLQPhJKoTvnloCwk9SKXz3lBIQfoKK4bvHlgA2Ujl8lxJ0YoXwXUrQmJXCdylBI1YM
|
||||
3+Vp3SQrh89SL8nK4esGD0/qJlg9fO7uJVg5fO3yEX6C1cPXLh9shPAvGMK/YFYOX59bL4WEjawevj4/
|
||||
bITwL5iVw5eEn0DfmSuHz48xJtD2qL8zf0UJP4nOv0cDu4LvTUigtXI0sCt4Y0ISvdkqGtzqEn4DdDJG
|
||||
O2bRAFeWAx2N0A8ZRwNc2TsTGqHzcdEgV5XwG6Kl30rrfpUVGqLlUzTQFeUkbwf0IqNosKtJ+B3Q9B8N
|
||||
djU5wduJD2Y04JUk/I58M6NBryLhd0SnY6NBryLHtztzbUYDX0HCH4Cm12jwZ0v4A3hhRoM/Wx7cGITu
|
||||
oEUBzJTj2wPRu/ajEGZJ+AOpdvCD8Adza0ZBzFA3oXhwYzBVDn1ydn8CV2YUxmgJfxIVzv3pO59pfwIV
|
||||
zv3pJA8/zTIJTblRKL3VdK/gudKfjEKIAuql7jTqSR3u5hVA0/+Ic39aYWiZqa1mKETPY98+xXNVX5h7
|
||||
Mwovo6Z4HShlii9Oy+lfU7yexmGKX4g3ZhTmKWoG0dcILMjWzR8dGGGKPwNOWf4xxZ8hjx391vWBpniu
|
||||
4s8UXQRGv/zBFH9hKGjdDZRM8QAAAAAAAAAAAAAAAAA12O3+AseEEu6imt+zAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<data name="buttonAdd.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
|
@ -11,12 +11,8 @@ namespace ProjectPublishing.Repositories
|
||||
{
|
||||
IEnumerable<Order> ReadOrders();
|
||||
|
||||
Order ReadOrderById(int id);
|
||||
|
||||
void CreateOrder(Order order);
|
||||
|
||||
void UpdateOrder(Order order);
|
||||
|
||||
void DeleteOrder(int id);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace ProjectPublishing.Repositories.Implementations
|
||||
|
||||
public Material ReadMaterialById(int id)
|
||||
{
|
||||
return Material.CreateMaterial(0, Entities.Enums.MaterialType.Cardboard);
|
||||
return Material.CreateMaterial(0, "", Entities.Enums.MaterialType.Cardboard);
|
||||
}
|
||||
|
||||
public IEnumerable<Material> ReadMaterials()
|
||||
|
@ -1,5 +1,6 @@
|
||||
using ProjectPublishing.Entities;
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -19,7 +20,7 @@ namespace ProjectPublishing.Repositories.Implementations
|
||||
|
||||
public Order ReadOrderById(int id)
|
||||
{
|
||||
return Order.CreateOrder(0, string.Empty, Entities.Enums.ProductType.Advertisement, 0, Entities.Enums.OrderStatus.Done, 0, 0, 0);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<Order> ReadOrders()
|
||||
|
Loading…
x
Reference in New Issue
Block a user