Advertisement
Gropic

Login Form

Nov 5th, 2016
2,336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.64 KB | None | 0 0
  1. namespace YourForm1name
  2. {
  3.     public partial class Form1 : Form
  4.     {
  5.         string username = "Admin";
  6.         string password = "Admin";
  7.  
  8.         public Form1()
  9.         {
  10.             InitializeComponent();
  11.         }
  12.  
  13.         private void label1_Click(object sender, EventArgs e)
  14.         {
  15.             Close();
  16.         }
  17.  
  18.         private void pictureBox1_Click(object sender, EventArgs e)
  19.         {
  20.             if (textBox1.Text == username)
  21.             {
  22.                 if (textBox2.Text == password)
  23.                 {
  24.                     MessageBox.Show("Login was Succesful!");
  25.                     Form2 openform2 = new Form2();
  26.                     this.Hide();
  27.                     openform2.ShowDialog();
  28.                 }else
  29.                 {
  30.                     MessageBox.Show("Username or Password is Wrong!");
  31.                 }
  32.             }
  33.         }
  34.  
  35.         private void Form1_Load(object sender, EventArgs e)
  36.         {
  37.  
  38.         }
  39.  
  40.         private void label6_Click(object sender, EventArgs e)
  41.         {
  42.             if (textBox1.Text == username)
  43.             {
  44.                 if (textBox2.Text == password)
  45.                 {
  46.                     MessageBox.Show("Login was Succesful!");
  47.                     Form2 openform2 = new Form2();
  48.                     this.Hide();
  49.                     openform2.ShowDialog();
  50.                 }else
  51.                 {
  52.                     MessageBox.Show("Username or Password is Wrong!");
  53.                 }
  54.             }
  55.         }
  56.  
  57.         private void Form1_FormClosed(object sender, FormClosedEventArgs e)
  58.         {
  59.             Application.Exit();
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement