This commit is contained in:
VictoriaPresnyakova 2023-03-07 13:56:31 +04:00
parent 1108e675fa
commit 72a89c6d61
3 changed files with 48 additions and 104 deletions

View File

@ -31,7 +31,7 @@
this.StoreNameLabel = new System.Windows.Forms.Label(); this.StoreNameLabel = new System.Windows.Forms.Label();
this.StoreAdressLabel = new System.Windows.Forms.Label(); this.StoreAdressLabel = new System.Windows.Forms.Label();
this.OpeningDateLabel = new System.Windows.Forms.Label(); this.OpeningDateLabel = new System.Windows.Forms.Label();
this.NameComboBox = new System.Windows.Forms.ComboBox(); this.NameTextBox = new System.Windows.Forms.TextBox();
this.AdressTextBox = new System.Windows.Forms.TextBox(); this.AdressTextBox = new System.Windows.Forms.TextBox();
this.DataGridView = new System.Windows.Forms.DataGridView(); this.DataGridView = new System.Windows.Forms.DataGridView();
this.JewelName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.JewelName = new System.Windows.Forms.DataGridViewTextBoxColumn();
@ -46,44 +46,47 @@
// StoreNameLabel // StoreNameLabel
// //
this.StoreNameLabel.AutoSize = true; this.StoreNameLabel.AutoSize = true;
this.StoreNameLabel.Location = new System.Drawing.Point(12, 9); this.StoreNameLabel.Location = new System.Drawing.Point(17, 15);
this.StoreNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.StoreNameLabel.Name = "StoreNameLabel"; this.StoreNameLabel.Name = "StoreNameLabel";
this.StoreNameLabel.Size = new System.Drawing.Size(119, 15); this.StoreNameLabel.Size = new System.Drawing.Size(179, 25);
this.StoreNameLabel.TabIndex = 0; this.StoreNameLabel.TabIndex = 0;
this.StoreNameLabel.Text = "Название магазина: "; this.StoreNameLabel.Text = "Название магазина: ";
// //
// StoreAdressLabel // StoreAdressLabel
// //
this.StoreAdressLabel.AutoSize = true; this.StoreAdressLabel.AutoSize = true;
this.StoreAdressLabel.Location = new System.Drawing.Point(12, 40); this.StoreAdressLabel.Location = new System.Drawing.Point(17, 67);
this.StoreAdressLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.StoreAdressLabel.Name = "StoreAdressLabel"; this.StoreAdressLabel.Name = "StoreAdressLabel";
this.StoreAdressLabel.Size = new System.Drawing.Size(100, 15); this.StoreAdressLabel.Size = new System.Drawing.Size(151, 25);
this.StoreAdressLabel.TabIndex = 1; this.StoreAdressLabel.TabIndex = 1;
this.StoreAdressLabel.Text = "Адрес магазина: "; this.StoreAdressLabel.Text = "Адрес магазина: ";
// //
// OpeningDateLabel // OpeningDateLabel
// //
this.OpeningDateLabel.AutoSize = true; this.OpeningDateLabel.AutoSize = true;
this.OpeningDateLabel.Location = new System.Drawing.Point(12, 72); this.OpeningDateLabel.Location = new System.Drawing.Point(17, 120);
this.OpeningDateLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.OpeningDateLabel.Name = "OpeningDateLabel"; this.OpeningDateLabel.Name = "OpeningDateLabel";
this.OpeningDateLabel.Size = new System.Drawing.Size(93, 15); this.OpeningDateLabel.Size = new System.Drawing.Size(140, 25);
this.OpeningDateLabel.TabIndex = 2; this.OpeningDateLabel.TabIndex = 2;
this.OpeningDateLabel.Text = "Дата открытия: "; this.OpeningDateLabel.Text = "Дата открытия: ";
// //
// NameComboBox // NameTextBox
// //
this.NameComboBox.FormattingEnabled = true; this.NameTextBox.Location = new System.Drawing.Point(196, 10);
this.NameComboBox.Location = new System.Drawing.Point(137, 6); this.NameTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.NameComboBox.Name = "NameComboBox"; this.NameTextBox.Name = "NameTextBox";
this.NameComboBox.Size = new System.Drawing.Size(174, 23); this.NameTextBox.Size = new System.Drawing.Size(247, 31);
this.NameComboBox.TabIndex = 3; this.NameTextBox.TabIndex = 3;
this.NameComboBox.SelectedIndexChanged += new System.EventHandler(this.NameComboBox_SelectedIndexChanged);
// //
// AdressTextBox // AdressTextBox
// //
this.AdressTextBox.Location = new System.Drawing.Point(137, 37); this.AdressTextBox.Location = new System.Drawing.Point(196, 62);
this.AdressTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.AdressTextBox.Name = "AdressTextBox"; this.AdressTextBox.Name = "AdressTextBox";
this.AdressTextBox.Size = new System.Drawing.Size(174, 23); this.AdressTextBox.Size = new System.Drawing.Size(247, 31);
this.AdressTextBox.TabIndex = 4; this.AdressTextBox.TabIndex = 4;
// //
// DataGridView // DataGridView
@ -93,33 +96,41 @@
this.JewelName, this.JewelName,
this.JewelPrice, this.JewelPrice,
this.JewelCount}); this.JewelCount});
this.DataGridView.Location = new System.Drawing.Point(12, 109); this.DataGridView.Location = new System.Drawing.Point(17, 182);
this.DataGridView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.DataGridView.Name = "DataGridView"; this.DataGridView.Name = "DataGridView";
this.DataGridView.RowHeadersWidth = 62;
this.DataGridView.RowTemplate.Height = 25; this.DataGridView.RowTemplate.Height = 25;
this.DataGridView.Size = new System.Drawing.Size(776, 288); this.DataGridView.Size = new System.Drawing.Size(1109, 480);
this.DataGridView.TabIndex = 6; this.DataGridView.TabIndex = 6;
// //
// JewelName // JewelName
// //
this.JewelName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.JewelName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.JewelName.HeaderText = "Название изделия"; this.JewelName.HeaderText = "Название изделия";
this.JewelName.MinimumWidth = 8;
this.JewelName.Name = "JewelName"; this.JewelName.Name = "JewelName";
// //
// JewelPrice // JewelPrice
// //
this.JewelPrice.HeaderText = "Цена"; this.JewelPrice.HeaderText = "Цена";
this.JewelPrice.MinimumWidth = 8;
this.JewelPrice.Name = "JewelPrice"; this.JewelPrice.Name = "JewelPrice";
this.JewelPrice.Width = 150;
// //
// JewelCount // JewelCount
// //
this.JewelCount.HeaderText = "Количество"; this.JewelCount.HeaderText = "Количество";
this.JewelCount.MinimumWidth = 8;
this.JewelCount.Name = "JewelCount"; this.JewelCount.Name = "JewelCount";
this.JewelCount.Width = 150;
// //
// SaveButton // SaveButton
// //
this.SaveButton.Location = new System.Drawing.Point(552, 403); this.SaveButton.Location = new System.Drawing.Point(789, 672);
this.SaveButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.SaveButton.Name = "SaveButton"; this.SaveButton.Name = "SaveButton";
this.SaveButton.Size = new System.Drawing.Size(115, 35); this.SaveButton.Size = new System.Drawing.Size(164, 58);
this.SaveButton.TabIndex = 7; this.SaveButton.TabIndex = 7;
this.SaveButton.Text = "Сохранить"; this.SaveButton.Text = "Сохранить";
this.SaveButton.UseVisualStyleBackColor = true; this.SaveButton.UseVisualStyleBackColor = true;
@ -127,9 +138,10 @@
// //
// ButtonCancel // ButtonCancel
// //
this.ButtonCancel.Location = new System.Drawing.Point(673, 403); this.ButtonCancel.Location = new System.Drawing.Point(961, 672);
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.ButtonCancel.Name = "ButtonCancel"; this.ButtonCancel.Name = "ButtonCancel";
this.ButtonCancel.Size = new System.Drawing.Size(115, 35); this.ButtonCancel.Size = new System.Drawing.Size(164, 58);
this.ButtonCancel.TabIndex = 8; this.ButtonCancel.TabIndex = 8;
this.ButtonCancel.Text = "Отменить"; this.ButtonCancel.Text = "Отменить";
this.ButtonCancel.UseVisualStyleBackColor = true; this.ButtonCancel.UseVisualStyleBackColor = true;
@ -137,25 +149,27 @@
// //
// OpeningDatePicker // OpeningDatePicker
// //
this.OpeningDatePicker.Location = new System.Drawing.Point(137, 66); this.OpeningDatePicker.Location = new System.Drawing.Point(196, 110);
this.OpeningDatePicker.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.OpeningDatePicker.Name = "OpeningDatePicker"; this.OpeningDatePicker.Name = "OpeningDatePicker";
this.OpeningDatePicker.Size = new System.Drawing.Size(174, 23); this.OpeningDatePicker.Size = new System.Drawing.Size(247, 31);
this.OpeningDatePicker.TabIndex = 9; this.OpeningDatePicker.TabIndex = 9;
// //
// FormStore // FormStore
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); this.ClientSize = new System.Drawing.Size(1143, 750);
this.Controls.Add(this.OpeningDatePicker); this.Controls.Add(this.OpeningDatePicker);
this.Controls.Add(this.ButtonCancel); this.Controls.Add(this.ButtonCancel);
this.Controls.Add(this.SaveButton); this.Controls.Add(this.SaveButton);
this.Controls.Add(this.DataGridView); this.Controls.Add(this.DataGridView);
this.Controls.Add(this.AdressTextBox); this.Controls.Add(this.AdressTextBox);
this.Controls.Add(this.NameComboBox); this.Controls.Add(this.NameTextBox);
this.Controls.Add(this.OpeningDateLabel); this.Controls.Add(this.OpeningDateLabel);
this.Controls.Add(this.StoreAdressLabel); this.Controls.Add(this.StoreAdressLabel);
this.Controls.Add(this.StoreNameLabel); this.Controls.Add(this.StoreNameLabel);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "FormStore"; this.Name = "FormStore";
this.Text = "Изделия магазина"; this.Text = "Изделия магазина";
this.Load += new System.EventHandler(this.FormStore_Load); this.Load += new System.EventHandler(this.FormStore_Load);
@ -170,7 +184,7 @@
private Label StoreNameLabel; private Label StoreNameLabel;
private Label StoreAdressLabel; private Label StoreAdressLabel;
private Label OpeningDateLabel; private Label OpeningDateLabel;
private ComboBox NameComboBox; private TextBox NameTextBox;
private TextBox AdressTextBox; private TextBox AdressTextBox;
private DataGridView DataGridView; private DataGridView DataGridView;
private Button SaveButton; private Button SaveButton;

