public List <double> GetSalesByType(dbSale Sales) { List <double> List = new List <double>(); List <string> Types = new List <string> { "Interactive Timetabling", "Automated Timetabling", "Attendance Monitoring", "Room Booking", "Pay Claim", "Integration", "Consultancy", "Training" }; Sales.Connect(); if (Sales.ConnOpen() == true) { foreach (var item in Types) { DataTable table = Sales.SuperQuery($"SELECT SUM(Price) FROM `tbSale` WHERE `Product` = '{item}'").Tables[0]; if (string.IsNullOrEmpty(table.Rows[0][0].ToString())) { List.Add(0); } else { List.Add(double.Parse(table.Rows[0][0].ToString())); } } } Sales.ConnClose(); return(List); }
public List <double> GetSalesByDate(dbSale Sales) { List <double> List = new List <double>(); Sales.Connect(); if (Sales.ConnOpen() == true) { for (int i = 1; i <= 6; i++) { DataTable table = Sales.SuperQuery($"SELECT SUM(Price) FROM `tbSale` 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())); } } } Sales.ConnClose(); return(List); }