Исправил
This commit is contained in:
parent
e6926c9455
commit
2aca72eed3
@ -1,13 +0,0 @@
|
||||
namespace GasStation.Entities.Enums;
|
||||
|
||||
[Flags]
|
||||
public enum Gasmen
|
||||
{
|
||||
None = 0,
|
||||
|
||||
Gasman1 = 1,
|
||||
|
||||
Gasman2 = 2,
|
||||
|
||||
Gasman3 = 4
|
||||
}
|
11
GasStation/Entities/Enums/Post.cs
Normal file
11
GasStation/Entities/Enums/Post.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace GasStation.Entities.Enums;
|
||||
|
||||
[Flags]
|
||||
public enum Post
|
||||
{
|
||||
None = 0,
|
||||
|
||||
Gasman = 1,
|
||||
|
||||
Cashier = 2
|
||||
}
|
@ -4,11 +4,9 @@ public enum ProductType
|
||||
{
|
||||
None = 0 ,
|
||||
|
||||
Gas92 = 1 ,
|
||||
Gas = 1 ,
|
||||
|
||||
Gas95 = 2 ,
|
||||
Oil = 2 ,
|
||||
|
||||
Diesel = 3,
|
||||
|
||||
Oil = 4
|
||||
Antifreeze = 3
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace GasStation.Entities;
|
||||
using GasStation.Entities.Enums;
|
||||
|
||||
namespace GasStation.Entities;
|
||||
|
||||
public class Gasman
|
||||
{
|
||||
@ -8,13 +10,16 @@ public class Gasman
|
||||
|
||||
public string PhoneNumber { get; private set; } = string.Empty;
|
||||
|
||||
public static Gasman CreateGasman(int id, string gasmanName, string phoneNumber)
|
||||
public Post Post { get; private set; }
|
||||
|
||||
public static Gasman CreateGasman(int id, string gasmanName, string phoneNumber, Post post)
|
||||
{
|
||||
return new Gasman
|
||||
{
|
||||
Id = id,
|
||||
GasmanName = gasmanName,
|
||||
PhoneNumber = phoneNumber
|
||||
PhoneNumber = phoneNumber,
|
||||
Post = post
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -8,17 +8,14 @@ public class Product
|
||||
|
||||
public int Cost { get; private set; }
|
||||
|
||||
public Gasmen Gasmen { get; private set; }
|
||||
|
||||
public ProductType ProductType { get; private set; }
|
||||
|
||||
public static Product CreateProduct(int id, int cost ,Gasmen gasmen, ProductType productType)
|
||||
public static Product CreateProduct(int id, int cost, ProductType productType)
|
||||
{
|
||||
return new Product
|
||||
{
|
||||
Id = id,
|
||||
Cost = cost,
|
||||
Gasmen = gasmen,
|
||||
ProductType = productType
|
||||
};
|
||||
}
|
||||
|
20
GasStation/Entities/ProductSelling.cs
Normal file
20
GasStation/Entities/ProductSelling.cs
Normal file
@ -0,0 +1,20 @@
|
||||
namespace GasStation.Entities;
|
||||
|
||||
public class ProductSelling
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public int ProductID { get; private set; }
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
public static ProductSelling CreateSelling(int id, int productID, int count)
|
||||
{
|
||||
return new ProductSelling
|
||||
{
|
||||
Id = id,
|
||||
ProductID = productID,
|
||||
Count = count
|
||||
};
|
||||
}
|
||||
}
|
@ -6,21 +6,21 @@ public class Selling
|
||||
|
||||
public int GasmanId { get; private set; }
|
||||
|
||||
public int ProductID { get; private set; }
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
public IEnumerable<ProductSelling> ProdutcSellings { get; private set; } = [];
|
||||
|
||||
public DateTime SellingDateTime { get; private set; }
|
||||
|
||||
public static Selling CreateSelling(int id, int gasmanId, int productID, int count)
|
||||
public static Selling CreateSelling(int id, int gasmanId, int count, IEnumerable<ProductSelling> produtcSellings)
|
||||
{
|
||||
return new Selling
|
||||
{
|
||||
Id = id,
|
||||
GasmanId = gasmanId,
|
||||
ProductID = productID,
|
||||
Count = count,
|
||||
SellingDateTime = DateTime.Now
|
||||
SellingDateTime = DateTime.Now,
|
||||
ProdutcSellings = produtcSellings
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -8,19 +8,19 @@ public class Supply
|
||||
|
||||
public int ProductID { get; private set; }
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
public DateTime SupplyDate { get; private set; }
|
||||
|
||||
public IEnumerable<SupplySupply> SupplySupplies { get; private set; } = [];
|
||||
|
||||
public static Supply CreateSupply(int id, int supplierID, int productID, IEnumerable<SupplySupply> supplySupplies)
|
||||
public static Supply CreateSupply(int id, int supplierID, int productID, int count)
|
||||
{
|
||||
return new Supply
|
||||
{
|
||||
Id = id,
|
||||
SupplierID = supplierID,
|
||||
ProductID = productID,
|
||||
SupplyDate = DateTime.Now,
|
||||
SupplySupplies = supplySupplies
|
||||
Count = count,
|
||||
SupplyDate = DateTime.Now
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
namespace GasStation.Entities;
|
||||
|
||||
public class SupplySupply
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
public static SupplySupply CreateSupply(int id, int count)
|
||||
{
|
||||
return new SupplySupply
|
||||
{
|
||||
Id = id,
|
||||
Count = count
|
||||
};
|
||||
}
|
||||
}
|
29
GasStation/Forms/FormGasman.Designer.cs
generated
29
GasStation/Forms/FormGasman.Designer.cs
generated
@ -34,6 +34,8 @@
|
||||
textBoxNumber = new TextBox();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
label1 = new Label();
|
||||
checkedListBoxPost = new CheckedListBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
@ -70,7 +72,7 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(52, 169);
|
||||
buttonSave.Location = new Point(52, 243);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(75, 23);
|
||||
buttonSave.TabIndex = 4;
|
||||
@ -80,7 +82,7 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(219, 169);
|
||||
buttonCancel.Location = new Point(219, 243);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
buttonCancel.TabIndex = 5;
|
||||
@ -88,11 +90,30 @@
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(34, 133);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(69, 15);
|
||||
label1.TabIndex = 6;
|
||||
label1.Text = "Должность";
|
||||
//
|
||||
// checkedListBoxPost
|
||||
//
|
||||
checkedListBoxPost.FormattingEnabled = true;
|
||||
checkedListBoxPost.Location = new Point(141, 133);
|
||||
checkedListBoxPost.Name = "checkedListBoxPost";
|
||||
checkedListBoxPost.Size = new Size(153, 94);
|
||||
checkedListBoxPost.TabIndex = 7;
|
||||
//
|
||||
// FormGasman
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(421, 248);
|
||||
ClientSize = new Size(421, 291);
|
||||
Controls.Add(checkedListBoxPost);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxNumber);
|
||||
@ -113,5 +134,7 @@
|
||||
private TextBox textBoxNumber;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private Label label1;
|
||||
private CheckedListBox checkedListBoxPost;
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using GasStation.Entities;
|
||||
using GasStation.Entities.Enums;
|
||||
using GasStation.Repositories;
|
||||
|
||||
|
||||
@ -15,6 +16,11 @@ namespace GasStation.Forms
|
||||
InitializeComponent();
|
||||
_gasmanRepository = gasmanRepository ??
|
||||
throw new ArgumentNullException(nameof(gasmanRepository));
|
||||
|
||||
foreach (var elem in Enum.GetValues(typeof(Post)))
|
||||
{
|
||||
checkedListBoxPost.Items.Add(elem);
|
||||
}
|
||||
}
|
||||
|
||||
public int ID
|
||||
@ -29,6 +35,14 @@ namespace GasStation.Forms
|
||||
throw new InvalidDataException(nameof(gasman));
|
||||
}
|
||||
|
||||
foreach (Post elem in Enum.GetValues(typeof(Post)))
|
||||
{
|
||||
if ((elem & gasman.Post) != 0)
|
||||
{
|
||||
checkedListBoxPost.SetItemChecked(checkedListBoxPost.Items.IndexOf(elem), true);
|
||||
}
|
||||
}
|
||||
|
||||
textBoxName.Text = gasman.GasmanName;
|
||||
textBoxNumber.Text = gasman.PhoneNumber;
|
||||
_gasmanId = value;
|
||||
@ -46,7 +60,8 @@ namespace GasStation.Forms
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxName.Text) ||
|
||||
string.IsNullOrWhiteSpace(textBoxNumber.Text))
|
||||
string.IsNullOrWhiteSpace(textBoxNumber.Text) ||
|
||||
checkedListBoxPost.Items.Count == 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненые поля");
|
||||
}
|
||||
@ -69,6 +84,15 @@ namespace GasStation.Forms
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private Gasman CreateGasman(int id) => Gasman.CreateGasman(id, textBoxName.Text, textBoxNumber.Text);
|
||||
private Gasman CreateGasman(int id)
|
||||
{
|
||||
Post post = Post.None;
|
||||
foreach (var elem in checkedListBoxPost.CheckedItems)
|
||||
{
|
||||
post |= (Post)elem;
|
||||
}
|
||||
|
||||
return Gasman.CreateGasman(id, textBoxName.Text, textBoxNumber.Text, post);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
46
GasStation/Forms/FormProduct.Designer.cs
generated
46
GasStation/Forms/FormProduct.Designer.cs
generated
@ -28,30 +28,19 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
numericUpDownCost = new NumericUpDown();
|
||||
comboBoxProduct = new ComboBox();
|
||||
checkedListBoxGasman = new CheckedListBox();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownCost).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(43, 29);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(70, 15);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Заправщик";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(43, 132);
|
||||
label2.Location = new Point(33, 29);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(39, 15);
|
||||
label2.TabIndex = 1;
|
||||
@ -60,7 +49,7 @@
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(47, 202);
|
||||
label3.Location = new Point(33, 99);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(67, 15);
|
||||
label3.TabIndex = 2;
|
||||
@ -68,10 +57,10 @@
|
||||
//
|
||||
// numericUpDownCost
|
||||
//
|
||||
numericUpDownCost.Location = new Point(193, 202);
|
||||
numericUpDownCost.Location = new Point(178, 99);
|
||||
numericUpDownCost.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
numericUpDownCost.Name = "numericUpDownCost";
|
||||
numericUpDownCost.Size = new Size(156, 23);
|
||||
numericUpDownCost.Size = new Size(169, 23);
|
||||
numericUpDownCost.TabIndex = 3;
|
||||
numericUpDownCost.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
//
|
||||
@ -79,24 +68,16 @@
|
||||
//
|
||||
comboBoxProduct.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxProduct.FormattingEnabled = true;
|
||||
comboBoxProduct.Location = new Point(194, 132);
|
||||
comboBoxProduct.Location = new Point(179, 29);
|
||||
comboBoxProduct.Name = "comboBoxProduct";
|
||||
comboBoxProduct.Size = new Size(155, 23);
|
||||
comboBoxProduct.Size = new Size(168, 23);
|
||||
comboBoxProduct.TabIndex = 4;
|
||||
//
|
||||
// checkedListBoxGasman
|
||||
//
|
||||
checkedListBoxGasman.FormattingEnabled = true;
|
||||
checkedListBoxGasman.Location = new Point(194, 29);
|
||||
checkedListBoxGasman.Name = "checkedListBoxGasman";
|
||||
checkedListBoxGasman.Size = new Size(155, 76);
|
||||
checkedListBoxGasman.TabIndex = 5;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(47, 269);
|
||||
buttonSave.Location = new Point(33, 166);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(75, 23);
|
||||
buttonSave.Size = new Size(88, 25);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
@ -104,9 +85,9 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(269, 269);
|
||||
buttonCancel.Location = new Point(254, 166);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(80, 23);
|
||||
buttonCancel.Size = new Size(93, 25);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
@ -116,15 +97,13 @@
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(401, 314);
|
||||
ClientSize = new Size(414, 246);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(checkedListBoxGasman);
|
||||
Controls.Add(comboBoxProduct);
|
||||
Controls.Add(numericUpDownCost);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Name = "FormProduct";
|
||||
Text = "Товар";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownCost).EndInit();
|
||||
@ -133,13 +112,10 @@
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private NumericUpDown numericUpDownCost;
|
||||
private ComboBox comboBoxProduct;
|
||||
private CheckedListBox checkedListBoxGasman;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
using GasStation.Repositories;
|
||||
using GasStation.Entities;
|
||||
|
||||
namespace GasStation.Forms
|
||||
{
|
||||
namespace GasStation.Forms;
|
||||
|
||||
public partial class FormProduct : Form
|
||||
{
|
||||
|
||||
@ -16,10 +16,8 @@ namespace GasStation.Forms
|
||||
InitializeComponent();
|
||||
_productRepository = productRepository ??
|
||||
throw new ArgumentNullException(nameof(productRepository));
|
||||
foreach (var elem in Enum.GetValues(typeof(Gasmen)))
|
||||
{
|
||||
checkedListBoxGasman.Items.Add(elem);
|
||||
}
|
||||
|
||||
comboBoxProduct.DataSource = Enum.GetValues(typeof(ProductType));
|
||||
}
|
||||
|
||||
public int ID
|
||||
@ -34,15 +32,6 @@ namespace GasStation.Forms
|
||||
throw new InvalidDataException(nameof(product));
|
||||
}
|
||||
|
||||
foreach(Gasmen elem in Enum.GetValues(typeof(Gasmen)))
|
||||
{
|
||||
if ((elem & product.Gasmen) != 0)
|
||||
{
|
||||
checkedListBoxGasman.SetItemChecked(checkedListBoxGasman.Items.IndexOf(elem), true);
|
||||
}
|
||||
}
|
||||
|
||||
checkedListBoxGasman.SelectedItem = product.Gasmen;
|
||||
comboBoxProduct.SelectedItem = product.ProductType;
|
||||
_productId = value;
|
||||
}
|
||||
@ -58,7 +47,7 @@ namespace GasStation.Forms
|
||||
{
|
||||
try
|
||||
{
|
||||
if (checkedListBoxGasman.CheckedItems.Count == 0)
|
||||
if (comboBoxProduct.SelectedIndex < 1)
|
||||
{
|
||||
throw new Exception("Имеются незаполненые поля");
|
||||
}
|
||||
@ -81,14 +70,8 @@ namespace GasStation.Forms
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private Product CreateProduct(int id)
|
||||
{
|
||||
Gasmen gasmen = Gasmen.None;
|
||||
foreach (var elem in checkedListBoxGasman.CheckedItems)
|
||||
{
|
||||
gasmen |= (Gasmen)elem;
|
||||
}
|
||||
return Product.CreateProduct(id, Convert.ToInt32(numericUpDownCost.Value), gasmen, (ProductType)comboBoxProduct.SelectedItem!);
|
||||
}
|
||||
}
|
||||
private Product CreateProduct(int id) =>
|
||||
Product.CreateProduct(id, Convert.ToInt32(numericUpDownCost.Value),
|
||||
(ProductType)comboBoxProduct.SelectedItem!);
|
||||
|
||||
}
|
||||
|
114
GasStation/Forms/FormSelling.Designer.cs
generated
114
GasStation/Forms/FormSelling.Designer.cs
generated
@ -29,14 +29,15 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
numericUpDownCount = new NumericUpDown();
|
||||
label3 = new Label();
|
||||
comboBoxGasman = new ComboBox();
|
||||
comboBoxProduct = new ComboBox();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
|
||||
groupBoxSelling = new GroupBox();
|
||||
dataGridViewSelling = new DataGridView();
|
||||
ColumnProduct = new DataGridViewComboBoxColumn();
|
||||
ColumnCount = new DataGridViewTextBoxColumn();
|
||||
groupBoxSelling.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewSelling).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
@ -48,54 +49,19 @@
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Заправщик";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(47, 98);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(39, 15);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Товар";
|
||||
//
|
||||
// numericUpDownCount
|
||||
//
|
||||
numericUpDownCount.Location = new Point(149, 164);
|
||||
numericUpDownCount.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
numericUpDownCount.Name = "numericUpDownCount";
|
||||
numericUpDownCount.Size = new Size(120, 23);
|
||||
numericUpDownCount.TabIndex = 2;
|
||||
numericUpDownCount.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(47, 172);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(46, 15);
|
||||
label3.TabIndex = 3;
|
||||
label3.Text = "Кол-во";
|
||||
//
|
||||
// comboBoxGasman
|
||||
//
|
||||
comboBoxGasman.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxGasman.FormattingEnabled = true;
|
||||
comboBoxGasman.Location = new Point(147, 27);
|
||||
comboBoxGasman.Location = new Point(147, 35);
|
||||
comboBoxGasman.Name = "comboBoxGasman";
|
||||
comboBoxGasman.Size = new Size(121, 23);
|
||||
comboBoxGasman.Size = new Size(200, 23);
|
||||
comboBoxGasman.TabIndex = 4;
|
||||
//
|
||||
// comboBoxProduct
|
||||
//
|
||||
comboBoxProduct.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxProduct.FormattingEnabled = true;
|
||||
comboBoxProduct.Location = new Point(148, 90);
|
||||
comboBoxProduct.Name = "comboBoxProduct";
|
||||
comboBoxProduct.Size = new Size(121, 23);
|
||||
comboBoxProduct.TabIndex = 5;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(47, 238);
|
||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonSave.Location = new Point(47, 358);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(75, 23);
|
||||
buttonSave.TabIndex = 6;
|
||||
@ -105,7 +71,8 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(194, 238);
|
||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCancel.Location = new Point(279, 358);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
buttonCancel.TabIndex = 7;
|
||||
@ -113,22 +80,59 @@
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// groupBoxSelling
|
||||
//
|
||||
groupBoxSelling.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
groupBoxSelling.Controls.Add(dataGridViewSelling);
|
||||
groupBoxSelling.Location = new Point(47, 91);
|
||||
groupBoxSelling.Name = "groupBoxSelling";
|
||||
groupBoxSelling.Size = new Size(307, 211);
|
||||
groupBoxSelling.TabIndex = 8;
|
||||
groupBoxSelling.TabStop = false;
|
||||
groupBoxSelling.Text = "Продажа";
|
||||
//
|
||||
// dataGridViewSelling
|
||||
//
|
||||
dataGridViewSelling.AllowUserToResizeColumns = false;
|
||||
dataGridViewSelling.AllowUserToResizeRows = false;
|
||||
dataGridViewSelling.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewSelling.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewSelling.Columns.AddRange(new DataGridViewColumn[] { ColumnProduct, ColumnCount });
|
||||
dataGridViewSelling.Dock = DockStyle.Fill;
|
||||
dataGridViewSelling.Location = new Point(3, 19);
|
||||
dataGridViewSelling.MultiSelect = false;
|
||||
dataGridViewSelling.Name = "dataGridViewSelling";
|
||||
dataGridViewSelling.RowHeadersVisible = false;
|
||||
dataGridViewSelling.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewSelling.Size = new Size(301, 189);
|
||||
dataGridViewSelling.TabIndex = 0;
|
||||
//
|
||||
// ColumnProduct
|
||||
//
|
||||
ColumnProduct.HeaderText = "Товар";
|
||||
ColumnProduct.Name = "ColumnProduct";
|
||||
ColumnProduct.Resizable = DataGridViewTriState.True;
|
||||
ColumnProduct.SortMode = DataGridViewColumnSortMode.Automatic;
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
ColumnCount.HeaderText = "Количество";
|
||||
ColumnCount.Name = "ColumnCount";
|
||||
//
|
||||
// FormSelling
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(336, 297);
|
||||
ClientSize = new Size(458, 432);
|
||||
Controls.Add(groupBoxSelling);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(comboBoxProduct);
|
||||
Controls.Add(comboBoxGasman);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(numericUpDownCount);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Name = "FormSelling";
|
||||
Text = "Продажа";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
|
||||
groupBoxSelling.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewSelling).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -136,12 +140,12 @@
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private NumericUpDown numericUpDownCount;
|
||||
private Label label3;
|
||||
private ComboBox comboBoxGasman;
|
||||
private ComboBox comboBoxProduct;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private GroupBox groupBoxSelling;
|
||||
private DataGridView dataGridViewSelling;
|
||||
private DataGridViewComboBoxColumn ColumnProduct;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
using GasStation.Entities;
|
||||
using GasStation.Repositories;
|
||||
using GasStation.Repositories.Implementations;
|
||||
|
||||
|
||||
namespace GasStation.Forms
|
||||
@ -19,9 +18,9 @@ namespace GasStation.Forms
|
||||
comboBoxGasman.DisplayMember = "GasmanName";
|
||||
comboBoxGasman.ValueMember = "ID";
|
||||
|
||||
comboBoxProduct.DataSource = productRepository.ReadProduct();
|
||||
comboBoxProduct.DisplayMember = "ProductName";
|
||||
comboBoxProduct.ValueMember = "ID";
|
||||
ColumnProduct.DataSource = productRepository.ReadProduct();
|
||||
ColumnProduct.DisplayMember = "ProductType";
|
||||
ColumnProduct.ValueMember = "ID";
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
@ -29,13 +28,13 @@ namespace GasStation.Forms
|
||||
try
|
||||
{
|
||||
if (comboBoxGasman.SelectedIndex < 0 ||
|
||||
comboBoxProduct.SelectedIndex < 0)
|
||||
dataGridViewSelling.RowCount < 1)
|
||||
{
|
||||
throw new Exception("Имеются незаполненые поля");
|
||||
}
|
||||
|
||||
_sellingRepository.CreateSelling(Selling.CreateSelling(0, (int)comboBoxGasman.SelectedValue!,
|
||||
(int)comboBoxProduct.SelectedValue!, Convert.ToInt32(numericUpDownCount.Value)));
|
||||
0, CreateProductSellingsFromDataGrid()));
|
||||
|
||||
Close();
|
||||
}
|
||||
@ -47,5 +46,23 @@ namespace GasStation.Forms
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private List<ProductSelling> CreateProductSellingsFromDataGrid()
|
||||
{
|
||||
var list = new List<ProductSelling>();
|
||||
foreach (DataGridViewRow row in dataGridViewSelling.Rows)
|
||||
{
|
||||
if (row.Cells["ColumnProduct"].Value == null || row.Cells["ColumnCount"].Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
list.Add(ProductSelling.CreateSelling(0, Convert.ToInt32(row.Cells["ColumnProduct"].Value),
|
||||
Convert.ToInt32(row.Cells["ColumnCount"].Value)));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -117,4 +117,16 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="ColumnProduct.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnProduct.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
107
GasStation/Forms/FormSupply.Designer.cs
generated
107
GasStation/Forms/FormSupply.Designer.cs
generated
@ -31,19 +31,18 @@
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
labelSupplier = new Label();
|
||||
groupBoxSupply = new GroupBox();
|
||||
dataGridViewSupply = new DataGridView();
|
||||
ColumnProduct = new DataGridViewComboBoxColumn();
|
||||
ColumnCount = new DataGridViewTextBoxColumn();
|
||||
comboBoxSupplier = new ComboBox();
|
||||
groupBoxSupply.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewSupply).BeginInit();
|
||||
label1 = new Label();
|
||||
numericUpDownCount = new NumericUpDown();
|
||||
label2 = new Label();
|
||||
comboBoxProduct = new ComboBox();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonSave.Location = new Point(21, 290);
|
||||
buttonSave.Location = new Point(21, 236);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(89, 24);
|
||||
buttonSave.TabIndex = 1;
|
||||
@ -54,7 +53,7 @@
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCancel.Location = new Point(221, 290);
|
||||
buttonCancel.Location = new Point(221, 236);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(92, 24);
|
||||
buttonCancel.TabIndex = 2;
|
||||
@ -71,65 +70,67 @@
|
||||
labelSupplier.TabIndex = 5;
|
||||
labelSupplier.Text = "Поставщик";
|
||||
//
|
||||
// groupBoxSupply
|
||||
//
|
||||
groupBoxSupply.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
groupBoxSupply.Controls.Add(dataGridViewSupply);
|
||||
groupBoxSupply.Location = new Point(21, 62);
|
||||
groupBoxSupply.Name = "groupBoxSupply";
|
||||
groupBoxSupply.Size = new Size(292, 185);
|
||||
groupBoxSupply.TabIndex = 6;
|
||||
groupBoxSupply.TabStop = false;
|
||||
groupBoxSupply.Text = "Поставки";
|
||||
//
|
||||
// dataGridViewSupply
|
||||
//
|
||||
dataGridViewSupply.AllowUserToResizeColumns = false;
|
||||
dataGridViewSupply.AllowUserToResizeRows = false;
|
||||
dataGridViewSupply.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewSupply.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewSupply.Columns.AddRange(new DataGridViewColumn[] { ColumnProduct, ColumnCount });
|
||||
dataGridViewSupply.Dock = DockStyle.Fill;
|
||||
dataGridViewSupply.Location = new Point(3, 19);
|
||||
dataGridViewSupply.Name = "dataGridViewSupply";
|
||||
dataGridViewSupply.RowHeadersVisible = false;
|
||||
dataGridViewSupply.Size = new Size(286, 163);
|
||||
dataGridViewSupply.TabIndex = 0;
|
||||
//
|
||||
// ColumnProduct
|
||||
//
|
||||
ColumnProduct.HeaderText = "Товар";
|
||||
ColumnProduct.Name = "ColumnProduct";
|
||||
ColumnProduct.Resizable = DataGridViewTriState.True;
|
||||
ColumnProduct.SortMode = DataGridViewColumnSortMode.Automatic;
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
ColumnCount.HeaderText = "Кол-во";
|
||||
ColumnCount.Name = "ColumnCount";
|
||||
//
|
||||
// comboBoxSupplier
|
||||
//
|
||||
comboBoxSupplier.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxSupplier.FormattingEnabled = true;
|
||||
comboBoxSupplier.Location = new Point(97, 23);
|
||||
comboBoxSupplier.Name = "comboBoxSupplier";
|
||||
comboBoxSupplier.Size = new Size(216, 23);
|
||||
comboBoxSupplier.TabIndex = 7;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(21, 91);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(66, 15);
|
||||
label1.TabIndex = 8;
|
||||
label1.Text = "Количесто";
|
||||
//
|
||||
// numericUpDownCount
|
||||
//
|
||||
numericUpDownCount.Location = new Point(97, 89);
|
||||
numericUpDownCount.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
numericUpDownCount.Name = "numericUpDownCount";
|
||||
numericUpDownCount.Size = new Size(216, 23);
|
||||
numericUpDownCount.TabIndex = 9;
|
||||
numericUpDownCount.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(21, 147);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(39, 15);
|
||||
label2.TabIndex = 10;
|
||||
label2.Text = "Товар";
|
||||
//
|
||||
// comboBoxProduct
|
||||
//
|
||||
comboBoxProduct.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxProduct.FormattingEnabled = true;
|
||||
comboBoxProduct.Location = new Point(96, 147);
|
||||
comboBoxProduct.Name = "comboBoxProduct";
|
||||
comboBoxProduct.Size = new Size(217, 23);
|
||||
comboBoxProduct.TabIndex = 11;
|
||||
//
|
||||
// FormSupply
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(435, 380);
|
||||
ClientSize = new Size(435, 326);
|
||||
Controls.Add(comboBoxProduct);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(numericUpDownCount);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(comboBoxSupplier);
|
||||
Controls.Add(groupBoxSupply);
|
||||
Controls.Add(labelSupplier);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Name = "FormSupply";
|
||||
Text = "Поставки";
|
||||
groupBoxSupply.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewSupply).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -139,10 +140,10 @@
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private Label labelSupplier;
|
||||
private GroupBox groupBoxSupply;
|
||||
private DataGridView dataGridViewSupply;
|
||||
private ComboBox comboBoxSupplier;
|
||||
private DataGridViewComboBoxColumn ColumnProduct;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
private Label label1;
|
||||
private NumericUpDown numericUpDownCount;
|
||||
private Label label2;
|
||||
private ComboBox comboBoxProduct;
|
||||
}
|
||||
}
|
@ -17,22 +17,23 @@ namespace GasStation.Forms
|
||||
comboBoxSupplier.DisplayMember = "SupplierName";
|
||||
comboBoxSupplier.ValueMember = "ID";
|
||||
|
||||
ColumnProduct.DataSource = productRepository.ReadProduct();
|
||||
ColumnProduct.DisplayMember = "Cost";
|
||||
ColumnProduct.ValueMember = "ID";
|
||||
comboBoxProduct.DataSource = productRepository.ReadProduct();
|
||||
comboBoxProduct.DisplayMember = "ProductType";
|
||||
comboBoxProduct.ValueMember = "ID";
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dataGridViewSupply.RowCount < 1 ||
|
||||
if (comboBoxProduct.SelectedIndex < 0 ||
|
||||
comboBoxSupplier.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненые поля");
|
||||
}
|
||||
|
||||
_supplyRepository.CreateSupply(Supply.CreateSupply(0, (int)comboBoxSupplier.SelectedValue!, 0, CreateListSellingFromDataGrid()));
|
||||
_supplyRepository.CreateSupply(Supply.CreateSupply(0, (int)comboBoxSupplier.SelectedValue!,
|
||||
(int)comboBoxProduct.SelectedValue!, Convert.ToInt32(numericUpDownCount.Value)));
|
||||
|
||||
Close();
|
||||
}
|
||||
@ -45,19 +46,5 @@ namespace GasStation.Forms
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private List<SupplySupply> CreateListSellingFromDataGrid()
|
||||
{
|
||||
var list = new List<SupplySupply>();
|
||||
foreach (DataGridViewRow row in dataGridViewSupply.Rows)
|
||||
{
|
||||
if (row.Cells["ColumnProduct"].Value == null || row.Cells["ColumnCount"].Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list.Add(SupplySupply.CreateSupply(0, Convert.ToInt32(row.Cells["ColumnCount"].Value)));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,16 +117,4 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="ColumnProduct.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnProduct.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -4,7 +4,9 @@ namespace GasStation.Repositories;
|
||||
|
||||
public interface ISellingRepository
|
||||
{
|
||||
IEnumerable<Selling> ReadSelling(DateTime? dateTime = null, int? count = null, int? productID = null, int? gasmanID = null);
|
||||
IEnumerable<Selling> ReadSelling(DateTime? dateTime = null, int? count = null, int? gasmanID = null);
|
||||
|
||||
void CreateSelling(Selling selling);
|
||||
|
||||
void DeleteSelling(int id);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ namespace GasStation.Repositories;
|
||||
|
||||
public interface ISupplyRepository
|
||||
{
|
||||
IEnumerable<Supply> ReadSupply(DateTime? supplyDate = null, int? supplierID = null, int? productID = null);
|
||||
IEnumerable<Supply> ReadSupply(DateTime? supplyDate = null, int? supplierID = null, int? productID = null, int? count = null);
|
||||
|
||||
void CreateSupply(Supply supply);
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using GasStation.Entities;
|
||||
using GasStation.Entities.Enums;
|
||||
|
||||
namespace GasStation.Repositories.Implementations;
|
||||
|
||||
@ -14,7 +15,7 @@ public class GasmanRepository : IGasmanRepository
|
||||
|
||||
public Gasman ReadGasmanByID(int id)
|
||||
{
|
||||
return Gasman.CreateGasman(0, string.Empty, string.Empty);
|
||||
return Gasman.CreateGasman(0, string.Empty, string.Empty, Post.None);
|
||||
}
|
||||
|
||||
public IEnumerable<Gasman> ReadGasman()
|
||||
|
@ -20,7 +20,7 @@ public class ProductRepository : IProductRepository
|
||||
|
||||
public Product ReadProductByID(int id)
|
||||
{
|
||||
return Product.CreateProduct(0, 0, Gasmen.None, ProductType.None);
|
||||
return Product.CreateProduct(0, 0, ProductType.None);
|
||||
}
|
||||
|
||||
public void UpdateProduct(Product product)
|
||||
|
@ -8,7 +8,11 @@ public class SellingRepository : ISellingRepository
|
||||
{
|
||||
}
|
||||
|
||||
public IEnumerable<Selling> ReadSelling(DateTime? dateTime = null, int? count = null, int? productID = null, int? gasmanID = null)
|
||||
public void DeleteSelling(int id)
|
||||
{
|
||||
}
|
||||
|
||||
public IEnumerable<Selling> ReadSelling(DateTime? dateTime = null, int? count = null, int? gasmanID = null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class SupplyRepository : ISupplyRepository
|
||||
{
|
||||
}
|
||||
|
||||
public IEnumerable<Supply> ReadSupply(DateTime? supplyDate = null, int? supplierID = null, int? productID = null)
|
||||
public IEnumerable<Supply> ReadSupply(DateTime? supplyDate = null, int? supplierID = null, int? productID = null, int? count = null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user