コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: vivek147/RATM
        private void LoadGrid(string str1, string p)
        {
            errormessage.Text = "";
            ArrayList lidb = new ArrayList();

            using (SqlConnection con = new SqlConnection(CS))
            {
                SqlCommand cmd =
                    new SqlCommand("select Card_Type,Card_Id,Cvv,UserName,Months,Years from Bank_Detail where BankName_ID = @str and Card_Type = @p", con);
                cmd.Parameters.AddWithValue("@str", str1);
                cmd.Parameters.AddWithValue("@p", p);
                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    MyBankDetails mDetail = new MyBankDetails();
                    mDetail.CARD_TYPE   = (string)rdr[0];
                    mDetail.CARD_NUMBER = (long)rdr[1];
                    mDetail.CVV_NUMBER  = (long)rdr[2];
                    mDetail.CARDNAME    = (string)rdr[3];
                    mDetail.EXPIRYM     = (int)rdr[4];
                    mDetail.EXPIRYY     = (int)rdr[5];
                    lidb.Add(mDetail);
                }
            }


            Grid1.ItemsSource = lidb;
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: vivek147/RATM
        // To delete the data
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            MyBankDetails customerRow = Grid1.SelectedItem as MyBankDetails;


            if (customerRow == null)
            {
                errormessage.Text = "Please Select item to delete";
            }
            else
            {
                errormessage.Text = "";
                long ID = customerRow.CARD_NUMBER;
                using (SqlConnection con = new SqlConnection(CS))
                {
                    SqlCommand cmd =
                        new SqlCommand("delete from Bank_Detail where Card_Id = @ID", con);
                    cmd.Parameters.AddWithValue("@ID", ID);
                    con.Open();
                    int val = cmd.ExecuteNonQuery();
                    errormessage.Text = "item Deleted successfully";
                    string str = this.Cmb2.Items[this.Cmb2.SelectedIndex].ToString();
                    string id  = Cmb1.SelectedValue.ToString();

                    LoadGrid(id, str);

                    errormessage.Text = "Item Deleted";
                }
            }
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: vivek147/RATM
        private void SeIndexChanged(object sender, SelectionChangedEventArgs e)
        {
            MyBankDetails customerRow = Grid1.SelectedItem as MyBankDetails;

            if (customerRow != null)
            {
                Old_ID = customerRow.CARD_NUMBER;
            }
        }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: vivek147/RATM
        private void UpdateButton_Click(object sender, RoutedEventArgs e)
        {
            MyBankDetails customerRow = Grid1.SelectedItem as MyBankDetails;

            if (customerRow == null)
            {
                errormessage.Text = "Please Select item to be Updated";
            }
            else
            {
                errormessage.Text = "";
                long   New_ID = customerRow.CARD_NUMBER;
                long   Cvv    = customerRow.CVV_NUMBER;
                string Name   = customerRow.CARDNAME;
                int    ExM    = customerRow.EXPIRYM;
                int    ExY    = customerRow.EXPIRYY;
                using (SqlConnection con = new SqlConnection(CS))
                {
                    SqlCommand cmd =
                        new SqlCommand("update Bank_Detail Set Cvv=@Cvv , Card_Id =@New_ID ,UserName=@Name,Months=@ExM,Years=@ExY where Card_Id = @Old_ID", con);
                    cmd.Parameters.AddWithValue("@Old_ID", Old_ID);
                    cmd.Parameters.AddWithValue("@New_ID", New_ID);
                    cmd.Parameters.AddWithValue("@Cvv", Cvv);
                    cmd.Parameters.AddWithValue("@Name", Name);
                    cmd.Parameters.AddWithValue("@ExM", ExM);
                    cmd.Parameters.AddWithValue("@ExY", ExY);
                    con.Open();
                    int val = cmd.ExecuteNonQuery();
                    errormessage.Text = "item Updated successfully";

                    string str = this.Cmb2.Items[this.Cmb2.SelectedIndex].ToString();
                    string id  = Cmb1.SelectedValue.ToString();

                    LoadGrid(id, str);
                }
            }
        }