LabWork01_Hard: Фиксы

This commit is contained in:
Safgerd 2023-03-25 22:45:18 +04:00
parent bb968d63f9
commit 2f35992cc1
11 changed files with 59 additions and 59 deletions

View File

@ -32,7 +32,7 @@
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.автомобилиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.shopsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonSupplyShop = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonCreateOrder = new System.Windows.Forms.Button();
@ -60,7 +60,7 @@
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.компонентыToolStripMenuItem,
this.автомобилиToolStripMenuItem,
this.shopsToolStripMenuItem});
this.магазиныToolStripMenuItem});
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
this.справочникиToolStripMenuItem.Text = "Справочники";
@ -79,12 +79,12 @@
this.автомобилиToolStripMenuItem.Text = "Автомобили";
this.автомобилиToolStripMenuItem.Click += new System.EventHandler(this.автомобилиToolStripMenuItem_Click);
//
// shopsToolStripMenuItem
// магазиныToolStripMenuItem
//
this.shopsToolStripMenuItem.Name = "shopsToolStripMenuItem";
this.shopsToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
this.shopsToolStripMenuItem.Text = "Магазины";
this.shopsToolStripMenuItem.Click += new System.EventHandler(this.shopsToolStripMenuItem_Click);
this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
this.магазиныToolStripMenuItem.Text = "Магазины";
this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.магазиныToolStripMenuItem_Click);
//
// buttonSupplyShop
//
@ -193,7 +193,7 @@
private Button buttonSetToDone;
private Button buttonSetToFinish;
private Button buttonUpdate;
private ToolStripMenuItem shopsToolStripMenuItem;
private ToolStripMenuItem магазиныToolStripMenuItem;
private Button buttonSupplyShop;
}
}

View File

@ -70,6 +70,15 @@ namespace AutomobilePlant
}
}
private void магазиныToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
if (service is FormShops form)
{
form.ShowDialog();
}
}
private void ButtonCreateOrder_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
@ -165,15 +174,6 @@ namespace AutomobilePlant
LoadData();
}
private void shopsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
if (service is FormShops form)
{
form.ShowDialog();
}
}
private void buttonSupplyShop_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShopSupply));

View File

@ -38,8 +38,8 @@
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.foundingDateLabel = new System.Windows.Forms.Label();
this.foundingDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.openingDateLabel = new System.Windows.Forms.Label();
this.openingDateTimePicker = new System.Windows.Forms.DateTimePicker();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
@ -131,29 +131,29 @@
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
// foundingDateLabel
// openingDateLabel
//
this.foundingDateLabel.AutoSize = true;
this.foundingDateLabel.Location = new System.Drawing.Point(14, 83);
this.foundingDateLabel.Name = "foundingDateLabel";
this.foundingDateLabel.Size = new System.Drawing.Size(121, 20);
this.foundingDateLabel.TabIndex = 13;
this.foundingDateLabel.Text = "Дата основания";
this.openingDateLabel.AutoSize = true;
this.openingDateLabel.Location = new System.Drawing.Point(14, 83);
this.openingDateLabel.Name = "openingDateLabel";
this.openingDateLabel.Size = new System.Drawing.Size(121, 20);
this.openingDateLabel.TabIndex = 13;
this.openingDateLabel.Text = "Дата открытия";
//
// foundingDateTimePicker
// openingDateTimePicker
//
this.foundingDateTimePicker.Location = new System.Drawing.Point(141, 78);
this.foundingDateTimePicker.Name = "foundingDateTimePicker";
this.foundingDateTimePicker.Size = new System.Drawing.Size(274, 27);
this.foundingDateTimePicker.TabIndex = 14;
this.openingDateTimePicker.Location = new System.Drawing.Point(141, 78);
this.openingDateTimePicker.Name = "openingDateTimePicker";
this.openingDateTimePicker.Size = new System.Drawing.Size(274, 27);
this.openingDateTimePicker.TabIndex = 14;
//
// FormShop
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(445, 489);
this.Controls.Add(this.foundingDateTimePicker);
this.Controls.Add(this.foundingDateLabel);
this.Controls.Add(this.openingDateTimePicker);
this.Controls.Add(this.openingDateLabel);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.dataGridView);
@ -182,7 +182,7 @@
private DataGridViewTextBoxColumn ColumnId;
private DataGridViewTextBoxColumn ColumnCarName;
private DataGridViewTextBoxColumn ColumnCount;
private Label foundingDateLabel;
private DateTimePicker foundingDateTimePicker;
private Label openingDateLabel;
private DateTimePicker openingDateTimePicker;
}
}

View File