View File

@ -28,13 +28,6 @@ namespace JewelryStore
_logger = logger; _logger = logger;
_listStores = logic.ReadList(null); _listStores = logic.ReadList(null);
_logic = logic; _logic = logic;
if (_listStores != null)
{
NameComboBox.DisplayMember = "StoreName";
NameComboBox.ValueMember = "Id";
NameComboBox.DataSource = _listStores;
NameComboBox.SelectedItem = null;
}
} }
private IStoreModel? GetStore(int id) private IStoreModel? GetStore(int id)
@ -55,7 +48,7 @@ namespace JewelryStore
private void SaveButton_Click(object sender, EventArgs e) private void SaveButton_Click(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(NameComboBox.Text)) if (string.IsNullOrEmpty(NameTextBox.Text))
{ {
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
@ -74,7 +67,7 @@ namespace JewelryStore
DateTime.TryParse(OpeningDatePicker.Text, out var dateTime); DateTime.TryParse(OpeningDatePicker.Text, out var dateTime);
StoreBindingModel model = new() StoreBindingModel model = new()
{ {
StoreName = NameComboBox.Text, StoreName = NameTextBox.Text,
StoreAdress = AdressTextBox.Text, StoreAdress = AdressTextBox.Text,
OpeningDate = dateTime OpeningDate = dateTime
}; };
@ -121,10 +114,10 @@ namespace JewelryStore
{ {
try try
{ {
var model = GetStore(extendDate ? Id : Convert.ToInt32(NameComboBox.SelectedValue)); var model = GetStore(extendDate ? Id : Convert.ToInt32(NameTextBox.Text));
if (model != null) if (model != null)
{ {
NameComboBox.Text = model.StoreName; NameTextBox.Text = model.StoreName;
AdressTextBox.Text = model.StoreAdress; AdressTextBox.Text = model.StoreAdress;
OpeningDatePicker.Text = Convert.ToString(model.OpeningDate); OpeningDatePicker.Text = Convert.ToString(model.OpeningDate);
DataGridView.Rows.Clear(); DataGridView.Rows.Clear();
@ -143,9 +136,6 @@ namespace JewelryStore
} }
} }
private void NameComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
LoadData(false);
}
} }
} }

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<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.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">