diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.Designer.cs deleted file mode 100644 index 3b7011a..0000000 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.Designer.cs +++ /dev/null @@ -1,211 +0,0 @@ -namespace BlacksmithWorkshop -{ - partial class FormShop - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - dataGridView = new DataGridView(); - ColumnId = new DataGridViewTextBoxColumn(); - ColumnName = new DataGridViewTextBoxColumn(); - ColumnPrice = new DataGridViewTextBoxColumn(); - ColumnCount = new DataGridViewTextBoxColumn(); - dateTimePicker = new DateTimePicker(); - labelName = new Label(); - labelAddress = new Label(); - labelDate = new Label(); - textBoxName = new TextBox(); - textBoxAddress = new TextBox(); - buttonSave = new Button(); - buttonCancel = new Button(); - CapacityUpDown = new NumericUpDown(); - CapacityLabel = new Label(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - ((System.ComponentModel.ISupportInitialize)CapacityUpDown).BeginInit(); - SuspendLayout(); - // - // dataGridView - // - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnName, ColumnPrice, ColumnCount }); - dataGridView.Location = new Point(12, 128); - dataGridView.Name = "dataGridView"; - dataGridView.RowTemplate.Height = 25; - dataGridView.Size = new Size(553, 254); - dataGridView.TabIndex = 0; - // - // ColumnId - // - ColumnId.HeaderText = ""; - ColumnId.Name = "ColumnId"; - ColumnId.Visible = false; - // - // ColumnName - // - ColumnName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - ColumnName.HeaderText = "Изделие"; - ColumnName.Name = "ColumnName"; - // - // ColumnPrice - // - ColumnPrice.HeaderText = "Цена"; - ColumnPrice.Name = "ColumnPrice"; - // - // ColumnCount - // - ColumnCount.HeaderText = "Количество"; - ColumnCount.Name = "ColumnCount"; - // - // dateTimePicker - // - dateTimePicker.Location = new Point(150, 63); - dateTimePicker.Name = "dateTimePicker"; - dateTimePicker.Size = new Size(166, 23); - dateTimePicker.TabIndex = 1; - // - // labelName - // - labelName.AutoSize = true; - labelName.Location = new Point(12, 9); - labelName.Name = "labelName"; - labelName.Size = new Size(62, 15); - labelName.TabIndex = 2; - labelName.Text = "Название:"; - // - // labelAddress - // - labelAddress.AutoSize = true; - labelAddress.Location = new Point(12, 38); - labelAddress.Name = "labelAddress"; - labelAddress.Size = new Size(43, 15); - labelAddress.TabIndex = 3; - labelAddress.Text = "Адрес:"; - // - // labelDate - // - labelDate.AutoSize = true; - labelDate.Location = new Point(12, 69); - labelDate.Name = "labelDate"; - labelDate.Size = new Size(90, 15); - labelDate.TabIndex = 4; - labelDate.Text = "Дата открытия:"; - // - // textBoxName - // - textBoxName.Location = new Point(150, 6); - textBoxName.Name = "textBoxName"; - textBoxName.Size = new Size(166, 23); - textBoxName.TabIndex = 5; - // - // textBoxAddress - // - textBoxAddress.Location = new Point(150, 35); - textBoxAddress.Name = "textBoxAddress"; - textBoxAddress.Size = new Size(166, 23); - textBoxAddress.TabIndex = 6; - // - // buttonSave - // - buttonSave.Location = new Point(12, 401); - buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(123, 25); - buttonSave.TabIndex = 7; - buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; - buttonSave.Click += SaveButton_Click; - // - // buttonCancel - // - buttonCancel.Location = new Point(150, 401); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(123, 25); - buttonCancel.TabIndex = 8; - buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; - buttonCancel.Click += CancelButton_Click; - // - // CapacityUpDown - // - CapacityUpDown.Location = new Point(150, 92); - CapacityUpDown.Maximum = new decimal(new int[] { 10000, 0, 0, 0 }); - CapacityUpDown.Name = "CapacityUpDown"; - CapacityUpDown.Size = new Size(166, 23); - CapacityUpDown.TabIndex = 9; - // - // CapacityLabel - // - CapacityLabel.AutoSize = true; - CapacityLabel.Location = new Point(12, 94); - CapacityLabel.Name = "CapacityLabel"; - CapacityLabel.Size = new Size(80, 15); - CapacityLabel.TabIndex = 10; - CapacityLabel.Text = "Вместимость"; - // - // FormShop - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(585, 450); - Controls.Add(buttonCancel); - Controls.Add(buttonSave); - Controls.Add(textBoxAddress); - Controls.Add(textBoxName); - Controls.Add(labelDate); - Controls.Add(labelAddress); - Controls.Add(labelName); - Controls.Add(dateTimePicker); - Controls.Add(dataGridView); - Controls.Add(CapacityLabel); - Controls.Add(CapacityUpDown); - Name = "FormShop"; - StartPosition = FormStartPosition.CenterParent; - Text = "Магазин"; - Load += FormShop_Load; - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ((System.ComponentModel.ISupportInitialize)CapacityUpDown).EndInit(); - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private DataGridView dataGridView; - private DateTimePicker dateTimePicker; - private Label labelName; - private Label labelAddress; - private Label labelDate; - private TextBox textBoxName; - private TextBox textBoxAddress; - private DataGridViewTextBoxColumn ColumnId; - private DataGridViewTextBoxColumn ColumnName; - private DataGridViewTextBoxColumn ColumnPrice; - private DataGridViewTextBoxColumn ColumnCount; - private Button buttonSave; - private Button buttonCancel; - private NumericUpDown CapacityUpDown; - private Label CapacityLabel; - } -} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.cs deleted file mode 100644 index bc29ad2..0000000 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.cs +++ /dev/null @@ -1,123 +0,0 @@ -using BlacksmithWorkshopContracts.BindingModels; -using BlacksmithWorkshopContracts.BusinessLogicsContracts; -using BlacksmithWorkshopContracts.SearchModels; -using BlacksmithWorkshopDataModels.Models; -using Microsoft.Extensions.Logging; -using Microsoft.VisualBasic.Logging; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace BlacksmithWorkshop -{ - public partial class FormShop : Form - { - private readonly ILogger _logger; - private readonly IShopLogic _logic; - public int? _id; - private Dictionary _manufactures; - public FormShop(ILogger logger, IShopLogic logic) - { - InitializeComponent(); - _logger = logger; - _logic = logic; - _manufactures = new(); - } - private void FormShop_Load(object sender, EventArgs e) - { - if (_id.HasValue) - { - _logger.LogInformation("Загрузка магазина"); - try - { - var shop = _logic.ReadElement(new ShopSearchModel { Id = _id }); - if (shop != null) - { - textBoxName.Text = shop.ShopName; - textBoxAddress.Text = shop.Address; - dateTimePicker.Text = shop.OpeningDate.ToString(); - _manufactures = shop.ShopManufactures ?? new Dictionary(); - CapacityUpDown.Value = shop.MaxCapacity; - } - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки магазина"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - } - private void LoadData() - { - _logger.LogInformation("Загрузка товаров магазина"); - try - { - if (_manufactures != null) - { - foreach (var manufactures in _manufactures) - { - dataGridView.Rows.Add(new object[] { manufactures.Key, manufactures.Value.Item1.ManufactureName, - manufactures.Value.Item1.Price, manufactures.Value.Item2 }); - } - } - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка загрузки изделий магазина"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); - } - } - private void CancelButton_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - Close(); - } - private void SaveButton_Click(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(textBoxName.Text)) - { - MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - if (string.IsNullOrEmpty(textBoxAddress.Text)) - { - MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - _logger.LogInformation("Сохранение магазина"); - try - { - var model = new ShopBindingModel - { - Id = _id ?? 0, - ShopName = textBoxName.Text, - Address = textBoxAddress.Text, - OpeningDate = dateTimePicker.Value.Date, - MaxCapacity = Convert.ToInt32(CapacityUpDown.Value) - }; - var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); - if (!operationResult) - { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); - } - MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); - DialogResult = DialogResult.OK; - Close(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка сохранения магазина"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } -} diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.resx deleted file mode 100644 index b0c7c5d..0000000 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormShop.resx +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - True - - - True - - - True - - - True - - \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs deleted file mode 100644 index 4addc8a..0000000 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs +++ /dev/null @@ -1,58 +0,0 @@ -using BlacksmithWorkshopBusinessLogic.BusinessLogics; -using BlacksmithWorkshopContracts.BusinessLogicsContracts; -using BlacksmithWorkshopContracts.StoragesContracts; -using BlacksmithWorkshopFileImplement.Implements; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using NLog.Extensions.Logging; -using System; - -namespace BlacksmithWorkshop -{ - internal static class Program - { - private static ServiceProvider? _serviceProvider; - public static ServiceProvider? ServiceProvider => _serviceProvider; - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); - var services = new ServiceCollection(); - ConfigureServices(services); - _serviceProvider = services.BuildServiceProvider(); - Application.Run(_serviceProvider.GetRequiredService()); - } - private static void ConfigureServices(ServiceCollection services) - { - services.AddLogging(option => - { - option.SetMinimumLevel(LogLevel.Information); - option.AddNLog("nlog.config"); - }); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - } - } -} \ No newline at end of file