Ejemplo n.º 1
0
        public void RemoveAccInfo(int id)
        {
            AccInfoC inter = new AccInfoC();
            AccInfo  info  = new AccInfo();

            info        = inter.FindAccInfo(id);
            info.Amount = -1 * Convert.ToDouble(info.Amount) + "";
            if (info.Kind == "Regular")
            {
                Regular(info);
            }
            if (info.Kind == "Income")
            {
                Income(info);
            }
            if (info.Kind == "Expenses")
            {
                Expenses(info);
            }
            if (info.Kind == "Third party")
            {
                Thirdparty(info);
            }
            while (con.State == ConnectionState.Open)
            {
                System.Threading.Thread.Sleep(500);
            }
            con.Open();
            MySqlCommand cmd = new MySqlCommand("DELETE FROM AccInfo WHERE Id = @id", con);

            cmd.Parameters.AddWithValue("@id", id);
            cmd.ExecuteNonQuery();
            con.Close();
        }
Ejemplo n.º 2
0
        public void RemoveAcc(Account acc)
        {
            string newname = "Deleted Account Number" + acc.AccountNum;
            //delete from DB

            AccInfoC       inter = new AccInfoC();
            List <AccInfo> l     = inter.ListBelongToBank(acc.AccountNum, "01/01/1900", DateTime.Now.ToShortDateString(), "All", "All");

            //change all the transference that was from and to this account to be know as outside account
            foreach (var v in l)
            {
                v.Kind = "Third party";

                if (v.Requestfrom == acc.AccountNum)
                {
                    v.Requestfrom = newname;
                }
                else
                {
                    v.RequestTo = newname;
                }

                inter.UpdateWhenDelete(v);
            }

            //delete the account
            while (con.State == ConnectionState.Open)
            {
                System.Threading.Thread.Sleep(500);
            }
            con.Open();

            MySqlCommand cmd = new MySqlCommand("DELETE FROM Account WHERE AccountNum = @id", con);

            cmd.Parameters.AddWithValue("@id", acc.AccountNum);
            cmd.ExecuteNonQuery();
            con.Close();
        }