示例#1
0
        public void CalculateInterest()

        {
            Accounte a      = new Accounte();
            int      id     = Int32.Parse(Console.ReadLine());
            int      branch = a.SearchType(id);


            int bal = a.SearchData(id);

            if (branch == 0)
            {
                bal = bal + (int)(bal * (0.04)) / 100;
                try
                {
                    a.Update(id, bal);
                    Console.WriteLine("{0}", bal);
                }

                catch (Exception ob)
                {
                    Console.WriteLine("update could not be performed");

                    Console.WriteLine(ob.Message);
                }
            }
            else if (branch == 1)
            {
                bal = bal + (int)(bal * 0.01) / 100;
                try
                {
                    a.Update(id, bal);
                }
                catch (Exception ob)
                {
                    Console.WriteLine("update could not be performed");

                    Console.WriteLine(ob.Message);
                }
            }
            else
            {
                Console.WriteLine("Cannot calculate interest on DMAT account");
            }
        }
示例#2
0
        public void Withdraw()
        {
            Console.WriteLine("enter the id \n" + "enter the  money to be withdrawn");
            int      id  = Int32.Parse(Console.ReadLine());
            int      bal = Int32.Parse(Console.ReadLine());
            Accounte a   = new Accounte();
            int      b   = a.SearchData(id);
            int      t   = a.SearchType(id);
            int      minBalance;
            int      flag = 0;

            if (b != 0)
            {
                Console.WriteLine("previous balance is {0}", b);
                if (t == 0)
                {
                    minBalance = 1000;
                    if (b >= minBalance && bal < b)
                    {
                        Console.WriteLine("Saving Account");
                        b = b - bal;
                        try
                        {
                            a.Update(id, b);
                            Console.WriteLine("updated balance is {0}", b);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }

                        flag = 1;
                    }
                }
                else if (t == 1)
                {
                    if (bal < b)
                    {
                        Console.WriteLine("Current Account");
                        b = b - bal;
                        try
                        {
                            a.Update(id, b);
                            Console.WriteLine("updated balance is {0}", b);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                        flag = 1;
                    }
                }
                else
                {
                    Console.WriteLine("DMAT Account");

                    int bala = b - bal;
                    if (bala > -10000)
                    {
                        b = b - bal;
                        try
                        {
                            a.Update(id, b);
                            Console.WriteLine("updated balance is {0}", b);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }

                        flag = 1;
                    }
                }
                if (flag == 0)
                {
                    Console.WriteLine("Cannot withdraw money");
                }
            }
        }