예제 #1
0
        public void Populate_ListView(string myquery)
        {
            listView1.Items.Clear();
            ListViewItem iItem;
            string       query = myquery;

            if (CreateNewCard.OpenConnection())
            {
                try
                {
                    MySqlCommand    cmd        = new MySqlCommand(query, CreateNewCard.conn);
                    MySqlDataReader dataReader = cmd.ExecuteReader();
                    while (dataReader.Read())
                    {
                        if (EncryptDecrypt.DecryptString(dataReader[3].ToString(), CreateNewCard.salt) == "True" && DateTime.Compare(DateTime.Now, DateTime.ParseExact("30/" + EncryptDecrypt.DecryptString(dataReader[4].ToString(), CreateNewCard
                                                                                                                                                                                                            .salt), "dd/MM/yy", System.Globalization.CultureInfo.InvariantCulture)) <= 0)
                        {
                            iItem    = new ListViewItem(EncryptDecrypt.DecryptString(dataReader[0].ToString(), CreateNewCard.salt));
                            fullname = EncryptDecrypt.DecryptString(dataReader[1].ToString(), CreateNewCard.salt) + " " + EncryptDecrypt.DecryptString(dataReader[2].ToString(), CreateNewCard.salt);
                            expiry   = EncryptDecrypt.DecryptString(dataReader[4].ToString(), CreateNewCard.salt);
                            iItem.SubItems.Add(fullname);
                            iItem.SubItems.Add(expiry);
                            listView1.Items.Add(iItem);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    CreateNewCard.CloseConnection();
                }
                listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            }
        }
예제 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (Int32.Parse(Balance_Inquiry.balance) >= Int32.Parse(Amount.Text))
            {
                int rbalance;
                rbalance = Int32.Parse(Balance_Inquiry.balance) - Int32.Parse(Amount.Text);
                if (Int32.Parse(Amount.Text) >= 1000)
                {
                    int rewardpoint = Int32.Parse(Amount.Text) / 1000;
                    int newpoints   = Int32.Parse(Balance_Inquiry.points) + rewardpoint;
                    CreateNewCard.Insert("Update card_list set ponts = '" + EncryptDecrypt.EncryptString(newpoints.ToString(), CreateNewCard.salt) + "' where Card_No = '" + CardInsert.encrcardnum + "'");
                }
                CreateNewCard.Insert("Update card_list set balance = '" + EncryptDecrypt.EncryptString(rbalance.ToString(), CreateNewCard.salt) + "' where Card_No = '" + CardInsert.encrcardnum + "'");

                CreateNewCard.Initialize("server=localhost;uid=root;pwd=;database=alaybank_cards;sslmode=none;");
                CreateNewCard.Insert("Insert into alay" + CardInsert.cardnum + " (`trans_id`, `trans_details`) VALUES (NULL ,'" + EncryptDecrypt.EncryptString("Paid bill on " + DateTime.Now, CreateNewCard.salt) + "');");
                if (MessageBox.Show("Do you want another Transaction?", "Another Transaction", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Form mm = new Menu();
                    mm.Show();
                    this.Close();
                }
                else
                {
                    CreateNewCard.Initialize();
                    CreateNewCard.Insert("Insert Into transrec values ('" + CardInsert.cardnum + "','" + rbalance + "')");
                    Form print = new Recieptprint();
                    Recieptprint.source = "cash";
                    print.ShowDialog();
                    MessageBox.Show("Thank You for Using Alay Bank ATM");
                    Form splash = new Splash_Screen();
                    splash.Show();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Transaction cannot be processed!\n Insufficient Balance\n Thank you for using Alay Bank ATM");
            }
        }