Esempio n. 1
0
        public FormCategory(string buttonCategory)
        {
            InitializeComponent();
            btnAddEditDelCat.Text = buttonCategory;
            category = new Category_();
            if (btnAddEditDelCat.Text == "Dodaj")
            {
                labelNameCat.Visible   = false;
                cbNameCategory.Visible = false;
                this.Text = "Dodaj kategorię";
            }
            else
            {
                labelNameCat.Visible   = true;
                cbNameCategory.Visible = true;
                setComboBox();
                this.Text = "Edytuj kategorię";

                if (btnAddEditDelCat.Text == "Usuń")
                {
                    textBoxNameCategory.Visible = false;
                    labelNameCategory.Visible   = false;
                    this.Text = "Usuń kategorię";
                }
            }
        }
Esempio n. 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Category_ category_ = db.Category_.Find(id);

            db.Category_.Remove(category_);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "categoryId,categoryName")] Category_ category_)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category_).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category_));
 }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "categoryId,categoryName")] Category_ category_)
        {
            if (ModelState.IsValid)
            {
                db.Category_.Add(category_);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category_));
        }
Esempio n. 5
0
        // GET: Category_/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Category_ category_ = db.Category_.Find(id);

            if (category_ == null)
            {
                return(HttpNotFound());
            }
            return(View(category_));
        }