Пример #1
0
        private void FRapport_Load(object sender, EventArgs e)
        {
            List <RapportVisite> Rapport = DAORapportVisite.GetRapportVisite();

            foreach (RapportVisite Rapports in Rapport)
            {
                //On crée un tableau de chaine de caractères : chaque cellule contient un attribut chaine de caractères du client
                RapportVisite unRapport = new RapportVisite(Rapports.Numero, Rapports.Date, Rapports.Bilan, Rapports.Motif, Rapports.Pra_num, Rapports.Vis_matricule);
                RapportsListe.Add(unRapport);
            }
            RapportVisite Rapportaffiche = RapportsListe[0];

            TBXNumRapport.Text   = Rapportaffiche.Numero;
            TBXMotif.Text        = Rapportaffiche.Motif;
            TBXBilan.Text        = Rapportaffiche.Bilan;
            BTNPrecedent.Enabled = false;

            foreach (Praticien praticien in praticiens)
            {
                string nomPrenom = praticien.Nom + " " + praticien.Prenom;

                CBXPraticien.Items.Add(nomPrenom);
            }
            CBXPraticien.SelectedIndex = Rapportaffiche.Pra_num - 1;
        }
Пример #2
0
        private void BTNEnregistrer_Click(object sender, EventArgs e)
        {
            if (nouveau)
            {
                RapportVisite nouveauRapport = new RapportVisite();
                nouveauRapport.Numero = TBXNumRapport.Text;
                char[]        separateurs      = new char[] { '/', ':', ' ', '-' };
                string        sqlFormattedDate = "1970-01-01";
                List <string> eltDate          = new List <string>(TBXDateRapport.Text.Split(separateurs));
                if (eltDate.Count == 3)
                {
                    DateTime newDate = new DateTime(Convert.ToInt32(eltDate[0]), Convert.ToInt32(eltDate[1]), Convert.ToInt32(eltDate[2]));
                    sqlFormattedDate = newDate.ToString("yyyy-MM-dd HH:mm:ss");
                }
                else if (eltDate.Count == 6)
                {
                    DateTime newDate = new DateTime(Convert.ToInt32(eltDate[0]), Convert.ToInt32(eltDate[1]), Convert.ToInt32(eltDate[2]), Convert.ToInt32(eltDate[3]), Convert.ToInt32(eltDate[4]), Convert.ToInt32(eltDate[5]));
                    sqlFormattedDate = newDate.ToString("yyyy-MM-dd HH:mm:ss");
                }
                nouveauRapport.Date    = sqlFormattedDate;
                nouveauRapport.Bilan   = TBXBilan.Text;
                nouveauRapport.Motif   = TBXMotif.Text;
                nouveauRapport.Pra_num = CBXPraticien.SelectedIndex + 1;
                if (DAORapportVisite.CreateRapport(nouveauRapport))
                {
                    RapportsListe.Add(nouveauRapport);
                }
                ;
            }
            else
            {
                RapportVisite rapportModifie   = new RapportVisite();
                char[]        separateurs      = new char[] { '/', ':', ' ', '-' };
                string        sqlFormattedDate = "1970-01-01";
                List <string> eltDate          = new List <string>(TBXDateRapport.Text.Split(separateurs));
                if (eltDate.Count == 3)
                {
                    DateTime newDate = new DateTime(Convert.ToInt32(eltDate[0]), Convert.ToInt32(eltDate[1]), Convert.ToInt32(eltDate[2]));
                    sqlFormattedDate = newDate.ToString("yyyy-MM-dd HH:mm:ss");
                }
                else if (eltDate.Count == 6)
                {
                    DateTime newDate = new DateTime(Convert.ToInt32(eltDate[0]), Convert.ToInt32(eltDate[1]), Convert.ToInt32(eltDate[2]), Convert.ToInt32(eltDate[3]), Convert.ToInt32(eltDate[4]), Convert.ToInt32(eltDate[5]));
                    sqlFormattedDate = newDate.ToString("yyyy-MM-dd HH:mm:ss");
                }
                rapportModifie.Numero  = TBXNumRapport.Text;
                rapportModifie.Date    = sqlFormattedDate;
                rapportModifie.Bilan   = TBXBilan.Text;
                rapportModifie.Motif   = TBXMotif.Text;
                rapportModifie.Pra_num = CBXPraticien.SelectedIndex + 1;
                DAORapportVisite.UpdateRapport(rapportModifie);
                this.RapportsListe[index] = rapportModifie;
            }

            this.refresh();
        }
