fix
This commit is contained in:
parent
47eb037c61
commit
35856195e8
@ -52,7 +52,7 @@ namespace SoftwareInstallationBusinessLogic
|
|||||||
public bool Create(ShopBindingModel model)
|
public bool Create(ShopBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
model.Pastries = new();
|
model.Packages = new();
|
||||||
if (_shopStorage.Insert(model) == null)
|
if (_shopStorage.Insert(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
@ -123,8 +123,7 @@ namespace SoftwareInstallationBusinessLogic
|
|||||||
{
|
{
|
||||||
throw new ArgumentException("Количество добавляемого изделия должно быть больше 0", nameof(count));
|
throw new ArgumentException("Количество добавляемого изделия должно быть больше 0", nameof(count));
|
||||||
}
|
}
|
||||||
_logger.LogInformation("AddPackageInShop. ShopName:{ShopName}.Id:{ Id}",
|
_logger.LogInformation("AddPackageInShop. ShopName:{ShopName}.Id:{ Id}", model.Name, model.Id);
|
||||||
model.Name, model.Id);
|
|
||||||
var element = _shopStorage.GetElement(model);
|
var element = _shopStorage.GetElement(model);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
@ -133,9 +132,8 @@ namespace SoftwareInstallationBusinessLogic
|
|||||||
}
|
}
|
||||||
_logger.LogInformation("AddPackageInShop find. Id:{Id}", element.Id);
|
_logger.LogInformation("AddPackageInShop find. Id:{Id}", element.Id);
|
||||||
|
|
||||||
|
var prevCount = element.Packages.GetValueOrDefault(package.Id, (package, 0)).Item2;
|
||||||
var prevCount = element.Pastries.GetValueOrDefault(package.Id, (package, 0)).Item2;
|
element.Packages[package.Id] = (package, prevCount + count);
|
||||||
element.Pastries[package.Id] = (package, prevCount + count);
|
|
||||||
_logger.LogInformation(
|
_logger.LogInformation(
|
||||||
"AddPackageInShop. Has been added {count} {package} in {ShopName}",
|
"AddPackageInShop. Has been added {count} {package} in {ShopName}",
|
||||||
count, package.PackageName, element.Name);
|
count, package.PackageName, element.Name);
|
||||||
@ -146,7 +144,7 @@ namespace SoftwareInstallationBusinessLogic
|
|||||||
Address = element.Address,
|
Address = element.Address,
|
||||||
Name = element.Name,
|
Name = element.Name,
|
||||||
DateOpening = element.DateOpening,
|
DateOpening = element.DateOpening,
|
||||||
Pastries = element.Pastries
|
Packages = element.Packages
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace SoftwareInstallationContracts.BindingModels
|
|||||||
|
|
||||||
public DateTime DateOpening { get; set; } = DateTime.Now;
|
public DateTime DateOpening { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
public Dictionary<int, (IPackageModel, int)> Pastries
|
public Dictionary<int, (IPackageModel, int)> Packages
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
|
@ -15,7 +15,7 @@ namespace SoftwareInstallationContracts.ViewModels
|
|||||||
[DisplayName("Время открытия")]
|
[DisplayName("Время открытия")]
|
||||||
public DateTime DateOpening { get; set; } = DateTime.Now;
|
public DateTime DateOpening { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
public Dictionary<int, (IPackageModel, int)> Pastries
|
public Dictionary<int, (IPackageModel, int)> Packages
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
|
@ -7,6 +7,6 @@ namespace SoftwareInstallationDataModels
|
|||||||
string Name { get; }
|
string Name { get; }
|
||||||
string Address { get; }
|
string Address { get; }
|
||||||
DateTime DateOpening { get; }
|
DateTime DateOpening { get; }
|
||||||
Dictionary<int, (IPackageModel, int)> Pastries { get; }
|
Dictionary<int, (IPackageModel, int)> Packages { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace SoftwareInstallationListImplement
|
|||||||
|
|
||||||
public DateTime DateOpening { get; private set; }
|
public DateTime DateOpening { get; private set; }
|
||||||
|
|
||||||
public Dictionary<int, (IPackageModel, int)> Pastries
|
public Dictionary<int, (IPackageModel, int)> Packages
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
private set;
|
||||||
@ -33,7 +33,7 @@ namespace SoftwareInstallationListImplement
|
|||||||
Name = model.Name,
|
Name = model.Name,
|
||||||
Address = model.Address,
|
Address = model.Address,
|
||||||
DateOpening = model.DateOpening,
|
DateOpening = model.DateOpening,
|
||||||
Pastries = new()
|
Packages = new()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update(ShopBindingModel? model)
|
public void Update(ShopBindingModel? model)
|
||||||
@ -45,14 +45,14 @@ namespace SoftwareInstallationListImplement
|
|||||||
Name = model.Name;
|
Name = model.Name;
|
||||||
Address = model.Address;
|
Address = model.Address;
|
||||||
DateOpening = model.DateOpening;
|
DateOpening = model.DateOpening;
|
||||||
Pastries = model.Pastries;
|
Packages = model.Packages;
|
||||||
}
|
}
|
||||||
public ShopViewModel GetViewModel => new()
|
public ShopViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
Name = Name,
|
Name = Name,
|
||||||
Address = Address,
|
Address = Address,
|
||||||
Pastries = Pastries,
|
Packages = Packages,
|
||||||
DateOpening = DateOpening,
|
DateOpening = DateOpening,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,11 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.comboBoxShop = new System.Windows.Forms.ComboBox();
|
this.textBoxShop = new System.Windows.Forms.ComboBox();
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
this.comboBoxPackage = new System.Windows.Forms.ComboBox();
|
this.textBoxPackage = new System.Windows.Forms.ComboBox();
|
||||||
this.numericUpDownCount = new System.Windows.Forms.NumericUpDown();
|
this.numericUpDownCount = new System.Windows.Forms.NumericUpDown();
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
@ -41,11 +41,11 @@
|
|||||||
//
|
//
|
||||||
// comboBoxShop
|
// comboBoxShop
|
||||||
//
|
//
|
||||||
this.comboBoxShop.FormattingEnabled = true;
|
this.textBoxShop.FormattingEnabled = true;
|
||||||
this.comboBoxShop.Location = new System.Drawing.Point(214, 17);
|
this.textBoxShop.Location = new System.Drawing.Point(214, 17);
|
||||||
this.comboBoxShop.Name = "comboBoxShop";
|
this.textBoxShop.Name = "comboBoxShop";
|
||||||
this.comboBoxShop.Size = new System.Drawing.Size(222, 23);
|
this.textBoxShop.Size = new System.Drawing.Size(222, 23);
|
||||||
this.comboBoxShop.TabIndex = 3;
|
this.textBoxShop.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
@ -76,11 +76,11 @@
|
|||||||
//
|
//
|
||||||
// comboBoxPackage
|
// comboBoxPackage
|
||||||
//
|
//
|
||||||
this.comboBoxPackage.FormattingEnabled = true;
|
this.textBoxPackage.FormattingEnabled = true;
|
||||||
this.comboBoxPackage.Location = new System.Drawing.Point(214, 44);
|
this.textBoxPackage.Location = new System.Drawing.Point(214, 44);
|
||||||
this.comboBoxPackage.Name = "comboBoxPackage";
|
this.textBoxPackage.Name = "comboBoxPackage";
|
||||||
this.comboBoxPackage.Size = new System.Drawing.Size(222, 23);
|
this.textBoxPackage.Size = new System.Drawing.Size(222, 23);
|
||||||
this.comboBoxPackage.TabIndex = 6;
|
this.textBoxPackage.TabIndex = 6;
|
||||||
//
|
//
|
||||||
// numericUpDownCount
|
// numericUpDownCount
|
||||||
//
|
//
|
||||||
@ -124,10 +124,10 @@
|
|||||||
this.Controls.Add(this.buttonCancel);
|
this.Controls.Add(this.buttonCancel);
|
||||||
this.Controls.Add(this.buttonSave);
|
this.Controls.Add(this.buttonSave);
|
||||||
this.Controls.Add(this.numericUpDownCount);
|
this.Controls.Add(this.numericUpDownCount);
|
||||||
this.Controls.Add(this.comboBoxPackage);
|
this.Controls.Add(this.textBoxPackage);
|
||||||
this.Controls.Add(this.label3);
|
this.Controls.Add(this.label3);
|
||||||
this.Controls.Add(this.label2);
|
this.Controls.Add(this.label2);
|
||||||
this.Controls.Add(this.comboBoxShop);
|
this.Controls.Add(this.textBoxShop);
|
||||||
this.Controls.Add(this.label1);
|
this.Controls.Add(this.label1);
|
||||||
this.Name = "FormAddPackageInShop";
|
this.Name = "FormAddPackageInShop";
|
||||||
this.Text = "форма добавления пакета в магазин";
|
this.Text = "форма добавления пакета в магазин";
|
||||||
@ -139,11 +139,11 @@
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private ComboBox comboBoxShop;
|
private ComboBox textBoxShop;
|
||||||
private Label label1;
|
private Label label1;
|
||||||
private Label label2;
|
private Label label2;
|
||||||
private Label label3;
|
private Label label3;
|
||||||
private ComboBox comboBoxPackage;
|
private ComboBox textBoxPackage;
|
||||||
private NumericUpDown numericUpDownCount;
|
private NumericUpDown numericUpDownCount;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
|
@ -21,7 +21,7 @@ namespace SoftwareInstallationView
|
|||||||
private readonly IShopLogic _shopLogic;
|
private readonly IShopLogic _shopLogic;
|
||||||
private readonly IPackageLogic _packageLogic;
|
private readonly IPackageLogic _packageLogic;
|
||||||
private readonly List<ShopViewModel>? _listShops;
|
private readonly List<ShopViewModel>? _listShops;
|
||||||
private readonly List<PackageViewModel>? _listPastries;
|
private readonly List<PackageViewModel>? _listPackages;
|
||||||
|
|
||||||
public FormAddPackageInShop(ILogger<FormAddPackageInShop> logger, IShopLogic shopLogic, IPackageLogic packageLogic)
|
public FormAddPackageInShop(ILogger<FormAddPackageInShop> logger, IShopLogic shopLogic, IPackageLogic packageLogic)
|
||||||
{
|
{
|
||||||
@ -32,30 +32,30 @@ namespace SoftwareInstallationView
|
|||||||
_listShops = shopLogic.ReadList(null);
|
_listShops = shopLogic.ReadList(null);
|
||||||
if (_listShops != null)
|
if (_listShops != null)
|
||||||
{
|
{
|
||||||
comboBoxShop.DisplayMember = "Name";
|
textBoxShop.DisplayMember = "Name";
|
||||||
comboBoxShop.ValueMember = "Id";
|
textBoxShop.ValueMember = "Id";
|
||||||
comboBoxShop.DataSource = _listShops;
|
textBoxShop.DataSource = _listShops;
|
||||||
comboBoxShop.SelectedItem = null;
|
textBoxShop.SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_listPastries = packageLogic.ReadList(null);
|
_listPackages = packageLogic.ReadList(null);
|
||||||
if (_listPastries != null)
|
if (_listPackages != null)
|
||||||
{
|
{
|
||||||
comboBoxPackage.DisplayMember = "PackageName";
|
textBoxPackage.DisplayMember = "PackageName";
|
||||||
comboBoxPackage.ValueMember= "Id";
|
textBoxPackage.ValueMember= "Id";
|
||||||
comboBoxPackage.DataSource = _listPastries;
|
textBoxPackage.DataSource = _listPackages;
|
||||||
comboBoxPackage.SelectedItem = null;
|
textBoxPackage.SelectedItem = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (comboBoxShop.SelectedValue == null)
|
if (textBoxShop.SelectedValue == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (comboBoxPackage.SelectedValue == null)
|
if (textBoxPackage.SelectedValue == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
@ -65,14 +65,14 @@ namespace SoftwareInstallationView
|
|||||||
{
|
{
|
||||||
var package = _packageLogic.ReadElement(new()
|
var package = _packageLogic.ReadElement(new()
|
||||||
{
|
{
|
||||||
Id = (int)comboBoxPackage.SelectedValue
|
Id = (int)textBoxPackage.SelectedValue
|
||||||
});
|
});
|
||||||
if (package == null)
|
if (package == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Не найдено изделие. Дополнительная информация в логах.");
|
throw new Exception("Не найдено изделие. Дополнительная информация в логах.");
|
||||||
}
|
}
|
||||||
var resultOperation = _shopLogic.AddPackage(
|
var resultOperation = _shopLogic.AddPackage(
|
||||||
model: new() { Id = (int)comboBoxShop.SelectedValue },
|
model: new() { Id = (int)textBoxShop.SelectedValue },
|
||||||
package: package,
|
package: package,
|
||||||
count: (int)numericUpDownCount.Value
|
count: (int)numericUpDownCount.Value
|
||||||
);
|
);
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
this.comboBoxShop = new System.Windows.Forms.ComboBox();
|
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.PackageName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.PackageName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.Price = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.Price = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
@ -37,9 +36,10 @@
|
|||||||
this.label2 = new System.Windows.Forms.Label();
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
this.textBoxAddress = new System.Windows.Forms.TextBox();
|
this.textBoxAddress = new System.Windows.Forms.TextBox();
|
||||||
this.textBoxDateOpening = new System.Windows.Forms.TextBox();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
this.buttonSave = new System.Windows.Forms.Button();
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.textBoxShop = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxDateOpening = new System.Windows.Forms.DateTimePicker();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -52,15 +52,6 @@
|
|||||||
this.label1.TabIndex = 0;
|
this.label1.TabIndex = 0;
|
||||||
this.label1.Text = "Название магазина:";
|
this.label1.Text = "Название магазина:";
|
||||||
//
|
//
|
||||||
// comboBoxShop
|
|
||||||
//
|
|
||||||
this.comboBoxShop.FormattingEnabled = true;
|
|
||||||
this.comboBoxShop.Location = new System.Drawing.Point(12, 27);
|
|
||||||
this.comboBoxShop.Name = "comboBoxShop";
|
|
||||||
this.comboBoxShop.Size = new System.Drawing.Size(141, 23);
|
|
||||||
this.comboBoxShop.TabIndex = 1;
|
|
||||||
this.comboBoxShop.SelectedIndexChanged += new System.EventHandler(this.ComboBoxShop_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
@ -108,9 +99,9 @@
|
|||||||
this.label3.AutoSize = true;
|
this.label3.AutoSize = true;
|
||||||
this.label3.Location = new System.Drawing.Point(386, 9);
|
this.label3.Location = new System.Drawing.Point(386, 9);
|
||||||
this.label3.Name = "label3";
|
this.label3.Name = "label3";
|
||||||
this.label3.Size = new System.Drawing.Size(100, 15);
|
this.label3.Size = new System.Drawing.Size(87, 15);
|
||||||
this.label3.TabIndex = 4;
|
this.label3.TabIndex = 4;
|
||||||
this.label3.Text = "Время открытия:";
|
this.label3.Text = "Дата открытия";
|
||||||
//
|
//
|
||||||
// textBoxAddress
|
// textBoxAddress
|
||||||
//
|
//
|
||||||
@ -119,13 +110,6 @@
|
|||||||
this.textBoxAddress.Size = new System.Drawing.Size(221, 23);
|
this.textBoxAddress.Size = new System.Drawing.Size(221, 23);
|
||||||
this.textBoxAddress.TabIndex = 5;
|
this.textBoxAddress.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// textBoxDateOpening
|
|
||||||
//
|
|
||||||
this.textBoxDateOpening.Location = new System.Drawing.Point(386, 27);
|
|
||||||
this.textBoxDateOpening.Name = "textBoxDateOpening";
|
|
||||||
this.textBoxDateOpening.Size = new System.Drawing.Size(209, 23);
|
|
||||||
this.textBoxDateOpening.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
@ -148,19 +132,33 @@
|
|||||||
this.buttonSave.UseVisualStyleBackColor = true;
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
//
|
//
|
||||||
|
// textBoxShop
|
||||||
|
//
|
||||||
|
this.textBoxShop.Location = new System.Drawing.Point(13, 27);
|
||||||
|
this.textBoxShop.Name = "textBoxShop";
|
||||||
|
this.textBoxShop.Size = new System.Drawing.Size(140, 23);
|
||||||
|
this.textBoxShop.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// textBoxDateOpening
|
||||||
|
//
|
||||||
|
this.textBoxDateOpening.Location = new System.Drawing.Point(386, 27);
|
||||||
|
this.textBoxDateOpening.Name = "textBoxDateOpening";
|
||||||
|
this.textBoxDateOpening.Size = new System.Drawing.Size(200, 23);
|
||||||
|
this.textBoxDateOpening.TabIndex = 10;
|
||||||
|
//
|
||||||
// FormShop
|
// FormShop
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(607, 317);
|
this.ClientSize = new System.Drawing.Size(607, 317);
|
||||||
|
this.Controls.Add(this.textBoxDateOpening);
|
||||||
|
this.Controls.Add(this.textBoxShop);
|
||||||
this.Controls.Add(this.buttonSave);
|
this.Controls.Add(this.buttonSave);
|
||||||
this.Controls.Add(this.buttonCancel);
|
this.Controls.Add(this.buttonCancel);
|
||||||
this.Controls.Add(this.textBoxDateOpening);
|
|
||||||
this.Controls.Add(this.textBoxAddress);
|
this.Controls.Add(this.textBoxAddress);
|
||||||
this.Controls.Add(this.label3);
|
this.Controls.Add(this.label3);
|
||||||
this.Controls.Add(this.label2);
|
this.Controls.Add(this.label2);
|
||||||
this.Controls.Add(this.dataGridView);
|
this.Controls.Add(this.dataGridView);
|
||||||
this.Controls.Add(this.comboBoxShop);
|
|
||||||
this.Controls.Add(this.label1);
|
this.Controls.Add(this.label1);
|
||||||
this.Name = "FormShop";
|
this.Name = "FormShop";
|
||||||
this.Text = "Просмотр изделий магазина";
|
this.Text = "Просмотр изделий магазина";
|
||||||
@ -174,16 +172,16 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Label label1;
|
private Label label1;
|
||||||
private ComboBox comboBoxShop;
|
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
private Label label2;
|
private Label label2;
|
||||||
private Label label3;
|
private Label label3;
|
||||||
private TextBox textBoxAddress;
|
private TextBox textBoxAddress;
|
||||||
private TextBox textBoxDateOpening;
|
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private DataGridViewTextBoxColumn PackageName;
|
private DataGridViewTextBoxColumn PackageName;
|
||||||
private DataGridViewTextBoxColumn Price;
|
private DataGridViewTextBoxColumn Price;
|
||||||
private DataGridViewTextBoxColumn Count;
|
private DataGridViewTextBoxColumn Count;
|
||||||
}
|
private TextBox textBoxShop;
|
||||||
|
private DateTimePicker textBoxDateOpening;
|
||||||
|
}
|
||||||
}
|
}
|
@ -51,27 +51,20 @@ namespace SoftwareInstallationView
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
_listShops = logic.ReadList(null);
|
_listShops = logic.ReadList(null);
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
if (_listShops != null)
|
|
||||||
{
|
|
||||||
comboBoxShop.DisplayMember = "Name";
|
|
||||||
comboBoxShop.ValueMember = "Id";
|
|
||||||
comboBoxShop.DataSource = _listShops;
|
|
||||||
comboBoxShop.SelectedItem = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadData(bool extendDate = true)
|
private void LoadData(bool extendDate = true)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var model = GetShop(extendDate ? Id : Convert.ToInt32(comboBoxShop.SelectedValue));
|
var model = GetShop(extendDate ? Id : Convert.ToInt32(null));
|
||||||
if (model != null)
|
if (model != null)
|
||||||
{
|
{
|
||||||
comboBoxShop.Text = model.Name;
|
textBoxShop.Text = model.Name;
|
||||||
textBoxAddress.Text = model.Address;
|
textBoxAddress.Text = model.Address;
|
||||||
textBoxDateOpening.Text = Convert.ToString(model.DateOpening);
|
textBoxDateOpening.Text = Convert.ToString(model.DateOpening);
|
||||||
dataGridView.Rows.Clear();
|
dataGridView.Rows.Clear();
|
||||||
foreach (var el in model.Pastries.Values)
|
foreach (var el in model.Packages.Values)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Add(new object[]{el.Item1.PackageName, el.Item1.Price, el.Item2 });
|
dataGridView.Rows.Add(new object[]{el.Item1.PackageName, el.Item1.Price, el.Item2 });
|
||||||
}
|
}
|
||||||
@ -86,14 +79,9 @@ namespace SoftwareInstallationView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ComboBoxShop_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
LoadData(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(comboBoxShop.Text))
|
if (string.IsNullOrEmpty(textBoxShop.Text))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Заполните название", "Ошибка",
|
MessageBox.Show("Заполните название", "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
@ -111,7 +99,7 @@ namespace SoftwareInstallationView
|
|||||||
DateTime.TryParse(textBoxDateOpening.Text, out var dateTime);
|
DateTime.TryParse(textBoxDateOpening.Text, out var dateTime);
|
||||||
ShopBindingModel model = new()
|
ShopBindingModel model = new()
|
||||||
{
|
{
|
||||||
Name = comboBoxShop.Text,
|
Name = textBoxShop.Text,
|
||||||
Address = textBoxAddress.Text,
|
Address = textBoxAddress.Text,
|
||||||
DateOpening = dateTime
|
DateOpening = dateTime
|
||||||
};
|
};
|
||||||
@ -153,5 +141,5 @@ namespace SoftwareInstallationView
|
|||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,4 +66,13 @@
|
|||||||
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="PackageName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Price.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
@ -28,7 +28,7 @@ namespace SoftwareInstallationView
|
|||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
dataGridView.Columns["Pastries"].Visible = false;
|
dataGridView.Columns["Packages"].Visible = false;
|
||||||
dataGridView.Columns["Name"].AutoSizeMode =
|
dataGridView.Columns["Name"].AutoSizeMode =
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user