public List <VoorraadControle> GetVoorraadControles() { try { List <VoorraadControle> controles = new List <VoorraadControle>(); using (SqlConnection conn = new SqlConnection(connectie)) { if (conn.State != ConnectionState.Open) { conn.Open(); using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "SELECT VcId, VcProductId, VcDatumControle, VcOudeVoorraad, VcNieuweVoorraad, VcOpmerking " + "FROM Voorraadcontrolel"; cmd.Connection = conn; using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { int id = reader.GetInt32(0); Product product = sqlProduct.GetProductById(reader.GetInt32(1)); Lid controleur = null; if (!reader.IsDBNull(2)) { controleur = sqlLid.GetLidFromId(reader.GetInt32(2)); } DateTime datum = reader.GetDateTime(3); int oudeVoorraad = reader.GetInt32(4); int nieuweVoorraad = reader.GetInt32(5); VoorraadEnum soort = (VoorraadEnum)Enum.Parse(typeof(VoorraadEnum), reader.GetString(5)); VoorraadControle controle = new VoorraadControle(id, product, controleur, datum, oudeVoorraad, nieuweVoorraad, soort); controles.Add(controle); } return(controles); } } } } return(null); } catch (Exception exception) { throw new Exception(exception.Message); } }
public List <Authentication> GetAuthentications() { try { List <Authentication> authentications = new List <Authentication>(); using (SqlConnection conn = new SqlConnection(connectie)) { if (conn.State != ConnectionState.Open) { conn.Open(); using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "SELECT * FROM Authenticatie;"; cmd.Connection = conn; using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { int id = reader.GetInt32(0); string name = reader.GetString(1); string wachtwoord = reader.GetString(2); int kassaId = reader.GetInt32(3); Lid lid = sqllid.GetLidFromId(reader.GetInt32(4)); Authentication auth = new Authentication(id, name, wachtwoord, lid, kassaId); authentications.Add(auth); } return(authentications); } } } } return(null); } catch (Exception exception) { throw new Exception(exception.Message); } }
public List <Bestelling> GetAllPaidBestellingen() { try { List <Bestelling> bestellingen = new List <Bestelling>(); using (SqlConnection conn = new SqlConnection(connectie)) { if (conn.State != ConnectionState.Open) { conn.Open(); using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "SELECT * " + "FROM Bestelling " + "WHERE BKassaId = @kassaId AND BBetalld = 1;"; cmd.Parameters.AddWithValue("@kassaId", 0); cmd.Connection = conn; using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { int id = reader.GetInt32(0); Lid persoon = null; string persoonNaam = ""; if (!reader.IsDBNull(1)) { persoon = sqlLid.GetLidFromId(reader.GetInt32(1)); } if (!reader.IsDBNull(2)) { persoonNaam = reader.GetString(2); } DateTime datum = reader.GetDateTime(3); bool betaald = reader.GetBoolean(4); int kassaId = reader.GetInt32(5); DateTime datumbetaald = DateTime.Parse("1-1-1900"); if (betaald) { datumbetaald = reader.GetDateTime(6); } bool betaaldBonnen = false; if (!reader.IsDBNull(7)) { betaaldBonnen = reader.GetBoolean(7); } decimal betaaldBedrag = reader.GetDecimal(8); Bestelling _bestelling; if (persoon != null) { _bestelling = new Bestelling(id, persoon, datum); } else { _bestelling = new Bestelling(id, persoonNaam, datum); } _bestelling.AddProductenToList(GetProductenInBestelling(id)); _bestelling.SetBetaaldBedrag(betaaldBedrag); bestellingen.Add(SuppGetAllBestellingen(_bestelling, betaald, kassaId, datumbetaald, betaaldBonnen)); } } return(bestellingen); } } } return(null); } catch (Exception exception) { throw new Exception(exception.Message); } }