Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

mercredi 2 avril 2014

Tp Complete MODE DECONNECTEE Avec Solution

4/02/2014 06:33:00 PM Posted by Ahmed

Tp Complete  MODE DECONNECTEE Avec Solution



public partial class Form_For : Form
    {
        formateurDataContext bd = new formateurDataContext();
        public int pos = 0;
        List<Formateur> listeformateurs;
--------------------------------------------------------------
        public void Afficher(Formateur F)
        {
            mtriculeTextBox.Text = F.Mtricule.ToString();
            nom_formateurTextBox.Text = F.Nom_formateur;
            prenom_formateurTextBox.Text = F.Prenom_formateur;
            specialite_formateurTextBox.Text = F.Specialite_formateur;
        }
--------------------------------------------------------------------

public Formateur chercher(string mat)
        {
            Formateur F = listeformateurs.FirstOrDefault(P => P.Mtricule == mat);
            return F;
        }
--------------------------------------------------------------
      public Form_For()
        {
            InitializeComponent();
 }
--------------------------------------------------------------
private void Form1_Load(object sender, EventArgs e)
        {
            listeformateurs = bd.Formateur.ToList();
            Afficher(listeformateurs[pos]);
            textBox1.Text = (pos + 1).ToString() + " / " + listeformateurs.Count.ToString();
 }
---------------------------------------------------------------
private void btn_nouveau_Click(object sender, EventArgs e)
        {
            mtriculeTextBox.Text = "";
            nom_formateurTextBox.Text = "";
            prenom_formateurTextBox.Text = "";
            specialite_formateurTextBox.Text = "";
            btAjouter.Visible = true;
            btNouveau.Visible = false;
            mtriculeTextBox.Enabled = true;
        }
---------------------------------------------------------
private void btAjouter_Click(object sender, EventArgs e)
        {
            Formateur F = new Formateur();
            Formateur F1 = listeformateurs.FirstOrDefault(P => P.Mtricule == mtriculeTextBox.Text);
            if (F1 == null)
            {
                F.Mtricule = mtriculeTextBox.Text;
                F.Nom_formateur = nom_formateurTextBox.Text;
                F.Prenom_formateur = prenom_formateurTextBox.Text;
                F.Specialite_formateur = specialite_formateurTextBox.Text;
                bd.Formateur.InsertOnSubmit(F);
                listeformateurs.Add(F);
                btNouveau.Visible = true;
                btAjouter.Visible = false;
                mtriculeTextBox.Enabled = false;
                textBox1.Text = listeformateurs.Count.ToString() + "/" + listeformateurs.Count.ToString();
            }
            else
            {
                MessageBox.Show("existe dèjà");
            }
        }
--------------------------------------------------------------

private void btChercher_Click(object sender, EventArgs e)
        {
            Formateur F = new Formateur();
            F = listeformateurs.FirstOrDefault(P => P.Mtricule == txtrecherchnum.Text);
            if (F != null)
            {
                Afficher(F);
                pos = listeformateurs.IndexOf(F);
                textBox1.Text = (pos + 1).ToString() + "/" + listeformateurs.Count.ToString();
                
            }
            else
            {
                MessageBox.Show("n existe pas ", "errer");
            }
        }
---------------------------------------------------------------

private void btModifier_Click(object sender, EventArgs e)
        {
            Formateur F = new Formateur();
            F = listeformateurs.FirstOrDefault(p => p.Mtricule == mtriculeTextBox.Text);
            F.Mtricule = mtriculeTextBox.Text;
            F.Nom_formateur = nom_formateurTextBox.Text;
            F.Prenom_formateur = prenom_formateurTextBox.Text;
            F.Specialite_formateur = specialite_formateurTextBox.Text ;
        }
-----------------------------------------------------------------
        private void btSupprimer_Click(object sender, EventArgs e)
        {
         
                string mat =  mtriculeTextBox.Text;
                Formateur F = chercher(mat);
                bd.Formateur.DeleteOnSubmit(F);
                listeformateurs.Remove(F);
        
                if (pos == listeformateurs.Count)
                    pos--;
             
                Afficher(listeformateurs[pos]);
                textBox1.Text = (pos + 1).ToString() + " / " + listeformateurs.Count.ToString();

            }
----------------------------------------------------------------
private void btEnregistrer_Click(object sender, EventArgs e)
        {
            try
            {
                bd.SubmitChanges();
                //btModifier.Visible = false;
                //btSupprimer.Visible = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
          
        }

---------------------------------------------------------------

   private void btpremier_Click(object sender, EventArgs e)
        {

            pos = 0;
            Afficher(listeformateurs[pos]);
            textBox1.Text = (pos + 1).ToString() + " / " + listeformateurs.Count.ToString();
        }

--------------------------------------------------------------

   private void btprecedent_Click(object sender, EventArgs e)
        {
            pos--;
            if (pos < 0)
                pos = 0;
            Afficher(listeformateurs[pos]);
            textBox1.Text = (pos + 1).ToString() + " / " + listeformateurs.Count.ToString();           
        }

-------------------------------------------------------------

  private void btsuivent_Click(object sender, EventArgs e)
        {
            pos++;
            if (pos >= listeformateurs.Count)
                pos = listeformateurs.Count - 1;
            Afficher(listeformateurs[pos]);
            textBox1.Text = (pos + 1).ToString() + " / " + listeformateurs.Count.ToString();
           
        }
------------------------------------------------------------

 private void btdernier_Click(object sender, EventArgs e)
        {
            pos = listeformateurs.Count - 1;
            Afficher(listeformateurs[pos]);
            textBox1.Text = (pos + 1).ToString() + " / " + listeformateurs.Count.ToString();
          
        }

-------------------------------------------------------------

  private void btQuitter_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
                                          Telecharger Lien desuus