123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- 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();
- }
- }
- }
|