private void LoadMonthlyData(monthInYear type, int year) { saleRecordModelBindingSource.Clear(); SaleReportController controller = new SaleReportController(); MySqlConnection connection = new MySqlConnection("server = " + connectData.server() + "; database = " + connectData.database() + "; username = "******"; password="******";"); string txt = "select sum(totalprice) from salesrecord group by year(date)='" + year.ToString() + "'" + ", month(date)='" + type.ToString() + "'"; MySqlCommand command = new MySqlCommand(txt, connection); connection.Open(); MySqlDataReader r = command.ExecuteReader(); MonthlyResult monthlyResult = new MonthlyResult((int)type, year); while (r.Read()) { int total = int.Parse(r[0].ToString()); int monthly = Convert.ToInt32(type); //int totalItems = int.Parse(r[1].ToString()); monthlyResult.LoadData(year, monthly, total); } monthlyResult.Show(); }
public List <SaleRecordModel> GetALlSaleRecordByMonthAndYear(monthInYear choosing, int year) { SaleRecordDBModel datas = new SaleRecordDBModel(); datas.GetConnectionString(connection.server(), connection.database(), connection.username(), connection.password()); //1 return(datas.GetSaleByMonthInYear(choosing, year)); }
public List <SaleRecordModel> GetSaleByMonthInYear(monthInYear month, int year) { int lMonth = (int)month; //result string txt = "SELECT * FROM `salesrecord` WHERE MONTH(date) = " + lMonth + " and Year(date) = " + year + ""; return(dbListDataComment(txt)); }