//De totalen ophalen (inclusief btw, exlusief btw en het btw bedrag zelf) public Totalen GetTotalen(int KlantNr) { MySqlConnection sqlConn = new MySqlConnection(ConnStr); sqlConn.Open(); string query = "SELECT " + "SUM(aantal * prijs) AS excl, " + "SUM(aantal * prijs) * 0.21 AS btw, " + "SUM(aantal * prijs) + SUM(aantal * prijs) * 0.21 AS incl " + "FROM tblartikel INNER JOIN " + "tblwinkelmand ON tblartikel.artNr = tblwinkelmand.artNr where klantnr=" + KlantNr; MySqlCommand sqlCmd = new MySqlCommand(query, sqlConn); MySqlDataReader reader = sqlCmd.ExecuteReader(); Totalen _totaal = new Totalen(); while (reader.Read()) { _totaal.Incl = Convert.ToDouble(reader["incl"]); _totaal.BTW = Convert.ToDouble(reader["btw"]); _totaal.Excl = Convert.ToDouble(reader["excl"]); } sqlConn.Close(); return(_totaal); }
public Totalen getTotals(int klnr) { MySqlConnection conn = new MySqlConnection(ConnStr); conn.Open(); string qry = "SELECT SUM(Aantal * Prijs ) as TotExBtw, SUM((Aantal * Prijs) * 0.21) as Btw, SUM((Aantal * Prijs) * 1.21) as TotIncBtw FROM tblwinkelmandje INNER JOIN tblproduct on tblproduct.ArtNr = " + "tblwinkelmandje.ArtNr " + "WHERE KlantNr=" + klnr; MySqlCommand cmd = new MySqlCommand(qry, conn); MySqlDataReader dtr = cmd.ExecuteReader(); Totalen tot = new Totalen(); while (dtr.Read()) { tot.TotExBtw = Convert.ToDouble(dtr["TotExBtw"]); tot.Btw = Convert.ToDouble(dtr["Btw"]); tot.TotIncBtw = Convert.ToDouble(dtr["TotIncBtw"]); } conn.Close(); return tot; }