private void InitForm()
        {
            this.labFormation.Content = Controleur.GetFormationStagiaire(codeStagiaire);
            KeyValuePair<string,string> kvp = Controleur.GetInfosTitre(codeStagiaire);
            codeTitre = kvp.Key;
            this.txtLibTitre.Text = kvp.Value;
            this.dgDates.ItemsSource = Controleur.GetListeDatesEpreuvesTitre(codeTitre);

            #region EtatAvancement
            //0 -> non inscrit
            //1 -> inscrit mais pas valide
            //2 -> inscrit et valide mais pas obtenu,
            //3 -> inscrit, valide et obtenu
            int etatInscription = Controleur.CheckIfInscrit(codeStagiaire, codeTitre);
            switch(etatInscription)
            {
                case 0:
                    histoPassageT = new PassageTitre(codeTitre, codeStagiaire);
                    groupBox2.IsEnabled = false;
                    break;
                case 1:
                    histoPassageT = Controleur.GetPassageTitre(codeStagiaire, codeTitre);
                    groupBox2.IsEnabled = false;
                    break;
                case 2:
                    histoPassageT = Controleur.GetPassageTitre(codeStagiaire, codeTitre);
                    groupBox1.IsEnabled = false;
                    break;
                case 3:
                    histoPassageT = Controleur.GetPassageTitre(codeStagiaire, codeTitre);
                    groupBox1.IsEnabled = false;
                    groupBox2.IsEnabled = false;
                    break;
                default:
                    groupBox1.IsEnabled = false;
                    groupBox2.IsEnabled = false;
                    break;
            }
            #endregion

            ReInitPassageTitre();
        }
        private void ReInitPassageTitre()
        {
            passageTitre = new PassageTitre(histoPassageT.CodeTitre, histoPassageT.CodeStagiaire,
                histoPassageT.DatePassage, histoPassageT.EstObtenu, histoPassageT.EstValide);

            this.dpPassage.SelectedDate = passageTitre.DatePassage;
            this.dpNewPass.SelectedDate = passageTitre.DatePassage;
            this.chkValide.IsChecked = passageTitre.EstValide;
            this.rbNon.IsChecked = !passageTitre.EstObtenu;
            this.rbOui.IsChecked = passageTitre.EstObtenu;
        }
 public int UpdateInscription(PassageTitre passageT)
 {
     return DAL.TitresDAL.UpdatePassageTitre(passageT);
 }
 public int InscrireStagiaire(PassageTitre passageT)
 {
     return DAL.TitresDAL.AjouterPassageTitre(passageT);
 }
Beispiel #5
0
        public static int UpdatePassageTitre(PassageTitre passageT)
        {
            try
            {
                string req = "update PassageTitre set datePassage=@dateP, estObtenu=@isO, estValide=@isV"+
                    " where codeTitre=@codeT and codeStagiaire=@codeS";

                SqlConnection conn = ConnexionSQL.CreationConnexion();
                SqlCommand commande = conn.CreateCommand();
                commande.CommandText = req;
                commande.Parameters.AddWithValue("@codeT", passageT.CodeTitre);
                commande.Parameters.AddWithValue("@codeS", passageT.CodeStagiaire);
                commande.Parameters.AddWithValue("@dateP", passageT.DatePassage);
                commande.Parameters.AddWithValue("@isO", passageT.EstObtenu);
                commande.Parameters.AddWithValue("@isV", passageT.EstValide);

                int retour = commande.ExecuteNonQuery();
                conn.Close();
                return retour;
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show("Impossible de mettre à jour l'inscription du stagiaire au titre : " + e.Message,
                    "Inscription Titre", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Stop);
                return -2;
            }
        }
Beispiel #6
0
        public static PassageTitre GetPassageTitre(int codeStagiaire, string codeTitre)
        {
            try
            {
                SqlConnection connexion = ConnexionSQL.CreationConnexion();

                if (connexion != null)
                {
                    string reqPassTitre = "select datePassage, estObtenu, estValide " +
                    "from PASSAGETITRE where CodeStagiaire = @codeStagiaire and CodeTitre = @codeTitre";

                    SqlCommand commande = connexion.CreateCommand();
                    commande.CommandText = reqPassTitre;
                    commande.Parameters.AddWithValue("@codeStagiaire", codeStagiaire);
                    commande.Parameters.AddWithValue("@codeTitre", codeTitre);
                    SqlDataReader reader = commande.ExecuteReader();

                    PassageTitre pt = new PassageTitre();

                    while (reader.Read())
                    {
                        DateTime date = reader.GetDateTime(0);
                        bool obtenu = !reader.IsDBNull(1) ? reader.GetBoolean(1) : false;
                        bool valide = !reader.IsDBNull(2) ? reader.GetBoolean(2) : false;

                        pt = new PassageTitre(codeTitre, codeStagiaire, date, obtenu, valide);
                    }
                    connexion.Close();

                    return pt;
                }

                return null;
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show("Impossible de récupérer les informations sur son passage au titre : " + e.Message,
                    "Inscription Titre", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Stop);
                return null;
            }
        }
Beispiel #7
0
        public static int AjouterPassageTitre(PassageTitre passageT)
        {
            try
            {
                int checkEtat = ControlerSiInscrit(passageT.CodeStagiaire, passageT.CodeTitre);
                int retour = -1;

                if(checkEtat == 0)
                {
                    string req = "insert into PassageTitre (CodeTitre,CodeStagiaire,datePassage,estObtenu,estValide) " +
                                 "select @codeT, @codeS, @dateP, @isO, @isV where not exists " +
                                 "(select 0 from PassageTitre where CodeStagiaire=@codeS and CodeTitre=@codeT)";

                    SqlConnection conn = ConnexionSQL.CreationConnexion();
                    SqlCommand commande = conn.CreateCommand();
                    commande.CommandText = req;
                    commande.Parameters.AddWithValue("@codeT", passageT.CodeTitre);
                    commande.Parameters.AddWithValue("@codeS", passageT.CodeStagiaire);
                    commande.Parameters.AddWithValue("@dateP", passageT.DatePassage);
                    commande.Parameters.AddWithValue("@isO", passageT.EstObtenu);
                    commande.Parameters.AddWithValue("@isV", passageT.EstValide);

                    retour = commande.ExecuteNonQuery();
                    conn.Close();
                }
                else if(checkEtat == 1)
                {
                    string req = "update PassageTitre set estValide=@isV where CodeStagiaire=@codeS and CodeTitre=@codeT";
                    SqlConnection conn = ConnexionSQL.CreationConnexion();
                    SqlCommand commande = conn.CreateCommand();
                    commande.CommandText = req;
                    commande.Parameters.AddWithValue("@codeT", passageT.CodeTitre);
                    commande.Parameters.AddWithValue("@codeS", passageT.CodeStagiaire);
                    commande.Parameters.AddWithValue("@isV", passageT.EstValide);

                    retour = commande.ExecuteNonQuery();
                    conn.Close();
                }
                return retour;
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show("Impossible d'inscrire le stagiaire au titre : " + e.Message,
                    "Inscription Titre", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Stop);
                return -2;
            }
        }