예제 #1
0
 private void btn_Submit_Click(object sender, EventArgs e)
 {
     if (tb_SecurityQAnswer.Text != "" && cb_AccountType.Text != "" && cb_SecurityQuestion.Text != "")
     {
         using (connection = new SqlConnection(GlobalVariablesClass.connectionString))
             using (SqlDataAdapter adapter = new SqlDataAdapter("INSERT INTO tbl_Account([Account Type],[Account Balance],[Security Question],[Security Question Answer],[customerID]) VALUES (@accountType,'0',@SecQues,@SecQuesAns,@customerID); SELECT SCOPE_IDENTITY()", connection))
             {
                 adapter.SelectCommand.Parameters.AddWithValue("@accountType", cb_AccountType.SelectedItem);
                 adapter.SelectCommand.Parameters.AddWithValue("@SecQues", cb_SecurityQuestion.SelectedItem);
                 adapter.SelectCommand.Parameters.AddWithValue("@SecQuesAns", tb_SecurityQAnswer.Text.ToLower());
                 adapter.SelectCommand.Parameters.AddWithValue("@customerID", Convert.ToInt16(GlobalVariablesClass.customerID));
                 DataTable accountNumber = new DataTable();
                 adapter.Fill(accountNumber);
                 GlobalVariablesClass.accountNumber = accountNumber.Rows[0][0].ToString();
             }
         AccountViewingScreen frm = new AccountViewingScreen();
         this.Hide();
         frm.ShowDialog();
         this.Close();
     }
     else
     {
         MessageBox.Show("You must not leave inputs blank");
     }
 }
        private void btn_Submit_Click(object sender, EventArgs e)
        {
            GlobalVariablesClass.accountNumber = lb_YourAccounts.SelectedValue.ToString();
            AccountViewingScreen frm = new AccountViewingScreen();

            this.Hide();
            frm.ShowDialog();
            this.Close();
        }
 private void btn_SubmitSQAnswer_Click(object sender, EventArgs e)
 {
     if (tb_AnswerBox.Text.ToLower() == answer.ToLower())
     {
         using (connection = new SqlConnection(GlobalVariablesClass.connectionString))
             using (SqlCommand cmd = new SqlCommand("UPDATE tbl_Account SET customerID = '" + Convert.ToInt16(GlobalVariablesClass.customerID) + "' WHERE [Account Number] = '" + Convert.ToInt16(GlobalVariablesClass.accountNumber) + "' ", connection))
             {
                 connection.Open();
                 cmd.ExecuteNonQuery();
                 connection.Close();
                 AccountViewingScreen frm = new AccountViewingScreen();
                 this.Hide();
                 frm.ShowDialog();
                 this.Close();
             }
     }
     else
     {
         MessageBox.Show("Incorrect answer please try again");
     }
 }