Upload files to 'ShipyardView'

This commit is contained in:
Ivan_Starostin 2024-06-02 17:22:30 +04:00
parent b1ee7c922e
commit 1865aa693a
2 changed files with 304 additions and 259 deletions

View File

@ -36,11 +36,13 @@
labelItem = new Label(); labelItem = new Label();
labelcount = new Label(); labelcount = new Label();
labeltotal = new Label(); labeltotal = new Label();
ComboBoxClient = new ComboBox();
labelClient = new Label();
SuspendLayout(); SuspendLayout();
// //
// textBoxCount // textBoxCount
// //
textBoxCount.Location = new Point(455, 56); textBoxCount.Location = new Point(343, 62);
textBoxCount.Name = "textBoxCount"; textBoxCount.Name = "textBoxCount";
textBoxCount.Size = new Size(125, 27); textBoxCount.Size = new Size(125, 27);
textBoxCount.TabIndex = 1; textBoxCount.TabIndex = 1;
@ -57,7 +59,7 @@
// ComboBoxManufacture // ComboBoxManufacture
// //
ComboBoxManufacture.FormattingEnabled = true; ComboBoxManufacture.FormattingEnabled = true;
ComboBoxManufacture.Location = new Point(271, 55); ComboBoxManufacture.Location = new Point(129, 55);
ComboBoxManufacture.Name = "ComboBoxManufacture"; ComboBoxManufacture.Name = "ComboBoxManufacture";
ComboBoxManufacture.Size = new Size(151, 28); ComboBoxManufacture.Size = new Size(151, 28);
ComboBoxManufacture.TabIndex = 3; ComboBoxManufacture.TabIndex = 3;
@ -86,7 +88,7 @@
// labelItem // labelItem
// //
labelItem.AutoSize = true; labelItem.AutoSize = true;
labelItem.Location = new Point(271, 22); labelItem.Location = new Point(165, 22);
labelItem.Name = "labelItem"; labelItem.Name = "labelItem";
labelItem.Size = new Size(67, 20); labelItem.Size = new Size(67, 20);
labelItem.TabIndex = 6; labelItem.TabIndex = 6;
@ -95,7 +97,7 @@
// labelcount // labelcount
// //
labelcount.AutoSize = true; labelcount.AutoSize = true;
labelcount.Location = new Point(455, 22); labelcount.Location = new Point(360, 22);
labelcount.Name = "labelcount"; labelcount.Name = "labelcount";
labelcount.Size = new Size(88, 20); labelcount.Size = new Size(88, 20);
labelcount.TabIndex = 7; labelcount.TabIndex = 7;
@ -110,11 +112,30 @@
labeltotal.TabIndex = 8; labeltotal.TabIndex = 8;
labeltotal.Text = "итого:"; labeltotal.Text = "итого:";
// //
// ComboBoxClient
//
ComboBoxClient.FormattingEnabled = true;
ComboBoxClient.Location = new Point(511, 62);
ComboBoxClient.Name = "ComboBoxClient";
ComboBoxClient.Size = new Size(151, 28);
ComboBoxClient.TabIndex = 9;
//
// labelClient
//
labelClient.AutoSize = true;
labelClient.Location = new Point(537, 19);
labelClient.Name = "labelClient";
labelClient.Size = new Size(56, 20);
labelClient.TabIndex = 10;
labelClient.Text = "клиент";
//
// FormCreateOrder // FormCreateOrder
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 209); ClientSize = new Size(800, 209);
Controls.Add(labelClient);
Controls.Add(ComboBoxClient);
Controls.Add(labeltotal); Controls.Add(labeltotal);
Controls.Add(labelcount); Controls.Add(labelcount);
Controls.Add(labelItem); Controls.Add(labelItem);
@ -139,5 +160,7 @@
private Label labelItem; private Label labelItem;
private Label labelcount; private Label labelcount;
private Label labeltotal; private Label labeltotal;
private ComboBox ComboBoxClient;
private Label labelClient;
} }
} }

View File

@ -1,5 +1,6 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using ShipyardContracts.BindingModels; using ShipyardContracts.BindingModels;
using ShipyardContracts.BusinessLogicContracts;
using ShipyardContracts.BusinessLogicsContracts; using ShipyardContracts.BusinessLogicsContracts;
using ShipyardContracts.SearchModels; using ShipyardContracts.SearchModels;
@ -10,13 +11,15 @@ namespace ShipyardView
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IShipLogic _logicP; private readonly IShipLogic _logicP;
private readonly IOrderLogic _logicO; private readonly IOrderLogic _logicO;
private readonly IClientLogic _logicC;
public FormCreateOrder(ILogger<FormCreateOrder> logger, IShipLogic public FormCreateOrder(ILogger<FormCreateOrder> logger, IShipLogic
logicP, IOrderLogic logicO) logicP, IOrderLogic logicO, IClientLogic logicC)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logicP = logicP; _logicP = logicP;
_logicO = logicO; _logicO = logicO;
_logicC = logicC;
} }
private void FormCreateOrder_Load(object sender, EventArgs e) private void FormCreateOrder_Load(object sender, EventArgs e)
{ {
@ -39,6 +42,24 @@ namespace ShipyardView
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error); MessageBoxIcon.Error);
} }
_logger.LogInformation("Загрузка клиентов для заказа");
try
{
var list = _logicC.ReadList(null);
if (list != null)
{
ComboBoxClient.DisplayMember = "ClientFIO";
ComboBoxClient.ValueMember = "Id";
ComboBoxClient.DataSource = list;
ComboBoxClient.SelectedItem = null;
}
_logger.LogInformation("Клиенты загружены");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки клиентов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
} }
private void CalcSum() private void CalcSum()
{ {
@ -91,6 +112,7 @@ namespace ShipyardView
var operationResult = _logicO.CreateOrder(new OrderBindingModel var operationResult = _logicO.CreateOrder(new OrderBindingModel
{ {
ShipId = Convert.ToInt32(ComboBoxManufacture.SelectedValue), ShipId = Convert.ToInt32(ComboBoxManufacture.SelectedValue),
ClientId = Convert.ToInt32(ComboBoxClient.SelectedValue),
Count = Convert.ToInt32(textBoxCount.Text), Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text) Sum = Convert.ToDouble(textBoxSum.Text)
}); });