Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.SqlClient;
- using System.Drawing;
- using System.Linq;
- using System.Reflection.Emit;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using MetroFramework;
- using System.Data.SQLite;
- namespace PyCharm
- {
- public partial class FormAuthorization : MetroFramework.Forms.MetroForm
- {
- Database Data;
- public FormAuthorization()
- {
- InitializeComponent();
- metroTabControl1.SelectedTab = Authorizationtab;
- }
- private void txtUsername_Click(object sender, EventArgs e)
- {
- txtUsername.Text = "";
- }
- private void txtPassword_Click(object sender, EventArgs e)
- {
- txtPassword.Text = "";
- }
- private void txtRegistrLogin_Click(object sender, EventArgs e)
- {
- RegistrLogin.Text = "";
- }
- private void txtRegistrPassword_Click(object sender, EventArgs e)
- {
- RegistrPassword.Text = "";
- }
- private void FormAuthorization_Load(object sender, EventArgs e)
- {
- Data = new Database();
- Data.getconnection();
- }
- private void insert(string username,string password)
- {
- try
- {
- using (SQLiteConnection con=new SQLiteConnection(Data.connectionString))
- {
- con.Open();
- SQLiteCommand command = new SQLiteCommand();
- string query = @"INSERT INTO LOGIN (Username,Password)VALUES(@Username,@Password)";
- command.CommandText = query;
- command.Connection = con;
- command.Parameters.Add(new SQLiteParameter("@Username",username));
- command.Parameters.Add(new SQLiteParameter("@Password",password));
- command.ExecuteNonQuery();
- MessageBox.Show("Успешная регистрация","Уведомление",MessageBoxButtons.OK,MessageBoxIcon.Information);
- con.Close();
- }
- }
- catch
- {
- MessageBox.Show("Ошибка при добавлении в базу", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void btnRegistr_Click(object sender, EventArgs e)
- {
- if(RegistrLogin.Text != string.Empty && RegistrPassword.Text != string.Empty)
- {
- insert(RegistrLogin.Text,RegistrPassword.Text);
- }
- else
- {
- MessageBox.Show("Заполните все поля", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment