private void btnAjouterPatient_Click(object sender, EventArgs e)
        {
            string   nom             = txtNomMedecin.Text;
            string   prenom          = txtPrenomMedecin.Text;
            DateTime date            = DateTimePickerNaissanceMedecin.Value;
            string   typeChambre     = comboBxTypeChambre.Text;
            string   departement     = comboBxDepartement.Text;
            string   Assurance       = "NON";
            string   LouerTelevision = "NON";
            string   LouerTelephone  = "NON";
            string   numeroLit       = comboBxNumeroLit.Text;

            int nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));


            //Selection de l'option d'assurance privée
            if (rBtnNONAssurance.Checked == true)
            {
                Assurance = "NON";
            }
            else if (rBtnOUIAssurance.Checked == true)
            {
                Assurance = "OUI";
            }

            //selection de l'option Location de television
            if (rBtnLouerTelevisionNON.Checked == true)
            {
                LouerTelevision = "NON";
            }
            else if (rBtnLouerTelevisionOUI.Checked == true)
            {
                LouerTelevision = "OUI";
            }

            /// //selection de l'option Location de telephone
            if (rBtnLocationTelephoneNON.Checked == true)
            {
                LouerTelephone = "NON";
            }
            else if (rBtnLocationTelephoneNON.Checked == true)
            {
                LouerTelephone = "OUI";
            }


            //Verifions si nos champs sont vides
            //Daans le cas contraire
            if (verif())
            {
                //Les patients agés de 16 ans ou mons qui ne sont pas admis pour une chirurgie
                //sont automatiquent dirigés vers les chambres du département de pédiatrie
                //lorsqun lit correspondant au type est dispo
                if (nombreLitsDispo > 0)
                {
                    int dateNaisssancePatient = DateTimePickerNaissanceMedecin.Value.Year;
                    int dateActuel            = DateTime.Now.Year;


                    if ((dateActuel - dateNaisssancePatient) <= 16)
                    {
                        if (typeChambre != "Chirurgie")
                        {
                            typeChambre     = "Pédiatrie";
                            nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));

                            if (nombreLitsDispo > 0)
                            {
                                if (patient.VerificationNumeroLit(departement, typeChambre))
                                {
                                    if (patient.VerificationTypeChambre(typeChambre))
                                    {
                                        if (patient.VerificationDepartement(departement))
                                        {
                                            if (nombreLitsDispo > 0)
                                            {
                                                if (patient.InsererPatient(nom, prenom, date, departement, Assurance,
                                                                           typeChambre, LouerTelevision, LouerTelephone, numeroLit))
                                                {
                                                    nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));



                                                    //
                                                    MessageBox.Show("Insertion du patient avec succès.", "Information",
                                                                    MessageBoxButtons.OK, MessageBoxIcon.Information);

                                                    numeroLit = comboBxNumeroLit.Text;
                                                    patient.SupprimerLits(numeroLit, typeChambre);

                                                    //On diminiue les lits diponibles a chaque ajout
                                                    nombreLitsDispo -= 1;

                                                    //Modification de notre table tblDisponibilites
                                                    patient.ModifierDisponibites(nombreLitsDispo, departement, typeChambre);
                                                }
                                                else
                                                {
                                                    MessageBox.Show("Échec d'insertion du patient.", "Information",
                                                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                }
                                            }
                                            else
                                            {
                                                MessageBox.Show("Impossible d'ajouter de patients car nous n'avons plus de " +
                                                                "lits disponibles.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("Ce département n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Ce type de chambre n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Ce numéro de lit n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                        }
                    }
                }
                else
                {
                    comboBxTypeChambre.Focus();
                    typeChambre = comboBxTypeChambre.Text;

                    if (nombreLitsDispo <= 0)
                    {
                        MessageBox.Show("Impossible d'ajouter de patients car nous n'avons plus de lits disponibles.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                //**************************************************
                //6 eme point du projet
                if (Assurance == "NON")
                {
                    if (typeChambre == "standard")
                    {
                        nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));

                        if (nombreLitsDispo > 0)
                        {
                            if (patient.VerificationNumeroLit(departement, typeChambre))
                            {
                                if (patient.VerificationTypeChambre(typeChambre))
                                {
                                    if (patient.VerificationDepartement(departement))
                                    {
                                        if (nombreLitsDispo > 0)
                                        {
                                            if (patient.InsererPatient(nom, prenom, date, departement, Assurance,
                                                                       typeChambre, LouerTelevision, LouerTelephone, numeroLit))
                                            {
                                                nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));



                                                //
                                                MessageBox.Show("Insertion du patient avec succès.", "Information",
                                                                MessageBoxButtons.OK, MessageBoxIcon.Information);

                                                numeroLit = comboBxNumeroLit.Text;
                                                patient.SupprimerLits(numeroLit, typeChambre);

                                                //On diminiue les lits diponibles a chaque ajout
                                                nombreLitsDispo -= 1;

                                                //Modification de notre table tblDisponibilites
                                                patient.ModifierDisponibites(nombreLitsDispo, departement, typeChambre);
                                            }
                                            else
                                            {
                                                MessageBox.Show("Échec d'insertion du patient.", "Information",
                                                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("Impossible d'ajouter de patients car nous n'avons plus de " +
                                                            "lits disponibles.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Ce département n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Ce type de chambre n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Ce numéro de lit n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else if ((nombreLitsDispo <= 0))
                        {
                            if (typeChambre == "privée" || typeChambre == "semi-privée")
                            {
                                if (typeChambre == "privée")
                                {
                                    nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));

                                    if (nombreLitsDispo <= 0)
                                    {
                                        MessageBox.Show("Impossible d'ajouter de patients car nous n'avons plus de " +
                                                        "lits disponibles.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                    else
                                    {
                                        nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));
                                        //insertion sans frais supp
                                        //AJout avec succes
                                        if (patient.VerificationNumeroLit(departement, typeChambre))
                                        {
                                            if (patient.VerificationTypeChambre(typeChambre))
                                            {
                                                if (patient.VerificationDepartement(departement))
                                                {
                                                    if (nombreLitsDispo > 0)
                                                    {
                                                        if (patient.InsererPatient(nom, prenom, date, departement, Assurance,
                                                                                   typeChambre, LouerTelevision, LouerTelephone, numeroLit))
                                                        {
                                                            nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));



                                                            //
                                                            MessageBox.Show("Insertion du patient avec succès.", "Information",
                                                                            MessageBoxButtons.OK, MessageBoxIcon.Information);

                                                            numeroLit = comboBxNumeroLit.Text;
                                                            patient.SupprimerLits(numeroLit, typeChambre);

                                                            //On diminiue les lits diponibles a chaque ajout
                                                            nombreLitsDispo -= 1;

                                                            //Modification de notre table tblDisponibilites
                                                            patient.ModifierDisponibites(nombreLitsDispo, departement, typeChambre);
                                                        }
                                                        else
                                                        {
                                                            MessageBox.Show("Échec d'insertion du patient.", "Information",
                                                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        MessageBox.Show("Impossible d'ajouter de patients car nous n'avons plus de " +
                                                                        "lits disponibles.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                    }
                                                }
                                                else
                                                {
                                                    MessageBox.Show("Ce département n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                }
                                            }
                                            else
                                            {
                                                MessageBox.Show("Ce type de chambre n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("Ce numéro de lit n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        }
                                    }
                                }
                                else if (typeChambre == "semi-privée")
                                {
                                    nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));


                                    if (nombreLitsDispo <= 0)
                                    {
                                        MessageBox.Show("Impossible d'ajouter de patients car nous n'avons plus de " +
                                                        "lits disponibles.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                    else
                                    {
                                        //insertion sans frais supp
                                        //AJout avec succes
                                        if (patient.VerificationNumeroLit(departement, typeChambre))
                                        {
                                            if (patient.VerificationTypeChambre(typeChambre))
                                            {
                                                if (patient.VerificationDepartement(departement))
                                                {
                                                    if (nombreLitsDispo > 0)
                                                    {
                                                        if (patient.InsererPatient(nom, prenom, date, departement, Assurance,
                                                                                   typeChambre, LouerTelevision, LouerTelephone, numeroLit))
                                                        {
                                                            nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));



                                                            //
                                                            MessageBox.Show("Insertion du patient avec succès.", "Information",
                                                                            MessageBoxButtons.OK, MessageBoxIcon.Information);

                                                            numeroLit = comboBxNumeroLit.Text;
                                                            patient.SupprimerLits(numeroLit, typeChambre);

                                                            //On diminiue les lits diponibles a chaque ajout
                                                            nombreLitsDispo -= 1;

                                                            //Modification de notre table tblDisponibilites
                                                            patient.ModifierDisponibites(nombreLitsDispo, departement, typeChambre);
                                                        }
                                                        else
                                                        {
                                                            MessageBox.Show("Échec d'insertion du patient.", "Information",
                                                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        MessageBox.Show("Impossible d'ajouter de patients car nous n'avons plus de " +
                                                                        "lits disponibles.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                    }
                                                }
                                                else
                                                {
                                                    MessageBox.Show("Ce département n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                }
                                            }
                                            else
                                            {
                                                MessageBox.Show("Ce type de chambre n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("Ce numéro de lit n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }


                //*******************************************
                //8 eme point du projet
                if (departement == "Chirurgie")
                {
                    nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));

                    if (nombreLitsDispo <= 0)
                    {
                        MessageBox.Show("Impossible d'ajouter de patients car nous n'avons plus de " +
                                        "lits disponibles.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        comboBxTypeChambre.Focus();
                        typeChambre     = comboBxTypeChambre.Text;
                        nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));

                        if (nombreLitsDispo <= 0)
                        {
                            MessageBox.Show("Impossible d'ajouter de patients car nous n'avons plus de " +
                                            "lits disponibles.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            //insertion sans frais sup
                            if (patient.VerificationNumeroLit(departement, typeChambre))
                            {
                                if (patient.VerificationTypeChambre(typeChambre))
                                {
                                    if (patient.VerificationDepartement(departement))
                                    {
                                        if (nombreLitsDispo > 0)
                                        {
                                            if (patient.InsererPatient(nom, prenom, date, departement, Assurance,
                                                                       typeChambre, LouerTelevision, LouerTelephone, numeroLit))
                                            {
                                                nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));



                                                //
                                                MessageBox.Show("Insertion du patient avec succès.", "Information",
                                                                MessageBoxButtons.OK, MessageBoxIcon.Information);

                                                numeroLit = comboBxNumeroLit.Text;
                                                patient.SupprimerLits(numeroLit, typeChambre);

                                                //On diminiue les lits diponibles a chaque ajout
                                                nombreLitsDispo -= 1;

                                                //Modification de notre table tblDisponibilites
                                                patient.ModifierDisponibites(nombreLitsDispo, departement, typeChambre);
                                            }
                                            else
                                            {
                                                MessageBox.Show("Échec d'insertion du patient.", "Information",
                                                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("Impossible d'ajouter de patients car nous n'avons plus de " +
                                                            "lits disponibles.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Ce département n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Ce type de chambre n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Ce numéro de lit n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                }

                ///*****************************************
                ///7 eme point du projet
                ///
                if (Assurance == "NON")
                {
                    nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, "standard"));

                    if (nombreLitsDispo > 0)
                    {
                        if (typeChambre == "privée" || typeChambre == "semi-privée")
                        {
                            nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));

                            if (patient.VerificationNumeroLit(departement, typeChambre))
                            {
                                if (patient.VerificationTypeChambre(typeChambre))
                                {
                                    if (patient.VerificationDepartement(departement))
                                    {
                                        if (nombreLitsDispo > 0)
                                        {
                                            if (patient.InsererPatient(nom, prenom, date, departement, Assurance,
                                                                       typeChambre, LouerTelevision, LouerTelephone, numeroLit))
                                            {
                                                nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));

                                                MessageBox.Show("Vous serez chargé de frais supplémentaires.", "Attention",
                                                                MessageBoxButtons.OK, MessageBoxIcon.Information);

                                                //
                                                MessageBox.Show("Insertion du patient avec succès.", "Information",
                                                                MessageBoxButtons.OK, MessageBoxIcon.Information);

                                                numeroLit = comboBxNumeroLit.Text;
                                                patient.SupprimerLits(numeroLit, typeChambre);

                                                //On diminiue les lits diponibles a chaque ajout
                                                nombreLitsDispo -= 1;

                                                //Modification de notre table tblDisponibilites
                                                patient.ModifierDisponibites(nombreLitsDispo, departement, typeChambre);
                                            }
                                            else
                                            {
                                                MessageBox.Show("Échec d'insertion du patient.", "Information",
                                                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("Impossible d'ajouter de patients car nous n'avons plus de " +
                                                            "lits disponibles.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("Ce département n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Ce type de chambre n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Ce numéro de lit n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                }
                else if (Assurance == "OUI")
                {
                    if (patient.VerificationNumeroLit(departement, typeChambre))
                    {
                        if (patient.VerificationTypeChambre(typeChambre))
                        {
                            if (patient.VerificationDepartement(departement))
                            {
                                if (nombreLitsDispo > 0)
                                {
                                    if (patient.InsererPatient(nom, prenom, date, departement, Assurance,
                                                               typeChambre, LouerTelevision, LouerTelephone, numeroLit))
                                    {
                                        nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));



                                        //
                                        MessageBox.Show("Insertion du patient avec succès.", "Information",
                                                        MessageBoxButtons.OK, MessageBoxIcon.Information);

                                        numeroLit = comboBxNumeroLit.Text;
                                        patient.SupprimerLits(numeroLit, typeChambre);

                                        //On diminiue les lits diponibles a chaque ajout
                                        nombreLitsDispo -= 1;

                                        //Modification de notre table tblDisponibilites
                                        patient.ModifierDisponibites(nombreLitsDispo, departement, typeChambre);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Échec d'insertion du patient.", "Information",
                                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Impossible d'ajouter de patients car nous n'avons plus de " +
                                                    "lits disponibles.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Ce département n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Ce type de chambre n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Ce numéro de lit n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else if (Assurance == "OUI" || Assurance == "NON")
                {
                    nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));

                    if (patient.VerificationNumeroLit(departement, typeChambre))
                    {
                        if (patient.VerificationTypeChambre(typeChambre))
                        {
                            if (patient.VerificationDepartement(departement))
                            {
                                if (nombreLitsDispo > 0)
                                {
                                    if (patient.InsererPatient(nom, prenom, date, departement, Assurance,
                                                               typeChambre, LouerTelevision, LouerTelephone, numeroLit))
                                    {
                                        nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));



                                        //
                                        MessageBox.Show("Insertion du patient avec succès.", "Information",
                                                        MessageBoxButtons.OK, MessageBoxIcon.Information);

                                        numeroLit = comboBxNumeroLit.Text;
                                        patient.SupprimerLits(numeroLit, typeChambre);

                                        //On diminiue les lits diponibles a chaque ajout
                                        nombreLitsDispo -= 1;

                                        //Modification de notre table tblDisponibilites
                                        patient.ModifierDisponibites(nombreLitsDispo, departement, typeChambre);
                                    }
                                    else
                                    {
                                        MessageBox.Show("Échec d'insertion du patient.", "Information",
                                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Impossible d'ajouter de patients car nous n'avons plus de " +
                                                    "lits disponibles.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Ce département n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Ce type de chambre n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Ce numéro de lit n'existe pas.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            else
            {
                MessageBox.Show("Certains champs sont vides.", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #2
0
        private void btnCongé_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtNombreJours.Text != "" && Convert.ToInt16(txtNombreJours.Text) > 0)
                {
                    if ((MessageBox.Show("Êtes-vous sur de vouloir donné des congés à ce patient ?", "Libérer patient", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
                    {
                        //Récuperons la valeur de la premiere colonne de la rangée selectionné
                        //qui est L'id du médecin

                        try
                        {
                            int      IdPatient       = int.Parse(dtgPatientsParMedecin.CurrentRow.Cells[0].Value.ToString());
                            string   nom             = dtgPatientsParMedecin.CurrentRow.Cells[1].Value.ToString();
                            string   prenom          = dtgPatientsParMedecin.CurrentRow.Cells[2].Value.ToString();
                            DateTime dateNaissance   = (DateTime)dtgPatientsParMedecin.CurrentRow.Cells[3].Value;
                            string   departement     = dtgPatientsParMedecin.CurrentRow.Cells[4].Value.ToString();
                            string   assurance       = dtgPatientsParMedecin.CurrentRow.Cells[5].Value.ToString();
                            string   typeChambre     = dtgPatientsParMedecin.CurrentRow.Cells[6].Value.ToString();
                            string   louerTelevision = dtgPatientsParMedecin.CurrentRow.Cells[7].Value.ToString();
                            string   louerTelephone  = dtgPatientsParMedecin.CurrentRow.Cells[8].Value.ToString();
                            string   NumeroLit       = dtgPatientsParMedecin.CurrentRow.Cells[9].Value.ToString();
                            int      nbrDeJours      = Convert.ToInt16(txtNombreJours.Text);

                            //Suppression du patient de notre table
                            if (patient.DonnerCongéDuPatient(IdPatient))
                            {
                                MessageBox.Show("Le patient à quitter l'hôpital avec succès", "Libérer patient", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                //Libérons notre lit en l'ajoutant comme disponible dans notre table tblLits
                                patient.InsererLit(NumeroLit, departement, typeChambre);

                                int nombreLitsDispo = Convert.ToInt16(patient.NombreLitDipo(departement, typeChambre));

                                //Incrémentons le nombre de lits disponibles.
                                nombreLitsDispo += 1;


                                //MOdifier les disponibilites
                                patient.ModifierDisponibites(nombreLitsDispo, departement, typeChambre);

                                //Insertion du patient dans la tables des anciens patients
                                //pour garder une trace sur lui
                                patient.InsererAncienPatient(IdPatient, nom, prenom, dateNaissance,
                                                             departement, assurance, typeChambre, louerTelevision, louerTelephone, nbrDeJours);
                            }
                            else
                            {
                                MessageBox.Show("Échec de libération du patient", "Libérer patient", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                        catch (NullReferenceException)
                        {
                            MessageBox.Show("Vous ne disposez d'aucun patient ,raison pour laquelle cette opéraion de libération de patient"
                                            + " est impossible.", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Vous devez saisir une valeur positive dans ce champ."
                                    , "Attention", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtNombreJours.Focus();
                }
            }
            catch (FormatException)
            {
                MessageBox.Show("Vous devez saisir une valeur numérique pour ce champ."
                                , "Attention", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtNombreJours.Focus();
            }
        }