ILOVALAR - Axborot tizimlari va texnalogiyalari

ILOVALAR
Auth.cs
using Guna.UI2.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace pasport_sys
{
public partial class Auth : Form
{
Query query = new Query();
public Auth()
{
InitializeComponent();
}
private void Auth_Load(object sender, EventArgs e)
{
EmailTextBox.Text = "narzikulovnodirbek@gmail.com";
PasswordTextBox.Text = "1234567890";
PassportTextBox.Text = "AC0310828";
EmailRegTextBox.Text = "narzikulovnodirbek@gmail.com";
PasswordRegTextBox.Text = "1234567890";
RePasswordRegTextBox.Text = "1234567890";
}
private void Auth_FormClosed(object sender, FormClosedEventArgs e)
{
Application.Exit();
}
private void LoginButton_Click(object sender, EventArgs e)
{
DataTable current_user = query.Select($"SELECT * FROM users_table WHERE email='{EmailTextBox.Text}' AND password='{PasswordTextBox.Text}'");
if (current_user.Rows.Count == 1)
{
Main main = new Main(current_user.Rows[0]);
main.Show();
this.Hide();
}
else MessageBox.Show("Email yoki parol xato");
}
private void RegisterButton_Click(object sender, EventArgs e)
{
DataTable exist_user = query.Select($"SELECT * FROM users_table WHERE email='{EmailRegTextBox.Text}'");
DataTable exist_user_pass = query.Select($"SELECT * FROM pass_app WHERE passport='{PassportTextBox.Text}'");
DataTable exist_user_metrka = query.Select($"SELECT * FROM user_details WHERE metrka='{PassportTextBox.Text}'");
if (exist_user.Rows.Count == 1 || exist_user_pass.Rows.Count == 1 || exist_user_metrka.Rows.Count == 1)
MessageBox.Show("Bunday foydalanuvchi oldin roʻyxatdan oʻtgan.");
else if (exist_user_pass.Rows.Count == 0 || exist_user_metrka.Rows.Count == 0) MessageBox.Show("Bunday Pasportli foydalanuvchi tizimda yoʻq.");
else
{
if (exist_user_pass.Rows.Count == 1)
{
query.post_put_delete($"INSERT INTO users_table(email, password, user_details_id) VALUES" +
$"('{EmailRegTextBox.Text}', '{PasswordRegTextBox.Text}', {exist_user_pass.Rows[0]["user_details_id"]})");
}
else if (exist_user_metrka.Rows.Count == 1)
{
query.post_put_delete($"INSERT INTO users_table(email, password, user_details_id) VALUES" +
$"('{EmailRegTextBox.Text}', '{PasswordRegTextBox.Text}', {exist_user_metrka.Rows[0]["Id"]})");
}
DataTable current_user = query.Select($"SELECT * FROM users_table WHERE email='{EmailTextBox.Text}' AND password='{PasswordTextBox.Text}'");
if (current_user.Rows.Count == 1)
{
Main main = new Main(current_user.Rows[0]);
main.Show();
this.Hide();
}
else MessageBox.Show("Registratsiyada xato...");
}
}
private void LoginTextBoxes_Changed(object sender, EventArgs e)
{
Guna2TextBox textBox = (Guna2TextBox)sender;
if (textBox.PlaceholderText == "Email")
General.text_validator(sender, e, "^[a-zA-Z0-9_]+@[a-zA-Z]+\\.[a-zA-Z]{2,}$", EmailTextBox.Text, EmailLabel, TextBox_TextChanged);
if (textBox.PlaceholderText == "Parol")
General.text_validator(sender, e, "^.{8,}$", PasswordTextBox.Text, PasswordLabel, TextBox_TextChanged);
}
private void RegTextBoxes_Changed(object sender, EventArgs e)
{
Guna2TextBox textBox = (Guna2TextBox)sender;
if (textBox.PlaceholderText == "Passport seriya, nomer")
General.text_validator(sender, e, "^[A-Z]{2}[0-9]{7}$", PassportTextBox.Text, PassportLabel, RegTextBox_TextChanged);
if (textBox.PlaceholderText == "Email")
General.text_validator(sender, e, "^[a-zA-Z0-9_]+@[a-zA-Z]+\\.[a-zA-Z]{2,}$", EmailRegTextBox.Text, EmailRegLabel, RegTextBox_TextChanged);
if (textBox.PlaceholderText == "Parol")
General.text_validator(sender, e, "^.{8,}$", PasswordRegTextBox.Text, PasswordRegLabel, RegTextBox_TextChanged);
if (textBox.PlaceholderText == "Parolni takrorlang")
{
RePasswordRegLabel.Visible = true;
if (PasswordRegTextBox.Text == RePasswordRegTextBox.Text) RePasswordRegLabel.Visible = false;
RegTextBox_TextChanged(sender, e);
}
}
private void TextBox_TextChanged(object sender, EventArgs e)
{
LoginButton.Enabled = false;
if (!EmailLabel.Visible && !PasswordLabel.Visible && EmailTextBox.Text != "" && PasswordTextBox.Text != "")
LoginButton.Enabled = true;
}
private void RegTextBox_TextChanged(object sender, EventArgs e)
{
RegisterButton.Enabled = false;
if (!EmailRegLabel.Visible && !RePasswordRegLabel.Visible && !PassportLabel.Visible &&
EmailRegTextBox.Text != "" && RePasswordRegTextBox.Text != "" && PassportTextBox.Text != "")
RegisterButton.Enabled = true;
}
}
}
|