Beispiel #1
0
        public void Modifier()
        {
            if (dataGridElements.SelectedItems.Count == 1)
            {
                //Faire la modif
                //Civilite civiliteAModifier = dataGridElements.SelectedItem as Civilite;
                CATEGORIE CATEGORIEAModifier = (CATEGORIE)dataGridElements.SelectedItem;

                Categorie window = new Categorie(CATEGORIEAModifier);
                window.ShowDialog();

                if (window.DialogResult.HasValue && window.DialogResult == true)
                {
                    //Sauvegarde
                    ((App)App.Current).entity.SaveChanges();
                }
                else
                {
                    //On rafraichit l'entity pour éviter les erreurs de données "fantomes" mal déliées
                    ((App)App.Current).entity = new LISA_DIGITALEntities();
                }
            }
            else
            {
                MessageBox.Show("Merci de sélectionner un et un élément maximum");
            }
            RefreshDatas();
        }
Beispiel #2
0
        public void Ajouter()
        {
            Categorie window = new Categorie();

            window.ShowDialog();


            if (window.DialogResult.HasValue && window.DialogResult == true)
            {
                //Sauvegarde
                CATEGORIE CATEGORIEToAdd = (CATEGORIE)window.DataContext;


                ((App)App.Current).entity.CATEGORIE.Add(CATEGORIEToAdd);

                ((App)App.Current).entity.SaveChanges();
            }
            else
            {
                //On rafraichit l'entity pour éviter les erreurs de données "fantomes" mal déliées
                ((App)App.Current).entity = new LISA_DIGITALEntities();
            }

            RefreshDatas();
        }
Beispiel #3
0
        public void Supprimer()
        {
            if (dataGridElements.SelectedItems.Count == 1)
            {
                //Faire la modif
                CATEGORIE civiliteASupprimer = (CATEGORIE)dataGridElements.SelectedItem;

                if (MessageBox.Show("Êtes-vous sûr de vouloir supprimer cet élément ?",
                                    "Suppression",
                                    MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    ((App)App.Current).entity.CATEGORIE.Remove(civiliteASupprimer);

                    //Sauvegarde
                    ((App)App.Current).entity.SaveChanges();
                }
                else
                {
                    //On rafraichit l'entity pour éviter les erreurs de données "fantomes" mal déliées
                    ((App)App.Current).entity = new LISA_DIGITALEntities();
                }
            }
            else
            {
                MessageBox.Show("Merci de sélectionner un et un élément maximum");
            }
            RefreshDatas();
        }
Beispiel #4
0
        public ActionResult DeleteConfirmed(short id)
        {
            CATEGORIE cATEGORIE = db.CATEGORIE.Find(id);

            db.CATEGORIE.Remove(cATEGORIE);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #5
0
        public void chargerCategories()
        {
            Application.DoEvents();
            CATEGORIE.Clear();
            CATEGORIE.Merge(CLIENT_APP_PARAM.gcws.SELECT_ALL_CATEGORIE());

            bsCategorie.DataSource = CATEGORIE;
        }
Beispiel #6
0
 public ActionResult Edit([Bind(Include = "ID_CATEGORIE,LIBELLE_CATEGORIE")] CATEGORIE cATEGORIE)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cATEGORIE).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cATEGORIE));
 }
Beispiel #7
0
        public ActionResult Create([Bind(Include = "ID_CATEGORIE,LIBELLE_CATEGORIE")] CATEGORIE cATEGORIE)
        {
            if (ModelState.IsValid)
            {
                db.CATEGORIE.Add(cATEGORIE);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cATEGORIE));
        }
Beispiel #8
0
        public Categorie(CATEGORIE CatAModif = null)
        {
            InitializeComponent();

            if (CatAModif == null)
            {
                this.DataContext = new CATEGORIE();
            }
            else
            {
                this.DataContext = CatAModif;
            }
        }
