12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- 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 Khozeev8
- {
- public partial class Registration : Form
- {
- Database database = new Database();
- public Registration()
- {
- InitializeComponent();
- StartPosition = FormStartPosition.CenterScreen;
- }
- private void Registration_Load(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- var login = textBox1.Text;
- var password = textBox2.Text;
- string querystring = $"insert into Пользователи(Логин, Пароль) values ('{login}' , '{password}')";
- SqlCommand command = new SqlCommand(querystring, database.GetConnection());
- database.openConnection();
- if (command.ExecuteNonQuery() == 1)
- {
- MessageBox.Show("Аккаунт успешно создан!", "Успех!");
- Aithorization frm = new Aithorization();
- this.Hide();
- frm.Show();
- }
- else
- {
- MessageBox.Show("Аккаунт не создан!");
- }
- database.closeConnection();
- }
- private Boolean checkuser()
- {
- var loginuser = textBox1.Text;
- var passuser = textBox2.Text;
- SqlDataAdapter adapter = new SqlDataAdapter();
- DataTable table = new DataTable();
- string querystring = $"select Логин, Пароль from Пользователи where Логин = '{loginuser}' and Пароль = '{passuser}'";
- SqlCommand command = new SqlCommand(querystring, database.GetConnection());
- adapter.SelectCommand = command;
- adapter.Fill(table);
- if (table.Rows.Count > 0)
- {
- MessageBox.Show("Пользователь уже существует!");
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
|