123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- 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 yrok2
- {
- public partial class Form3 : Form
- {
- Class1 database = new Class1();
- public Form3()
- {
- InitializeComponent();
- StartPosition = FormStartPosition.CenterScreen;
- }
- private void Form3_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 LoginPassword(Login, Password) values ('{login}' , '{password}')";
- SqlCommand command = new SqlCommand(querystring, database.GetConnection());
- database.openConnection();
- if (command.ExecuteNonQuery() == 1)
- {
- MessageBox.Show("Аккаунт успешно создан!", "Успех!");
- Authorization frm = new Authorization();
- 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 Login, Password from LoginPassword where Login = '{loginuser}' and Password = '{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;
- }
- }
- }
- }
|