Beispiel #9
0
        // GET: Administration/Categorie/Delete/5
        public ActionResult Delete(short?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CATEGORIE cATEGORIE = db.CATEGORIE.Find(id);

            if (cATEGORIE == null)
            {
                return(HttpNotFound());
            }
            return(View(cATEGORIE));
        }
        private void btnCrea_Click(object sender, EventArgs e)
        {
            SocialNetworkVenditeDbDataContext db = new SocialNetworkVenditeDbDataContext();
            var categoria = from c in db.CATEGORIEs
                            where c.nome == txtNomeCategoria.Text
                            select c;

            if (categoria.Count() != 0)
            {
                MessageBox.Show("Questo nome di categoria è già utilizzato!", "Errore sezione",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (txtNomeCategoria.Text == "")
            {
                MessageBox.Show("La categoria deve avere un nome!", "Errore sezione",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (txtDescrizione.Text == "")
            {
                MessageBox.Show("Devi scegliere una descrizione!", "Errore descrizione",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                CATEGORIE newCategory = new CATEGORIE
                {
                    nome        = txtNomeCategoria.Text,
                    descrizione = txtDescrizione.Text,
                    emailUtente = this.email
                };
                db.CATEGORIEs.InsertOnSubmit(newCategory);
                try
                {
                    db.SubmitChanges();
                    txtNomeCategoria.Text = "";
                    txtDescrizione.Text   = "";
                    MessageBox.Show("Categoria creata con successo!", "Successo creazione categoria",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception e1)
                {
                    Console.WriteLine(e1);
                    MessageBox.Show("C'è stato qualche errore con la crezione della categoria!", "Errore creazione categoria",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #11
0
        public CategorieDetail(int categorie_id)
        {
            db               = new EcommerceEntities();
            Categories       = new List <CATEGORIE>();
            CategorieCurrent = db.CATEGORIEs.First(x => x.CATEGORIE_ID == categorie_id);
            CATEGORIE root = new CATEGORIE();

            #region TimRootCategorie
            root = CategorieCurrent;
            while (root.CATEGORIE_ROOT != null)
            {
                root = root.CATEGORIE2;
            }
            CategorieRoot = root;
            #endregion
            Categories = root.CATEGORIE1.ToList();
        }
Beispiel #12
0
 public ActionResult Categorie1(CATEGORIE1 CATEGORIES)
 {
     // ViewBag.MonParam5 = iz;
     try {
         if (CATEGORIES.NomCat == "autre")
         {
             // ViewBag.Vue = true;
             return(View("Produit"));
         }
         int       nbrLigne = 0;
         DataTable dt       = new DataTable();
         using (SqlConnection SqlCon = new SqlConnection(connectionString))
         {
             SqlCon.Open();
             string         query = "SELECT * FROM CATEGORIE";
             SqlDataAdapter SqlDa = new SqlDataAdapter(query, SqlCon);
             SqlDa.Fill(dt);
         }
         nbrLigne = Convert.ToInt32(dt.Rows.Count.ToString());
         int val = 1;
         if (dt.Rows.Count == 0)
         {
             using (SqlConnection SqlCon = new SqlConnection(connectionString))
             {
                 SqlCon.Open();
                 string     query  = "INSERT INTO CATEGORIE (IdCat,NomCat,IdUser) VALUES (@IdCat,@NomCat,@IdUser)";
                 SqlCommand SqlCom = new SqlCommand(query, SqlCon);
                 SqlCom.Parameters.AddWithValue("@IdCat", val);
                 SqlCom.Parameters.AddWithValue("@NomCat", CATEGORIES.NomCat);
                 SqlCom.Parameters.AddWithValue("@IdUser", IDUSER);
                 IDCAT         = val;
                 ANDRANA.IDCAT = IDCAT;
                 SqlCom.ExecuteNonQuery();
                 //string query1 = "INSERT INTO VENDEUR (IdUser,IdCat) VALUES (@IdUser,@IdCat)";
                 //SqlCommand SqlCom1 = new SqlCommand(query1, SqlCon);
                 //SqlCom1.ExecuteNonQuery();
                 return(RedirectToAction("Produit1", new { III = IDCAT }));
             }
         }
         else
         {
             //VERIFICATION SI CATEGORIE EXISTE (CONDITION)
             DataTable dt1 = new DataTable();
             using (SqlConnection SqlCon = new SqlConnection(connectionString))
             {
                 SqlCon.Open();
                 string         query = "SELECT * FROM CATEGORIE WHERE NomCat='" + CATEGORIES.NomCat + "'";
                 SqlDataAdapter SqlDa = new SqlDataAdapter(query, SqlCon);
                 SqlDa.Fill(dt1);
             }
             if (dt1.Rows.Count == 0)
             {
                 using (SqlConnection SqlCon = new SqlConnection(connectionString))
                 {
                     SqlCon.Open();
                     MyStoreEntities4 s = new MyStoreEntities4();
                     CATEGORIE        c = new CATEGORIE();
                     c   = s.CATEGORIE.ToList().Last();
                     val = c.IdCat + 1;
                     string     query  = "INSERT INTO CATEGORIE (IdCat,NomCat,IdUser) VALUES (@IdCat,@NomCat,@IdUser)";
                     SqlCommand SqlCom = new SqlCommand(query, SqlCon);
                     SqlCom.Parameters.AddWithValue("@IdCat", val);
                     SqlCom.Parameters.AddWithValue("@NomCat", CATEGORIES.NomCat);
                     SqlCom.Parameters.AddWithValue("@IdUser", IDUSER);
                     SqlCom.ExecuteNonQuery();
                     IDCAT         = val;
                     ANDRANA.IDCAT = IDCAT;
                     return(RedirectToAction("Produit1", new { III = IDCAT }));
                 }
             }
             else
             {
                 IDCAT = Convert.ToInt32(dt1.Rows[0][0].ToString());
                 return(RedirectToAction("Produit1", new { III = IDCAT }));
             }
             //FIN
         }
     }
     catch
     {
         return(RedirectToAction("HttpNotFoun", "ACCUEIL"));
     }
 }