Example #1
0
 private void BtnSubmit_Click(object sender, EventArgs e)
 {
     Uname = TxtBxUsrNm.Text.ToString();
     Pwd = TxtBxPwd.Text.ToString();
     if (Uname == null || Uname == "")
     {
         if (Pwd == null || Pwd == "")
         {
             MessageBox.Show("Please Enter a value for Username and Password fields or Register yourself.");
             TxtBxUsrNm.Focus();
         }
         else
         {
             MessageBox.Show("Username Field cannot be blank. Please enter a value or register yourself.");
             TxtBxUsrNm.Focus();
         }
     }
     else if (Pwd == null || Pwd == "")
     {
         MessageBox.Show("Password Field cannot be blank. Please enter a value or register yourself.");
         TxtBxPwd.Focus();
     }
     else
     {
         comm = new OleDbCommand("SELECT [UserName] FROM Login WHERE [UserName] = '" + Uname + "' AND Password = '******';", conn);
         try
         {
             if (conn.State == System.Data.ConnectionState.Open)
             {
                 reader = comm.ExecuteReader();
                 if (reader.HasRows == true)
                 {
                     SelectAction sa = new SelectAction();
                     sa.UName = this.Uname;
                     sa.Pwd = this.Pwd;
                     this.Hide();
                     sa.Show();
                 }
                 else
                 {
                     MessageBox.Show("Sorry. We did not find your records in our database. Please register again.");
                     AddUser au = new AddUser();
                     au.UName = this.Uname;
                     au.pwd = this.Pwd;
                     this.Close();
                     au.Show();
                 }
                 reader.Close();
                 conn.Close();
             }
         }
         catch (Exception er)
         {
             MessageBox.Show("Error at Data Retreival " + er.Message);
             conn.Close();
         }
     }
 }
Example #2
0
 private void BtnBack_Click(object sender, EventArgs e)
 {
     SelectAction sa = new SelectAction();
     this.Close();
     sa.Show();
 }