From f12b7f6c384a40f3f3b5d9e6f80b7dcb6ea9224d Mon Sep 17 00:00:00 2001 From: Timourka Date: Tue, 26 Mar 2024 21:33:40 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B0=D0=BC=D1=83=D1=82=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=81=D1=91=D1=80=D0=B2=D0=B8=D1=81=20=D0=BF=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=B9=D0=B4=D0=B5=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUBD_Car_rent/Forms/FormCarModel.Designer.cs | 39 ++++++ SUBD_Car_rent/Forms/FormCarModel.cs | 14 +++ SUBD_Car_rent/Forms/FormCarModel.resx | 120 +++++++++++++++++++ SUBD_Car_rent/Forms/FormMain.cs | 6 +- SUBD_Car_rent/Forms/Forms.csproj | 4 + SUBD_Car_rent/Forms/Program.cs | 16 ++- 6 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 SUBD_Car_rent/Forms/FormCarModel.Designer.cs create mode 100644 SUBD_Car_rent/Forms/FormCarModel.cs create mode 100644 SUBD_Car_rent/Forms/FormCarModel.resx 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