예제 #1
0
        public RendezVous Read(int id_rdv, bool isReadFromEchantillonDonne)
        {
            RendezVous rendezVous = null;

            if (OpenConnection())
            {
                rendezVous = new RendezVous();
                EmployeDAO          employeManager          = new EmployeDAO();
                PraticienDAO        praticienManager        = new PraticienDAO();
                EchantillonDonneDAO echantillonDonneManager = new EchantillonDonneDAO();

                command             = manager.CreateCommand();
                command.CommandText = "SELECT * " +
                                      "FROM rendez_vous " +
                                      "WHERE id_rdv = @id " +
                                      "ORDER BY date_rdv ASC";
                command.Parameters.AddWithValue("@id", id_rdv);

                // Lecture des résultats
                dataReader = command.ExecuteReader();

                while (dataReader.Read())
                {
                    rendezVous.Id_rdv           = (int)dataReader["id_rdv"];
                    rendezVous.Date_bilan       = (DateTime)dataReader["date_bilan"];
                    rendezVous.Date_rdv         = (DateTime)dataReader["date_rdv"];
                    rendezVous.Employe          = employeManager.Read((int)dataReader["id_commercial"]);
                    rendezVous.Praticien        = praticienManager.Read((int)dataReader["id_praticien"]);
                    rendezVous.Indice_confiance = (int)dataReader["indice_confiance"];
                    // Utilisation d'un Enum.Parse pour transformer un string en Enum
                    // Pour ce faire : (Type Enum)Enum.Parse(typeof(Type Enum), (string)variable);
                    rendezVous.Motif_rdv = (RendezVous.Rdv)Enum.Parse(typeof(RendezVous.Rdv), (string)dataReader["motif_rdv"]);

                    if (!isReadFromEchantillonDonne)
                    {
                        rendezVous.Liste_echantillons_donnes = echantillonDonneManager.ReadAllFromRendezVous(rendezVous.Id_rdv);
                    }
                }

                dataReader.Close();
                CloseConnection();
            }
            return(rendezVous);
        }
예제 #2
0
        public List <RendezVous> ReadRDVHistoFromCommercialID(int id_commercial)
        {
            List <RendezVous> liste_rdv = new List <RendezVous>();

            if (OpenConnection())
            {
                RendezVous          rdv;
                EmployeDAO          employeManager          = new EmployeDAO();
                PraticienDAO        praticienManager        = new PraticienDAO();
                EchantillonDonneDAO echantillonDonneManager = new EchantillonDonneDAO();

                command             = manager.CreateCommand();
                command.CommandText = "SELECT * FROM rendez_vous WHERE id_commercial = @id_commercial AND date_rdv < NOW()";

                command.Parameters.AddWithValue("@id_commercial", id_commercial);

                dataReader = command.ExecuteReader();
                Debug.WriteLine("==== Je suis appellé une fois pour lire les RDV");
                while (dataReader.Read())
                {
                    rdv                           = new RendezVous();
                    rdv.Id_rdv                    = (int)dataReader["id_rdv"];
                    rdv.Employe                   = employeManager.Read((int)dataReader["id_commercial"]);
                    rdv.Praticien                 = praticienManager.Read((int)dataReader["id_praticien"]);
                    rdv.Date_rdv                  = (DateTime)dataReader["date_rdv"];
                    rdv.Date_bilan                = (DateTime)dataReader["date_bilan"];
                    rdv.Motif_rdv                 = (RendezVous.Rdv)Enum.Parse(typeof(RendezVous.Rdv), (string)dataReader["motif_rdv"]);
                    rdv.Indice_confiance          = (int)dataReader["indice_confiance"];
                    rdv.Liste_echantillons_donnes = echantillonDonneManager.ReadAllFromRendezVous(rdv.Id_rdv);
                    liste_rdv.Add(rdv);
                }
                dataReader.Close();
                command.ExecuteNonQuery();
                CloseConnection();
            }
            return(liste_rdv);
        }
예제 #3
0
        public List <RendezVous> ReadAll()
        {
            List <RendezVous> liste_rdv = new List <RendezVous>();

            if (OpenConnection())
            {
                RendezVous          rdv;
                EmployeDAO          employeManager          = new EmployeDAO();
                PraticienDAO        praticienManager        = new PraticienDAO();
                EchantillonDonneDAO echantillonDonneManager = new EchantillonDonneDAO();

                command             = manager.CreateCommand();
                command.CommandText = "SELECT * FROM rendez_vous";

                dataReader = command.ExecuteReader();


                while (dataReader.Read())
                {
                    rdv                           = new RendezVous();
                    rdv.Id_rdv                    = (int)dataReader["id_rdv"];
                    rdv.Employe                   = employeManager.Read((int)dataReader["id_commercial"]);
                    rdv.Praticien                 = praticienManager.Read((int)dataReader["id_praticien"]);
                    rdv.Date_rdv                  = (DateTime)dataReader["date_rdv"];
                    rdv.Motif_rdv                 = (RendezVous.Rdv)Enum.Parse(typeof(RendezVous.Rdv), (string)dataReader["motif_rdv"]);
                    rdv.Indice_confiance          = (int)dataReader["indice_confiance"];
                    rdv.Date_bilan                = (DateTime)dataReader["date_bilan"];
                    rdv.Liste_echantillons_donnes = echantillonDonneManager.ReadAllFromRendezVous(rdv.Id_rdv);
                    liste_rdv.Add(rdv);
                }
                dataReader.Close();
                command.ExecuteNonQuery();
                CloseConnection();
            }
            return(liste_rdv);
        }