В товарах выпадающий список магазинов, а не ID

Магазины при загрузке формы теперь прогружаются (Load += в дизайнере).
AutoResizeColumn - Fill для дизайнеров форм
This commit is contained in:
sa 2024-12-03 12:56:36 +03:00
parent b379829b47
commit 78706eac6f
10 changed files with 24 additions and 20 deletions

View File

@ -6,11 +6,11 @@ public class Product
public ProductTypeEnum Type { get; private set; } public ProductTypeEnum Type { get; private set; }
public double Power { get; private set; } public double Power { get; private set; }
public int Price { get; private set; } public int Price { get; private set; }
public int StoreId { get; private set; } public int Store { get; private set; }
public float Thickness { get; private set; } public float Thickness { get; private set; }
public string Disease { get; private set; } = string.Empty; public string Disease { get; private set; } = string.Empty;
public static Product CreateEntity(int id, ProductTypeEnum type, double power, int price, int storeId, float thickness, string disease) public static Product CreateEntity(int id, ProductTypeEnum type, double power, int price, int store, float thickness, string disease)
{ {
return new Product return new Product
{ {
@ -18,7 +18,7 @@ public class Product
Type = type, Type = type,
Power = power, Power = power,
Price = price, Price = price,
StoreId = storeId, Store = store,
Thickness = thickness, Thickness = thickness,
Disease = disease ?? string.Empty Disease = disease ?? string.Empty
}; };

View File

@ -85,6 +85,7 @@
// //
dataGridViewData.AllowUserToAddRows = false; dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false; dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill; dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0); dataGridViewData.Location = new Point(0, 0);

View File

@ -1,5 +1,4 @@
using ProjectOpticsStore.Repositories; using ProjectOpticsStore.Repositories;
using ProjectOpticsStore.Repositories.Implementations;
using Unity; using Unity;
namespace ProjectOpticsStore.Forms; namespace ProjectOpticsStore.Forms;

View File

@ -72,6 +72,7 @@
// //
dataGridViewOrders.AllowUserToAddRows = false; dataGridViewOrders.AllowUserToAddRows = false;
dataGridViewOrders.AllowUserToDeleteRows = false; dataGridViewOrders.AllowUserToDeleteRows = false;
dataGridViewOrders.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewOrders.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridViewOrders.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewOrders.Dock = DockStyle.Fill; dataGridViewOrders.Dock = DockStyle.Fill;
dataGridViewOrders.Location = new Point(0, 0); dataGridViewOrders.Location = new Point(0, 0);

View File

@ -1,7 +1,4 @@
using ProjectOpticsStore.Repositories; using ProjectOpticsStore.Repositories;
using ProjectOpticsStore.Entities;
using ProjectOpticsStore.Repositories.Implementations;
namespace ProjectOpticsStore.Forms; namespace ProjectOpticsStore.Forms;
public partial class FormOrders : Form public partial class FormOrders : Form

View File

@ -39,9 +39,9 @@
label6 = new Label(); label6 = new Label();
textBoxPower = new TextBox(); textBoxPower = new TextBox();
textBoxPrice = new TextBox(); textBoxPrice = new TextBox();
textBoxStoreID = new TextBox();
textBoxThickness = new TextBox(); textBoxThickness = new TextBox();
textBoxDisease = new TextBox(); textBoxDisease = new TextBox();
comboBoxStore = new ComboBox();
SuspendLayout(); SuspendLayout();
// //
// buttonSave // buttonSave
@ -140,13 +140,6 @@
textBoxPrice.Size = new Size(254, 27); textBoxPrice.Size = new Size(254, 27);
textBoxPrice.TabIndex = 12; textBoxPrice.TabIndex = 12;
// //
// textBoxStoreID
//
textBoxStoreID.Location = new Point(157, 284);
textBoxStoreID.Name = "textBoxStoreID";
textBoxStoreID.Size = new Size(254, 27);
textBoxStoreID.TabIndex = 13;
//
// textBoxThickness // textBoxThickness
// //
textBoxThickness.Location = new Point(157, 349); textBoxThickness.Location = new Point(157, 349);
@ -162,14 +155,23 @@
textBoxDisease.Size = new Size(254, 67); textBoxDisease.Size = new Size(254, 67);
textBoxDisease.TabIndex = 15; textBoxDisease.TabIndex = 15;
// //
// comboBoxStore
//
comboBoxStore.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxStore.FormattingEnabled = true;
comboBoxStore.Location = new Point(157, 287);
comboBoxStore.Name = "comboBoxStore";
comboBoxStore.Size = new Size(254, 28);
comboBoxStore.TabIndex = 16;
//
// FormProduct // FormProduct
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(436, 545); ClientSize = new Size(436, 545);
Controls.Add(comboBoxStore);
Controls.Add(textBoxDisease); Controls.Add(textBoxDisease);
Controls.Add(textBoxThickness); Controls.Add(textBoxThickness);
Controls.Add(textBoxStoreID);
Controls.Add(textBoxPrice); Controls.Add(textBoxPrice);
Controls.Add(textBoxPower); Controls.Add(textBoxPower);
Controls.Add(label6); Controls.Add(label6);
@ -200,8 +202,8 @@
private Label label6; private Label label6;
private TextBox textBoxPower; private TextBox textBoxPower;
private TextBox textBoxPrice; private TextBox textBoxPrice;
private TextBox textBoxStoreID;
private TextBox textBoxThickness; private TextBox textBoxThickness;
private TextBox textBoxDisease; private TextBox textBoxDisease;
private ComboBox comboBoxStore;
} }
} }

