Beispiel #1
0
        void remplirGrid()
        {
            using (BiblioEntities context = new BiblioEntities())
            {
                var demandes = context.demandes.Select(c => new
                {
                    Nom_Eleve         = c.eleve.nom + " " + c.eleve.prenom,
                    Titre_Livre       = c.livre.titre,
                    Date_Prise        = c.date_prise,
                    Date_Retour       = c.date_retour,
                    Validation_Retour = c.valide_Retour,
                }).ToList();

                bs.DataSource = demandes;

                ComboBoxTri.Items.Clear();

                for (int i = 0; i < dataGridViewTransfert.Columns.Count - 1; i++)
                {
                    ComboBoxTri.Items.Add(dataGridViewTransfert.Columns[i].Name);
                }

                dataGridViewTransfert.DataSource = bs;
            }
        }
Beispiel #2
0
        private void ComboBoxFilter_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (BiblioEntities context = new BiblioEntities())
            {
                bool val;

                if (ComboBoxFilter.Text == "Validé")
                {
                    val = true;
                }

                else if (ComboBoxFilter.Text == "Non Validé")
                {
                    val = false;
                }
                else
                {
                    remplirGrid();
                    return;
                }

                var demandes = context.demandes.Where(c => c.valide_Retour == val).Select(c => new
                {
                    Nom_Eleve         = c.eleve.nom + " " + c.eleve.prenom,
                    Titre_Livre       = c.livre.titre,
                    Date_Prise        = c.date_prise,
                    Date_Retour       = c.date_retour,
                    Validation_Retour = c.valide_Retour,
                }).ToList();

                bs.DataSource = demandes;
                dataGridViewTransfert.DataSource = bs;
            }
        }
Beispiel #3
0
        private void checkboxValidation_CheckedChanged(object sender, EventArgs e)
        {
            if (checkboxValidation.Checked == true)
            {
                dateTimePikerRetour.Value = DateTime.Now;
            }
            else
            {
                dateTimePikerRetour.Value = dateR;
            }

            using (BiblioEntities context = new BiblioEntities())
            {
                int id_eleve = int.Parse(comboEleve.SelectedValue.ToString());
                int id_livre = int.Parse(comboLivre.SelectedValue.ToString());
                var dem      = context.demandes.FirstOrDefault(c => c.id_eleve == id_eleve && c.id_livre == id_livre);

                if (dem != null)
                {
                    dem.date_retour = dateTimePikerRetour.Value;

                    bs.EndEdit();
                    context.SaveChanges();
                }
            }
        }
Beispiel #4
0
        //Methode Modifier Entity framework
        private void btnModifier_Click(object sender, EventArgs e)
        {
            using (BiblioEntities context = new BiblioEntities())
            {
                int id_eleve = int.Parse(comboEleve.SelectedValue.ToString());
                int id_livre = int.Parse(comboLivre.SelectedValue.ToString());
                var dem      = context.demandes.FirstOrDefault(c => c.id_eleve == id_eleve && c.id_livre == id_livre);

                if (dem != null)
                {
                    dem.id_eleve      = int.Parse(comboEleve.SelectedValue.ToString());
                    dem.id_livre      = int.Parse(comboLivre.SelectedValue.ToString());
                    dem.date_prise    = dateTimePikerPrise.Value;
                    dem.date_retour   = dateTimePikerRetour.Value;
                    dem.valide_Retour = checkboxValidation.Checked;

                    context.SaveChanges();
                    bs.EndEdit();
                    MessageBox.Show("Bien Modifier");
                    remplirGrid();
                    RemplirCombo();
                }
                else
                {
                    MessageBox.Show("Cette Demande n'existe pas ");
                }
            }
        }
