Esempio n. 1
0
        public List <DebitCredit> retrieveRecords(string debitcredit)
        {
            int dc = -1;

            if (debitcredit.Equals("debit"))
            {
                dc = 0;
            }
            else
            {
                dc = 1;
            }

            DateTime date  = DateTime.Now;
            string   month = BudgetForm.getMonth(date.Month);

            List <DebitCredit> dataList = new List <DebitCredit>();

            string        query     = "select description, amount from accounts where category = '" + dc + "' and month = '" + month + "' order by day asc";
            SQLiteCommand myCommand = new SQLiteCommand(query, myConnection);

            OpenConnection();
            SQLiteDataReader dr = myCommand.ExecuteReader();

            while (dr.Read())
            {
                DebitCredit data = new DebitCredit();
                data.description = dr[0].ToString();
                data.amount      = Convert.ToInt32(dr[1]);

                dataList.Add(data);
            }
            CloseConnection();
            return(dataList);
        }
Esempio n. 2
0
        public Dictionary <string, int> retrieveAmountCurrentMonth()
        {
            Dictionary <string, int> sums = new Dictionary <string, int>();

            int      incomeSum  = 0;
            int      expenseSum = 0;
            int      totalSum   = 0;
            DateTime date       = DateTime.Now;
            string   month      = BudgetForm.getMonth(date.Month);

            string query = "select amount, category from accounts where month = '" + month + "'";

            SQLiteCommand myCommand = new SQLiteCommand(query, myConnection);

            OpenConnection();
            SQLiteDataReader dr = myCommand.ExecuteReader();

            while (dr.Read())
            {
                if (Convert.ToInt32(dr[1]) == 1)
                {
                    incomeSum += Convert.ToInt32(dr[0]);
                }
                else
                {
                    expenseSum += Convert.ToInt32(dr[0]);
                }
            }

            CloseConnection();

            totalSum = incomeSum - expenseSum;

            sums.Add("income", incomeSum);
            sums.Add("expense", expenseSum);
            sums.Add("total", totalSum);

            return(sums);
        }