View File

@ -34,7 +34,7 @@ public partial class FormProduct : Form
// Заполнение текстовых полей // Заполнение текстовых полей
textBoxPower.Text = product.Power.ToString(); textBoxPower.Text = product.Power.ToString();
textBoxPrice.Text = product.Price.ToString(); textBoxPrice.Text = product.Price.ToString();
textBoxStoreID.Text = product.StoreId.ToString(); comboBoxStore.Text = product.Store.ToString();
textBoxThickness.Text = product.Thickness.ToString("F2"); textBoxThickness.Text = product.Thickness.ToString("F2");
textBoxDisease.Text = product.Disease; textBoxDisease.Text = product.Disease;
@ -68,7 +68,7 @@ public partial class FormProduct : Form
if (checkedListBoxProductType.CheckedItems.Count == 0 || if (checkedListBoxProductType.CheckedItems.Count == 0 ||
string.IsNullOrWhiteSpace(textBoxPower.Text) || string.IsNullOrWhiteSpace(textBoxPower.Text) ||
string.IsNullOrWhiteSpace(textBoxPrice.Text) || string.IsNullOrWhiteSpace(textBoxPrice.Text) ||
string.IsNullOrWhiteSpace(textBoxStoreID.Text) || string.IsNullOrWhiteSpace(comboBoxStore.Text) ||
string.IsNullOrWhiteSpace(textBoxThickness.Text)) string.IsNullOrWhiteSpace(textBoxThickness.Text))
{ {
throw new Exception("Имеются незаполненные поля."); throw new Exception("Имеются незаполненные поля.");
@ -109,7 +109,7 @@ public partial class FormProduct : Form
productType, productType,
double.Parse(textBoxPower.Text), double.Parse(textBoxPower.Text),
int.Parse(textBoxPrice.Text), int.Parse(textBoxPrice.Text),
int.Parse(textBoxStoreID.Text), int.Parse(comboBoxStore.Text),
float.Parse(textBoxThickness.Text), float.Parse(textBoxThickness.Text),
textBoxDisease.Text textBoxDisease.Text
); );

View File

@ -85,6 +85,7 @@
// //
dataGridViewProducts.AllowUserToAddRows = false; dataGridViewProducts.AllowUserToAddRows = false;
dataGridViewProducts.AllowUserToDeleteRows = false; dataGridViewProducts.AllowUserToDeleteRows = false;
dataGridViewProducts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewProducts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridViewProducts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewProducts.Dock = DockStyle.Fill; dataGridViewProducts.Dock = DockStyle.Fill;
dataGridViewProducts.Location = new Point(0, 0); dataGridViewProducts.Location = new Point(0, 0);

View File

@ -85,6 +85,7 @@
// //
dataGridViewStores.AllowUserToAddRows = false; dataGridViewStores.AllowUserToAddRows = false;
dataGridViewStores.AllowUserToDeleteRows = false; dataGridViewStores.AllowUserToDeleteRows = false;
dataGridViewStores.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewStores.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridViewStores.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewStores.Dock = DockStyle.Fill; dataGridViewStores.Dock = DockStyle.Fill;
dataGridViewStores.Location = new Point(0, 0); dataGridViewStores.Location = new Point(0, 0);
@ -105,6 +106,7 @@
Controls.Add(panelButtons); Controls.Add(panelButtons);
Name = "FormStores"; Name = "FormStores";
Text = "Так сказать магазины"; Text = "Так сказать магазины";
Load += FormStores_Load;
panelButtons.ResumeLayout(false); panelButtons.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewStores).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridViewStores).EndInit();
ResumeLayout(false); ResumeLayout(false);

View File

@ -59,6 +59,7 @@
// //
dataGridViewSupplies.AllowUserToAddRows = false; dataGridViewSupplies.AllowUserToAddRows = false;
dataGridViewSupplies.AllowUserToDeleteRows = false; dataGridViewSupplies.AllowUserToDeleteRows = false;
dataGridViewSupplies.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewSupplies.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridViewSupplies.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewSupplies.Dock = DockStyle.Fill; dataGridViewSupplies.Dock = DockStyle.Fill;
dataGridViewSupplies.Location = new Point(0, 0); dataGridViewSupplies.Location = new Point(0, 0);