Exemplo n.º 1
0
        private void LivreurDataGrid_DoubleClick(object sender, EventArgs e)
        {
            if (LivreurDataGrid.CurrentRow.Index != -1)
            {
                if (LibelleForm.libelle == "Livreur")
                {
                    code             = Convert.ToInt32(LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value);
                    model1           = db.Livreurs.Where(x => x.CodeLivreur == code).FirstOrDefault();
                    textcode.Text    = LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value.ToString();
                    textlibelle.Text = model1.Libelle;
                }
                if (LibelleForm.libelle == "Moyen de Transport")
                {
                    code             = Convert.ToInt32(LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value);
                    model2           = db.MoyenTransports.Where(x => x.CodeMoyenTransport == code).FirstOrDefault();
                    textcode.Text    = LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value.ToString();
                    textlibelle.Text = model2.Libelle;
                }
                if (LibelleForm.libelle == "Banque")
                {
                    code             = Convert.ToInt32(LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value);
                    model3           = db.Banques.Where(x => x.CodeBanque == code).FirstOrDefault();
                    textcode.Text    = LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value.ToString();
                    textlibelle.Text = model3.Libelle;
                }
                if (LibelleForm.libelle == "Mode de Réglement")
                {
                    code             = Convert.ToInt32(LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value);
                    model4           = db.ModeReglements.Where(x => x.CodeModeReg == code).FirstOrDefault();
                    textcode.Text    = LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value.ToString();
                    textlibelle.Text = model4.Libelle;
                }
                if (LibelleForm.libelle == "Type Client")
                {
                    code             = Convert.ToInt32(LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value);
                    model5           = db.TypeClients.Where(x => x.CodeTypeClient == code).FirstOrDefault();
                    textcode.Text    = LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value.ToString();
                    textlibelle.Text = model5.Libelle;
                }
                if (LibelleForm.libelle == "Liste Familles")
                {
                    code             = Convert.ToInt32(LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value);
                    model6           = db.Familles.Where(x => x.CodeFamille == code).FirstOrDefault();
                    textcode.Text    = LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value.ToString();
                    textlibelle.Text = model6.LibelleFamille;
                }
                if (LibelleForm.libelle == "Type de Production")
                {
                    code             = Convert.ToInt32(LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value);
                    model7           = db.TypeProductions.Where(x => x.CodeTypeProd == code).FirstOrDefault();
                    textcode.Text    = LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value.ToString();
                    textlibelle.Text = model7.Libelle;
                }
                if (LibelleForm.libelle == "Type de Comptage")
                {
                    code             = Convert.ToInt32(LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value);
                    model8           = db.TypeComptages.Where(x => x.CodeTypeCom == code).FirstOrDefault();
                    textcode.Text    = LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value.ToString();
                    textlibelle.Text = model8.Libelle;
                }
                if (LibelleForm.libelle == "Colisage")
                {
                    code             = Convert.ToInt32(LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value);
                    model9           = db.Colisages.Where(x => x.CodeColisage == code).FirstOrDefault();
                    textcode.Text    = LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value.ToString();
                    textlibelle.Text = model9.Libelle;
                }
                if (LibelleForm.libelle == "Unité")
                {
                    code             = Convert.ToInt32(LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value);
                    model10          = db.Unites.Where(x => x.CodeUnite == code).FirstOrDefault();
                    textcode.Text    = LivreurDataGrid.CurrentRow.Cells["CodeLivreur"].Value.ToString();
                    textlibelle.Text = model10.Libelle;
                }
            }

            btnsave.Visible     = false;
            btnModifier.Visible = true;
            btndelete.Enabled   = true;
        }
