From 798bbe5552fd20f751d1c3782ea923e3499d0ad5 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Wed, 14 Feb 2024 13:55:10 +0400 Subject: [PATCH] FormShop --- .../BlacksmithWorkshop/FormShop.Designer.cs | 180 ++++++++++-------- .../BlacksmithWorkshop/FormShop.cs | 20 +- .../BlacksmithWorkshop/FormShop.resx | 12 ++ 3 files changed, 125 insertions(+), 87 deletions(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.Designer.cs index e9c3004..f949e94 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.Designer.cs @@ -28,77 +28,31 @@ /// private void InitializeComponent() { - DataGridView = new DataGridView(); - dateTimePicker1 = new DateTimePicker(); - labelName = new Label(); - label2 = new Label(); - labelDate = new Label(); - textBox1 = new TextBox(); - textBox2 = new TextBox(); + dataGridView = new DataGridView(); ColumnId = new DataGridViewTextBoxColumn(); ColumnName = new DataGridViewTextBoxColumn(); ColumnPrice = new DataGridViewTextBoxColumn(); ColumnCount = new DataGridViewTextBoxColumn(); - ((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit(); + dateTimePicker = new DateTimePicker(); + labelName = new Label(); + labelAddress = new Label(); + labelDate = new Label(); + textBoxName = new TextBox(); + textBoxAddress = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); // - // DataGridView + // dataGridView // - DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - DataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnName, ColumnPrice, ColumnCount }); - DataGridView.Location = new Point(12, 101); - DataGridView.Name = "DataGridView"; - DataGridView.RowTemplate.Height = 25; - DataGridView.Size = new Size(479, 281); - DataGridView.TabIndex = 0; - // - // dateTimePicker1 - // - dateTimePicker1.Location = new Point(150, 63); - dateTimePicker1.Name = "dateTimePicker1"; - dateTimePicker1.Size = new Size(166, 23); - dateTimePicker1.TabIndex = 1; - // - // labelName - // - labelName.AutoSize = true; - labelName.Location = new Point(12, 9); - labelName.Name = "labelName"; - labelName.Size = new Size(62, 15); - labelName.TabIndex = 2; - labelName.Text = "Название:"; - // - // label2 - // - label2.AutoSize = true; - label2.Location = new Point(12, 38); - label2.Name = "label2"; - label2.Size = new Size(43, 15); - label2.TabIndex = 3; - label2.Text = "Адрес:"; - // - // labelDate - // - labelDate.AutoSize = true; - labelDate.Location = new Point(12, 69); - labelDate.Name = "labelDate"; - labelDate.Size = new Size(90, 15); - labelDate.TabIndex = 4; - labelDate.Text = "Дата открытия:"; - // - // textBox1 - // - textBox1.Location = new Point(150, 6); - textBox1.Name = "textBox1"; - textBox1.Size = new Size(166, 23); - textBox1.TabIndex = 5; - // - // textBox2 - // - textBox2.Location = new Point(150, 35); - textBox2.Name = "textBox2"; - textBox2.Size = new Size(166, 23); - textBox2.TabIndex = 6; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnName, ColumnPrice, ColumnCount }); + dataGridView.Location = new Point(12, 101); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(553, 281); + dataGridView.TabIndex = 0; // // ColumnId // @@ -116,44 +70,116 @@ // ColumnPrice.HeaderText = "Цена"; ColumnPrice.Name = "ColumnPrice"; - ColumnPrice.Width = 236; // // ColumnCount // ColumnCount.HeaderText = "Количество"; ColumnCount.Name = "ColumnCount"; // + // dateTimePicker + // + dateTimePicker.Location = new Point(150, 63); + dateTimePicker.Name = "dateTimePicker"; + dateTimePicker.Size = new Size(166, 23); + dateTimePicker.TabIndex = 1; + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(12, 9); + labelName.Name = "labelName"; + labelName.Size = new Size(62, 15); + labelName.TabIndex = 2; + labelName.Text = "Название:"; + // + // labelAddress + // + labelAddress.AutoSize = true; + labelAddress.Location = new Point(12, 38); + labelAddress.Name = "labelAddress"; + labelAddress.Size = new Size(43, 15); + labelAddress.TabIndex = 3; + labelAddress.Text = "Адрес:"; + // + // labelDate + // + labelDate.AutoSize = true; + labelDate.Location = new Point(12, 69); + labelDate.Name = "labelDate"; + labelDate.Size = new Size(90, 15); + labelDate.TabIndex = 4; + labelDate.Text = "Дата открытия:"; + // + // textBoxName + // + textBoxName.Location = new Point(150, 6); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(166, 23); + textBoxName.TabIndex = 5; + // + // textBoxAddress + // + textBoxAddress.Location = new Point(150, 35); + textBoxAddress.Name = "textBoxAddress"; + textBoxAddress.Size = new Size(166, 23); + textBoxAddress.TabIndex = 6; + // + // buttonSave + // + buttonSave.Location = new Point(12, 401); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(123, 25); + buttonSave.TabIndex = 7; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += SaveButton_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(150, 401); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(123, 25); + buttonCancel.TabIndex = 8; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += CancelButton_Click; + // // FormShop // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); - Controls.Add(textBox2); - Controls.Add(textBox1); + ClientSize = new Size(585, 450); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxAddress); + Controls.Add(textBoxName); Controls.Add(labelDate); - Controls.Add(label2); + Controls.Add(labelAddress); Controls.Add(labelName); - Controls.Add(dateTimePicker1); - Controls.Add(DataGridView); + Controls.Add(dateTimePicker); + Controls.Add(dataGridView); Name = "FormShop"; Text = "FormShop"; - ((System.ComponentModel.ISupportInitialize)DataGridView).EndInit(); + Load += FormShop_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); PerformLayout(); } #endregion - private DataGridView DataGridView; - private DateTimePicker dateTimePicker1; + private DataGridView dataGridView; + private DateTimePicker dateTimePicker; private Label labelName; - private Label label2; + private Label labelAddress; private Label labelDate; - private TextBox textBox1; - private TextBox textBox2; + private TextBox textBoxName; + private TextBox textBoxAddress; private DataGridViewTextBoxColumn ColumnId; private DataGridViewTextBoxColumn ColumnName; private DataGridViewTextBoxColumn ColumnPrice; private DataGridViewTextBoxColumn ColumnCount; + private Button buttonSave; + private Button buttonCancel; } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.cs index 1cfe0fd..9d551fe 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.cs @@ -39,9 +39,9 @@ namespace BlacksmithWorkshop var shop = _logic.ReadElement(new ShopSearchModel { Id = _id }); if (shop != null) { - NameTextBox.Text = shop.ShopName; - AddressTextBox.Text = shop.Address; - DateTimePicker.Text = shop.OpeningDate.ToString(); + textBoxName.Text = shop.ShopName; + textBoxAddress.Text = shop.Address; + dateTimePicker.Text = shop.OpeningDate.ToString(); _manufactures = shop.ShopManufactures; } LoadData(); @@ -63,7 +63,7 @@ namespace BlacksmithWorkshop { foreach (var manufactures in _manufactures) { - System.Windows.Forms.DataGridView.Rows.Add(new object[] { manufactures.Key, manufactures.Value.Item1.ManufactureName, + dataGridView.Rows.Add(new object[] { manufactures.Key, manufactures.Value.Item1.ManufactureName, manufactures.Value.Item1.Price, manufactures.Value.Item2 }); } } @@ -82,12 +82,12 @@ namespace BlacksmithWorkshop } private void SaveButton_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(NameTextBox.Text)) + if (string.IsNullOrEmpty(textBoxName.Text)) { MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (string.IsNullOrEmpty(AddressTextBox.Text)) + if (string.IsNullOrEmpty(textBoxAddress.Text)) { MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; @@ -98,10 +98,10 @@ namespace BlacksmithWorkshop var model = new ShopBindingModel { Id = _id ?? 0, - ShopName = NameTextBox.Text, - Address = AddressTextBox.Text, - DateOpen = DateTimePicker.Value.Date, - ShopComputers = _manufactures + ShopName = textBoxName.Text, + Address = textBoxAddress.Text, + OpeningDate = dateTimePicker.Value.Date, + ShopManufactures = _manufactures }; var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); if (!operationResult) diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.resx index b0c7c5d..ef64542 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.resx +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.resx @@ -129,4 +129,16 @@ True + + True + + + True + + + True + + + True + \ No newline at end of file