public void ChargerLesEmployesDesServices(MySqlConnection Cnx) { MySqlCommand Cmd = new MySqlCommand(); MySqlDataReader Rdr; Cmd.Connection = Cnx; foreach (Service s in LesServices) { Cmd.CommandText = "select * from employe where emp_service=s.id;"; Rdr = Cmd.ExecuteReader(); int i; while (Rdr.Read()) { i = 0; while (i < LesEmployes.Count && LesEmployes[i].Id != Int32.Parse(Rdr.GetString(0))) { i++; } if (LesEmployes[i].Id == Int32.Parse(Rdr.GetString(0))) { s.LesEmployesDuService.Add(LesEmployes[i]); } Rdr.Close(); } } }
public void ChargerEmployes(MySqlConnection Cnx) { Cnx.Open(); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = Cnx; cmd.CommandText = "employe"; cmd.CommandType = CommandType.TableDirect; MySqlDataReader Rdr; Rdr = cmd.ExecuteReader(); while (Rdr.Read()) { Employe unEmploye = new Employe(Int32.Parse(Rdr.GetString(0)), Rdr.GetString(1), Rdr.GetString(2), Rdr.GetString(3), Decimal.Parse(Rdr.GetString(4)), Byte.Parse(Rdr.GetString(5)), null); lesEmployes.Add(unEmploye); } Cnx.Close(); }
public void ChargerService(MySqlConnection Cnx) { MySqlCommand cmd = new MySqlCommand(); cmd.Connection = Cnx; cmd.CommandText = "service"; cmd.CommandType = CommandType.TableDirect; MySqlDataReader Rdr; Rdr = cmd.ExecuteReader(); while (Rdr.Read()) { if (Rdr.GetString(2) == "P") { Service unService = new Service(Int32.Parse(Rdr.GetString(0)), Rdr.GetString(1), Rdr.GetString(2), Rdr.GetString(3), Int32.Parse(Rdr.GetString(4))); lesServices.Add(unService); } else if (Rdr.GetString(2) == "A") { Service unService = new Service(Int32.Parse(Rdr.GetString(0)), Rdr.GetString(1), Rdr.GetString(2), Decimal.Parse(Rdr.GetString(5))); lesServices.Add(unService); } } }