Exemplo n.º 2
0
        private void btndelete_Click(object sender, EventArgs e)
        {
            int    codeParametrage = Convert.ToInt32(textcode.Text.Trim());
            string libelle         = textlibelle.Text.Trim();

            if (MessageBox.Show("Etes-vous sûr de vouloir supprimer ce type?", "Supprimer?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (LibelleForm.libelle == "Livreur")
                {
                    Livreur liv = db.Livreurs.ToList <DAL.Livreur>().Where(w => w.CodeLivreur == codeParametrage).FirstOrDefault();
                    GenericRepository <Livreur> livr = new GenericRepository <Livreur>(db);
                    livr.Delete(liv);
                }


                if (LibelleForm.libelle == "Moyen de Transport")
                {
                    MoyenTransport moy = db.MoyenTransports.ToList <DAL.MoyenTransport>().Where(w => w.CodeMoyenTransport == codeParametrage).FirstOrDefault();
                    GenericRepository <MoyenTransport> moys = new GenericRepository <MoyenTransport>(db);
                    moys.Delete(moy);
                }
                if (LibelleForm.libelle == "Banque")
                {
                    Banque ban = db.Banques.ToList <DAL.Banque>().Where(w => w.CodeBanque == codeParametrage).FirstOrDefault();
                    GenericRepository <Banque> bans = new GenericRepository <Banque>(db);
                    bans.Delete(ban);
                }
                if (LibelleForm.libelle == "Mode de Réglement")
                {
                    ModeReglement mode = db.ModeReglements.ToList <DAL.ModeReglement>().Where(w => w.CodeModeReg == codeParametrage).FirstOrDefault();
                    GenericRepository <ModeReglement> modes = new GenericRepository <ModeReglement>(db);
                    modes.Delete(mode);
                }
                if (LibelleForm.libelle == "Type Client")
                {
                    Client cl = db.Clients.ToList <DAL.Client>().Where(w => w.CodeClient == codeParametrage).FirstOrDefault();
                    GenericRepository <Client> cls = new GenericRepository <Client>(db);
                    cls.Delete(cl);
                }
                if (LibelleForm.libelle == "Liste Familles")
                {
                    Famille famille = db.Familles.ToList <Famille>().Where(w => w.CodeFamille == codeParametrage).FirstOrDefault();
                    GenericRepository <Famille> fam = new GenericRepository <Famille>(db);
                    fam.Insert(famille);
                }
                if (LibelleForm.libelle == "Type de Production")
                {
                    EasyPlant.DAL.TypeProduction prod = db.TypeProductions.ToList <DAL.TypeProduction>().Where(w => w.CodeTypeProd == codeParametrage).FirstOrDefault();
                    GenericRepository <EasyPlant.DAL.TypeProduction> prods = new GenericRepository <EasyPlant.DAL.TypeProduction>(db);
                    prods.Insert(prod);
                }
                if (LibelleForm.libelle == "Type de Comptage")
                {
                    EasyPlant.DAL.TypeComptage typecomp = db.TypeComptages.ToList <DAL.TypeComptage>().Where(w => w.CodeTypeCom == codeParametrage).FirstOrDefault();
                    GenericRepository <EasyPlant.DAL.TypeComptage> typecomps = new GenericRepository <EasyPlant.DAL.TypeComptage>(db);
                    typecomps.Insert(typecomp);
                }

                if (LibelleForm.libelle == "Colisage")
                {
                    EasyPlant.DAL.Colisage col = db.Colisages.ToList <DAL.Colisage>().Where(w => w.CodeColisage == codeParametrage).FirstOrDefault();
                    GenericRepository <EasyPlant.DAL.Colisage> cols = new GenericRepository <EasyPlant.DAL.Colisage>(db);
                    cols.Insert(col);
                }
                if (LibelleForm.libelle == "Unité")
                {
                    EasyPlant.DAL.Unite uni = db.Unites.ToList <DAL.Unite>().Where(w => w.CodeUnite == codeParametrage).FirstOrDefault();
                    GenericRepository <EasyPlant.DAL.Unite> unis = new GenericRepository <EasyPlant.DAL.Unite>(db);
                    unis.Insert(uni);
                }

                db.SaveChanges();
                Clear();
                frmCodeLibelle_Load(sender, e);
                MessageBox.Show("Suppresion avec succées");
            }
        }
Exemplo n.º 3
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            int    codeParametrage = Convert.ToInt32(textcode.Text.Trim());
            string libelle         = textlibelle.Text.Trim();

            //
            //Save Livreur
            //

            if (LibelleForm.libelle == "Livreur")
            {
                Livreur liv = db.Livreurs.ToList <DAL.Livreur>().Where(w => w.CodeLivreur == codeParametrage).FirstOrDefault();
                if (liv == null)
                {
                    liv = new Livreur {
                        CodeLivreur = codeParametrage, Libelle = libelle
                    };
                    GenericRepository <Livreur> livr = new GenericRepository <Livreur>(db);
                    livr.Insert(liv);
                }
                else
                {
                    MessageBox.Show("Enregistrement existe déjà", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Save Moyen de Transport
            //
            if (LibelleForm.libelle == "Moyen de Transport")
            {
                EasyPlant.DAL.MoyenTransport moyenTransport = new EasyPlant.DAL.MoyenTransport {
                    CodeMoyenTransport = codeParametrage, Libelle = libelle
                };
                GenericRepository <MoyenTransport> GenmoyenTransp = new GenericRepository <MoyenTransport>(db);
                GenmoyenTransp.Insert(moyenTransport);
            }
            //
            //Save Banque
            //
            if (LibelleForm.libelle == "Banque")
            {
                EasyPlant.DAL.Banque banque = new EasyPlant.DAL.Banque {
                    CodeBanque = codeParametrage, Libelle = libelle
                };
                GenericRepository <Banque> GeneBanque = new GenericRepository <Banque>(db);
                GeneBanque.Insert(banque);
            }
            //
            //Save Mode de Réglement
            //
            if (LibelleForm.libelle == "Mode de Réglement")
            {
                EasyPlant.DAL.ModeReglement modeReglement = new EasyPlant.DAL.ModeReglement {
                    CodeModeReg = codeParametrage, Libelle = libelle
                };
                GenericRepository <ModeReglement> GenmoyenTransp = new GenericRepository <ModeReglement>(db);
                GenmoyenTransp.Insert(modeReglement);
            }
            //
            //Save Type Client
            //
            if (LibelleForm.libelle == "Type Client")
            {
                EasyPlant.DAL.TypeClient typeclient = new EasyPlant.DAL.TypeClient {
                    CodeTypeClient = codeParametrage, Libelle = libelle
                };
                GenericRepository <TypeClient> GenmoyenTransp = new GenericRepository <TypeClient>(db);
                GenmoyenTransp.Insert(typeclient);
            }
            //
            //Save Familles
            //
            if (LibelleForm.libelle == "Liste Familles")
            {
                EasyPlant.DAL.Famille famille = new EasyPlant.DAL.Famille {
                    CodeFamille = codeParametrage, LibelleFamille = libelle
                };
                GenericRepository <EasyPlant.DAL.Famille> fam = new GenericRepository <EasyPlant.DAL.Famille>(db);
                fam.Insert(famille);
            }
            //
            //Save Type production
            //
            if (LibelleForm.libelle == "Type de Production")
            {
                EasyPlant.DAL.TypeProduction prod = new EasyPlant.DAL.TypeProduction {
                    CodeTypeProd = codeParametrage, Libelle = libelle
                };
                GenericRepository <EasyPlant.DAL.TypeProduction> prods = new GenericRepository <EasyPlant.DAL.TypeProduction>(db);
                prods.Insert(prod);
            }
            //
            //Save Type Comptage
            //
            if (LibelleForm.libelle == "Type de Comptage")
            {
                EasyPlant.DAL.TypeComptage typecomp = new EasyPlant.DAL.TypeComptage {
                    CodeTypeCom = codeParametrage, Libelle = libelle
                };
                GenericRepository <EasyPlant.DAL.TypeComptage> typecomps = new GenericRepository <EasyPlant.DAL.TypeComptage>(db);
                typecomps.Insert(typecomp);
            }
            //
            //Save Colisage
            //
            if (LibelleForm.libelle == "Colisage")
            {
                EasyPlant.DAL.Colisage col = new EasyPlant.DAL.Colisage {
                    CodeColisage = codeParametrage, Libelle = libelle
                };
                GenericRepository <EasyPlant.DAL.Colisage> cols = new GenericRepository <EasyPlant.DAL.Colisage>(db);
                cols.Insert(col);
            }
            //
            //Save Unité
            //
            if (LibelleForm.libelle == "Unité")
            {
                EasyPlant.DAL.Unite uni = new EasyPlant.DAL.Unite {
                    CodeUnite = codeParametrage, Libelle = libelle
                };
                GenericRepository <EasyPlant.DAL.Unite> unis = new GenericRepository <EasyPlant.DAL.Unite>(db);
                unis.Insert(uni);
            }
            MessageBox.Show("Enregistrement avec succées");
            Clear();
            frmCodeLibelle_Load(sender, e);
        }