diff --git a/ProjectCarpentryWorkshop/Forms/FormMaterialSupply.Designer.cs b/ProjectCarpentryWorkshop/Forms/FormMaterialSupply.Designer.cs index fa9072d..14bf2a7 100644 --- a/ProjectCarpentryWorkshop/Forms/FormMaterialSupply.Designer.cs +++ b/ProjectCarpentryWorkshop/Forms/FormMaterialSupply.Designer.cs @@ -32,8 +32,8 @@ buttonCancel = new Button(); labelName = new Label(); labelCount = new Label(); - textBoxName = new TextBox(); numericUpDownCount = new NumericUpDown(); + comboBoxMaterial = new ComboBox(); ((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit(); SuspendLayout(); // @@ -75,13 +75,6 @@ labelCount.TabIndex = 4; labelCount.Text = "Count"; // - // textBoxName - // - textBoxName.Location = new Point(124, 46); - textBoxName.Name = "textBoxName"; - textBoxName.Size = new Size(120, 23); - textBoxName.TabIndex = 7; - // // numericUpDownCount // numericUpDownCount.Location = new Point(124, 97); @@ -89,18 +82,27 @@ numericUpDownCount.Size = new Size(120, 23); numericUpDownCount.TabIndex = 8; // - // FormMaterialSpent + // comboBoxMaterial + // + comboBoxMaterial.FormattingEnabled = true; + comboBoxMaterial.Location = new Point(123, 43); + comboBoxMaterial.Name = "comboBoxMaterial"; + comboBoxMaterial.Size = new Size(121, 23); + comboBoxMaterial.TabIndex = 9; + comboBoxMaterial.SelectedIndexChanged += comboBoxMaterial_SelectedIndexChanged; + // + // FormMaterialSupply // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(304, 204); + Controls.Add(comboBoxMaterial); Controls.Add(numericUpDownCount); - Controls.Add(textBoxName); Controls.Add(labelCount); Controls.Add(labelName); Controls.Add(buttonCancel); Controls.Add(buttonAdd); - Name = "FormMaterialSpent"; + Name = "FormMaterialSupply"; Text = "FormMaterialSpent"; ((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit(); ResumeLayout(false); @@ -115,5 +117,7 @@ private Label labelCount; private TextBox textBoxName; private NumericUpDown numericUpDownCount; + private ComboBox comboBoxMaterial; + private ComboBox comboBox1; } } \ No newline at end of file diff --git a/ProjectCarpentryWorkshop/Forms/FormMaterialSupply.cs b/ProjectCarpentryWorkshop/Forms/FormMaterialSupply.cs index 356c445..b3708b6 100644 --- a/ProjectCarpentryWorkshop/Forms/FormMaterialSupply.cs +++ b/ProjectCarpentryWorkshop/Forms/FormMaterialSupply.cs @@ -9,13 +9,21 @@ using System.Threading.Tasks; using System.Windows.Forms; using ProjectCarpentryWorkshop.Entities; using ProjectCarpentryWorkshop.Repositories; +using ProjectCarpentryWorkshop.Repositories.Implementations; namespace ProjectCarpentryWorkshop.Forms { public partial class FormMaterialSupply : Form { private readonly IMaterialSupplyRepository _materialSpentRepository; + IMaterialRepository materialRepository; private int? _materialSpentId; + + private void comboBoxMaterial_SelectedIndexChanged(object sender, EventArgs e) + { + + } + public int Id { set @@ -27,7 +35,7 @@ namespace ProjectCarpentryWorkshop.Forms { throw new InvalidDataException(nameof(materialSpent)); } - textBoxName.Text = materialSpent.Name; + comboBoxMaterial.DataSource = materialRepository.ReadMaterials(); numericUpDownCount.Value = materialSpent.Count; _materialSpentId = value; } @@ -69,5 +77,7 @@ namespace ProjectCarpentryWorkshop.Forms } } private void buttonCancel_Click_1(object sender, EventArgs e) => Close(); + + } } \ No newline at end of file diff --git a/ProjectCarpentryWorkshop/Forms/FormMaterialSupply.resx b/ProjectCarpentryWorkshop/Forms/FormMaterialSupply.resx index 1af7de1..af32865 100644 --- a/ProjectCarpentryWorkshop/Forms/FormMaterialSupply.resx +++ b/ProjectCarpentryWorkshop/Forms/FormMaterialSupply.resx @@ -1,17 +1,17 @@  - diff --git a/ProjectCarpentryWorkshop/Forms/FormOrderProduction.Designer.cs b/ProjectCarpentryWorkshop/Forms/FormOrderProduction.Designer.cs index 77d7ddb..1ee6432 100644 --- a/ProjectCarpentryWorkshop/Forms/FormOrderProduction.Designer.cs +++ b/ProjectCarpentryWorkshop/Forms/FormOrderProduction.Designer.cs @@ -131,7 +131,7 @@ ColumnCount.HeaderText = "Count"; ColumnCount.Name = "ColumnCount"; // - // FormOrderProduct + // FormOrderProduction // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; @@ -143,7 +143,7 @@ Controls.Add(labelStatus); Controls.Add(buttonCancel); Controls.Add(buttonAdd); - Name = "FormOrderProduct"; + Name = "FormOrderProduction"; Text = "FormOrder"; groupBox.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); diff --git a/ProjectCarpentryWorkshop/Forms/FormOrderProduction.cs b/ProjectCarpentryWorkshop/Forms/FormOrderProduction.cs index e4f411d..68bb82e 100644 --- a/ProjectCarpentryWorkshop/Forms/FormOrderProduction.cs +++ b/ProjectCarpentryWorkshop/Forms/FormOrderProduction.cs @@ -16,6 +16,8 @@ namespace ProjectCarpentryWorkshop.Forms { public partial class FormOrderProduction : Form { + + private readonly IOrderRepository _orderRepository; public FormOrderProduction(IOrderRepository orderRepository, IProductionRepository productRepository) { @@ -58,5 +60,7 @@ namespace ProjectCarpentryWorkshop.Forms } return list; } + + } } diff --git a/ProjectCarpentryWorkshop/Forms/FormOrderProduction.resx b/ProjectCarpentryWorkshop/Forms/FormOrderProduction.resx index 1af7de1..af32865 100644 --- a/ProjectCarpentryWorkshop/Forms/FormOrderProduction.resx +++ b/ProjectCarpentryWorkshop/Forms/FormOrderProduction.resx @@ -1,17 +1,17 @@  - diff --git a/ProjectCarpentryWorkshop/Program.cs b/ProjectCarpentryWorkshop/Program.cs index e93ceb5..a585f5d 100644 --- a/ProjectCarpentryWorkshop/Program.cs +++ b/ProjectCarpentryWorkshop/Program.cs @@ -1,6 +1,10 @@ using ProjectCarpentryWorkshop.Repositories.Implementations; using ProjectCarpentryWorkshop.Repositories; using Unity; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using Serilog; +using Unity.Microsoft.Logging; namespace ProjectCarpentryWorkshop { @@ -20,13 +24,29 @@ namespace ProjectCarpentryWorkshop private static IUnityContainer CreateContainer() { var container = new UnityContainer(); + container.AddExtension(new LoggingExtension(CreateLoggerFactory())); //add logger in unity + container.RegisterType(); container.RegisterType(); container.RegisterType(); container.RegisterType(); + container.RegisterType(); + + return container; } + private static LoggerFactory CreateLoggerFactory() + { + var loggerFactory = new LoggerFactory(); //serlog logger + loggerFactory.AddSerilog(new LoggerConfiguration() + .ReadFrom.Configuration(new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json") + .Build()) + .CreateLogger()); + return loggerFactory; + } } } \ No newline at end of file diff --git a/ProjectCarpentryWorkshop/ProjectCarpentryWorkshop.csproj b/ProjectCarpentryWorkshop/ProjectCarpentryWorkshop.csproj index accbdf0..b7fa169 100644 --- a/ProjectCarpentryWorkshop/ProjectCarpentryWorkshop.csproj +++ b/ProjectCarpentryWorkshop/ProjectCarpentryWorkshop.csproj @@ -9,7 +9,14 @@ + + + + + + + @@ -27,4 +34,10 @@ + + + PreserveNewest + + + \ No newline at end of file diff --git a/ProjectCarpentryWorkshop/Repositories/IConnectionString.cs b/ProjectCarpentryWorkshop/Repositories/IConnectionString.cs new file mode 100644 index 0000000..ee74221 --- /dev/null +++ b/ProjectCarpentryWorkshop/Repositories/IConnectionString.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectCarpentryWorkshop.Repositories; + +public interface IConnectionString +{ + public string connectionString {get;} + + + +} diff --git a/ProjectCarpentryWorkshop/Repositories/Implementations/ConnectionString.cs b/ProjectCarpentryWorkshop/Repositories/Implementations/ConnectionString.cs new file mode 100644 index 0000000..123a80a --- /dev/null +++ b/ProjectCarpentryWorkshop/Repositories/Implementations/ConnectionString.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectCarpentryWorkshop.Repositories.Implementations; + +public class ConnectionString : IConnectionString +{ + public string connectionString => ""; +} diff --git a/ProjectCarpentryWorkshop/Repositories/Implementations/MaterialRepository.cs b/ProjectCarpentryWorkshop/Repositories/Implementations/MaterialRepository.cs index 7d9530c..5aa2f05 100644 --- a/ProjectCarpentryWorkshop/Repositories/Implementations/MaterialRepository.cs +++ b/ProjectCarpentryWorkshop/Repositories/Implementations/MaterialRepository.cs @@ -1,4 +1,5 @@ -using ProjectCarpentryWorkshop.Entities; +using Microsoft.Extensions.Logging; +using ProjectCarpentryWorkshop.Entities; using System; using System.Collections.Generic; using System.Linq; @@ -9,8 +10,19 @@ namespace ProjectCarpentryWorkshop.Repositories.Implementations; public class MaterialRepository : IMaterialRepository { + private readonly IConnectionString _connectionString; + private readonly ILogger _logger; + public MaterialRepository(IConnectionString connectionString, ILoggerlogger) + { + _connectionString = connectionString; + _logger = logger; + } + public void CreateMaterial(Material material) { + _logger.LogInformation("Добавление материала"); + _logger.LogDebug(); + } public void DeleteMaterial(int id) diff --git a/ProjectCarpentryWorkshop/appsettings.json b/ProjectCarpentryWorkshop/appsettings.json new file mode 100644 index 0000000..ac7e20a --- /dev/null +++ b/ProjectCarpentryWorkshop/appsettings.json @@ -0,0 +1,15 @@ +{ + "Serilog": { + "Using": [ "Serilog.Sinks.File" ], + "MinimumLevel": "Debug", + "WriteTo": [ + { + "Name": "File", + "Args": { + "path": "Logs/workshop_log.txt", + "rollingInterval": "Day" + } + } + ] + } +} \ No newline at end of file