From 293282019b59dd2d19e5987554b546f98119a92c Mon Sep 17 00:00:00 2001 From: frog24 Date: Mon, 20 May 2024 20:33:34 +0400 Subject: [PATCH] =?UTF-8?q?=D1=84=D1=83=D0=BB=D0=BB=20=D0=BB=D0=B0=D0=B1?= =?UTF-8?q?=D0=B0.=20=D0=94=D0=B0=D0=BD=D0=BD=D1=8B=D0=B5=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BE=D1=81=D1=8F=D1=82=D1=81=D1=8F=20=D1=82?= =?UTF-8?q?=D1=83=D0=B4=D0=B0=20=D0=BE=D0=B1=D1=80=D0=B0=D1=82=D0=BD=D0=BE?= =?UTF-8?q?,=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=B8=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D0=BE=20=D1=81=20=D0=B2=D1=8B=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=BD=D0=BE=D0=B9=20=D0=91=D0=94,=20=D0=BD=D1=83=20?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=BE=20=D0=BC=D0=B5=D0=BB=D0=BE=D1=87=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DepartmentStaffDatabase/Abstracts.cs | 14 +- .../DepartmentStaffDatabase/Implements.cs | 143 +++++++++++++----- .../MongoImplements.cs | 73 +++++---- .../DepartmentStaffView/FormMain.Designer.cs | 39 +++-- .../DepartmentStaffView/FormMain.cs | 105 ++++++++++++- 5 files changed, 285 insertions(+), 89 deletions(-) diff --git a/DepartmentStaffView/DepartmentStaffDatabase/Abstracts.cs b/DepartmentStaffView/DepartmentStaffDatabase/Abstracts.cs index 158823f..369ac20 100644 --- a/DepartmentStaffView/DepartmentStaffDatabase/Abstracts.cs +++ b/DepartmentStaffView/DepartmentStaffDatabase/Abstracts.cs @@ -8,7 +8,7 @@ namespace DepartmentStaffDatabase { public abstract class Abstracts { - public abstract void CreateDepartment(Department department); + public abstract void CreateDepartment(Department department, bool isChangedBD = false); public abstract void UpdateDepartment(Department department); public abstract void DeleteDepartment(int id); public abstract Department GetDepartment(int id); @@ -16,15 +16,15 @@ namespace DepartmentStaffDatabase public abstract List GetDepartments(); public abstract void DeleteDepartments(); - public abstract void CreatePosition(Position position); + public abstract void CreatePosition(Position position, bool isChangedBD = false); public abstract void UpdatePosition(Position position); public abstract void DeletePosition(int id); public abstract Position GetPosition(int id); public abstract Position GetPosition(string positionName); public abstract List GetPositions(); - public abstract void Deletepositions(); + public abstract void DeletePositions(); - public abstract void CreateEmployee(Employee employee); + public abstract void CreateEmployee(Employee employee, bool isChangedBD = false); public abstract void UpdateEmployee(Employee employee); public abstract void DeleteEmployee(int id); public abstract Employee GetEmployee(int id); @@ -32,14 +32,14 @@ namespace DepartmentStaffDatabase public abstract List GetEmployees(); public abstract void DeleteEmployees(); - public abstract void CreateContract(Contract contract); + public abstract void CreateContract(Contract contract, bool isChangedBD = false); public abstract void UpdateContract(Contract contract); public abstract void DeleteContract(int id); public abstract Contract GetContract(int id); public abstract List GetContracts(); public abstract void DeleteContracts(); - public abstract void CreateCourse(Course course); + public abstract void CreateCourse(Course course, bool isChangedBD = false); public abstract void UpdateCourse(Course course); public abstract void DeleteCourse(int id); public abstract Course GetCourse(int id); @@ -47,7 +47,7 @@ namespace DepartmentStaffDatabase public abstract void DeleteCourses(); - public abstract void CreateEmployee_Course(Employee_Course employee_course); + public abstract void CreateEmployee_Course(Employee_Course employee_course, bool isChangedBD = false); public abstract void DeleteEmployee_Course(int empId, int courseId); public abstract Employee_Course GetEmployee_Course(int empId, int courseId); public abstract List GetEmployee_Courses(); diff --git a/DepartmentStaffView/DepartmentStaffDatabase/Implements.cs b/DepartmentStaffView/DepartmentStaffDatabase/Implements.cs index 349960c..df72b1c 100644 --- a/DepartmentStaffView/DepartmentStaffDatabase/Implements.cs +++ b/DepartmentStaffView/DepartmentStaffDatabase/Implements.cs @@ -14,15 +14,27 @@ namespace DepartmentStaffDatabase { return new NpgsqlConnection("Host=192.168.56.103;Username=postgres;Password=postgres;Database=TestLab3"); } - public override void CreateDepartment(Department department) + public override void CreateDepartment(Department department, bool isChangedBD = false) { using var conn = GetConnect(); conn.Open(); - using var cmd = new NpgsqlCommand - ("INSERT INTO department VALUES (nextval('Department_seq'), @Name, @Head)", conn); - cmd.Parameters.AddWithValue("@name", department.DepartmentName); - cmd.Parameters.AddWithValue("@head", department.Head); - cmd.ExecuteNonQuery(); + if (!isChangedBD) + { + using var cmd = new NpgsqlCommand + ("INSERT INTO department VALUES (nextval('Department_seq'), @Name, @Head)", conn); + cmd.Parameters.AddWithValue("@name", department.DepartmentName); + cmd.Parameters.AddWithValue("@head", department.Head); + cmd.ExecuteNonQuery(); + } + else + { + using var cmd = new NpgsqlCommand + ("INSERT INTO department VALUES (@Id, @Name, @Head)", conn); + cmd.Parameters.AddWithValue("@id", department.Id); + cmd.Parameters.AddWithValue("@name", department.DepartmentName); + cmd.Parameters.AddWithValue("@head", department.Head); + cmd.ExecuteNonQuery(); + } } public override void UpdateDepartment(Department department) { @@ -104,16 +116,29 @@ namespace DepartmentStaffDatabase //======================================================================= - public override void CreatePosition(Position position) + public override void CreatePosition(Position position, bool isChangedBD = false) { using var conn = GetConnect(); conn.Open(); - using var cmd = new NpgsqlCommand + if (!isChangedBD) + { + using var cmd = new NpgsqlCommand ("INSERT INTO position VALUES (nextval('Position_seq'), @Name, @Salary, @DepartmentId)", conn); - cmd.Parameters.AddWithValue("@name", position.PositionName); - cmd.Parameters.AddWithValue("@salary", position.Salary); - cmd.Parameters.AddWithValue("@departmentId", position.DepartmentId); - cmd.ExecuteNonQuery(); + cmd.Parameters.AddWithValue("@name", position.PositionName); + cmd.Parameters.AddWithValue("@salary", position.Salary); + cmd.Parameters.AddWithValue("@departmentId", position.DepartmentId); + cmd.ExecuteNonQuery(); + } + else + { + using var cmd = new NpgsqlCommand + ("INSERT INTO position VALUES (@Id, @Name, @Salary, @DepartmentId)", conn); + cmd.Parameters.AddWithValue("@id", position.Id); + cmd.Parameters.AddWithValue("@name", position.PositionName); + cmd.Parameters.AddWithValue("@salary", position.Salary); + cmd.Parameters.AddWithValue("@departmentId", position.DepartmentId); + cmd.ExecuteNonQuery(); + } } public override void UpdatePosition(Position position) { @@ -189,7 +214,7 @@ namespace DepartmentStaffDatabase } return positions; } - public override void Deletepositions() + public override void DeletePositions() { using var conn = GetConnect(); conn.Open(); @@ -199,19 +224,35 @@ namespace DepartmentStaffDatabase //======================================================================= - public override void CreateEmployee(Employee employee) + public override void CreateEmployee(Employee employee, bool isChangedBD = false) { using var conn = GetConnect(); conn.Open(); - using var cmd = new NpgsqlCommand - ("INSERT INTO employee VALUES (nextval('Employee_seq'), @Name, @Birthdate, @Address, @PhoneNumber, @Email, @PositionId)", conn); - cmd.Parameters.AddWithValue("@name", employee.EmployeeName); - cmd.Parameters.AddWithValue("@Birthdate", employee.Birthdate); - cmd.Parameters.AddWithValue("@Address", employee.Address); - cmd.Parameters.AddWithValue("@PhoneNumber", employee.PhoneNumber); - cmd.Parameters.AddWithValue("@Email", employee.Email); - cmd.Parameters.AddWithValue("@PositionId", employee.PositionId); - cmd.ExecuteNonQuery(); + if (!isChangedBD) + { + using var cmd = new NpgsqlCommand + ("INSERT INTO employee VALUES (nextval('Employee_seq'), @Name, @Birthdate, @Address, @PhoneNumber, @Email, @PositionId)", conn); + cmd.Parameters.AddWithValue("@name", employee.EmployeeName); + cmd.Parameters.AddWithValue("@Birthdate", employee.Birthdate); + cmd.Parameters.AddWithValue("@Address", employee.Address); + cmd.Parameters.AddWithValue("@PhoneNumber", employee.PhoneNumber); + cmd.Parameters.AddWithValue("@Email", employee.Email); + cmd.Parameters.AddWithValue("@PositionId", employee.PositionId); + cmd.ExecuteNonQuery(); + } + else + { + using var cmd = new NpgsqlCommand + ("INSERT INTO employee VALUES (@Id, @Name, @Birthdate, @Address, @PhoneNumber, @Email, @PositionId)", conn); + cmd.Parameters.AddWithValue("@id", employee.Id); + cmd.Parameters.AddWithValue("@name", employee.EmployeeName); + cmd.Parameters.AddWithValue("@Birthdate", employee.Birthdate); + cmd.Parameters.AddWithValue("@Address", employee.Address); + cmd.Parameters.AddWithValue("@PhoneNumber", employee.PhoneNumber); + cmd.Parameters.AddWithValue("@Email", employee.Email); + cmd.Parameters.AddWithValue("@PositionId", employee.PositionId); + cmd.ExecuteNonQuery(); + } } public override void UpdateEmployee(Employee employee) { @@ -310,16 +351,29 @@ namespace DepartmentStaffDatabase //======================================================================= - public override void CreateContract(Contract contract) + public override void CreateContract(Contract contract, bool isChangedBD = false) { using var conn = GetConnect(); conn.Open(); - using var cmd = new NpgsqlCommand - ("INSERT INTO contract VALUES (nextval('Contract_seq'), @DateOfConclusin, @Duration, @EmployeeId)", conn); - cmd.Parameters.AddWithValue("@dateOfConclusin", contract.DateOfConclusion); - cmd.Parameters.AddWithValue("@duration", contract.Duration); - cmd.Parameters.AddWithValue("@employeeId", contract.EmployeeId); - cmd.ExecuteNonQuery(); + if (!isChangedBD) + { + using var cmd = new NpgsqlCommand + ("INSERT INTO contract VALUES (nextval('Contract_seq'), @DateOfConclusin, @Duration, @EmployeeId)", conn); + cmd.Parameters.AddWithValue("@dateOfConclusin", contract.DateOfConclusion); + cmd.Parameters.AddWithValue("@duration", contract.Duration); + cmd.Parameters.AddWithValue("@employeeId", contract.EmployeeId); + cmd.ExecuteNonQuery(); + } + else + { + using var cmd = new NpgsqlCommand + ("INSERT INTO contract VALUES (@Id, @DateOfConclusin, @Duration, @EmployeeId)", conn); + cmd.Parameters.AddWithValue("@id", contract.Id); + cmd.Parameters.AddWithValue("@dateOfConclusin", contract.DateOfConclusion); + cmd.Parameters.AddWithValue("@duration", contract.Duration); + cmd.Parameters.AddWithValue("@employeeId", contract.EmployeeId); + cmd.ExecuteNonQuery(); + } } public override void UpdateContract(Contract contract) { @@ -387,16 +441,29 @@ namespace DepartmentStaffDatabase //======================================================================= - public override void CreateCourse(Course course) + public override void CreateCourse(Course course, bool isChangedBD = false) { using var conn = GetConnect(); conn.Open(); - using var cmd = new NpgsqlCommand - ("INSERT INTO course VALUES (nextval('Course_seq'), @EventDateb, @HoursNumber, @Result)", conn); - cmd.Parameters.AddWithValue("@EventDateb", course.DateOfEvent); - cmd.Parameters.AddWithValue("@HoursNumber", course.HoursNumber); - cmd.Parameters.AddWithValue("@Result", course.Result); - cmd.ExecuteNonQuery(); + if (!isChangedBD) + { + using var cmd = new NpgsqlCommand + ("INSERT INTO course VALUES (nextval('Course_seq'), @EventDateb, @HoursNumber, @Result)", conn); + cmd.Parameters.AddWithValue("@EventDateb", course.DateOfEvent); + cmd.Parameters.AddWithValue("@HoursNumber", course.HoursNumber); + cmd.Parameters.AddWithValue("@Result", course.Result); + cmd.ExecuteNonQuery(); + } + else + { + using var cmd = new NpgsqlCommand + ("INSERT INTO course VALUES (@Id, @EventDateb, @HoursNumber, @Result)", conn); + cmd.Parameters.AddWithValue("@Id", course.Id); + cmd.Parameters.AddWithValue("@EventDateb", course.DateOfEvent); + cmd.Parameters.AddWithValue("@HoursNumber", course.HoursNumber); + cmd.Parameters.AddWithValue("@Result", course.Result); + cmd.ExecuteNonQuery(); + } } public override void UpdateCourse(Course course) { @@ -464,7 +531,7 @@ namespace DepartmentStaffDatabase //======================================================================= - public override void CreateEmployee_Course(Employee_Course employee_course) + public override void CreateEmployee_Course(Employee_Course employee_course, bool isChangedBD = false) { using var conn = GetConnect(); conn.Open(); diff --git a/DepartmentStaffView/DepartmentStaffDatabase/MongoImplements.cs b/DepartmentStaffView/DepartmentStaffDatabase/MongoImplements.cs index ba45499..5826b50 100644 --- a/DepartmentStaffView/DepartmentStaffDatabase/MongoImplements.cs +++ b/DepartmentStaffView/DepartmentStaffDatabase/MongoImplements.cs @@ -33,14 +33,17 @@ namespace DepartmentStaffDatabase _employee_CourseCollection = _database.GetCollection("employee_courses"); } - public override void CreateDepartment(Department department) + public override void CreateDepartment(Department department, bool isChangedBD = false) { - var maxId = 0; - if (GetDepartments().Count > 0) + if (!isChangedBD) { - maxId = _departmentCollection.AsQueryable().Max(dep => dep.Id); + var maxId = 0; + if (GetDepartments().Count > 0) + { + maxId = _departmentCollection.AsQueryable().Max(dep => dep.Id); + } + department.Id = maxId + 1; } - department.Id = maxId + 1; _departmentCollection.InsertOne(department); } public override void UpdateDepartment(Department department) @@ -70,14 +73,17 @@ namespace DepartmentStaffDatabase //======================================================================= - public override void CreatePosition(Position position) + public override void CreatePosition(Position position, bool isChangedBD = false) { - var maxId = 0; - if (GetPositions().Count > 0) + if (!isChangedBD) { - maxId = _positionCollection.AsQueryable().Max(pos => pos.Id); + var maxId = 0; + if (GetPositions().Count > 0) + { + maxId = _positionCollection.AsQueryable().Max(pos => pos.Id); + } + position.Id = maxId + 1; } - position.Id = maxId + 1; _positionCollection.InsertOne(position); } public override void UpdatePosition(Position position) @@ -105,21 +111,24 @@ namespace DepartmentStaffDatabase { return _positionCollection.Find(_ => true).ToList(); } - public override void Deletepositions() + public override void DeletePositions() { _positionCollection.DeleteMany(_ => true); } //======================================================================= - public override void CreateEmployee(Employee employee) + public override void CreateEmployee(Employee employee, bool isChangedBD = false) { - var maxId = 0; - if (GetEmployees().Count > 0) + if (!isChangedBD) { - maxId = _employeeCollection.AsQueryable().Max(emp => emp.Id); + var maxId = 0; + if (GetEmployees().Count > 0) + { + maxId = _employeeCollection.AsQueryable().Max(emp => emp.Id); + } + employee.Id = maxId + 1; } - employee.Id = maxId + 1; _employeeCollection.InsertOne(employee); } public override void UpdateEmployee(Employee employee) @@ -152,19 +161,22 @@ namespace DepartmentStaffDatabase } public override void DeleteEmployees() { - _positionCollection.DeleteMany(_ => true); + _employeeCollection.DeleteMany(_ => true); } //======================================================================= - public override void CreateContract(Contract contract) + public override void CreateContract(Contract contract, bool isChangedBD = false) { - var maxId = 0; - if (GetContracts().Count > 0) + if (!isChangedBD) { - maxId = _contractCollection.AsQueryable().Max(con => con.Id); + var maxId = 0; + if (GetContracts().Count > 0) + { + maxId = _contractCollection.AsQueryable().Max(con => con.Id); + } + contract.Id = maxId + 1; } - contract.Id = maxId + 1; _contractCollection.InsertOne(contract); } public override void UpdateContract(Contract contract) @@ -190,19 +202,22 @@ namespace DepartmentStaffDatabase } public override void DeleteContracts() { - _positionCollection.DeleteMany(_ => true); + _contractCollection.DeleteMany(_ => true); } //======================================================================= - public override void CreateCourse(Course course) + public override void CreateCourse(Course course, bool isChangedBD = false) { - var maxId = 0; - if (GetCourses().Count > 0) + if (!isChangedBD) { - maxId = _courseCollection.AsQueryable().Max(crs => crs.Id); + var maxId = 0; + if (GetCourses().Count > 0) + { + maxId = _courseCollection.AsQueryable().Max(crs => crs.Id); + } + course.Id = maxId + 1; } - course.Id = maxId + 1; _courseCollection.InsertOne(course); } public override void UpdateCourse(Course course) @@ -233,7 +248,7 @@ namespace DepartmentStaffDatabase //======================================================================= - public override void CreateEmployee_Course(Employee_Course employee_course) + public override void CreateEmployee_Course(Employee_Course employee_course, bool isChangedBD = false) { var maxId = 0; if (GetEmployee_Courses().Count > 0) diff --git a/DepartmentStaffView/DepartmentStaffView/FormMain.Designer.cs b/DepartmentStaffView/DepartmentStaffView/FormMain.Designer.cs index 8310639..8e260ac 100644 --- a/DepartmentStaffView/DepartmentStaffView/FormMain.Designer.cs +++ b/DepartmentStaffView/DepartmentStaffView/FormMain.Designer.cs @@ -43,7 +43,8 @@ buttonEmployeesDelete = new Button(); buttonEmployeesUpdate = new Button(); buttonEmployeesCreate = new Button(); - radioButtonMongo = new RadioButton(); + checkBox1 = new CheckBox(); + label1 = new Label(); SuspendLayout(); // // buttonDepartments @@ -196,25 +197,34 @@ buttonEmployeesCreate.UseVisualStyleBackColor = true; buttonEmployeesCreate.Click += buttonEmployeesCreate_Click; // - // radioButtonMongo + // checkBox1 // - radioButtonMongo.AutoSize = true; - radioButtonMongo.ImageAlign = ContentAlignment.TopRight; - radioButtonMongo.Location = new Point(561, 341); - radioButtonMongo.Name = "radioButtonMongo"; - radioButtonMongo.Size = new Size(79, 19); - radioButtonMongo.TabIndex = 16; - radioButtonMongo.TabStop = true; - radioButtonMongo.Text = "MongoDB"; - radioButtonMongo.UseVisualStyleBackColor = true; - radioButtonMongo.CheckedChanged += radioButtonMongo_CheckedChanged; + checkBox1.AutoSize = true; + checkBox1.Location = new Point(557, 343); + checkBox1.Name = "checkBox1"; + checkBox1.Size = new Size(80, 19); + checkBox1.TabIndex = 17; + checkBox1.Text = "MongoDB"; + checkBox1.UseVisualStyleBackColor = true; + checkBox1.CheckedChanged += radioButtonMongo_CheckedChanged; + // + // label1 + // + label1.AutoSize = true; + label1.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + label1.Location = new Point(349, 339); + label1.Name = "label1"; + label1.Size = new Size(202, 21); + label1.TabIndex = 18; + label1.Text = "Тeкущая СУБД: PostgreSQL"; // // FormMain // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(649, 371); - Controls.Add(radioButtonMongo); + Controls.Add(label1); + Controls.Add(checkBox1); Controls.Add(buttonEmployeesDelete); Controls.Add(buttonEmployeesUpdate); Controls.Add(buttonEmployeesCreate); @@ -253,6 +263,7 @@ private Button buttonEmployeesDelete; private Button buttonEmployeesUpdate; private Button buttonEmployeesCreate; - private RadioButton radioButtonMongo; + private CheckBox checkBox1; + private Label label1; } } \ No newline at end of file diff --git a/DepartmentStaffView/DepartmentStaffView/FormMain.cs b/DepartmentStaffView/DepartmentStaffView/FormMain.cs index 0585f6b..e6158a3 100644 --- a/DepartmentStaffView/DepartmentStaffView/FormMain.cs +++ b/DepartmentStaffView/DepartmentStaffView/FormMain.cs @@ -248,17 +248,120 @@ namespace DepartmentStaffView MessageBox.Show("Удалено 200 работников за " + (end - start).Milliseconds.ToString() + " миллисекунд"); } + //перевод из постгреса в монго + private void changeToMongoDB() + { + MongoImplements mongoImplements = new(); + Implements postreImplements = new(); + + //все удалил + mongoImplements.DeleteEmployee_Courses(); + mongoImplements.DeleteContracts(); + mongoImplements.DeleteCourses(); + mongoImplements.DeleteEmployees(); + mongoImplements.DeletePositions(); + mongoImplements.DeleteDepartments(); + + //взял данные из постгреса + var listDepartments = postreImplements.GetDepartments(); + var listPositions = postreImplements.GetPositions(); + var listEmployees = postreImplements.GetEmployees(); + var listCourses = postreImplements.GetCourses(); + var listContracts = postreImplements.GetContracts(); + var listEmployee_Courses = postreImplements.GetEmployee_Courses(); + + //заношу в монго + foreach (var element in listDepartments) + { + mongoImplements.CreateDepartment(element, true); + } + foreach (var element in listPositions) + { + mongoImplements.CreatePosition(element, true); + } + foreach (var element in listEmployees) + { + mongoImplements.CreateEmployee(element, true); + } + foreach (var element in listCourses) + { + mongoImplements.CreateCourse(element, true); + } + foreach (var element in listContracts) + { + mongoImplements.CreateContract(element, true); + } + foreach (var element in listEmployee_Courses) + { + mongoImplements.CreateEmployee_Course(element, true); + } + } + + private void changeToPostgreSQL() + { + MongoImplements mongoImplements = new(); + Implements postreImplements = new(); + + //все удалил + postreImplements.DeleteEmployee_Courses(); + postreImplements.DeleteContracts(); + postreImplements.DeleteCourses(); + postreImplements.DeleteEmployees(); + postreImplements.DeletePositions(); + postreImplements.DeleteDepartments(); + + //взял данные из монго + var listDepartments = mongoImplements.GetDepartments(); + var listPositions = mongoImplements.GetPositions(); + var listEmployees = mongoImplements.GetEmployees(); + var listCourses = mongoImplements.GetCourses(); + var listContracts = mongoImplements.GetContracts(); + var listEmployee_Courses = mongoImplements.GetEmployee_Courses(); + + //заношу в постгрес + foreach (var element in listDepartments) + { + postreImplements.CreateDepartment(element, true); + } + foreach (var element in listPositions) + { + postreImplements.CreatePosition(element, true); + } + foreach (var element in listEmployees) + { + postreImplements.CreateEmployee(element, true); + } + foreach (var element in listCourses) + { + postreImplements.CreateCourse(element, true); + } + foreach (var element in listContracts) + { + postreImplements.CreateContract(element, true); + } + foreach (var element in listEmployee_Courses) + { + postreImplements.CreateEmployee_Course(element, true); + } + } + private void radioButtonMongo_CheckedChanged(object sender, EventArgs e) { - if (radioButtonMongo.Checked) + if (checkBox1.Checked) { Program.ChangeDB(false); MessageBox.Show("База данных сменилась на MongoDB"); + changeToMongoDB(); + MessageBox.Show("Данные были перемещены в БД на MongoDB"); + label1.Text = "Тeкущая СУБД: MongoDB"; } else { Program.ChangeDB(true); MessageBox.Show("База данных сменилась на PostgreSQL"); + changeToPostgreSQL(); + MessageBox.Show("Данные были перемещены в БД на PostgreSQL"); + label1.Text = "Тeкущая СУБД: PostgreSQL"; } } }