В товарах выпадающий список магазинов, а не 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 double Power { 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 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
{
@ -18,7 +18,7 @@ public class Product
Type = type,
Power = power,
Price = price,
StoreId = storeId,
Store = store,
Thickness = thickness,
Disease = disease ?? string.Empty
};

View File

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

View File

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

View File

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

View File

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

View File

@ -39,9 +39,9 @@
label6 = new Label();
textBoxPower = new TextBox();
textBoxPrice = new TextBox();
textBoxStoreID = new TextBox();
textBoxThickness = new TextBox();
textBoxDisease = new TextBox();
comboBoxStore = new ComboBox();
SuspendLayout();
//
// buttonSave
@ -140,13 +140,6 @@
textBoxPrice.Size = new Size(254, 27);
textBoxPrice.TabIndex = 12;
//
// textBoxStoreID
//
textBoxStoreID.Location = new Point(157, 284);
textBoxStoreID.Name = "textBoxStoreID";
textBoxStoreID.Size = new Size(254, 27);
textBoxStoreID.TabIndex = 13;
//
// textBoxThickness
//
textBoxThickness.Location = new Point(157, 349);
@ -162,14 +155,23 @@
textBoxDisease.Size = new Size(254, 67);
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
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(436, 545);
Controls.Add(comboBoxStore);
Controls.Add(textBoxDisease);
Controls.Add(textBoxThickness);
Controls.Add(textBoxStoreID);
Controls.Add(textBoxPrice);
Controls.Add(textBoxPower);
Controls.Add(label6);
@ -200,8 +202,8 @@
private Label label6;
private TextBox textBoxPower;
private TextBox textBoxPrice;
private TextBox textBoxStoreID;
private TextBox textBoxThickness;
private TextBox textBoxDisease;
private ComboBox comboBoxStore;
}
}

View File

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

View File

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

View File

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

View File

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