From 244e5a811ff11885c76c6c1d957e1bff2ec77769 Mon Sep 17 00:00:00 2001 From: VictoriaPresnyakova Date: Tue, 7 Mar 2023 13:56:31 +0400 Subject: [PATCH] full --- JewelryStore/FormStore.Designer.cs | 70 ++++++++++++++++++------------ JewelryStore/FormStore.cs | 20 +++------ JewelryStore/FormStore.resx | 62 +------------------------- 3 files changed, 48 insertions(+), 104 deletions(-) diff --git a/JewelryStore/FormStore.Designer.cs b/JewelryStore/FormStore.Designer.cs index 583d00c..6713844 100644 --- a/JewelryStore/FormStore.Designer.cs +++ b/JewelryStore/FormStore.Designer.cs @@ -31,7 +31,7 @@ this.StoreNameLabel = new System.Windows.Forms.Label(); this.StoreAdressLabel = 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.DataGridView = new System.Windows.Forms.DataGridView(); this.JewelName = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -46,44 +46,47 @@ // StoreNameLabel // 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.Size = new System.Drawing.Size(119, 15); + this.StoreNameLabel.Size = new System.Drawing.Size(179, 25); this.StoreNameLabel.TabIndex = 0; this.StoreNameLabel.Text = "Название магазина: "; // // StoreAdressLabel // 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.Size = new System.Drawing.Size(100, 15); + this.StoreAdressLabel.Size = new System.Drawing.Size(151, 25); this.StoreAdressLabel.TabIndex = 1; this.StoreAdressLabel.Text = "Адрес магазина: "; // // OpeningDateLabel // 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.Size = new System.Drawing.Size(93, 15); + this.OpeningDateLabel.Size = new System.Drawing.Size(140, 25); this.OpeningDateLabel.TabIndex = 2; this.OpeningDateLabel.Text = "Дата открытия: "; // - // NameComboBox + // NameTextBox // - this.NameComboBox.FormattingEnabled = true; - this.NameComboBox.Location = new System.Drawing.Point(137, 6); - this.NameComboBox.Name = "NameComboBox"; - this.NameComboBox.Size = new System.Drawing.Size(174, 23); - this.NameComboBox.TabIndex = 3; - this.NameComboBox.SelectedIndexChanged += new System.EventHandler(this.NameComboBox_SelectedIndexChanged); + this.NameTextBox.Location = new System.Drawing.Point(196, 10); + this.NameTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.NameTextBox.Name = "NameTextBox"; + this.NameTextBox.Size = new System.Drawing.Size(247, 31); + this.NameTextBox.TabIndex = 3; // // 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.Size = new System.Drawing.Size(174, 23); + this.AdressTextBox.Size = new System.Drawing.Size(247, 31); this.AdressTextBox.TabIndex = 4; // // DataGridView @@ -93,33 +96,41 @@ this.JewelName, this.JewelPrice, 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.RowHeadersWidth = 62; 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; // // JewelName // this.JewelName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.JewelName.HeaderText = "Название изделия"; + this.JewelName.MinimumWidth = 8; this.JewelName.Name = "JewelName"; // // JewelPrice // this.JewelPrice.HeaderText = "Цена"; + this.JewelPrice.MinimumWidth = 8; this.JewelPrice.Name = "JewelPrice"; + this.JewelPrice.Width = 150; // // JewelCount // this.JewelCount.HeaderText = "Количество"; + this.JewelCount.MinimumWidth = 8; this.JewelCount.Name = "JewelCount"; + this.JewelCount.Width = 150; // // 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.Size = new System.Drawing.Size(115, 35); + this.SaveButton.Size = new System.Drawing.Size(164, 58); this.SaveButton.TabIndex = 7; this.SaveButton.Text = "Сохранить"; this.SaveButton.UseVisualStyleBackColor = true; @@ -127,9 +138,10 @@ // // 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.Size = new System.Drawing.Size(115, 35); + this.ButtonCancel.Size = new System.Drawing.Size(164, 58); this.ButtonCancel.TabIndex = 8; this.ButtonCancel.Text = "Отменить"; this.ButtonCancel.UseVisualStyleBackColor = true; @@ -137,25 +149,27 @@ // // 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.Size = new System.Drawing.Size(174, 23); + this.OpeningDatePicker.Size = new System.Drawing.Size(247, 31); this.OpeningDatePicker.TabIndex = 9; // // 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.ClientSize = new System.Drawing.Size(800, 450); + this.ClientSize = new System.Drawing.Size(1143, 750); this.Controls.Add(this.OpeningDatePicker); this.Controls.Add(this.ButtonCancel); this.Controls.Add(this.SaveButton); this.Controls.Add(this.DataGridView); this.Controls.Add(this.AdressTextBox); - this.Controls.Add(this.NameComboBox); + this.Controls.Add(this.NameTextBox); this.Controls.Add(this.OpeningDateLabel); this.Controls.Add(this.StoreAdressLabel); this.Controls.Add(this.StoreNameLabel); + this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.Name = "FormStore"; this.Text = "Изделия магазина"; this.Load += new System.EventHandler(this.FormStore_Load); @@ -170,7 +184,7 @@ private Label StoreNameLabel; private Label StoreAdressLabel; private Label OpeningDateLabel; - private ComboBox NameComboBox; + private TextBox NameTextBox; private TextBox AdressTextBox; private DataGridView DataGridView; private Button SaveButton; diff --git a/JewelryStore/FormStore.cs b/JewelryStore/FormStore.cs index 042d003..f42a421 100644 --- a/JewelryStore/FormStore.cs +++ b/JewelryStore/FormStore.cs @@ -28,13 +28,6 @@ namespace JewelryStore _logger = logger; _listStores = logic.ReadList(null); _logic = logic; - if (_listStores != null) - { - NameComboBox.DisplayMember = "StoreName"; - NameComboBox.ValueMember = "Id"; - NameComboBox.DataSource = _listStores; - NameComboBox.SelectedItem = null; - } } private IStoreModel? GetStore(int id) @@ -55,7 +48,7 @@ namespace JewelryStore private void SaveButton_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(NameComboBox.Text)) + if (string.IsNullOrEmpty(NameTextBox.Text)) { MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -74,7 +67,7 @@ namespace JewelryStore DateTime.TryParse(OpeningDatePicker.Text, out var dateTime); StoreBindingModel model = new() { - StoreName = NameComboBox.Text, + StoreName = NameTextBox.Text, StoreAdress = AdressTextBox.Text, OpeningDate = dateTime }; @@ -121,10 +114,10 @@ namespace JewelryStore { try { - var model = GetStore(extendDate ? Id : Convert.ToInt32(NameComboBox.SelectedValue)); + var model = GetStore(extendDate ? Id : Convert.ToInt32(NameTextBox.Text)); if (model != null) { - NameComboBox.Text = model.StoreName; + NameTextBox.Text = model.StoreName; AdressTextBox.Text = model.StoreAdress; OpeningDatePicker.Text = Convert.ToString(model.OpeningDate); DataGridView.Rows.Clear(); @@ -143,9 +136,6 @@ namespace JewelryStore } } - private void NameComboBox_SelectedIndexChanged(object sender, EventArgs e) - { - LoadData(false); - } + } } diff --git a/JewelryStore/FormStore.resx b/JewelryStore/FormStore.resx index 1af7de1..f298a7b 100644 --- a/JewelryStore/FormStore.resx +++ b/JewelryStore/FormStore.resx @@ -1,64 +1,4 @@ - - - +