PasswordForm

    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.Windows.Forms;
    9| 
  10| namespace MyDesktop
  11| {
  12|     public partial class frmPassword : Form
  13|     {
  14|     MyDesktop_Form oMD;
  15| 
  16|     public bool bOK;
  17| 
  18|     public string sPassword;
  19| 
  20|     public frmPassword()
  21|     {
  22|         InitializeComponent();
  23|     }
  24| 
  25|     private void btnCancel_Click(object sender, EventArgs e)
  26|     {
  27|         txtPassword.Text = "";
  28|         this.Hide();
  29|     }
  30| 
  31|     private void btnOK_Click(object sender, EventArgs e)
  32|     {
  33|         Valid();
  34|     }
  35| 
  36|     public void Set_Up(MyDesktop_Form oMDF_Object)
  37|     {
  38|         oMD = oMDF_Object;
  39|     }
  40| 
  41|      private void txtPassword_KeyDown(object sender, KeyEventArgs e)
  42|     {
  43| 
  44|         if(e.KeyCode.Equals(Keys.Enter))
  45|         {
  46|             Valid();
  47|         }
  48|     }
  49| 
  50|     public void Valid()
  51|     {
  52|         string[] arrPassword = { "RNG", "rng", "KMG", "kmg" };
  53|         int iCount = 0;
  54|    55|             foreach (string sStored in arrPassword)
  56|             {
  57|                 if (txtPassword.Text == sStored)
  58|                 {
  59|                     oMD.bPass = true;
  60|                     oMD.Launch_Site();
  61|                     this.Hide();
  62|                     break;
  63|                 }
  64|                 if (iCount == 3)
  65|                 {
  66|                     MessageBox.Show("Invalid Password");
  67|                     txtPassword.Text = "";
  68|                     txtPassword.Focus();
  69|                 }
  70|                 iCount++;
  71|             }
  72| 
  73|             iCount = 0;
  74|         }
  75|     }
  76| }