Advertisement
DrAungWinHtut

And Gate in CSharp

Feb 22nd, 2022
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace _2022022201_CS_Login
  12. {
  13.     public partial class frmLogin : Form
  14.     {
  15.  
  16.         //external variable
  17.         //global variable
  18.         int errCount = 0;
  19.  
  20.  
  21.         public frmLogin()
  22.         {
  23.             InitializeComponent();
  24.         }
  25.  
  26.         private void btnLogin_Click(object sender, EventArgs e)
  27.         {
  28.             string sUname = txtUname.Text;
  29.             string sPass = txtPass.Text;
  30.  
  31.             if (sUname == "aung" && sPass == "1234")
  32.             {
  33.                 MessageBox.Show("You have successfully login to system!");
  34.                 txtSecret.Visible = true;
  35.                 txtSecret.Text = "This is Secret message!";
  36.             }
  37.             else
  38.             {
  39.                 errCount = errCount + 1;
  40.                 if (errCount == 3)
  41.                 {
  42.                     MessageBox.Show("Login Failed 3 times!, Sorry... Bye!");
  43.                     timer1.Enabled = true;
  44.                     this.Enabled = false;
  45.                 }
  46.                 else
  47.                 {
  48.                     MessageBox.Show("Login Failed!, Pls try again!");
  49.                 }
  50.             }
  51.  
  52.         }
  53.  
  54.         private void timer1_Tick(object sender, EventArgs e)
  55.         {
  56.             Application.Exit();
  57.         }
  58.     }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement