diff --git a/SUBD_Car_rent/Forms/FormCarModel.Designer.cs b/SUBD_Car_rent/Forms/FormCarModel.Designer.cs new file mode 100644 index 0000000..10ec0ee --- /dev/null +++ b/SUBD_Car_rent/Forms/FormCarModel.Designer.cs @@ -0,0 +1,39 @@ +namespace Forms +{ + partial class FormCarModel + { + /// + /// 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() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "FormCarModel"; + } + + #endregion + } +} \ No newline at end of file diff --git a/SUBD_Car_rent/Forms/FormCarModel.cs b/SUBD_Car_rent/Forms/FormCarModel.cs new file mode 100644 index 0000000..867cd93 --- /dev/null +++ b/SUBD_Car_rent/Forms/FormCarModel.cs @@ -0,0 +1,14 @@ +using database; + +namespace Forms +{ + public partial class FormCarModel : Form + { + private Abstractions bd; + public FormCarModel(Abstractions _bd) + { + InitializeComponent(); + bd = _bd; + } + } +} diff --git a/SUBD_Car_rent/Forms/FormCarModel.resx b/SUBD_Car_rent/Forms/FormCarModel.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SUBD_Car_rent/Forms/FormCarModel.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/SUBD_Car_rent/Forms/FormMain.cs b/SUBD_Car_rent/Forms/FormMain.cs index 3c52181..d6ff695 100644 --- a/SUBD_Car_rent/Forms/FormMain.cs +++ b/SUBD_Car_rent/Forms/FormMain.cs @@ -12,7 +12,11 @@ namespace Forms private void carModelToolStripMenuItem_Click(object sender, EventArgs e) { - + var service = Program.ServiceProvider?.GetService(typeof(FormCarModel)); + if (service is FormCarModel form) + { + form.ShowDialog(); + } } private void carToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/SUBD_Car_rent/Forms/Forms.csproj b/SUBD_Car_rent/Forms/Forms.csproj index f2ca8eb..d97ca3c 100644 --- a/SUBD_Car_rent/Forms/Forms.csproj +++ b/SUBD_Car_rent/Forms/Forms.csproj @@ -8,6 +8,10 @@ enable + + + + diff --git a/SUBD_Car_rent/Forms/Program.cs b/SUBD_Car_rent/Forms/Program.cs index db0074d..5acc591 100644 --- a/SUBD_Car_rent/Forms/Program.cs +++ b/SUBD_Car_rent/Forms/Program.cs @@ -1,7 +1,12 @@ +using database; +using Microsoft.Extensions.DependencyInjection; + namespace Forms { internal static class Program { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; /// /// The main entry point for the application. /// @@ -11,7 +16,16 @@ namespace Forms // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormMain()); + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + Application.Run(_serviceProvider.GetRequiredService()); + } + private static void ConfigureServices(ServiceCollection services) + { + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file