Esempio n. 1
0
 private void btn_Submit_Click(object sender, EventArgs e)
 {
     if (txt_Cust.Text == "" || txt_PIN.Text == "")
     {
         MessageBox.Show("Please provide Customer Number and PIN");
         return;
     }
     try
     {
         //Create SqlConnection
         SqlConnection con = new SqlConnection(cs);
         SqlCommand cmd = new SqlCommand("Select * from [BankCustomer] where CustomerNumber=@customernumber and PIN=@pin", con);
         cmd.Parameters.AddWithValue("@customernumber", txt_Cust.Text);
         cmd.Parameters.AddWithValue("@pin", txt_PIN.Text);
         con.Open();
         SqlDataAdapter adapt = new SqlDataAdapter(cmd);
         DataSet ds = new DataSet();
         adapt.Fill(ds);
         con.Close();
         int count = ds.Tables[0].Rows.Count;
         //If count is equal to 1, than show frmMain form
         if (count == 1)
         {
             MessageBox.Show("Login Successful");
             this.Hide();
             AccountView fm = new AccountView(txt_Cust.Text);
             fm.Show();
         }
         else
         {
             MessageBox.Show("Login Failed");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }