Anonim_999

Zad2Registration

Jun 16th, 2022
1,040
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3.  
  4. namespace Zad2
  5. {
  6.     public partial class Form1 : Form
  7.     {
  8.         public Form1()
  9.         {
  10.             InitializeComponent();
  11.         }
  12.  
  13.         private void button1_Click(object sender, EventArgs e)
  14.         {
  15.             if (LoginTextBox.Text != "" && PasswordTextBox.Text != "" && ConfirmPasswordTextBox.Text != "")
  16.             {
  17.                 if (PasswordTextBox.Text.Length < 6)
  18.                 {
  19.                     MessageBox.Show("Пароль должен содержать не меньше 6 символов");
  20.                 }
  21.                 else
  22.                 {
  23.                     if (PasswordTextBox.Text != ConfirmPasswordTextBox.Text)
  24.                     {
  25.                         MessageBox.Show("Пароли не совпадают");
  26.                     }
  27.                     else
  28.                     {
  29.                         User user = new User(LoginTextBox.Text,PasswordTextBox.Text);
  30.                         Main main = new Main(user);
  31.                         main.ShowDialog();
  32.                     }
  33.                 }
  34.             }
  35.         }
  36.  
  37.         private void button2_Click(object sender, EventArgs e)
  38.         {
  39.             Application.Exit();
  40.         }
  41.  
  42.         private void Form1_Load(object sender, EventArgs e)
  43.         {
  44.             PasswordTextBox.PasswordChar = '*';
  45.             ConfirmPasswordTextBox.PasswordChar = '*';
  46.         }
  47.     }
  48.  
  49.     public class User
  50.     {
  51.         private string _login;
  52.         private string _password;
  53.  
  54.         public string Login => _login;
  55.         public string Password => _password;
  56.  
  57.         public User(string login, string password)
  58.         {
  59.             _login = login;
  60.             _password = password;
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment