private void button4_Click(object sender, EventArgs e) { AddFoodCategory adf = new AddFoodCategory(); adf.Show(); //if (adf.ShowDialog() == DialogResult.OK) //{ // LoadGrid(); //} }
//Manage Food Category public ActionResult ManageFoodCategories() { CanteenAutomationSystemDbEntities1 CAS = new CanteenAutomationSystemDbEntities1(); List <AddFoodCategory> AllfCategory = new List <AddFoodCategory>(); foreach (Category C in CAS.Categories) { AddFoodCategory FC1 = new AddFoodCategory(); FC1.Categoryid = C.CategoryId; FC1.name = C.Name; FC1.description = C.Description; AllfCategory.Add(FC1); } return(View(AllfCategory)); }
// Add Food Category public ActionResult AddFoodCategories(AddFoodCategory FC) { try { Category FC1 = new Category(); FC1.CategoryId = FC.Categoryid; FC1.Name = FC.name; FC1.Description = FC.description; CanteenAutomationSystemDbEntities1 CAS = new CanteenAutomationSystemDbEntities1(); CAS.Categories.Add(FC1); CAS.SaveChanges(); return(RedirectToAction("ManageFoodCategories")); } catch (Exception e) { return(View()); } }