Beispiel #1
0
        public List <double> GetExpensesByType(dbExpense Expenses)
        {
            List <double> List = new List <double>();

            List <string> Types = new List <string> {
                "Employee salaries", "Office Expenses", "Vehicles Expenses", "Equipment Expenses", "Maintenance Expenses", "Business Insurances", "Consultancy Fees", "Marketing Costs", "Miscellaneous Expenses"
            };

            Expenses.Connect();
            if (Expenses.ConnOpen() == true)
            {
                foreach (var item in Types)
                {
                    DataTable table = Expenses.SuperQuery($"SELECT SUM(Amount) FROM `tbExpense` WHERE `Type` = '{item}'").Tables[0];

                    if (string.IsNullOrEmpty(table.Rows[0][0].ToString()))
                    {
                        List.Add(0);
                    }
                    else
                    {
                        List.Add(double.Parse(table.Rows[0][0].ToString()));
                    }
                }
            }
            Expenses.ConnClose();

            return(List);
        }
Beispiel #2
0
        public List <double> GetExpensesByDate(dbExpense Expenses)
        {
            List <double> List = new List <double>();

            Expenses.Connect();
            if (Expenses.ConnOpen() == true)
            {
                for (int i = 1; i <= 6; i++)
                {
                    DataTable table = Expenses.SuperQuery($"SELECT SUM(Amount) FROM `tbExpense` WHERE year(Date) = 2019 AND month(Date) = {i}").Tables[0];
                    if (string.IsNullOrEmpty(table.Rows[0][0].ToString()))
                    {
                        List.Add(0);
                    }
                    else
                    {
                        List.Add(double.Parse(table.Rows[0][0].ToString()));
                    }
                }
            }
            Expenses.ConnClose();

            return(List);
        }