в форму добавлен выбор клиента

This commit is contained in:
VictoriaPresnyakova 2023-04-03 16:54:22 +04:00
parent c201a83177
commit bbe2fa4b79
3 changed files with 56 additions and 70 deletions

View File

@ -36,12 +36,14 @@
this.textBoxSum = new System.Windows.Forms.TextBox();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.comboBoxClient = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// comboBoxJewel
//
this.comboBoxJewel.FormattingEnabled = true;
this.comboBoxJewel.Location = new System.Drawing.Point(115, 14);
this.comboBoxJewel.Location = new System.Drawing.Point(166, 22);
this.comboBoxJewel.Name = "comboBoxJewel";
this.comboBoxJewel.Size = new System.Drawing.Size(250, 33);
this.comboBoxJewel.TabIndex = 0;
@ -58,7 +60,7 @@
// labelCount
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(12, 67);
this.labelCount.Location = new System.Drawing.Point(12, 70);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(107, 25);
this.labelCount.TabIndex = 2;
@ -67,7 +69,7 @@
// labelSum
//
this.labelSum.AutoSize = true;
this.labelSum.Location = new System.Drawing.Point(12, 118);
this.labelSum.Location = new System.Drawing.Point(12, 174);
this.labelSum.Name = "labelSum";
this.labelSum.Size = new System.Drawing.Size(67, 25);
this.labelSum.TabIndex = 3;
@ -75,7 +77,7 @@
//
// textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(115, 64);
this.textBoxCount.Location = new System.Drawing.Point(166, 72);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(250, 31);
this.textBoxCount.TabIndex = 4;
@ -83,7 +85,7 @@
//
// textBoxSum
//
this.textBoxSum.Location = new System.Drawing.Point(115, 115);
this.textBoxSum.Location = new System.Drawing.Point(166, 176);
this.textBoxSum.Name = "textBoxSum";
this.textBoxSum.ReadOnly = true;
this.textBoxSum.Size = new System.Drawing.Size(250, 31);
@ -91,7 +93,7 @@
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(31, 161);
this.buttonSave.Location = new System.Drawing.Point(74, 234);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(112, 34);
this.buttonSave.TabIndex = 6;
@ -101,7 +103,7 @@
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(253, 161);
this.buttonCancel.Location = new System.Drawing.Point(253, 234);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(112, 34);
this.buttonCancel.TabIndex = 7;
@ -109,11 +111,30 @@
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// comboBoxClient
//
this.comboBoxClient.FormattingEnabled = true;
this.comboBoxClient.Location = new System.Drawing.Point(166, 124);
this.comboBoxClient.Name = "comboBoxClient";
this.comboBoxClient.Size = new System.Drawing.Size(250, 33);
this.comboBoxClient.TabIndex = 8;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 122);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(126, 25);
this.label1.TabIndex = 9;
this.label1.Text = "Пользователь";
//
// FormCreateOrder
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(401, 207);
this.ClientSize = new System.Drawing.Size(550, 292);
this.Controls.Add(this.label1);
this.Controls.Add(this.comboBoxClient);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxSum);
@ -140,5 +161,7 @@
private TextBox textBoxSum;
private Button buttonSave;
private Button buttonCancel;
private ComboBox comboBoxClient;
private Label label1;
}
}

View File

@ -19,12 +19,14 @@ namespace JewelryStore
private readonly ILogger _logger;
private readonly IJewelLogic _logicP;
private readonly IOrderLogic _logicO;
public FormCreateOrder(ILogger<FormCreateOrder> logger, IJewelLogic logicP, IOrderLogic logicO)
private readonly IClientLogic _logicC;
public FormCreateOrder(ILogger<FormCreateOrder> logger, IJewelLogic logicP, IOrderLogic logicO, IClientLogic logicC)
{
InitializeComponent();
_logger = logger;
_logicP = logicP;
_logicO = logicO;
_logicC = logicC;
}
private void OrderForm_Load(object sender, EventArgs e)
@ -47,6 +49,24 @@ namespace JewelryStore
_logger.LogError(ex, "Ошибка загрузки списка драгоценностей");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
_logger.LogInformation("Загрузка клиентов для заказа");
try
{
var list = _logicC.ReadList(null);
if (list != null)
{
comboBoxClient.DisplayMember = "Клиент";
comboBoxClient.ValueMember = "Id";
comboBoxClient.DataSource = list.Select(c => c.ClientFIO).ToList();
comboBoxClient.SelectedItem = null;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка клиентов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void CalcSum()
{
@ -98,6 +118,7 @@ namespace JewelryStore
{
JewelId = Convert.ToInt32(comboBoxJewel.SelectedIndex) + 1,
JewelName = comboBoxJewel.SelectedValue.ToString(),
ClientId = Convert.ToInt32(comboBoxClient.SelectedIndex) + 1,
Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text)
});
@ -123,5 +144,7 @@ namespace JewelryStore
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
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
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">