private void bEdit_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string        name  = cbEditName.Text;
         double        price = double.Parse(tbEditPrice.Text);
         string        desc  = tbEditDesc.Text;
         string        img   = TelemealPath(tbEditImage.Text);
         Main_Category main  = Main_Category.All;
         Sub_Category  sub   = (Sub_Category)Enum.Parse(typeof(Sub_Category), cbEditCategory.Text);
         Food          food  = new Food
         {
             Name        = name,
             Price       = price,
             Description = desc,
             Img         = img,
             MainCtgr    = main,
             SubCtgr     = sub
         };
         conn.UpdateFood(food);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
        private void PopulateCBEditFoodID()
        {
            SQLiteDataReader reader = conn.ViewTable("Food");

            while (reader.Read())
            {
                Console.WriteLine($"{reader["id"].ToString()}, {reader["name"].ToString()}");
                int           id    = int.Parse(reader["id"].ToString());
                string        name  = (string)reader["name"];
                double        price = (double)reader["price"];
                string        desc  = (string)reader["desc"];
                string        image = (string)reader["img"];
                Main_Category main  = (Main_Category)Enum.Parse(typeof(Main_Category), reader["mainctgr"].ToString());
                Sub_Category  sub   = (Sub_Category)Enum.Parse(typeof(Sub_Category), reader["subctgr"].ToString());
                Food          food  = new Food
                {
                    Name        = name,
                    Price       = price,
                    Description = desc,
                    Img         = image,
                    MainCtgr    = main,
                    SubCtgr     = sub
                };

                lFood.Add(food);
                cbEditName.Items.Add(food.Name);
            }
            reader.Close();
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Sub_Category sub_Category = db.Sub_Category.Find(id);

            db.Sub_Category.Remove(sub_Category);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #4
0
        public int Delete(int id)
        {
            Sub_Category suBcat = this.context.Sub_Category.SingleOrDefault(x => x.Id == id);

            this.context.Sub_Category.Remove(suBcat);

            return(this.context.SaveChanges());
        }
Example #5
0
        public int Update(Sub_Category sub_category)
        {
            Sub_Category cat = this.context.Sub_Category.SingleOrDefault(x => x.Id == sub_category.Id);

            cat.Sub_Category_Name = sub_category.Sub_Category_Name;

            return(this.context.SaveChanges());
        }
 public ActionResult Edit([Bind(Include = "Id,Id_Category,Description")] Sub_Category sub_Category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sub_Category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Id_Category = new SelectList(db.Category, "Id", "Name", sub_Category.Id_Category);
     return(View(sub_Category));
 }
        public ActionResult update(Sub_Category sub_categories)
        {
            Sub_Category_manager category = new Sub_Category_manager();

            ViewBag.fk = category.getfk();

            if (ModelState.IsValid)
            {
                Concreate.Irepostory <Sub_Category> sub_category = new Sub_Category_manager();
                sub_category.Update_Item(sub_categories);
            }
            return(View());
        }
        // GET: Sub_Category/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Sub_Category sub_Category = db.Sub_Category.Find(id);

            if (sub_Category == null)
            {
                return(HttpNotFound());
            }
            return(View(sub_Category));
        }
        public ActionResult Add(Sub_Category item)
        {
            Sub_Category_manager category = new Sub_Category_manager();

            ViewBag.fk = category.getfk();


            if (ModelState.IsValid)
            {
                Concreate.Irepostory <Sub_Category> sub_category = new Sub_Category_manager();
                sub_category.Add(item);
            }
            return(View("Add"));
        }
        // GET: Sub_Category/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Sub_Category sub_Category = db.Sub_Category.Find(id);

            if (sub_Category == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id_Category = new SelectList(db.Category, "Id", "Name", sub_Category.Id_Category);
            return(View(sub_Category));
        }
Example #11
0
    public void DBOperation(string command, Sub_Category subCat = null, int id = 0)
    {
        switch (command)
        {
        case "Insert":
            client.InsertSubCategory(subCat);
            break;

        case "Delete":
            client.DeleteSubCategory(id);
            break;

        case "Update":
            // client.UpdateSubCategory(subCat);
            break;

        default:
            break;
        }
    }
 public int Update(Sub_Category sub_Category)
 {
     return(this.data.Update(sub_Category));
 }
 public int Insert(Sub_Category sub_Category)
 {
     return(this.data.Insert(sub_Category));
 }
        public PartialViewResult GetSubCategory(int id)
        {
            Sub_Category sub_Category = db.Sub_Categories.Where(x => x.topCategoryID == id).FirstOrDefault();

            return(PartialView("_PartialPageSubCategory", sub_Category));
        }
 public ActionResult delete(Sub_Category sub_categories)
 {
     Concreate.Irepostory <Sub_Category> sub_category = new Sub_Category_manager();
     sub_category.delete_ITeem(sub_categories);
     return(RedirectToAction("index"));
 }
Example #16
0
    void _view_InsertCommand(object sender, EventArgs e)
    {
        switch (_enumMaster)
        {
        case Constants.Master.Category:
            try
            {
                Category cat = new Category();
                cat.CategoryName_V     = _categoryView.CategoryName_V;
                cat.Status_N           = Constants.Status.Active;
                cat.CreatedBy          = "";
                cat.ParentCategoryID_N = _categoryView.ParentCategoryID_N;


                _modelCat.DBOperation(Constants.Action.Insert.ToString(), cat);
                _categoryView.strMessage     = "Successfully Inserted!!!";
                _categoryView.CategoryName_V = string.Empty;
                BindCategory(_categoryView);
            }
            catch (Exception ex)
            {
                _categoryView.strMessage = ex.InnerException.Message;
            }
            break;

        case Constants.Master.SubCategory:
            try
            {
                Sub_Category cat = new Sub_Category();
                cat.SubCategoryName_V = _masterListEntry.SubCategoryName_V;
                cat.CategoryID_N      = _masterListEntry.CategoryID_N;
                cat.Status_N          = Constants.Status.Active;
                cat.CreatedBy         = "";

                _modelSubCat.DBOperation(Constants.Action.Insert.ToString(), cat);
                _masterListEntry.strMessage        = "Successfully Inserted!!!";
                _masterListEntry.SubCategoryName_V = string.Empty;
                BindSubCategory(_masterListEntry);
            }
            catch (Exception ex)
            {
                _masterListEntry.strMessage = ex.InnerException.Message;
            }
            break;

        default:
            break;
        }
        //DocumentType c = new DocumentType();

        //c.DocumentTitle = _view.DocumentTitle;
        //c.CategoryID_N = _view.CategoryID;
        //c.Category = _view.CategorySelected;
        //c.DocType = (Constants.DocTypes)_view.DocumentType;
        //c.UserGUID = _view.UserGUID;
        //c.Status_N = Constants.CurrentStatus.Active;
        //c.CreatedBy = "";
        //_model.DBOperation("Insert", c);
        //_view.message = "Successfully Inserted!!!";
        //PopulateGrid();
        //_view.DataBind();

        //ClearControls();
    }
Example #17
0
 public int Insert(Sub_Category sub_category)
 {
     this.context.Sub_Category.Add(sub_category);
     return(this.context.SaveChanges());
 }