Пример #3
0
        //Construction d'une instance de rapportvisite à partir d'une ligne du résultat de la requête.
        //Rappel : on souhaite que la couche "Présentation" ne soit pas liée à la base de données.
        //Elle ne doit travailler qu'avec des objets métiers.
        private static RapportVisite CreerRapportVisite(DataRow row)
        {
            RapportVisite rapportvisite = new RapportVisite();

            rapportvisite.Numero        = row["RAP_NUM"].ToString();
            rapportvisite.Date          = row["RAP_DATE"].ToString();
            rapportvisite.Bilan         = row["RAP_BILAN"].ToString();
            rapportvisite.Motif         = row["RAP_MOTIF"].ToString();
            rapportvisite.Pra_num       = int.Parse(row["PRA_NUM"].ToString());
            rapportvisite.Vis_matricule = row["VIS_MATRICULE"].ToString();
            return(rapportvisite);
        }
Пример #4
0
        public static Boolean UpdateRapport(RapportVisite rapport)
        {
            string updateRapport = "UPDATE RAPPORTVISITE SET RAP_DATE='" + rapport.Date + "', RAP_BILAN='" + rapport.Bilan + "', RAP_MOTIF='" + rapport.Motif + "', PRA_NUM='" + rapport.Pra_num.ToString() + "' WHERE RAP_NUM='" + rapport.Numero + "';";
            int    updatedRows   = DBInterface.Update(updateRapport);

            if (updatedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public static Boolean CreateRapport(RapportVisite rapport)
        {
            RapportVisite nouveauRapport = null;
            string        createRapport  = "INSERT INTO RAPPORTVISITE VALUES ('" + rapport.NumRapport + "', '" + rapport.DateRapport + "', '" + rapport.BilanRapport + "', '" + rapport.MotifRapport + "', '" + rapport.Pra_numRapport + "', '" + rapport.Vis_matriculeRapport + "');";
            int           updatedRows    = DBInterface.Update(createRapport);

            if (updatedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #6
0
 private void BTNSuivant_Click(object sender, EventArgs e)
 {
     if (index < RapportsListe.Count - 1)
     {
         index += 1;
         if (index == RapportsListe.Count - 1)
         {
             BTNSuivant.Enabled = false;
         }
         RapportVisite Rapportaffiche = RapportsListe[index];
         TBXNumRapport.Text         = Rapportaffiche.Numero;
         TBXDateRapport.Text        = Rapportaffiche.Date;
         TBXMotif.Text              = Rapportaffiche.Motif;
         TBXBilan.Text              = Rapportaffiche.Bilan;
         CBXPraticien.SelectedIndex = Rapportaffiche.Pra_num - 1;
         BTNPrecedent.Enabled       = true;
     }
 }
Пример #7
0
        ///<summary>
        ///Fournit la liste de tous les rapportvisites.
        ///</summary>
        ///<returns>
        ///Une collection (list) de rapportvisites
        ///</returns>
        public static List <RapportVisite> GetRapportVisite()
        {
            //Collection de rapportvisite qui sera retournée à la couche présentation.
            //Cette dernière ne doit travailler qu'avec des objets métiers.
            List <RapportVisite> rapportvisite = null;
            //La requête à exécuter pour sélectionner tous les rapportvisites
            string selectRapportVisite = "SELECT RAP_NUM, RAP_DATE, RAP_BILAN, RAP_MOTIF, PRA_NUM, VIS_MATRICULE FROM rapportvisite";
            //On appelle la couche persistance pour faire exécuter la requête. On exécute la méthode statique Select de la classe DBInterface
            //Rappel : la méthode Select retourne un datatable
            DataTable dataTable = DBInterface.Select(selectRapportVisite);

            //Le Datatable retourné est transformé en collection de rapportvisite
            if (dataTable != null)
            {
                rapportvisite = new List <RapportVisite>();
                foreach (DataRow row in dataTable.Rows)
                {
                    RapportVisite rapportsvisites = CreerRapportVisite(row);
                    rapportvisite.Add(rapportsvisites);
                }
            }
            return(rapportvisite);
        }
 private void BTNPrecedent_Click(object sender, EventArgs e)
 {
     BTNSuivant.Enabled = true;
     if (index > 0)
     {
         index -= 1;
         if (index == 0)
         {
             BTNPrecedent.Enabled = false;
         }
         RapportVisite Rapportaffiche = RapportsListe[index];
         TBXNumRapport.Text         = Rapportaffiche.NumRapport;
         TBXDateRapport.Text        = Rapportaffiche.DateRapport;
         TBXMotif.Text              = Rapportaffiche.MotifRapport;
         TBXBilan.Text              = Rapportaffiche.BilanRapport;
         CBXPraticien.SelectedIndex = Rapportaffiche.Pra_numRapport - 1;
     }
     if (nouveau)
     {
         index = RapportsListe.Count - 1;
         TBXNumRapport.Enabled = false;
         this.nouveau          = false;
     }
 }