using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace Perevozki { public partial class Admin : Form { public Admin() { InitializeComponent(); StartPosition = FormStartPosition.CenterScreen; } private void button1_Click(object sender, EventArgs e) { DB dataBase = new DB(); var log = textBox1.Text; var pass = textBox2.Text; string querystring = $"insert into Polzovateli (Login, Password) values('{log}', '{pass}')"; SqlCommand command = new SqlCommand(querystring, dataBase.GetConnection()); dataBase.OpenConnection(); if(command.ExecuteNonQuery() ==1 ) { MessageBox.Show("Пользователь добавлен!"); } } private void button2_Click(object sender, EventArgs e) { DB dataBase = new DB(); var ID = textBox3.Text; string querystring = $"DELETE FROM Polzovateli WHERE IDUser = {ID}"; SqlCommand command = new SqlCommand(querystring, dataBase.GetConnection()); dataBase.OpenConnection(); if (command.ExecuteNonQuery() == 1) { MessageBox.Show("Пользователь удален!"); } else { MessageBox.Show("Такого пользователя нету"); } } private void button3_Click(object sender, EventArgs e) { } private void button3_Click_1(object sender, EventArgs e) { DB dataBase = new DB(); var log = textBox1.Text; var pass = textBox2.Text; var ID = textBox3.Text; string changeQuery = $"UPDATE Polzovateli SET Login = '{log}' , Password = '{pass}' where IDUser = '{ID}'"; SqlCommand command = new SqlCommand(changeQuery, dataBase.GetConnection()); dataBase.OpenConnection(); if (command.ExecuteNonQuery() == 1) { MessageBox.Show("Данные изменены"); } } private void button4_Click(object sender, EventArgs e) { Menu f4 = new Menu(); f4.Show(); Hide(); } } }