@ -45,14 +45,14 @@ namespace AutomobilePlant
{
textBoxName.Text = view.Name;
textBoxAddress.Text = view.Address;
foundingDateTimePicker.Value = view.FoundingDate;
openingDateTimePicker.Value = view.OpeningDate;
_shopCars = view.ShopCars ?? new Dictionary<int, (ICarModel, int)>();
LoadData();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Error during loading shop");
_logger.LogError(ex, "Ошибка загрузки магазина");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
@ -60,7 +60,7 @@ namespace AutomobilePlant
private void LoadData()
{
_logger.LogInformation("Loading shop's cars");
_logger.LogInformation("Загрузка авто магазина");
try
{
@ -75,7 +75,7 @@ namespace AutomobilePlant
}
catch (Exception ex)
{
_logger.LogError(ex, "Error during loading shop's cars");
_logger.LogError(ex, "Ошибка загрузки авто магазина");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
@ -94,7 +94,7 @@ namespace AutomobilePlant
return;
}
_logger.LogInformation("Saving shop");
_logger.LogInformation("Сохранение магазина");
try
{
@ -103,7 +103,7 @@ namespace AutomobilePlant
Id = _id ?? 0,
Name = textBoxName.Text,
Address = textBoxAddress.Text,
FoundingDate = foundingDateTimePicker.Value.Date,
OpeningDate = openingDateTimePicker.Value.Date,
ShopCars= _shopCars
};

View File

@ -30,7 +30,7 @@ namespace AutomobilePlant
private void FormShopSupply_Load(object sender, EventArgs e)
{
_logger.LogInformation("Loading cars for supplying");
_logger.LogInformation("Загрузка авто для пополнения");
try
{
@ -46,11 +46,11 @@ namespace AutomobilePlant
}
catch (Exception ex)
{
_logger.LogError(ex, "Error during loading cars for supplying");
_logger.LogError(ex, "Ошибка загрузки списка авто");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
_logger.LogInformation("Loading shops for supplying");
_logger.LogInformation("Загрузка магазинов для пополнения");
try
{
@ -66,7 +66,7 @@ namespace AutomobilePlant
}
catch (Exception ex)
{
_logger.LogError(ex, "Error during loading shops for supplying");
_logger.LogError(ex, "Ошибка загрузки списка магазинов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
@ -91,7 +91,7 @@ namespace AutomobilePlant
return;
}
_logger.LogInformation("Creation of supply");
_logger.LogInformation("Создание поставки");
try
{
@ -112,7 +112,7 @@ namespace AutomobilePlant
}
catch (Exception ex)
{
_logger.LogError(ex, "Error during creation of supply");
_logger.LogError(ex, "Ошибка создания поставки");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

View File

@ -44,12 +44,12 @@ namespace AutomobilePlant
dataGridView.Columns["ShopCars"].Visible = false;
}
_logger.LogInformation("Loading shops");
_logger.LogInformation("Загрузка магазинов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Error during loading shops");
_logger.LogError(ex, "Ошибка загрузки магазинов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
@ -97,7 +97,7 @@ namespace AutomobilePlant
if (MessageBox.Show("Удалить магазин?", "Подтверждение", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Deleting shop");
_logger.LogInformation("Удаление магазина");
try
{
@ -110,7 +110,7 @@ namespace AutomobilePlant
}
catch (Exception ex)
{
_logger.LogError(ex, "Error during deleting shop");
_logger.LogError(ex, "Ошибка удаления магазина");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

View File

@ -104,6 +104,7 @@ namespace AutomobilePlantBusinessLogic.BusinessLogics
Id = shopElement.Id,
Name = shopElement.Name,
Address = shopElement.Address,
OpeningDate = shopElement.OpeningDate,
ShopCars = shopElement.ShopCars
});

View File

@ -15,7 +15,7 @@ namespace AutomobilePlantContracts.BindingModels
public string Address { get; set; } = string.Empty;
public DateTime FoundingDate { get; set; }
public DateTime OpeningDate { get; set; }
public Dictionary<int, (ICarModel, int)> ShopCars { get; set; }
}

View File

@ -18,8 +18,8 @@ namespace AutomobilePlantContracts.ViewModels
[DisplayName("Адрес")]
public string Address { get; set; } = string.Empty;
[DisplayName("Дата основания")]
public DateTime FoundingDate { get; set; }
[DisplayName("Дата открытия")]
public DateTime OpeningDate { get; set; }
public Dictionary<int, (ICarModel, int)> ShopCars { get; set; } = new();
}

View File

@ -10,7 +10,7 @@ namespace AutomobilePlantDataModels.Models
{
string Name { get; }
string Address { get; }
DateTime FoundingDate { get; }
DateTime OpeningDate { get; }
Dictionary<int, (ICarModel, int)> ShopCars { get; }
}
}

View File

@ -18,8 +18,6 @@ namespace AutomobilePlantListImplements.Models
public string Address { get; private set; } = string.Empty;
public DateTime OpeningDate { get; private set; }
public DateTime FoundingDate { get; private set; }
public Dictionary<int, (ICarModel, int)> ShopCars { get; private set; } = new();
@ -35,7 +33,7 @@ namespace AutomobilePlantListImplements.Models
Id = model.Id,
Name = model.Name,
Address = model.Address,
FoundingDate = model.FoundingDate,
OpeningDate = model.OpeningDate,
ShopCars = new()
};
}
@ -49,6 +47,7 @@ namespace AutomobilePlantListImplements.Models
Name = model.Name;
Address = model.Address;
OpeningDate = model.OpeningDate;
ShopCars = model.ShopCars;
}
@ -57,7 +56,7 @@ namespace AutomobilePlantListImplements.Models
Id = Id,
Name = Name,
Address = Address,
FoundingDate = FoundingDate,
OpeningDate = OpeningDate,
ShopCars = ShopCars
};
}