Example #1
0
        private void btnModifier_Click(object sender, EventArgs e)
        {
            int    codeParametrage = Convert.ToInt32(textcode.Text.Trim());
            string libelle         = textlibelle.Text.Trim();

            //
            // Modifier Livreur
            //
            if (LibelleForm.libelle == "Livreur")
            {
                Livreur liv = db.Livreurs.ToList <DAL.Livreur>().Where(w => w.CodeLivreur == codeParametrage).FirstOrDefault();
                if (liv == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    liv.Libelle = libelle;
                    GenericRepository <Livreur> livr = new GenericRepository <Livreur>(db);
                    livr.Update(liv);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Moyen de Transport
            //
            if (LibelleForm.libelle == "Moyen de Transport")
            {
                MoyenTransport moy = db.MoyenTransports.ToList <DAL.MoyenTransport>().Where(w => w.CodeMoyenTransport == codeParametrage).FirstOrDefault();
                if (moy == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    moy.Libelle = libelle;
                    GenericRepository <MoyenTransport> Moys = new GenericRepository <MoyenTransport>(db);
                    Moys.Update(moy);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Banque
            //

            if (LibelleForm.libelle == "Banque")
            {
                Banque ban = db.Banques.ToList <DAL.Banque>().Where(w => w.CodeBanque == codeParametrage).FirstOrDefault();
                if (ban == null)
                {
                    MessageBox.Show("Enregistrementn'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    ban.Libelle = libelle;
                    GenericRepository <Banque> banques = new GenericRepository <Banque>(db);
                    banques.Update(ban);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Mode de Réglements
            //
            if (LibelleForm.libelle == "Mode de Réglement")
            {
                ModeReglement mode = db.ModeReglements.ToList <DAL.ModeReglement>().Where(w => w.CodeModeReg == codeParametrage).FirstOrDefault();
                if (mode == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    mode.Libelle = libelle;
                    GenericRepository <ModeReglement> modeReg = new GenericRepository <ModeReglement>(db);
                    modeReg.Update(mode);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Type Client
            //
            if (LibelleForm.libelle == "Type Client")
            {
                TypeClient typeCL = db.TypeClients.ToList <DAL.TypeClient>().Where(w => w.CodeTypeClient == codeParametrage).FirstOrDefault();
                if (typeCL == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    typeCL.Libelle = libelle;
                    GenericRepository <TypeClient> typeClient = new GenericRepository <TypeClient>(db);
                    typeClient.Update(typeCL);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Familles
            //
            if (LibelleForm.libelle == "Liste Familles")
            {
                Famille fam = db.Familles.ToList <DAL.Famille>().Where(w => w.CodeFamille == codeParametrage).FirstOrDefault();
                if (fam == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    fam.LibelleFamille = libelle;
                    GenericRepository <Famille> fams = new GenericRepository <Famille>(db);
                    fams.Update(fam);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Type production
            //
            if (LibelleForm.libelle == "Type de Production")
            {
                TypeProduction pro = db.TypeProductions.ToList <DAL.TypeProduction>().Where(w => w.CodeTypeProd == codeParametrage).FirstOrDefault();
                if (pro == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    pro.Libelle = libelle;
                    GenericRepository <TypeProduction> typeprod = new GenericRepository <TypeProduction>(db);
                    typeprod.Update(pro);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Type Comptage
            //
            if (LibelleForm.libelle == "Type de Comptage")
            {
                TypeComptage com = db.TypeComptages.ToList <DAL.TypeComptage>().Where(w => w.CodeTypeCom == codeParametrage).FirstOrDefault();
                if (com == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    com.Libelle = libelle;
                    GenericRepository <TypeComptage> typecom = new GenericRepository <TypeComptage>(db);
                    typecom.Update(com);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Colisage
            //
            if (LibelleForm.libelle == "Colisage")
            {
                Colisage col = db.Colisages.ToList <DAL.Colisage>().Where(w => w.CodeColisage == codeParametrage).FirstOrDefault();
                if (col == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    col.Libelle = libelle;
                    GenericRepository <Colisage> cols = new GenericRepository <Colisage>(db);
                    cols.Update(col);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //
            //Modifier Unité
            //
            if (LibelleForm.libelle == "Unité")
            {
                Unite uni = db.Unites.ToList <DAL.Unite>().Where(w => w.CodeUnite == codeParametrage).FirstOrDefault();
                if (uni == null)
                {
                    MessageBox.Show("Enregistrement n'existe pas", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    uni.Libelle = libelle;
                    GenericRepository <Unite> unis = new GenericRepository <Unite>(db);
                    unis.Update(uni);
                    MessageBox.Show("Enregistrement modifié avec succès", codeParametrage.ToString() + " " + libelle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            Clear();
            frmCodeLibelle_Load(sender, e);
        }
Example #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");
            }
        }