Exemplo n.º 1
0
        //static function to add new account
        static public void AddAccount(int ID)
        {
            Console.WriteLine("Enter the account name:");
            string name = Console.ReadLine();

            Console.WriteLine("Enter the money balance:");
            double money = Double.Parse(Console.ReadLine());

            Console.WriteLine("Select the currency:\n1.AZN\t2.USD\t3.EURO");
            CURR           cURR = new CURR();
            ConsoleKeyInfo cur  = Console.ReadKey(true);

            if (cur.Key == ConsoleKey.D1 || cur.Key == ConsoleKey.NumPad1)
            {
                cURR = CURR.AZN;
            }
            else if (cur.Key == ConsoleKey.D2 || cur.Key == ConsoleKey.NumPad2)
            {
                cURR = CURR.USD;
            }
            else if (cur.Key == ConsoleKey.D3 || cur.Key == ConsoleKey.NumPad3)
            {
                cURR = CURR.EURO;
            }
            Console.WriteLine("Enter the money to save in hidden balance(optional):");
            double hidden = Double.Parse(Console.ReadLine());
            int    id     = ID;

            accounts.Add(new Account {
                Name = name, Money = money, Currency = cURR, HiddenBalance = hidden, Account_ID = id
            });
        }
Exemplo n.º 2
0
 //static function to add money
 static public void AddMoney()
 {
     //if no accounts yet, first add account
     if (!AccountCheck())
     {
         AddAccount(1);
         //get account ID to work with
         Current_Account_ID = 1;
         accounts[0].categories_income[0].MoneySpent = accounts[0].Money;
     }
     else
     {
         Console.WriteLine("Enter the money amount:");
         double money = Double.Parse(Console.ReadLine());
         //select currency of spent money
         Console.WriteLine("Select the currency:\n1.AZN\t2.USD\t3.EURO");
         ConsoleKeyInfo select = Console.ReadKey(true);
         CURR           cURR   = new CURR();
         if (select.Key == ConsoleKey.D1 || select.Key == ConsoleKey.NumPad1)
         {
             cURR = CURR.AZN;
         }
         else if (select.Key == ConsoleKey.D2 || select.Key == ConsoleKey.NumPad2)
         {
             cURR = CURR.USD;
         }
         else if (select.Key == ConsoleKey.D3 || select.Key == ConsoleKey.NumPad3)
         {
             cURR = CURR.EURO;
         }
         //category spending add
         accounts[Current_Account_ID - 1].SpendOnCategory(accounts[Current_Account_ID - 1].categories_income, Type.Income, money, cURR);
     }
 }
Exemplo n.º 3
0
        //function OpsAdd
        public void OpsAdd(int CategoryID, double money, CURR currency)
        {
            //first check whether ops date should be changed
            Console.WriteLine("Do you want to specify date of the operation? Press 1 to set the date or 2 to use today's date by default");
            ConsoleKeyInfo ops_date = Console.ReadKey(true);
            //simple if function
            DateTime opsdate;

            if (ops_date.Key == ConsoleKey.NumPad1 || ops_date.Key == ConsoleKey.D1)
            {
                //enter ops date
                Console.WriteLine("Enter day of operation:");
                int day = Int32.Parse(Console.ReadLine());
                Console.WriteLine("Enter month of operation:");
                int month = Int32.Parse(Console.ReadLine());
                Console.WriteLine("Enter year of operation:");
                int year = Int32.Parse(Console.ReadLine());
                opsdate = new DateTime(year, month, day);
            }
            else
            {
                //set the time to current time by default
                opsdate = DateTime.Now;
            }
            //note of operation added
            Console.WriteLine("Enter the note for the operation");
            string note = Console.ReadLine();

            //operation added to the list of operations
            Ops.Add(new Operations {
                ID_Account = Account_ID, ID_Category = CategoryID, MoneySpent = money, OpsCurrency = currency, Note = note, date = opsdate
            });
        }
Exemplo n.º 4
0
        //static function to add spending
        static public void SpendMoney()
        {
            //if no accounts yet, first add account
            if (!AccountCheck())
            {
                AddAccount(1);
                //get account ID to work with
                Current_Account_ID = 1;
            }
            Console.WriteLine("Enter the money spent:");
            double money = Double.Parse(Console.ReadLine());

            //check the amoun of money, if 0 or negative then stop
            if (money <= 0)
            {
                Console.WriteLine($"Money can not be {money}, repeat again");
                return;
            }
            //select currency of spent money
            Console.WriteLine("Select the currency of spent money:\n1.AZN\t2.USD\t3.EURO");
            ConsoleKeyInfo select = Console.ReadKey(true);
            CURR           cURR   = new CURR();

            if (select.Key == ConsoleKey.D1 || select.Key == ConsoleKey.NumPad1)
            {
                cURR = CURR.AZN;
            }
            else if (select.Key == ConsoleKey.D2 || select.Key == ConsoleKey.NumPad2)
            {
                cURR = CURR.USD;
            }
            else if (select.Key == ConsoleKey.D3 || select.Key == ConsoleKey.NumPad3)
            {
                cURR = CURR.EURO;
            }
            //if accounts already exist work with existing or add new one
            else
            {
                foreach (var item in accounts)
                {
                    Console.WriteLine(item.ToString());
                }
                Console.WriteLine("======================");
                Console.WriteLine($"Select the account ID or add new account by entering {accounts.Last().Account_ID + 1} :");
                Current_Account_ID = Int32.Parse(Console.ReadLine());
                //add new account
                if (Current_Account_ID == accounts.Last().Account_ID + 1)
                {
                    AddAccount(Current_Account_ID);
                }
            }
            //category spending add
            accounts[Current_Account_ID - 1].SpendOnCategory(accounts[Current_Account_ID - 1].categories_expense, Type.Expense, money, cURR);
        }
Exemplo n.º 5
0
        //money being spent
        public void SpendOnCategory(List <Category> categories, Type category_type, double money, CURR currency)
        {
            //check whether spent currency is the same with accounts currency
            if (Currency != currency)
            {
                if (Currency == CURR.AZN)
                {
                    money *= Exchange[currency.ToString()];
                }
                else if (Currency == CURR.USD)
                {
                    if (currency == CURR.AZN)
                    {
                        money /= Exchange[Currency.ToString()];
                    }
                    else
                    {
                        money = money * Exchange[currency.ToString()] / Exchange["USD"];
                    }
                }
                else if (Currency == CURR.EURO)
                {
                    if (currency == CURR.AZN)
                    {
                        money /= Exchange[Currency.ToString()];
                    }
                    else
                    {
                        money = money * Exchange[currency.ToString()] / Exchange["EURO"];
                    }
                }
            }
            //print the categories list for user's choice
            foreach (var item in categories)
            {
                Console.WriteLine(item.ToString());
            }
            Console.WriteLine($"Select the ID of the category or enter {categories.Count+1} to add new category:");
            int Category_ID = Int32.Parse(Console.ReadLine());

            if (Category_ID == categories.Count + 1)
            {
                NewCategoryAdd(categories, category_type);
            }
            foreach (var item in categories)
            {
                //required category found by CategoryID
                if (item.ID == Category_ID)
                {
                    item.MoneySpent += money;
                }
            }
            //money amount subtracted from account's balance if expense
            if (category_type == Type.Expense)
            {
                Money -= money;
            }
            //money amount added to account's balance if income
            else
            {
                Money += money;
            }
            OpsAdd(Category_ID, money, Currency);
        }