Исправил
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 ,
|
None = 0 ,
|
||||||
|
|
||||||
Gas92 = 1 ,
|
Gas = 1 ,
|
||||||
|
|
||||||
Gas95 = 2 ,
|
Oil = 2 ,
|
||||||
|
|
||||||
Diesel = 3,
|
Antifreeze = 3
|
||||||
|
|
||||||
Oil = 4
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace GasStation.Entities;
|
using GasStation.Entities.Enums;
|
||||||
|
|
||||||
|
namespace GasStation.Entities;
|
||||||
|
|
||||||
public class Gasman
|
public class Gasman
|
||||||
{
|
{
|
||||||
@ -8,13 +10,16 @@ public class Gasman
|
|||||||
|
|
||||||
public string PhoneNumber { get; private set; } = string.Empty;
|
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
|
return new Gasman
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
GasmanName = gasmanName,
|
GasmanName = gasmanName,
|
||||||
PhoneNumber = phoneNumber
|
PhoneNumber = phoneNumber,
|
||||||
|
Post = post
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,17 +8,14 @@ public class Product
|
|||||||
|
|
||||||
public int Cost { get; private set; }
|
public int Cost { get; private set; }
|
||||||
|
|
||||||
public Gasmen Gasmen { get; private set; }
|
|
||||||
|
|
||||||
public ProductType ProductType { 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
|
return new Product
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
Cost = cost,
|
Cost = cost,
|
||||||
Gasmen = gasmen,
|
|
||||||
ProductType = productType
|
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 GasmanId { get; private set; }
|
||||||
|
|
||||||
public int ProductID { get; private set; }
|
|
||||||
|
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
|
public IEnumerable<ProductSelling> ProdutcSellings { get; private set; } = [];
|
||||||
|
|
||||||
public DateTime SellingDateTime { 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
|
return new Selling
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
GasmanId = gasmanId,
|
GasmanId = gasmanId,
|
||||||
ProductID = productID,
|
|
||||||
Count = count,
|
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 ProductID { get; private set; }
|
||||||
|
|
||||||
|
public int Count { get; private set; }
|
||||||
|
|
||||||
public DateTime SupplyDate { 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, int count)
|
||||||
|
|
||||||
public static Supply CreateSupply(int id, int supplierID, int productID, IEnumerable<SupplySupply> supplySupplies)
|
|
||||||
{
|
{
|
||||||
return new Supply
|
return new Supply
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
SupplierID = supplierID,
|
SupplierID = supplierID,
|
||||||
ProductID = productID,
|
ProductID = productID,
|
||||||
SupplyDate = DateTime.Now,
|
Count = count,
|
||||||
SupplySupplies = supplySupplies
|
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();
|
textBoxNumber = new TextBox();
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
|
label1 = new Label();
|
||||||
|
checkedListBoxPost = new CheckedListBox();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// labelName
|
// labelName
|
||||||
@ -70,7 +72,7 @@
|
|||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
buttonSave.Location = new Point(52, 169);
|
buttonSave.Location = new Point(52, 243);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(75, 23);
|
buttonSave.Size = new Size(75, 23);
|
||||||
buttonSave.TabIndex = 4;
|
buttonSave.TabIndex = 4;
|
||||||
@ -80,7 +82,7 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(219, 169);
|
buttonCancel.Location = new Point(219, 243);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(75, 23);
|
buttonCancel.Size = new Size(75, 23);
|
||||||
buttonCancel.TabIndex = 5;
|
buttonCancel.TabIndex = 5;
|
||||||
@ -88,11 +90,30 @@
|
|||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
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
|
// FormGasman
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(421, 248);
|
ClientSize = new Size(421, 291);
|
||||||
|
Controls.Add(checkedListBoxPost);
|
||||||
|
Controls.Add(label1);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Controls.Add(textBoxNumber);
|
Controls.Add(textBoxNumber);
|
||||||
@ -113,5 +134,7 @@
|
|||||||
private TextBox textBoxNumber;
|
private TextBox textBoxNumber;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
|
private Label label1;
|
||||||
|
private CheckedListBox checkedListBoxPost;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using GasStation.Entities;
|
using GasStation.Entities;
|
||||||
|
using GasStation.Entities.Enums;
|
||||||
using GasStation.Repositories;
|
using GasStation.Repositories;
|
||||||
|
|
||||||
|
|
||||||
@ -15,6 +16,11 @@ namespace GasStation.Forms
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_gasmanRepository = gasmanRepository ??
|
_gasmanRepository = gasmanRepository ??
|
||||||
throw new ArgumentNullException(nameof(gasmanRepository));
|
throw new ArgumentNullException(nameof(gasmanRepository));
|
||||||
|
|
||||||
|
foreach (var elem in Enum.GetValues(typeof(Post)))
|
||||||
|
{
|
||||||
|
checkedListBoxPost.Items.Add(elem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ID
|
public int ID
|
||||||
@ -29,6 +35,14 @@ namespace GasStation.Forms
|
|||||||
throw new InvalidDataException(nameof(gasman));
|
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;
|
textBoxName.Text = gasman.GasmanName;
|
||||||
textBoxNumber.Text = gasman.PhoneNumber;
|
textBoxNumber.Text = gasman.PhoneNumber;
|
||||||
_gasmanId = value;
|
_gasmanId = value;
|
||||||
@ -46,7 +60,8 @@ namespace GasStation.Forms
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(textBoxName.Text) ||
|
if (string.IsNullOrWhiteSpace(textBoxName.Text) ||
|
||||||
string.IsNullOrWhiteSpace(textBoxNumber.Text))
|
string.IsNullOrWhiteSpace(textBoxNumber.Text) ||
|
||||||
|
checkedListBoxPost.Items.Count == 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненые поля");
|
throw new Exception("Имеются незаполненые поля");
|
||||||
}
|
}
|
||||||
@ -69,6 +84,15 @@ namespace GasStation.Forms
|
|||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
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>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
label1 = new Label();
|
|
||||||
label2 = new Label();
|
label2 = new Label();
|
||||||
label3 = new Label();
|
label3 = new Label();
|
||||||
numericUpDownCost = new NumericUpDown();
|
numericUpDownCost = new NumericUpDown();
|
||||||
comboBoxProduct = new ComboBox();
|
comboBoxProduct = new ComboBox();
|
||||||
checkedListBoxGasman = new CheckedListBox();
|
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownCost).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownCost).BeginInit();
|
||||||
SuspendLayout();
|
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
|
||||||
//
|
//
|
||||||
label2.AutoSize = true;
|
label2.AutoSize = true;
|
||||||
label2.Location = new Point(43, 132);
|
label2.Location = new Point(33, 29);
|
||||||
label2.Name = "label2";
|
label2.Name = "label2";
|
||||||
label2.Size = new Size(39, 15);
|
label2.Size = new Size(39, 15);
|
||||||
label2.TabIndex = 1;
|
label2.TabIndex = 1;
|
||||||
@ -60,7 +49,7 @@
|
|||||||
// label3
|
// label3
|
||||||
//
|
//
|
||||||
label3.AutoSize = true;
|
label3.AutoSize = true;
|
||||||
label3.Location = new Point(47, 202);
|
label3.Location = new Point(33, 99);
|
||||||
label3.Name = "label3";
|
label3.Name = "label3";
|
||||||
label3.Size = new Size(67, 15);
|
label3.Size = new Size(67, 15);
|
||||||
label3.TabIndex = 2;
|
label3.TabIndex = 2;
|
||||||
@ -68,10 +57,10 @@
|
|||||||
//
|
//
|
||||||
// numericUpDownCost
|
// numericUpDownCost
|
||||||
//
|
//
|
||||||
numericUpDownCost.Location = new Point(193, 202);
|
numericUpDownCost.Location = new Point(178, 99);
|
||||||
numericUpDownCost.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
numericUpDownCost.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||||
numericUpDownCost.Name = "numericUpDownCost";
|
numericUpDownCost.Name = "numericUpDownCost";
|
||||||
numericUpDownCost.Size = new Size(156, 23);
|
numericUpDownCost.Size = new Size(169, 23);
|
||||||
numericUpDownCost.TabIndex = 3;
|
numericUpDownCost.TabIndex = 3;
|
||||||
numericUpDownCost.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
numericUpDownCost.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||||
//
|
//
|
||||||
@ -79,24 +68,16 @@
|
|||||||
//
|
//
|
||||||
comboBoxProduct.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxProduct.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxProduct.FormattingEnabled = true;
|
comboBoxProduct.FormattingEnabled = true;
|
||||||
comboBoxProduct.Location = new Point(194, 132);
|
comboBoxProduct.Location = new Point(179, 29);
|
||||||
comboBoxProduct.Name = "comboBoxProduct";
|
comboBoxProduct.Name = "comboBoxProduct";
|
||||||
comboBoxProduct.Size = new Size(155, 23);
|
comboBoxProduct.Size = new Size(168, 23);
|
||||||
comboBoxProduct.TabIndex = 4;
|
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
|
||||||
//
|
//
|
||||||
buttonSave.Location = new Point(47, 269);
|
buttonSave.Location = new Point(33, 166);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(75, 23);
|
buttonSave.Size = new Size(88, 25);
|
||||||
buttonSave.TabIndex = 6;
|
buttonSave.TabIndex = 6;
|
||||||
buttonSave.Text = "Сохранить";
|
buttonSave.Text = "Сохранить";
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
@ -104,9 +85,9 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(269, 269);
|
buttonCancel.Location = new Point(254, 166);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(80, 23);
|
buttonCancel.Size = new Size(93, 25);
|
||||||
buttonCancel.TabIndex = 7;
|
buttonCancel.TabIndex = 7;
|
||||||
buttonCancel.Text = "Отмена";
|
buttonCancel.Text = "Отмена";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
@ -116,15 +97,13 @@
|
|||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(401, 314);
|
ClientSize = new Size(414, 246);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Controls.Add(checkedListBoxGasman);
|
|
||||||
Controls.Add(comboBoxProduct);
|
Controls.Add(comboBoxProduct);
|
||||||
Controls.Add(numericUpDownCost);
|
Controls.Add(numericUpDownCost);
|
||||||
Controls.Add(label3);
|
Controls.Add(label3);
|
||||||
Controls.Add(label2);
|
Controls.Add(label2);
|
||||||
Controls.Add(label1);
|
|
||||||
Name = "FormProduct";
|
Name = "FormProduct";
|
||||||
Text = "Товар";
|
Text = "Товар";
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownCost).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownCost).EndInit();
|
||||||
@ -133,13 +112,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private Label label2;
|
private Label label2;
|
||||||
private Label label3;
|
private Label label3;
|
||||||
private NumericUpDown numericUpDownCost;
|
private NumericUpDown numericUpDownCost;
|
||||||
private ComboBox comboBoxProduct;
|
private ComboBox comboBoxProduct;
|
||||||
private CheckedListBox checkedListBoxGasman;
|
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
}
|
}
|
||||||
|
@ -2,93 +2,76 @@
|
|||||||
using GasStation.Repositories;
|
using GasStation.Repositories;
|
||||||
using GasStation.Entities;
|
using GasStation.Entities;
|
||||||
|
|
||||||
namespace GasStation.Forms
|
namespace GasStation.Forms;
|
||||||
|
|
||||||
|
public partial class FormProduct : Form
|
||||||
{
|
{
|
||||||
public partial class FormProduct : Form
|
|
||||||
|
private readonly IProductRepository _productRepository;
|
||||||
|
|
||||||
|
private int? _productId;
|
||||||
|
|
||||||
|
public FormProduct(IProductRepository productRepository)
|
||||||
{
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_productRepository = productRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(productRepository));
|
||||||
|
|
||||||
private readonly IProductRepository _productRepository;
|
comboBoxProduct.DataSource = Enum.GetValues(typeof(ProductType));
|
||||||
|
}
|
||||||
|
|
||||||
private int? _productId;
|
public int ID
|
||||||
|
{
|
||||||
public FormProduct(IProductRepository productRepository)
|
set
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_productRepository = productRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(productRepository));
|
|
||||||
foreach (var elem in Enum.GetValues(typeof(Gasmen)))
|
|
||||||
{
|
|
||||||
checkedListBoxGasman.Items.Add(elem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ID
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var product = _productRepository.ReadProductByID(value);
|
|
||||||
if (product == null)
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (checkedListBoxGasman.CheckedItems.Count == 0)
|
var product = _productRepository.ReadProductByID(value);
|
||||||
|
if (product == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненые поля");
|
throw new InvalidDataException(nameof(product));
|
||||||
}
|
}
|
||||||
if (_productId.HasValue)
|
|
||||||
{
|
comboBoxProduct.SelectedItem = product.ProductType;
|
||||||
_productRepository.UpdateProduct(CreateProduct(_productId.Value));
|
_productId = value;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_productRepository.CreateProduct(CreateProduct(0));
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
private Product CreateProduct(int id)
|
try
|
||||||
{
|
{
|
||||||
Gasmen gasmen = Gasmen.None;
|
if (comboBoxProduct.SelectedIndex < 1)
|
||||||
foreach (var elem in checkedListBoxGasman.CheckedItems)
|
|
||||||
{
|
{
|
||||||
gasmen |= (Gasmen)elem;
|
throw new Exception("Имеются незаполненые поля");
|
||||||
}
|
}
|
||||||
return Product.CreateProduct(id, Convert.ToInt32(numericUpDownCost.Value), gasmen, (ProductType)comboBoxProduct.SelectedItem!);
|
if (_productId.HasValue)
|
||||||
|
{
|
||||||
|
_productRepository.UpdateProduct(CreateProduct(_productId.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_productRepository.CreateProduct(CreateProduct(0));
|
||||||
|
}
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
|
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()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
label1 = new Label();
|
label1 = new Label();
|
||||||
label2 = new Label();
|
|
||||||
numericUpDownCount = new NumericUpDown();
|
|
||||||
label3 = new Label();
|
|
||||||
comboBoxGasman = new ComboBox();
|
comboBoxGasman = new ComboBox();
|
||||||
comboBoxProduct = new ComboBox();
|
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
buttonCancel = 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();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
@ -48,54 +49,19 @@
|
|||||||
label1.TabIndex = 0;
|
label1.TabIndex = 0;
|
||||||
label1.Text = "Заправщик";
|
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
|
||||||
//
|
//
|
||||||
comboBoxGasman.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxGasman.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxGasman.FormattingEnabled = true;
|
comboBoxGasman.FormattingEnabled = true;
|
||||||
comboBoxGasman.Location = new Point(147, 27);
|
comboBoxGasman.Location = new Point(147, 35);
|
||||||
comboBoxGasman.Name = "comboBoxGasman";
|
comboBoxGasman.Name = "comboBoxGasman";
|
||||||
comboBoxGasman.Size = new Size(121, 23);
|
comboBoxGasman.Size = new Size(200, 23);
|
||||||
comboBoxGasman.TabIndex = 4;
|
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
|
||||||
//
|
//
|
||||||
buttonSave.Location = new Point(47, 238);
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
buttonSave.Location = new Point(47, 358);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(75, 23);
|
buttonSave.Size = new Size(75, 23);
|
||||||
buttonSave.TabIndex = 6;
|
buttonSave.TabIndex = 6;
|
||||||
@ -105,7 +71,8 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(194, 238);
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonCancel.Location = new Point(279, 358);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(75, 23);
|
buttonCancel.Size = new Size(75, 23);
|
||||||
buttonCancel.TabIndex = 7;
|
buttonCancel.TabIndex = 7;
|
||||||
@ -113,22 +80,59 @@
|
|||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
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
|
// FormSelling
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(336, 297);
|
ClientSize = new Size(458, 432);
|
||||||
|
Controls.Add(groupBoxSelling);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Controls.Add(comboBoxProduct);
|
|
||||||
Controls.Add(comboBoxGasman);
|
Controls.Add(comboBoxGasman);
|
||||||
Controls.Add(label3);
|
|
||||||
Controls.Add(numericUpDownCount);
|
|
||||||
Controls.Add(label2);
|
|
||||||
Controls.Add(label1);
|
Controls.Add(label1);
|
||||||
Name = "FormSelling";
|
Name = "FormSelling";
|
||||||
Text = "Продажа";
|
Text = "Продажа";
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
|
groupBoxSelling.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewSelling).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -136,12 +140,12 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Label label1;
|
private Label label1;
|
||||||
private Label label2;
|
|
||||||
private NumericUpDown numericUpDownCount;
|
|
||||||
private Label label3;
|
|
||||||
private ComboBox comboBoxGasman;
|
private ComboBox comboBoxGasman;
|
||||||
private ComboBox comboBoxProduct;
|
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
|
private GroupBox groupBoxSelling;
|
||||||
|
private DataGridView dataGridViewSelling;
|
||||||
|
private DataGridViewComboBoxColumn ColumnProduct;
|
||||||
|
private DataGridViewTextBoxColumn ColumnCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
using GasStation.Entities;
|
using GasStation.Entities;
|
||||||
using GasStation.Repositories;
|
using GasStation.Repositories;
|
||||||
using GasStation.Repositories.Implementations;
|
|
||||||
|
|
||||||
|
|
||||||
namespace GasStation.Forms
|
namespace GasStation.Forms
|
||||||
@ -19,9 +18,9 @@ namespace GasStation.Forms
|
|||||||
comboBoxGasman.DisplayMember = "GasmanName";
|
comboBoxGasman.DisplayMember = "GasmanName";
|
||||||
comboBoxGasman.ValueMember = "ID";
|
comboBoxGasman.ValueMember = "ID";
|
||||||
|
|
||||||
comboBoxProduct.DataSource = productRepository.ReadProduct();
|
ColumnProduct.DataSource = productRepository.ReadProduct();
|
||||||
comboBoxProduct.DisplayMember = "ProductName";
|
ColumnProduct.DisplayMember = "ProductType";
|
||||||
comboBoxProduct.ValueMember = "ID";
|
ColumnProduct.ValueMember = "ID";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
@ -29,13 +28,13 @@ namespace GasStation.Forms
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (comboBoxGasman.SelectedIndex < 0 ||
|
if (comboBoxGasman.SelectedIndex < 0 ||
|
||||||
comboBoxProduct.SelectedIndex < 0)
|
dataGridViewSelling.RowCount < 1)
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненые поля");
|
throw new Exception("Имеются незаполненые поля");
|
||||||
}
|
}
|
||||||
|
|
||||||
_sellingRepository.CreateSelling(Selling.CreateSelling(0, (int)comboBoxGasman.SelectedValue!,
|
_sellingRepository.CreateSelling(Selling.CreateSelling(0, (int)comboBoxGasman.SelectedValue!,
|
||||||
(int)comboBoxProduct.SelectedValue!, Convert.ToInt32(numericUpDownCount.Value)));
|
0, CreateProductSellingsFromDataGrid()));
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
@ -47,5 +46,23 @@ namespace GasStation.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
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">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</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>
|
</root>
|
107
GasStation/Forms/FormSupply.Designer.cs
generated
107
GasStation/Forms/FormSupply.Designer.cs
generated
@ -31,19 +31,18 @@
|
|||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
labelSupplier = new Label();
|
labelSupplier = new Label();
|
||||||
groupBoxSupply = new GroupBox();
|
|
||||||
dataGridViewSupply = new DataGridView();
|
|
||||||
ColumnProduct = new DataGridViewComboBoxColumn();
|
|
||||||
ColumnCount = new DataGridViewTextBoxColumn();
|
|
||||||
comboBoxSupplier = new ComboBox();
|
comboBoxSupplier = new ComboBox();
|
||||||
groupBoxSupply.SuspendLayout();
|
label1 = new Label();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewSupply).BeginInit();
|
numericUpDownCount = new NumericUpDown();
|
||||||
|
label2 = new Label();
|
||||||
|
comboBoxProduct = new ComboBox();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
buttonSave.Location = new Point(21, 290);
|
buttonSave.Location = new Point(21, 236);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(89, 24);
|
buttonSave.Size = new Size(89, 24);
|
||||||
buttonSave.TabIndex = 1;
|
buttonSave.TabIndex = 1;
|
||||||
@ -54,7 +53,7 @@
|
|||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonCancel.Location = new Point(221, 290);
|
buttonCancel.Location = new Point(221, 236);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(92, 24);
|
buttonCancel.Size = new Size(92, 24);
|
||||||
buttonCancel.TabIndex = 2;
|
buttonCancel.TabIndex = 2;
|
||||||
@ -71,65 +70,67 @@
|
|||||||
labelSupplier.TabIndex = 5;
|
labelSupplier.TabIndex = 5;
|
||||||
labelSupplier.Text = "Поставщик";
|
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
|
||||||
//
|
//
|
||||||
|
comboBoxSupplier.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxSupplier.FormattingEnabled = true;
|
comboBoxSupplier.FormattingEnabled = true;
|
||||||
comboBoxSupplier.Location = new Point(97, 23);
|
comboBoxSupplier.Location = new Point(97, 23);
|
||||||
comboBoxSupplier.Name = "comboBoxSupplier";
|
comboBoxSupplier.Name = "comboBoxSupplier";
|
||||||
comboBoxSupplier.Size = new Size(216, 23);
|
comboBoxSupplier.Size = new Size(216, 23);
|
||||||
comboBoxSupplier.TabIndex = 7;
|
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
|
// FormSupply
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
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(comboBoxSupplier);
|
||||||
Controls.Add(groupBoxSupply);
|
|
||||||
Controls.Add(labelSupplier);
|
Controls.Add(labelSupplier);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Name = "FormSupply";
|
Name = "FormSupply";
|
||||||
Text = "Поставки";
|
Text = "Поставки";
|
||||||
groupBoxSupply.ResumeLayout(false);
|
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewSupply).EndInit();
|
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -139,10 +140,10 @@
|
|||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Label labelSupplier;
|
private Label labelSupplier;
|
||||||
private GroupBox groupBoxSupply;
|
|
||||||
private DataGridView dataGridViewSupply;
|
|
||||||
private ComboBox comboBoxSupplier;
|
private ComboBox comboBoxSupplier;
|
||||||
private DataGridViewComboBoxColumn ColumnProduct;
|
private Label label1;
|
||||||
private DataGridViewTextBoxColumn ColumnCount;
|
private NumericUpDown numericUpDownCount;
|
||||||
|
private Label label2;
|
||||||
|
private ComboBox comboBoxProduct;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,22 +17,23 @@ namespace GasStation.Forms
|
|||||||
comboBoxSupplier.DisplayMember = "SupplierName";
|
comboBoxSupplier.DisplayMember = "SupplierName";
|
||||||
comboBoxSupplier.ValueMember = "ID";
|
comboBoxSupplier.ValueMember = "ID";
|
||||||
|
|
||||||
ColumnProduct.DataSource = productRepository.ReadProduct();
|
comboBoxProduct.DataSource = productRepository.ReadProduct();
|
||||||
ColumnProduct.DisplayMember = "Cost";
|
comboBoxProduct.DisplayMember = "ProductType";
|
||||||
ColumnProduct.ValueMember = "ID";
|
comboBoxProduct.ValueMember = "ID";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (dataGridViewSupply.RowCount < 1 ||
|
if (comboBoxProduct.SelectedIndex < 0 ||
|
||||||
comboBoxSupplier.SelectedIndex < 0)
|
comboBoxSupplier.SelectedIndex < 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненые поля");
|
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();
|
Close();
|
||||||
}
|
}
|
||||||
@ -45,19 +46,5 @@ namespace GasStation.Forms
|
|||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
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">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</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>
|
</root>
|
@ -4,7 +4,9 @@ namespace GasStation.Repositories;
|
|||||||
|
|
||||||
public interface ISellingRepository
|
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 CreateSelling(Selling selling);
|
||||||
|
|
||||||
|
void DeleteSelling(int id);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ namespace GasStation.Repositories;
|
|||||||
|
|
||||||
public interface ISupplyRepository
|
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);
|
void CreateSupply(Supply supply);
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using GasStation.Entities;
|
using GasStation.Entities;
|
||||||
|
using GasStation.Entities.Enums;
|
||||||
|
|
||||||
namespace GasStation.Repositories.Implementations;
|
namespace GasStation.Repositories.Implementations;
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ public class GasmanRepository : IGasmanRepository
|
|||||||
|
|
||||||
public Gasman ReadGasmanByID(int id)
|
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()
|
public IEnumerable<Gasman> ReadGasman()
|
||||||
|
@ -20,7 +20,7 @@ public class ProductRepository : IProductRepository
|
|||||||
|
|
||||||
public Product ReadProductByID(int id)
|
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)
|
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 [];
|
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 [];
|
return [];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user