Beispiel #5
0
        //Methode Supprimer Entity framework
        private void btnAnnuler_Click(object sender, EventArgs e)
        {
            using (BiblioEntities context = new BiblioEntities())
            {
                int id_eleve = int.Parse(comboEleve.SelectedValue.ToString());
                int id_livre = int.Parse(comboLivre.SelectedValue.ToString());
                var dem      = context.demandes.FirstOrDefault(c => c.id_eleve == id_eleve && c.id_livre == id_livre);

                if (dem != null)
                {
                    DialogResult rep = MessageBox.Show("Annulation", "Voulez vous Annuler ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (rep == DialogResult.Yes)
                    {
                        context.demandes.Remove(dem);
                        context.SaveChanges();
                        MessageBox.Show("Bien Annuler");
                        remplirGrid();
                        RemplirCombo();
                    }
                }
                else
                {
                    MessageBox.Show("Cette Demande n'existe pas ");
                }
            }
        }
Beispiel #6
0
        //Methode Ajouter Entity framework
        private void btnAjouter_Click(object sender, EventArgs e)
        {
            using (BiblioEntities context = new BiblioEntities())
            {
                demande d = new demande();
                d.id_eleve      = int.Parse(comboEleve.SelectedValue.ToString());
                d.id_livre      = int.Parse(comboLivre.SelectedValue.ToString());
                d.date_prise    = dateTimePikerPrise.Value;
                d.date_retour   = dateTimePikerRetour.Value;
                d.valide_Retour = checkboxValidation.Checked;

                var dem = context.demandes.FirstOrDefault(c => c.id_eleve == d.id_eleve && c.id_livre == d.id_livre);

                if (dem == null)
                {
                    context.demandes.Add(d);
                    context.SaveChanges();
                    MessageBox.Show("Bien Ajouter");
                    remplirGrid();
                    RemplirCombo();
                }
                else
                {
                    MessageBox.Show("Cette Demande existe déja");
                }
            }
        }
Beispiel #7
0
        private void btnNouveau_Click(object sender, EventArgs e)
        {
            using (BiblioEntities context = new BiblioEntities())
            {
                demande d = new demande();
                d.id_eleve      = int.Parse(comboEleve.SelectedValue.ToString());
                d.id_livre      = int.Parse(comboLivre.SelectedValue.ToString());
                d.date_prise    = dateTimePikerPrise.Value;
                d.date_retour   = dateTimePikerRetour.Value;
                d.valide_Retour = checkboxValidation.Checked;

                context.demandes.Add(d);
                context.SaveChanges();
                MessageBox.Show("Bien Ajouter");
            }
        }
Beispiel #8
0
        void getQuantite()
        {
            try
            {
                int code = int.Parse(comboLivre.SelectedValue.ToString());
                using (BiblioEntities context = new BiblioEntities())
                {
                    var livre = context.livres.FirstOrDefault(c => c.id == code);

                    txtQtt.Text = livre.quantite + "";
                }
            }
            catch (Exception)
            {
            }
        }
Beispiel #9
0
        private void ComboBoxTri_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (BiblioEntities context = new BiblioEntities())
            {
                var demandes = context.demandes.Select(c => new
                {
                    Nom_Eleve         = c.eleve.nom + " " + c.eleve.prenom,
                    Titre_Livre       = c.livre.titre,
                    Date_Prise        = c.date_prise,
                    Date_Retour       = c.date_retour,
                    Validation_Retour = c.valide_Retour,
                }).ToList();



                switch (ComboBoxTri.SelectedIndex)
                {
                case 0:
                    var dem0 = demandes.OrderBy(c => c.Nom_Eleve).ToList();
                    bs.DataSource = dem0;
                    break;

                case 1:
                    var dem1 = demandes.OrderBy(c => c.Titre_Livre).ToList();
                    bs.DataSource = dem1;
                    break;

                case 2:
                    var dem2 = demandes.OrderByDescending(c => c.Date_Prise).ToList();
                    bs.DataSource = dem2;
                    break;

                case 3:
                    var dem3 = demandes.OrderByDescending(c => c.Date_Retour).ToList();
                    bs.DataSource = dem3;
                    break;

                default:
                    bs.DataSource = demandes;
                    break;
                }
            }

            dataGridViewTransfert.DataSource = bs;
        }
Beispiel #10
0
 private void txtliivre_TextChanged_1(object sender, EventArgs e)
 {
     using (BiblioEntities context = new BiblioEntities())
     {
         string txt = txtliivre.Text;
         if (txt == "")
         {
             RemplirCombo(); return;
         }
         var livres = context.livres.Where(c => c.titre.Contains(txt)).Select(c => new
         {
             id          = c.id,
             Titre_Livre = c.titre
         });
         comboLivre.DataSource    = livres.ToList();
         comboLivre.DisplayMember = "Titre_Livre";
         comboLivre.ValueMember   = "id";
     }
 }
Beispiel #11
0
 private void txteleve_TextChanged_1(object sender, EventArgs e)
 {
     using (BiblioEntities context = new BiblioEntities())
     {
         string txt = txteleve.Text;
         if (txt == "")
         {
             RemplirCombo(); return;
         }
         var eleves = context.eleves.Where(c => c.nom.Contains(txt) || c.prenom.Contains(txt)).Select(c => new
         {
             id        = c.id,
             Nom_Eleve = c.nom + " " + c.prenom
         });
         comboEleve.DataSource    = eleves.ToList();
         comboEleve.DisplayMember = "Nom_Eleve";
         comboEleve.ValueMember   = "id";
     }
 }
Beispiel #12
0
        void RemplirCombo()
        {
            using (BiblioEntities context = new BiblioEntities())
            {
                var eleves = context.eleves.Select(c => new
                {
                    id        = c.id,
                    Nom_Eleve = c.nom + " " + c.prenom
                });
                comboEleve.DataSource    = eleves.ToList();
                comboEleve.DisplayMember = "Nom_Eleve";
                comboEleve.ValueMember   = "id";

                var livres = context.livres.Where(c => c.disponibilite == true && c.quantite > 0).Select(c => new
                {
                    id          = c.id,
                    Titre_Livre = c.titre
                });
                comboLivre.DataSource    = livres.ToList();
                comboLivre.DisplayMember = "Titre_Livre";
                comboLivre.ValueMember   = "id";
            }
        }