} //internal iedereen kan het lezen maar alleen in eigen class kan veranderen public static int reserveering(int gekozenTafel, out int tafelstatus) { tafelstatus = 0; if (gekozenTafel != 0) { Methodes methode1 = new Methodes(); SqlConnection conn1; methode1.ConnectDatabase(out conn1); //Connect to database string connString1 = ConfigurationManager .ConnectionStrings["MayaMayaDatabase"] .ConnectionString; conn1 = new SqlConnection(connString1); conn1.Open(); string sqlcom1 = string.Format("SELECT Beschikbaarheid FROM Tafels WHERE tafelnummer={0}", gekozenTafel); SqlCommand command1 = new SqlCommand(sqlcom1, conn1); SqlDataReader reader = command1.ExecuteReader(); while (reader.Read()) { tafelstatus = (int)reader["Beschikbaarheid"]; } return(tafelstatus); } return(tafelstatus); }
//Slaat bestelling op in database public void SaveBestelling() { SqlConnection conn; Methodes methode = new Methodes(); methode.ConnectDatabase(out conn); SqlCommand command = new SqlCommand("INSERT INTO Bestellingen(DATUM_TIJD, TAFELNUMMER, PERSONEEL_ID, BETAALD_BEDRAG, BESTELTOTAAL, BETAALWIJZE, STATUS) VALUES(@datum_tijd, @tafelnummer, @personeel_id, @betaald_bedrag, @besteltotaal, @betaalwijze, @status)", conn); command.Parameters.AddWithValue("@datum_tijd", DateTime.Now); command.Parameters.AddWithValue("@tafelnummer", Tafels.tafelnummer); command.Parameters.AddWithValue("@personeel_id", Login.personeel_id); command.Parameters.AddWithValue("@betaald_bedrag", 0); command.Parameters.AddWithValue("@besteltotaal", Bestelling.totaalPrijs); command.Parameters.AddWithValue("@betaalwijze", "pin"); command.Parameters.AddWithValue("@status", 0); command.Connection = conn; command.ExecuteNonQuery(); conn.Close(); int bestelid = 0; conn.Open(); SqlCommand getBestelID = new SqlCommand("SELECT MAX(BESTEL_ID) FROM Bestellingen", conn); SqlDataReader reader = getBestelID.ExecuteReader(); while (reader.Read()) { bestelid = reader.GetInt32(0); } conn.Close(); conn.Open(); SqlCommand command2 = new SqlCommand("INSERT INTO Bestelling_Items(BESTEL_ID, ITEM_ID, AANTAL) VALUES(@bestel_id, @item_id, @aantal)"); foreach (KeyValuePair <int, int> item in dictionary) { command2.Parameters.Clear(); command2.Parameters.AddWithValue("@bestel_id", bestelid); command2.Parameters.AddWithValue("@item_id", item.Key); command2.Parameters.AddWithValue("@aantal", item.Value); command2.Connection = conn; command2.ExecuteNonQuery(); } conn.Close(); conn.Open(); string tafelBezet = string.Format("UPDATE Tafels SET BESCHIKBAARHEID='{0}' WHERE TAFELNUMMER={1}", 3, Tafels.tafelnummer); SqlCommand TafelBezet = new SqlCommand(tafelBezet, conn); TafelBezet.ExecuteNonQuery(); conn.Close(); }
//Slaat bestelling op in database public void SaveBestelling() { SqlConnection conn; Methodes methode = new Methodes(); methode.ConnectDatabase(out conn); SqlCommand command = new SqlCommand("INSERT INTO Bestellingen(DATUM_TIJD, TAFELNUMMER, PERSONEEL_ID, BETAALD_BEDRAG, BESTELTOTAAL, BETAALWIJZE, STATUS) VALUES(@datum_tijd, @tafelnummer, @personeel_id, @betaald_bedrag, @besteltotaal, @betaalwijze, @status)", conn); command.Parameters.AddWithValue("@datum_tijd", DateTime.Now); command.Parameters.AddWithValue("@tafelnummer", Tafels.tafelnummer); command.Parameters.AddWithValue("@personeel_id", Login.personeel_id); command.Parameters.AddWithValue("@betaald_bedrag", 0); command.Parameters.AddWithValue("@besteltotaal", Bestelling.totaalPrijs); command.Parameters.AddWithValue("@betaalwijze", "pin"); command.Parameters.AddWithValue("@status", 0); command.Connection = conn; command.ExecuteNonQuery(); conn.Close(); int bestelid = 0; conn.Open(); SqlCommand getBestelID = new SqlCommand("SELECT MAX(BESTEL_ID) FROM Bestellingen", conn); SqlDataReader reader = getBestelID.ExecuteReader(); while (reader.Read()) { bestelid = reader.GetInt32(0); } conn.Close(); conn.Open(); SqlCommand command2 = new SqlCommand("INSERT INTO Bestelling_Items(BESTEL_ID, ITEM_ID, AANTAL) VALUES(@bestel_id, @item_id, @aantal)"); foreach (KeyValuePair<int, int> item in dictionary) { command2.Parameters.Clear(); command2.Parameters.AddWithValue("@bestel_id", bestelid); command2.Parameters.AddWithValue("@item_id", item.Key); command2.Parameters.AddWithValue("@aantal", item.Value); command2.Connection = conn; command2.ExecuteNonQuery(); } conn.Close(); conn.Open(); string tafelBezet = string.Format("UPDATE Tafels SET BESCHIKBAARHEID='{0}' WHERE TAFELNUMMER={1}", 3, Tafels.tafelnummer); SqlCommand TafelBezet = new SqlCommand(tafelBezet, conn); TafelBezet.ExecuteNonQuery(); conn.Close(); }
public void getItems() { Methodes methode = new Methodes(); SqlConnection conn; methode.ConnectDatabase(out conn); string sql = string.Format("SELECT Menu_Items.Item_ID, Menu_Items.ITEM_NAAM, Menu_Items.PRIJS, Menu_Items.BTW_HEFFING, Bestellingen.STATUS, Bestelling_Items.AANTAL, Bestellingen.BESTEL_ID, Bestellingen.BETAALWIJZE, Bestellingen.BESTELTOTAAL, Bestellingen.BETAALD_BEDRAG From Bestellingen INNER JOIN Bestelling_Items ON Bestellingen.BESTEL_ID=Bestelling_Items.BESTEL_ID INNER JOIN Menu_Items ON Bestelling_Items.ITEM_ID=Menu_Items.ITEM_ID WHERE TAFELNUMMER ={0} AND STATUS = 0", Tafels.tafelnummer, conn); SqlCommand command = new SqlCommand(sql, conn); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { bestelItems.Add(new BesteldeItems(reader.GetInt32(0), reader.GetString(1), reader.GetDouble(2), reader.GetInt32(3), reader.GetInt32(4), reader.GetInt32(5), reader.GetInt32(6), reader.GetString(7), reader.GetDouble(8), reader.GetDouble(9))); } }
public string wachtwoordcorrect(string password) { Methodes methode = new Methodes(); SqlConnection conn; methode.ConnectDatabase(out conn); //Connect to database string connString = ConfigurationManager .ConnectionStrings["MayaMayaDatabase"] .ConnectionString; conn = new SqlConnection(connString); conn.Open(); //kijk of ww in database staat SqlCommand command = new SqlCommand("select AFDELING, PERSONEEL_ID, NAAM from Personeel where WACHTWOORD = '" + password + "'", conn); SqlDataReader reader = command.ExecuteReader(); string afdeling = "4"; while (reader.Read()) { afdeling = (string)reader["AFDELING"]; personeel_id = (int)reader["PERSONEEL_ID"]; persoon = (string)reader["NAAM"]; } conn.Close(); //^^als ww er instaat word via je ww je persso_id,naam en afdeling binnen gehaald //vver wordt terug gegeven weleke afdeling straks bij forms gegeven moet worden. 4 is als ww fout is je doet er niks mee maar je moet iets terug geven if (afdeling == "Bediening") { return "Bediening"; } else if(afdeling == "Bar") { return "Bar"; } else if (afdeling == "Keuken") { return "Keuken"; } else { return "4"; } }
public string wachtwoordcorrect(string password) { Methodes methode = new Methodes(); SqlConnection conn; methode.ConnectDatabase(out conn); //Connect to database string connString = ConfigurationManager .ConnectionStrings["MayaMayaDatabase"] .ConnectionString; conn = new SqlConnection(connString); conn.Open(); //kijk of ww in database staat SqlCommand command = new SqlCommand("select AFDELING, PERSONEEL_ID, NAAM from Personeel where WACHTWOORD = '" + password + "'", conn); SqlDataReader reader = command.ExecuteReader(); string afdeling = "4"; while (reader.Read()) { afdeling = (string)reader["AFDELING"]; personeel_id = (int)reader["PERSONEEL_ID"]; persoon = (string)reader["NAAM"]; } conn.Close(); //^^als ww er instaat word via je ww je persso_id,naam en afdeling binnen gehaald //vver wordt terug gegeven weleke afdeling straks bij forms gegeven moet worden. 4 is als ww fout is je doet er niks mee maar je moet iets terug geven if (afdeling == "Bediening") { return("Bediening"); } else if (afdeling == "Bar") { return("Bar"); } else if (afdeling == "Keuken") { return("Keuken"); } else { return("4"); } }
//Haalt Menu Items op uit database public void getItems() { SqlConnection conn; Methodes methode = new Methodes(); //Database Connection methode.ConnectDatabase(out conn); //Run SQL command SqlCommand command = new SqlCommand("SELECT Menu_Items.ITEM_ID, Menu_Items.CATEGORIE_ID, KAART_ID, Menu_Items.ITEM_NAAM, Menu_Items.VOORRAAD, Menu_Items.PRIJS, Menu_Items.BTW_HEFFING FROM Menu_Items INNER JOIN Menu_Categorie ON Menu_Items.CATEGORIE_ID = Menu_Categorie.CATEGORIE_ID", conn); SqlDataReader reader = command.ExecuteReader(); //Process results(record for record) while (reader.Read()) { Items.Add(new Item(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), reader.GetString(3), reader.GetInt32(4), reader.GetDouble(5), reader.GetInt32(6))); } conn.Close(); }
public static int reserveeringDeel2(int gekozenTafel) { int bezetcode = 2; int tafelstatus = 1; Methodes methode = new Methodes(); SqlConnection conn; methode.ConnectDatabase(out conn); //Connect to database string connString = ConfigurationManager .ConnectionStrings["MayaMayaDatabase"] .ConnectionString; conn = new SqlConnection(connString); conn.Open(); string sql = string.Format("UPDATE Tafels SET beschikbaarheid='{0}' WHERE tafelnummer={1}", bezetcode, gekozenTafel); SqlCommand command = new SqlCommand(sql, conn); command.ExecuteNonQuery(); return tafelstatus; }
public int tafelstatus { get; internal set; }//internal iedereen kan het lezen maar alleen in eigen class kan veranderen public static int reserveering(int gekozenTafel,out int tafelstatus) { tafelstatus = 0; if (gekozenTafel != 0) { Methodes methode1 = new Methodes(); SqlConnection conn1; methode1.ConnectDatabase(out conn1); //Connect to database string connString1 = ConfigurationManager .ConnectionStrings["MayaMayaDatabase"] .ConnectionString; conn1 = new SqlConnection(connString1); conn1.Open(); string sqlcom1 = string.Format("SELECT Beschikbaarheid FROM Tafels WHERE tafelnummer={0}", gekozenTafel); SqlCommand command1 = new SqlCommand(sqlcom1, conn1); SqlDataReader reader = command1.ExecuteReader(); while (reader.Read()) { tafelstatus = (int)reader["Beschikbaarheid"]; } return tafelstatus; } return tafelstatus; }
public static int reserveeringDeel2(int gekozenTafel) { int bezetcode = 2; int tafelstatus = 1; Methodes methode = new Methodes(); SqlConnection conn; methode.ConnectDatabase(out conn); //Connect to database string connString = ConfigurationManager .ConnectionStrings["MayaMayaDatabase"] .ConnectionString; conn = new SqlConnection(connString); conn.Open(); string sql = string.Format("UPDATE Tafels SET beschikbaarheid='{0}' WHERE tafelnummer={1}", bezetcode, gekozenTafel); SqlCommand command = new SqlCommand(sql, conn); command.ExecuteNonQuery(); return(tafelstatus); }
private void afrondenbutton_Click(object sender, EventArgs e) // bij het drukken van AFREKENEN! { int onbezetcode = 1; if (subtotal == 0) { string message = "U heeft niks ingevoerd, wilt u de proggama stoppen?"; string caption = "Error Detected in Input"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; result = MessageBox.Show(message, caption, buttons); if (result == System.Windows.Forms.DialogResult.Yes) { this.Close(); } } else if (!radioButton1.Checked && !radioButton2.Checked) { MessageBox.Show("Selecteer een betaalwijze"); } else { Methodes methode = new Methodes(); SqlConnection conn; methode.ConnectDatabase(out conn); // connect to database string connString = ConfigurationManager .ConnectionStrings["MayaMayaDatabase"] .ConnectionString; conn = new SqlConnection(connString); conn.Open(); string sql = string.Format("UPDATE Tafels SET beschikbaarheid= '{0}' WHERE tafelnummer={1}", onbezetcode, Tafels.tafelnummer); SqlCommand command = new SqlCommand(sql, conn); int rowsAffected = command.ExecuteNonQuery(); conn.Close(); conn.Open(); string betaalwijze = ""; bool isChecked = radioButton1.Checked; if (isChecked) { betaalwijze = "contant"; } else { betaalwijze = "pin"; } methode.ConnectDatabase(out conn); string insert = string.Format("UPDATE Bestellingen SET BETAALD_BEDRAG='{0}', BETAALWIJZE='{1}', STATUS='1' WHERE BESTEL_ID='{2}'", subtotal, betaalwijze, bestelID, conn); SqlCommand update = new SqlCommand(insert, conn); update.ExecuteNonQuery(); conn.Close(); succesafgerondscherm successcherm = new succesafgerondscherm(); successcherm.Show(); ListViewAfrekenen.Items.Clear(); BedragBerekening.Items.Clear(); Fooiberekening.Items.Clear(); fooiBox.Text = ""; subtotal = 0; invoer_getal = 0; fooiEnEind = 0; this.Close(); } }
public TafelOverzicht() { InitializeComponent(); //vertelt welke persoon er is ingelogd Subtext.Text = "Welkom " + Login.persoon; List <Tafels> tafels = new List <Tafels>(); Methodes methode = new Methodes(); SqlConnection conn; methode.ConnectDatabase(out conn); //Connect to database string connString = ConfigurationManager .ConnectionStrings["MayaMayaDatabase"] .ConnectionString; conn = new SqlConnection(connString); conn.Open(); SqlCommand command = new SqlCommand("select * from Tafels ", conn); SqlDataReader reader = command.ExecuteReader(); //int tafelstatus = 2; oude code //int tafelnummer = 1; while (reader.Read()) { Tafels status = new Tafels(); status.tafelstatus = (int)reader["Beschikbaarheid"]; status.tafelnummers = (int)reader["TAFELNUMMER"]; tafels.Add(status); } //ga alle tafels en kijk welke welke status heeft foreach (Tafels tafel in tafels) { if (tafel.tafelstatus == 2)//bezet { Control table = Controls["Tafel" + tafel.tafelnummers]; table.BackColor = Color.Blue; Control lable = Controls["TafelLabel" + tafel.tafelnummers]; lable.BackColor = Color.Blue; lable.Text = "Bezet"; } else if (tafel.tafelstatus == 3)//in verwerking { Control table = Controls["Tafel" + tafel.tafelnummers]; table.BackColor = Color.Red; Control lable = Controls["TafelLabel" + tafel.tafelnummers]; lable.BackColor = Color.Red; lable.Text = "Bezig"; } else if (tafel.tafelstatus == 4)//klaar voor servering { Control table = Controls["Tafel" + tafel.tafelnummers]; table.BackColor = Color.Green; Control lable = Controls["TafelLabel" + tafel.tafelnummers]; lable.BackColor = Color.Green; lable.Text = "Gereed"; } else //vrij (1 is vrij) { Control control = Controls["Tafel" + tafel.tafelnummers]; control.BackColor = Color.Yellow; Control lable = Controls["TafelLabel" + tafel.tafelnummers]; lable.BackColor = Color.Yellow; lable.Text = "Vrij"; } } /** oude code was voor als verbeteringen niet werken dan had ik toch nog wat * tafelstatus = (int)reader["Beschikbaarheid"]; * tafelnummer = (int)reader["TAFELNUMMER"]; * * * * switch(tafelnummer) * { * * case 1: * if (tafelstatus == 2)//bezet * { * Tafel1.BackColor = Color.Blue; * TafelLabel1.BackColor = Color.Blue; * TafelLabel1.Text = "Bezet"; * } * else if (tafelstatus == 3)//in verwerking * { * Tafel1.BackColor = Color.Red; * TafelLabel1.BackColor = Color.Red; * TafelLabel1.Text = "Bezig"; * * } * else if (tafelstatus == 4)//klaar voor servering * { * Tafel1.BackColor = Color.Green; * TafelLabel1.BackColor = Color.Green; * TafelLabel1.Text = "Gereed"; * * } * else //vrij (1 is vrij) * { * Tafel1.BackColor = Color.Yellow; * TafelLabel1.BackColor = Color.Yellow; * TafelLabel1.Text = "Vrij"; * } * break; * * case 2: * if (tafelstatus == 2)//bezet * { * Tafel2.BackColor = Color.Blue; * TafelLabel2.BackColor = Color.Blue; * TafelLabel2.Text = "Bezet"; * } * else if (tafelstatus == 3)//in verwerking * { * Tafel2.BackColor = Color.Red; * TafelLabel2.BackColor = Color.Red; * TafelLabel2.Text = "Bezig"; * } * else if (tafelstatus == 4)//klaar voor reservering * { * Tafel2.BackColor = Color.Green; * TafelLabel2.BackColor = Color.Green; * TafelLabel2.Text = "Gereed"; * } * else //vrij (1 is vrij) * { * Tafel2.BackColor = Color.Yellow; * TafelLabel2.BackColor = Color.Yellow; * TafelLabel2.Text = "Vrij"; * } * break; * * case 3: * if (tafelstatus == 2)//bezet * { * Tafel3.BackColor = Color.Blue; * TafelLabel3.BackColor = Color.Blue; * TafelLabel3.Text = "Bezet"; * } * else if (tafelstatus == 3)//in verwerking * { * Tafel3.BackColor = Color.Red; * TafelLabel3.BackColor = Color.Red; * TafelLabel3.Text = "Bezig"; * } * else if (tafelstatus == 4)//klaar voor reservering * { * Tafel3.BackColor = Color.Green; * TafelLabel3.BackColor = Color.Green; * TafelLabel3.Text = "Gereed"; * } * else //vrij (1 is vrij) * { * Tafel3.BackColor = Color.Yellow; * TafelLabel3.BackColor = Color.Yellow; * TafelLabel3.Text = "Vrij"; * } * break; * * case 4: * if (tafelstatus == 2)//bezet * { * Tafel4.BackColor = Color.Blue; * TafelLabel4.BackColor = Color.Blue; * TafelLabel4.Text = "Bezet"; * } * else if (tafelstatus == 3)//in verwerking * { * Tafel4.BackColor = Color.Red; * TafelLabel4.BackColor = Color.Red; * TafelLabel4.Text = "Bezig"; * } * else if (tafelstatus == 4)//klaar voor reservering * { * Tafel4.BackColor = Color.Green; * TafelLabel4.BackColor = Color.Green; * TafelLabel4.Text = "Gereed"; * } * else //vrij (1 is vrij) * { * Tafel4.BackColor = Color.Yellow; * TafelLabel4.BackColor = Color.Yellow; * TafelLabel4.Text = "Vrij"; * } * break; * case 5: * if (tafelstatus == 2)//bezet * { * Tafel5.BackColor = Color.Blue; * TafelLabel5.BackColor = Color.Blue; * TafelLabel5.Text = "Bezet"; * } * else if (tafelstatus == 3)//in verwerking * { * Tafel5.BackColor = Color.Red; * TafelLabel5.BackColor = Color.Red; * TafelLabel5.Text = "Bezig"; * } * else if (tafelstatus == 4)//klaar voor reservering * { * Tafel5.BackColor = Color.Green; * TafelLabel5.BackColor = Color.Green; * TafelLabel5.Text = "Gereed"; * } * else //vrij (1 is vrij) * { * Tafel5.BackColor = Color.Yellow; * TafelLabel5.BackColor = Color.Yellow; * TafelLabel5.Text = "Vrij"; * } * break; * * case 6: * if (tafelstatus == 2)//bezet * { * Tafel6.BackColor = Color.Blue; * TafelLabel6.BackColor = Color.Blue; * TafelLabel6.Text = "Bezet"; * } * else if (tafelstatus == 3)//in verwerking * { * Tafel6.BackColor = Color.Red; * TafelLabel6.BackColor = Color.Red; * TafelLabel6.Text = "Bezig"; * } * else if (tafelstatus == 4)//klaar voor reservering * { * Tafel6.BackColor = Color.Green; * TafelLabel6.BackColor = Color.Green; * TafelLabel6.Text = "Gereed"; * } * else //vrij (1 is vrij) * { * Tafel6.BackColor = Color.Yellow; * TafelLabel6.BackColor = Color.Yellow; * TafelLabel6.Text = "Vrij"; * } * break; * * case 7: * if (tafelstatus == 2)//bezet * { * Tafel7.BackColor = Color.Blue; * TafelLabel7.BackColor = Color.Blue; * TafelLabel7.Text = "Bezet"; * } * else if (tafelstatus == 3)//in verwerking * { * Tafel7.BackColor = Color.Red; * TafelLabel7.BackColor = Color.Red; * TafelLabel7.Text = "Bezig"; * } * else if (tafelstatus == 4)//klaar voor reservering * { * Tafel7.BackColor = Color.Green; * TafelLabel7.BackColor = Color.Green; * TafelLabel7.Text = "Gereed"; * } * else //vrij (1 is vrij) * { * Tafel7.BackColor = Color.Yellow; * TafelLabel7.BackColor = Color.Yellow; * TafelLabel7.Text = "Vrij"; * } * break; * * case 8: * if (tafelstatus == 2)//bezet * { * Tafel8.BackColor = Color.Blue; * TafelLabel8.BackColor = Color.Blue; * TafelLabel8.Text = "Bezet"; * } * else if (tafelstatus == 3)//in verwerking * { * Tafel8.BackColor = Color.Red; * TafelLabel8.BackColor = Color.Red; * TafelLabel8.Text = "Bezig"; * } * else if (tafelstatus == 4)//klaar voor reservering * { * Tafel8.BackColor = Color.Green; * TafelLabel8.BackColor = Color.Green; * TafelLabel8.Text = "Gereed"; * } * else //vrij (1 is vrij) * { * Tafel8.BackColor = Color.Yellow; * TafelLabel8.BackColor = Color.Yellow; * TafelLabel8.Text = "Vrij"; * } * break; * * case 9: * if (tafelstatus == 2)//bezet * { * Tafel9.BackColor = Color.Blue; * TafelLabel9.BackColor = Color.Blue; * TafelLabel9.Text = "Bezet"; * } * else if (tafelstatus == 3)//in verwerking * { * Tafel9.BackColor = Color.Red; * TafelLabel9.BackColor = Color.Red; * TafelLabel9.Text = "Bezig"; * } * else if (tafelstatus == 4)//klaar voor reservering * { * Tafel9.BackColor = Color.Green; * TafelLabel9.BackColor = Color.Green; * TafelLabel9.Text = "Gereed"; * } * else //vrij (1 is vrij) * { * Tafel9.BackColor = Color.Yellow; * TafelLabel9.BackColor = Color.Yellow; * TafelLabel9.Text = "Vrij"; * } * break; * * case 10: * if (tafelstatus == 2)//bezet * { * Tafel10.BackColor = Color.Blue; * TafelLabel10.BackColor = Color.Blue; * TafelLabel10.Text = "Bezet"; * } * else if (tafelstatus == 3)//in verwerking * { * Tafel10.BackColor = Color.Red; * TafelLabel10.BackColor = Color.Red; * TafelLabel10.Text = "Bezig"; * } * else if (tafelstatus == 4)//klaar voor reservering * { * Tafel10.BackColor = Color.Green; * TafelLabel10.BackColor = Color.Green; * TafelLabel10.Text = "Gereed"; * } * else //vrij (1 is vrij) * { * Tafel10.BackColor = Color.Yellow; * TafelLabel10.BackColor = Color.Yellow; * TafelLabel10.Text = "Vrij"; * } * break; * } * * * * * * } */ conn.Close(); }
public TafelOverzicht() { InitializeComponent(); //vertelt welke persoon er is ingelogd Subtext.Text = "Welkom "+ Login.persoon; List<Tafels> tafels = new List<Tafels>(); Methodes methode = new Methodes(); SqlConnection conn; methode.ConnectDatabase(out conn); //Connect to database string connString = ConfigurationManager .ConnectionStrings["MayaMayaDatabase"] .ConnectionString; conn = new SqlConnection(connString); conn.Open(); SqlCommand command = new SqlCommand("select * from Tafels ", conn); SqlDataReader reader = command.ExecuteReader(); //int tafelstatus = 2; oude code //int tafelnummer = 1; while (reader.Read()) { Tafels status = new Tafels(); status.tafelstatus = (int)reader["Beschikbaarheid"]; status.tafelnummers = (int)reader["TAFELNUMMER"]; tafels.Add(status); } //ga alle tafels en kijk welke welke status heeft foreach (Tafels tafel in tafels) if (tafel.tafelstatus == 2)//bezet { Control table = Controls["Tafel" + tafel.tafelnummers]; table.BackColor = Color.Blue; Control lable = Controls["TafelLabel" + tafel.tafelnummers]; lable.BackColor = Color.Blue; lable.Text = "Bezet"; } else if (tafel.tafelstatus == 3)//in verwerking { Control table = Controls["Tafel" + tafel.tafelnummers]; table.BackColor = Color.Red; Control lable = Controls["TafelLabel" + tafel.tafelnummers]; lable.BackColor = Color.Red; lable.Text = "Bezig"; } else if (tafel.tafelstatus == 4)//klaar voor servering { Control table = Controls["Tafel" + tafel.tafelnummers]; table.BackColor = Color.Green; Control lable = Controls["TafelLabel" + tafel.tafelnummers]; lable.BackColor = Color.Green; lable.Text = "Gereed"; } else //vrij (1 is vrij) { Control control = Controls["Tafel" + tafel.tafelnummers]; control.BackColor = Color.Yellow; Control lable = Controls["TafelLabel" + tafel.tafelnummers]; lable.BackColor = Color.Yellow; lable.Text = "Vrij"; } /** oude code was voor als verbeteringen niet werken dan had ik toch nog wat tafelstatus = (int)reader["Beschikbaarheid"]; tafelnummer = (int)reader["TAFELNUMMER"]; switch(tafelnummer) { case 1: if (tafelstatus == 2)//bezet { Tafel1.BackColor = Color.Blue; TafelLabel1.BackColor = Color.Blue; TafelLabel1.Text = "Bezet"; } else if (tafelstatus == 3)//in verwerking { Tafel1.BackColor = Color.Red; TafelLabel1.BackColor = Color.Red; TafelLabel1.Text = "Bezig"; } else if (tafelstatus == 4)//klaar voor servering { Tafel1.BackColor = Color.Green; TafelLabel1.BackColor = Color.Green; TafelLabel1.Text = "Gereed"; } else //vrij (1 is vrij) { Tafel1.BackColor = Color.Yellow; TafelLabel1.BackColor = Color.Yellow; TafelLabel1.Text = "Vrij"; } break; case 2: if (tafelstatus == 2)//bezet { Tafel2.BackColor = Color.Blue; TafelLabel2.BackColor = Color.Blue; TafelLabel2.Text = "Bezet"; } else if (tafelstatus == 3)//in verwerking { Tafel2.BackColor = Color.Red; TafelLabel2.BackColor = Color.Red; TafelLabel2.Text = "Bezig"; } else if (tafelstatus == 4)//klaar voor reservering { Tafel2.BackColor = Color.Green; TafelLabel2.BackColor = Color.Green; TafelLabel2.Text = "Gereed"; } else //vrij (1 is vrij) { Tafel2.BackColor = Color.Yellow; TafelLabel2.BackColor = Color.Yellow; TafelLabel2.Text = "Vrij"; } break; case 3: if (tafelstatus == 2)//bezet { Tafel3.BackColor = Color.Blue; TafelLabel3.BackColor = Color.Blue; TafelLabel3.Text = "Bezet"; } else if (tafelstatus == 3)//in verwerking { Tafel3.BackColor = Color.Red; TafelLabel3.BackColor = Color.Red; TafelLabel3.Text = "Bezig"; } else if (tafelstatus == 4)//klaar voor reservering { Tafel3.BackColor = Color.Green; TafelLabel3.BackColor = Color.Green; TafelLabel3.Text = "Gereed"; } else //vrij (1 is vrij) { Tafel3.BackColor = Color.Yellow; TafelLabel3.BackColor = Color.Yellow; TafelLabel3.Text = "Vrij"; } break; case 4: if (tafelstatus == 2)//bezet { Tafel4.BackColor = Color.Blue; TafelLabel4.BackColor = Color.Blue; TafelLabel4.Text = "Bezet"; } else if (tafelstatus == 3)//in verwerking { Tafel4.BackColor = Color.Red; TafelLabel4.BackColor = Color.Red; TafelLabel4.Text = "Bezig"; } else if (tafelstatus == 4)//klaar voor reservering { Tafel4.BackColor = Color.Green; TafelLabel4.BackColor = Color.Green; TafelLabel4.Text = "Gereed"; } else //vrij (1 is vrij) { Tafel4.BackColor = Color.Yellow; TafelLabel4.BackColor = Color.Yellow; TafelLabel4.Text = "Vrij"; } break; case 5: if (tafelstatus == 2)//bezet { Tafel5.BackColor = Color.Blue; TafelLabel5.BackColor = Color.Blue; TafelLabel5.Text = "Bezet"; } else if (tafelstatus == 3)//in verwerking { Tafel5.BackColor = Color.Red; TafelLabel5.BackColor = Color.Red; TafelLabel5.Text = "Bezig"; } else if (tafelstatus == 4)//klaar voor reservering { Tafel5.BackColor = Color.Green; TafelLabel5.BackColor = Color.Green; TafelLabel5.Text = "Gereed"; } else //vrij (1 is vrij) { Tafel5.BackColor = Color.Yellow; TafelLabel5.BackColor = Color.Yellow; TafelLabel5.Text = "Vrij"; } break; case 6: if (tafelstatus == 2)//bezet { Tafel6.BackColor = Color.Blue; TafelLabel6.BackColor = Color.Blue; TafelLabel6.Text = "Bezet"; } else if (tafelstatus == 3)//in verwerking { Tafel6.BackColor = Color.Red; TafelLabel6.BackColor = Color.Red; TafelLabel6.Text = "Bezig"; } else if (tafelstatus == 4)//klaar voor reservering { Tafel6.BackColor = Color.Green; TafelLabel6.BackColor = Color.Green; TafelLabel6.Text = "Gereed"; } else //vrij (1 is vrij) { Tafel6.BackColor = Color.Yellow; TafelLabel6.BackColor = Color.Yellow; TafelLabel6.Text = "Vrij"; } break; case 7: if (tafelstatus == 2)//bezet { Tafel7.BackColor = Color.Blue; TafelLabel7.BackColor = Color.Blue; TafelLabel7.Text = "Bezet"; } else if (tafelstatus == 3)//in verwerking { Tafel7.BackColor = Color.Red; TafelLabel7.BackColor = Color.Red; TafelLabel7.Text = "Bezig"; } else if (tafelstatus == 4)//klaar voor reservering { Tafel7.BackColor = Color.Green; TafelLabel7.BackColor = Color.Green; TafelLabel7.Text = "Gereed"; } else //vrij (1 is vrij) { Tafel7.BackColor = Color.Yellow; TafelLabel7.BackColor = Color.Yellow; TafelLabel7.Text = "Vrij"; } break; case 8: if (tafelstatus == 2)//bezet { Tafel8.BackColor = Color.Blue; TafelLabel8.BackColor = Color.Blue; TafelLabel8.Text = "Bezet"; } else if (tafelstatus == 3)//in verwerking { Tafel8.BackColor = Color.Red; TafelLabel8.BackColor = Color.Red; TafelLabel8.Text = "Bezig"; } else if (tafelstatus == 4)//klaar voor reservering { Tafel8.BackColor = Color.Green; TafelLabel8.BackColor = Color.Green; TafelLabel8.Text = "Gereed"; } else //vrij (1 is vrij) { Tafel8.BackColor = Color.Yellow; TafelLabel8.BackColor = Color.Yellow; TafelLabel8.Text = "Vrij"; } break; case 9: if (tafelstatus == 2)//bezet { Tafel9.BackColor = Color.Blue; TafelLabel9.BackColor = Color.Blue; TafelLabel9.Text = "Bezet"; } else if (tafelstatus == 3)//in verwerking { Tafel9.BackColor = Color.Red; TafelLabel9.BackColor = Color.Red; TafelLabel9.Text = "Bezig"; } else if (tafelstatus == 4)//klaar voor reservering { Tafel9.BackColor = Color.Green; TafelLabel9.BackColor = Color.Green; TafelLabel9.Text = "Gereed"; } else //vrij (1 is vrij) { Tafel9.BackColor = Color.Yellow; TafelLabel9.BackColor = Color.Yellow; TafelLabel9.Text = "Vrij"; } break; case 10: if (tafelstatus == 2)//bezet { Tafel10.BackColor = Color.Blue; TafelLabel10.BackColor = Color.Blue; TafelLabel10.Text = "Bezet"; } else if (tafelstatus == 3)//in verwerking { Tafel10.BackColor = Color.Red; TafelLabel10.BackColor = Color.Red; TafelLabel10.Text = "Bezig"; } else if (tafelstatus == 4)//klaar voor reservering { Tafel10.BackColor = Color.Green; TafelLabel10.BackColor = Color.Green; TafelLabel10.Text = "Gereed"; } else //vrij (1 is vrij) { Tafel10.BackColor = Color.Yellow; TafelLabel10.BackColor = Color.Yellow; TafelLabel10.Text = "Vrij"; } break; } } */ conn.Close(); }