Beispiel #1
0
        protected void btnCategoryDelete_Command(object sender, CommandEventArgs e)
        {
            int ID = Convert.ToInt32(e.CommandArgument);

            DeviceCategory category = db.DeviceCategories.Where(n => n.ID == ID).FirstOrDefault();

            if (category != null)
            {
                category.Visible = false;
                db.SaveChanges();
            }
        }
Beispiel #2
0
 protected void btnAddCategories_Click(object sender, EventArgs e)
 {
     if (db.DeviceCategories.Where(n => n.Category == category.Text).SingleOrDefault() == null)
     {
         DeviceCategory dCategory = new DeviceCategory();
         dCategory.Category = category.Text;
         dCategory.Visible  = true;
         db.DeviceCategories.Add(dCategory);
         db.SaveChanges();
         category.Text = string.Empty;
         loadListView();
     }
 }