Example #1
0
 public frmDetGenre(Genre G)
 {
     InitializeComponent();
     genreSelect = G;
     ctrlGen = new ctrlGenre();
     this.PositionBtn(260);
     this.btnEnregistrer.Click += new EventHandler(btnEnregistrer_Click);
     this.btnCopier.Click += new EventHandler(btnCopier_Click);
     annuler = true;
 }
Example #2
0
        public List<Genre> recherche(string cle)
        {
            List<Genre> lstGe = new List<Genre>();

            foreach (var item in RequeteSql.rechercheGenre(cle))
            {
                Genre ge = new Genre(item.IdGenre, item.NomGenre, item.ComGenre);
                lstGe.Add(ge);
            }
            return lstGe;
        }
Example #3
0
 public frmDetGenre(Genre G, int lvla)
 {
     InitializeComponent();
     genreSelect = G;
     ctrlGen = new ctrlGenre();
     ctrlGen.charger();
     ctrlGen.Statut = false;
     this.PositionBtn(260);
     this.btnEnregistrer.Click += new EventHandler(btnEnregistrer_Click);
     this.btnCopier.Visible = false;
     lvlAcces = lvla;
     checkLvlAcces();
     annuler = true;
 }
Example #4
0
 public void modifierChamp(string code)
 {
     if (code == "a")
     {
         this.btnActiverModif.Visible = false;
         genreSelect = null;
     }
     else
     {
         this.rtxtCom.ReadOnly = true;
         this.txtId.ReadOnly = true;
         this.txtNom.ReadOnly = true;
         remplirChamp();
     }
 }
Example #5
0
        public static void addGenre(Genre genre)
        {
            var add = new tblGenre();

            add.NomGenre = genre.nomGenre;
            add.ComGenre = genre.comGenre;

            db.tblGenre.Add(add);

            try
            {
                db.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #6
0
 public void modifierChamp(string code)
 {
     if (code == "a")
     {
         this.btnActiverModif.Visible = false;
         this.btnSupprimer.Visible = false;
         this.btnCopier.Visible = false;
         ctrlGen.Statut = false;
         genreSelect = null;
     }
     else
     {
         this.rtxtCom.ReadOnly = true;
         this.txtId.ReadOnly = true;
         this.txtNom.ReadOnly = true;
         this.btnEnregistrer.Enabled = false;
         remplirChamp();
     }
 }
Example #7
0
        public static void setGenre(Genre genre)
        {
            var r =
                (from gen in db.tblGenre
                 where gen.IdGenre == genre.idGenre
                 select gen).First();

            r.NomGenre = genre.nomGenre;
            r.ComGenre = genre.comGenre;

            try
            {
                db.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #8
0
        private void btnCopier_Click(object sender, EventArgs e)
        {
            Genre cop = new Genre();
            frmDetGenre frmCop;

            cop.nomGenre = txtNom.Text;
            cop.comGenre = rtxtCom.Text;

            frmCop = new frmDetGenre(cop);
            frmCop.remplirChamp();
            frmCop.btnCopier.Enabled = false;
            frmCop.btnSupprimer.Enabled = false;
            frmCop.btnActiverModif.Enabled = false;
            frmCop.txtNom.ReadOnly = false;
            frmCop.rtxtCom.ReadOnly = false;
            frmCop.statut = "Copie";
            frmCop.ShowDialog();
            if (frmCop.annuler == false)
            {
                this.Tag = frmCop.Tag;
                this.Close();
            }
            frmCop.Closed += (s, args) => this.Close();
        }
Example #9
0
        private void btnEnregistrer_Click(object sender, EventArgs e)
        {
            Genre enregistrement = new Genre();
            bool resultVerif;
            DialogResult resultEnr;

            enregistrement.nomGenre = txtNom.Text.Trim();
            enregistrement.comGenre = rtxtCom.Text.Trim();

            resultVerif = ctrlGen.verifier(enregistrement, genreSelect);

            if (resultVerif)
            {
                if (genreSelect != null && statut != "Copie")
                {
                    resultEnr = MessageBox.Show("Voulez-vous vraiment enregistrer?", "Enregistrement", MessageBoxButtons.YesNo);
                    if (resultEnr == DialogResult.Yes)
                    {
                        enregistrement.idGenre = Int32.Parse(txtId.Text.Trim());
                        ctrlGen.modifier(enregistrement);
                        this.Tag = enregistrement.nomGenre;
                        this.Close();
                    }
                }
                else
                {
                    if (ctrlGen.verifSemblable(enregistrement, genreSelect) == true)
                    {
                        resultEnr = MessageBox.Show("Voulez-vous vraiment enregistrer?", "Enregistrement", MessageBoxButtons.YesNo);
                        if (resultEnr == DialogResult.Yes)
                        {
                            ctrlGen.ajouter(enregistrement);
                            annuler = false;
                            this.Tag = enregistrement.nomGenre;
                            this.Close();
                        }
                    }
                }
            }
        }
Example #10
0
        private void modifierGenre()
        {
            var detGenre = new frmDetGenre();
            Genre genreSel = new Genre();
            int index = GridGenre.SelectedRows[0].Index;

            genreSel.idGenre = Int32.Parse((string)GridGenre.Rows[index].Cells[0].Value);
            genreSel.nomGenre = (string)GridGenre.Rows[index].Cells[1].Value;
            genreSel.comGenre = (string)GridGenre.Rows[index].Cells[2].Value;

            detGenre.Tag = genreSel.nomGenre;
            detGenre.genreSelect = genreSel;
            detGenre.modifierChamp("m");
            detGenre.ShowDialog();
            if (detGenre.Tag.ToString() == "0")
                this.Tag = 0;
            else
                this.Tag = detGenre.Tag;
            update();
        }