diff --git a/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.Designer.cs b/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.Designer.cs index 3a7ee25..4078047 100644 --- a/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.Designer.cs +++ b/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.Designer.cs @@ -36,6 +36,8 @@ textBoxSum = new TextBox(); buttonSave = new Button(); buttonCancel = new Button(); + comboBoxClients = new ComboBox(); + labelClient = new Label(); SuspendLayout(); // // labelSecureName @@ -67,33 +69,37 @@ // // comboBoxSecure // + comboBoxSecure.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; comboBoxSecure.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxSecure.FormattingEnabled = true; - comboBoxSecure.Location = new Point(110, 9); + comboBoxSecure.Location = new Point(113, 9); comboBoxSecure.Name = "comboBoxSecure"; - comboBoxSecure.Size = new Size(462, 28); + comboBoxSecure.Size = new Size(469, 28); comboBoxSecure.TabIndex = 0; comboBoxSecure.SelectedIndexChanged += ComboBoxSecure_SelectedIndexChanged; // // textBoxCount // - textBoxCount.Location = new Point(110, 43); + textBoxCount.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxCount.Location = new Point(113, 43); textBoxCount.Name = "textBoxCount"; - textBoxCount.Size = new Size(462, 27); + textBoxCount.Size = new Size(469, 27); textBoxCount.TabIndex = 1; textBoxCount.TextChanged += TextBoxCount_TextChanged; // // textBoxSum // - textBoxSum.Location = new Point(110, 75); + textBoxSum.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBoxSum.Location = new Point(113, 75); textBoxSum.Name = "textBoxSum"; textBoxSum.ReadOnly = true; - textBoxSum.Size = new Size(462, 27); + textBoxSum.Size = new Size(469, 27); textBoxSum.TabIndex = 2; // // buttonSave // - buttonSave.Location = new Point(370, 118); + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonSave.Location = new Point(379, 154); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(94, 29); buttonSave.TabIndex = 3; @@ -103,7 +109,8 @@ // // buttonCancel // - buttonCancel.Location = new Point(478, 118); + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.Location = new Point(487, 154); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(94, 29); buttonCancel.TabIndex = 4; @@ -111,11 +118,32 @@ buttonCancel.UseVisualStyleBackColor = true; buttonCancel.Click += ButtonCancel_Click; // + // comboBoxClients + // + comboBoxClients.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxClients.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxClients.FormattingEnabled = true; + comboBoxClients.Location = new Point(113, 108); + comboBoxClients.Name = "comboBoxClients"; + comboBoxClients.Size = new Size(469, 28); + comboBoxClients.TabIndex = 5; + // + // labelClient + // + labelClient.AutoSize = true; + labelClient.Location = new Point(12, 111); + labelClient.Name = "labelClient"; + labelClient.Size = new Size(63, 20); + labelClient.TabIndex = 6; + labelClient.Text = "Клмент:"; + // // FormCreateOrder // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(586, 160); + ClientSize = new Size(591, 196); + Controls.Add(labelClient); + Controls.Add(comboBoxClients); Controls.Add(buttonCancel); Controls.Add(buttonSave); Controls.Add(textBoxSum); @@ -141,5 +169,7 @@ private TextBox textBoxSum; private Button buttonSave; private Button buttonCancel; + private ComboBox comboBoxClients; + private Label labelClient; } } \ No newline at end of file diff --git a/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.cs b/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.cs index d075ddf..7e7add2 100644 --- a/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.cs +++ b/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.cs @@ -10,33 +10,50 @@ namespace SecuritySystemView private readonly ILogger _logger; private readonly ISecureLogic _logicSecure; private readonly IOrderLogic _logicOrder; - public FormCreateOrder(ILogger logger, ISecureLogic logicSecure, IOrderLogic logicOrder) + private readonly IClientLogic _clientLogic; + public FormCreateOrder(ILogger logger, ISecureLogic logicSecure, IOrderLogic logicOrder, IClientLogic clientLogic) { InitializeComponent(); _logger = logger; _logicSecure = logicSecure; _logicOrder = logicOrder; + _clientLogic = clientLogic; } private void FormCreateOrder_Load(object sender, EventArgs e) { _logger.LogInformation("Загрузка изделий для заказа"); try { - var list = _logicSecure.ReadList(null); - if (list != null) + var listSecures = _logicSecure.ReadList(null); + if (listSecures != null) { comboBoxSecure.DisplayMember = "SecureName"; comboBoxSecure.ValueMember = "Id"; - comboBoxSecure.DataSource = list; + comboBoxSecure.DataSource = listSecures; comboBoxSecure.SelectedItem = null; } - } catch (Exception ex) { _logger.LogError(ex, "Ошибка загрузки списка изделий"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } + try + { + var listClients = _clientLogic.ReadList(null); + if (listSecures != null) + { + comboBoxClients.DisplayMember = "ClientFIO"; + comboBoxClients.ValueMember = "Id"; + comboBoxClients.DataSource = listClients; + comboBoxClients.SelectedItem = null; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка клиентов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } private void CalcSum() { @@ -83,6 +100,12 @@ namespace SecuritySystemView MessageBoxButtons.OK, MessageBoxIcon.Error); return; } + if (comboBoxClients.SelectedValue == null) + { + MessageBox.Show("Выберите клиента", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } _logger.LogInformation("Создание заказа"); try { @@ -90,14 +113,15 @@ namespace SecuritySystemView { SecureId = Convert.ToInt32(comboBoxSecure.SelectedValue), Count = Convert.ToInt32(textBoxCount.Text), - Sum = Convert.ToDouble(textBoxSum.Text) + Sum = Convert.ToDouble(textBoxSum.Text), + ClientId = Convert.ToInt32(comboBoxClients.SelectedValue) }); if (!operationResult) { throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах."); } MessageBox.Show("Сохранение прошло успешно", "Сообщение", - MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; Close(); } diff --git a/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.resx b/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.resx index a395bff..af32865 100644 --- a/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.resx +++ b/SecuritySystem/SecuritySystemView/Order/FormCreateOrder.resx @@ -18,7 +18,7 @@ System.Resources.ResXResourceReader, System.Windows.Forms, ... System.Resources.ResXResourceWriter, System.Windows.Forms, ... this is my long stringthis is a comment - Blue + Blue [base64 mime encoded serialized .NET Framework object]