From 1758e6f5cedff57c057c2418bd73fb6c3cbf8c81 Mon Sep 17 00:00:00 2001 From: Timourka Date: Tue, 7 May 2024 22:49:14 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B5=D0=B6=D0=B4=D1=83=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B7=D0=BD=D1=8B=D0=BC=D0=B8=20=D1=81=D1=83=D0=B1?= =?UTF-8?q?=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUBD_Car_rent/Forms/FormMain.Designer.cs | 256 +++++++++++++---------- SUBD_Car_rent/Forms/FormMain.cs | 16 +- SUBD_Car_rent/Forms/Program.cs | 58 +++-- 3 files changed, 207 insertions(+), 123 deletions(-) diff --git a/SUBD_Car_rent/Forms/FormMain.Designer.cs b/SUBD_Car_rent/Forms/FormMain.Designer.cs index a76dce7..0cb3aae 100644 --- a/SUBD_Car_rent/Forms/FormMain.Designer.cs +++ b/SUBD_Car_rent/Forms/FormMain.Designer.cs @@ -20,115 +20,154 @@ base.Dispose(disposing); } - #region Windows Form Designer generated code + #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() - { - menuStrip1 = new MenuStrip(); - tablesToolStripMenuItem = new ToolStripMenuItem(); - carModelToolStripMenuItem = new ToolStripMenuItem(); - carToolStripMenuItem = new ToolStripMenuItem(); - branchToolStripMenuItem = new ToolStripMenuItem(); - clientToolStripMenuItem = new ToolStripMenuItem(); - rentalToolStripMenuItem = new ToolStripMenuItem(); - buttonTest = new Button(); - textBoxTest = new TextBox(); - menuStrip1.SuspendLayout(); - SuspendLayout(); - // - // menuStrip1 - // - menuStrip1.Items.AddRange(new ToolStripItem[] { tablesToolStripMenuItem }); - menuStrip1.Location = new Point(0, 0); - menuStrip1.Name = "menuStrip1"; - menuStrip1.Size = new Size(435, 24); - menuStrip1.TabIndex = 0; - menuStrip1.Text = "menuStrip1"; - // - // tablesToolStripMenuItem - // - tablesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { carModelToolStripMenuItem, carToolStripMenuItem, branchToolStripMenuItem, clientToolStripMenuItem, rentalToolStripMenuItem }); - tablesToolStripMenuItem.Name = "tablesToolStripMenuItem"; - tablesToolStripMenuItem.Size = new Size(50, 20); - tablesToolStripMenuItem.Text = "tables"; - // - // carModelToolStripMenuItem - // - carModelToolStripMenuItem.Name = "carModelToolStripMenuItem"; - carModelToolStripMenuItem.Size = new Size(127, 22); - carModelToolStripMenuItem.Text = "car model"; - carModelToolStripMenuItem.Click += carModelToolStripMenuItem_Click; - // - // carToolStripMenuItem - // - carToolStripMenuItem.Name = "carToolStripMenuItem"; - carToolStripMenuItem.Size = new Size(127, 22); - carToolStripMenuItem.Text = "car"; - carToolStripMenuItem.Click += carToolStripMenuItem_Click; - // - // branchToolStripMenuItem - // - branchToolStripMenuItem.Name = "branchToolStripMenuItem"; - branchToolStripMenuItem.Size = new Size(127, 22); - branchToolStripMenuItem.Text = "branch"; - branchToolStripMenuItem.Click += branchToolStripMenuItem_Click; - // - // clientToolStripMenuItem - // - clientToolStripMenuItem.Name = "clientToolStripMenuItem"; - clientToolStripMenuItem.Size = new Size(127, 22); - clientToolStripMenuItem.Text = "client"; - clientToolStripMenuItem.Click += clientToolStripMenuItem_Click; - // - // rentalToolStripMenuItem - // - rentalToolStripMenuItem.Name = "rentalToolStripMenuItem"; - rentalToolStripMenuItem.Size = new Size(127, 22); - rentalToolStripMenuItem.Text = "rental"; - rentalToolStripMenuItem.Click += rentalToolStripMenuItem_Click; - // - // buttonTest - // - buttonTest.Location = new Point(24, 50); - buttonTest.Name = "buttonTest"; - buttonTest.Size = new Size(75, 23); - buttonTest.TabIndex = 1; - buttonTest.Text = "buttonTest"; - buttonTest.UseVisualStyleBackColor = true; - buttonTest.Click += buttonTest_Click; - // - // textBoxTest - // - textBoxTest.Location = new Point(121, 51); - textBoxTest.Multiline = true; - textBoxTest.Name = "textBoxTest"; - textBoxTest.Size = new Size(251, 75); - textBoxTest.TabIndex = 2; - // - // FormMain - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(435, 167); - Controls.Add(textBoxTest); - Controls.Add(buttonTest); - Controls.Add(menuStrip1); - MainMenuStrip = menuStrip1; - Name = "FormMain"; - Text = "FormMain"; - menuStrip1.ResumeLayout(false); - menuStrip1.PerformLayout(); - ResumeLayout(false); - PerformLayout(); - } + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + menuStrip1 = new MenuStrip(); + tablesToolStripMenuItem = new ToolStripMenuItem(); + carModelToolStripMenuItem = new ToolStripMenuItem(); + carToolStripMenuItem = new ToolStripMenuItem(); + branchToolStripMenuItem = new ToolStripMenuItem(); + clientToolStripMenuItem = new ToolStripMenuItem(); + rentalToolStripMenuItem = new ToolStripMenuItem(); + buttonTest = new Button(); + textBoxTest = new TextBox(); + trackBarDB = new TrackBar(); + labelPostrges = new Label(); + labelMongoDB = new Label(); + menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)trackBarDB).BeginInit(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.Items.AddRange(new ToolStripItem[] { tablesToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(435, 24); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // tablesToolStripMenuItem + // + tablesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { carModelToolStripMenuItem, carToolStripMenuItem, branchToolStripMenuItem, clientToolStripMenuItem, rentalToolStripMenuItem }); + tablesToolStripMenuItem.Name = "tablesToolStripMenuItem"; + tablesToolStripMenuItem.Size = new Size(50, 20); + tablesToolStripMenuItem.Text = "tables"; + // + // carModelToolStripMenuItem + // + carModelToolStripMenuItem.Name = "carModelToolStripMenuItem"; + carModelToolStripMenuItem.Size = new Size(127, 22); + carModelToolStripMenuItem.Text = "car model"; + carModelToolStripMenuItem.Click += carModelToolStripMenuItem_Click; + // + // carToolStripMenuItem + // + carToolStripMenuItem.Name = "carToolStripMenuItem"; + carToolStripMenuItem.Size = new Size(127, 22); + carToolStripMenuItem.Text = "car"; + carToolStripMenuItem.Click += carToolStripMenuItem_Click; + // + // branchToolStripMenuItem + // + branchToolStripMenuItem.Name = "branchToolStripMenuItem"; + branchToolStripMenuItem.Size = new Size(127, 22); + branchToolStripMenuItem.Text = "branch"; + branchToolStripMenuItem.Click += branchToolStripMenuItem_Click; + // + // clientToolStripMenuItem + // + clientToolStripMenuItem.Name = "clientToolStripMenuItem"; + clientToolStripMenuItem.Size = new Size(127, 22); + clientToolStripMenuItem.Text = "client"; + clientToolStripMenuItem.Click += clientToolStripMenuItem_Click; + // + // rentalToolStripMenuItem + // + rentalToolStripMenuItem.Name = "rentalToolStripMenuItem"; + rentalToolStripMenuItem.Size = new Size(127, 22); + rentalToolStripMenuItem.Text = "rental"; + rentalToolStripMenuItem.Click += rentalToolStripMenuItem_Click; + // + // buttonTest + // + buttonTest.Location = new Point(75, 229); + buttonTest.Name = "buttonTest"; + buttonTest.Size = new Size(75, 23); + buttonTest.TabIndex = 1; + buttonTest.Text = "buttonTest"; + buttonTest.UseVisualStyleBackColor = true; + buttonTest.Click += buttonTest_Click; + // + // textBoxTest + // + textBoxTest.Location = new Point(172, 230); + textBoxTest.Multiline = true; + textBoxTest.Name = "textBoxTest"; + textBoxTest.Size = new Size(251, 75); + textBoxTest.TabIndex = 2; + // + // trackBarDB + // + trackBarDB.LargeChange = 1; + trackBarDB.Location = new Point(12, 34); + trackBarDB.Maximum = 100; + trackBarDB.Name = "trackBarDB"; + trackBarDB.Orientation = Orientation.Vertical; + trackBarDB.Size = new Size(45, 64); + trackBarDB.TabIndex = 3; + trackBarDB.MouseUp += trackBarDB_MouseUp; + // + // labelPostrges + // + labelPostrges.AutoSize = true; + labelPostrges.Font = new Font("Segoe UI", 20F, FontStyle.Regular, GraphicsUnit.Point); + labelPostrges.Location = new Point(33, 64); + labelPostrges.Name = "labelPostrges"; + labelPostrges.Size = new Size(117, 37); + labelPostrges.TabIndex = 4; + labelPostrges.Text = "Postrges"; + // + // labelMongoDB + // + labelMongoDB.AutoSize = true; + labelMongoDB.Font = new Font("Segoe UI", 20F, FontStyle.Regular, GraphicsUnit.Point); + labelMongoDB.Location = new Point(33, 27); + labelMongoDB.Name = "labelMongoDB"; + labelMongoDB.Size = new Size(138, 37); + labelMongoDB.TabIndex = 5; + labelMongoDB.Text = "MongoDB"; + // + // FormMain + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(435, 317); + Controls.Add(labelMongoDB); + Controls.Add(labelPostrges); + Controls.Add(trackBarDB); + Controls.Add(textBoxTest); + Controls.Add(buttonTest); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "FormMain"; + Text = "FormMain"; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)trackBarDB).EndInit(); + ResumeLayout(false); + PerformLayout(); + } - #endregion + #endregion - private MenuStrip menuStrip1; + private MenuStrip menuStrip1; private ToolStripMenuItem tablesToolStripMenuItem; private ToolStripMenuItem carModelToolStripMenuItem; private ToolStripMenuItem carToolStripMenuItem; @@ -137,5 +176,8 @@ private ToolStripMenuItem rentalToolStripMenuItem; private Button buttonTest; private TextBox textBoxTest; - } + private TrackBar trackBarDB; + private Label labelPostrges; + private Label labelMongoDB; + } } \ No newline at end of file diff --git a/SUBD_Car_rent/Forms/FormMain.cs b/SUBD_Car_rent/Forms/FormMain.cs index 41c5a04..bb1ef64 100644 --- a/SUBD_Car_rent/Forms/FormMain.cs +++ b/SUBD_Car_rent/Forms/FormMain.cs @@ -82,7 +82,21 @@ namespace Forms } } - /* + private void trackBarDB_MouseUp(object sender, MouseEventArgs e) + { + if (trackBarDB.Value > 50) + { + trackBarDB.Value = 100; + Program.ChangeDB(false); + } + else + { + trackBarDB.Value = 0; + Program.ChangeDB(true); + } + } + + /* private Abstractions bd = new Implementation(); private void button1_Click(object sender, EventArgs e) { diff --git a/SUBD_Car_rent/Forms/Program.cs b/SUBD_Car_rent/Forms/Program.cs index 71e88f2..782e53c 100644 --- a/SUBD_Car_rent/Forms/Program.cs +++ b/SUBD_Car_rent/Forms/Program.cs @@ -7,10 +7,31 @@ namespace Forms { private static ServiceProvider? _serviceProvider; public static ServiceProvider? ServiceProvider => _serviceProvider; - /// - /// The main entry point for the application. - /// - [STAThread] + + private static bool isPostgreSQL = true; + + private static void ConfigureServices(ServiceCollection services) + { + if (isPostgreSQL) + { + services.AddTransient(); + } + else + { + services.AddTransient(); + } + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + } + + /// + /// The main entry point for the application. + /// + [STAThread] static void Main() { // To customize application configuration such as set high DPI settings or default font, @@ -21,15 +42,22 @@ namespace Forms _serviceProvider = services.BuildServiceProvider(); Application.Run(_serviceProvider.GetRequiredService()); } - private static void ConfigureServices(ServiceCollection services) - { - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - } - } + + public static void ChangeDB() + { + isPostgreSQL = !isPostgreSQL; + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + } + public static void ChangeDB(bool newIsPostrgeSQL) + { + if (newIsPostrgeSQL == isPostgreSQL) + return; + isPostgreSQL = newIsPostrgeSQL; + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + } + } } \ No newline at end of file