public PartialViewResult Add(string mealSetID, string dishID) { int dish = int.Parse(dishID); int mealset = int.Parse(mealSetID); MealSetDishModel model = new MealSetDishModel(); Session["maxMealsetDish"] = ""; Session["existMealsetDish"] = ""; try { MealSetDishDetailTableAdapter mealSetDishAdapter = new MealSetDishDetailTableAdapter(); DataTable mealSetDishDT = new DataTable(); mealSetDishDT = mealSetDishAdapter.GetDataByMealSetID(mealset); int test = mealSetDishDT.Rows.Count; if (mealSetDishDT.Rows.Count >= 6) { Session["maxMealsetDish"] = "Số lượng món ăn trong suất ăn đã đầy. Bỏ món ăn ko cần để có thể thêm món mới!"; return PartialView("_MealSetDish", model); } mealSetDishDT = mealSetDishAdapter.GetDataByMealsetDish(mealset, dish); if (mealSetDishDT.Rows.Count != 0) { Session["existMealsetDish"] = "Món ăn đã được thêm trước đó. Vui lòng chọn món ăn khác!"; return PartialView("_MealSetDish", model); } mealSetDishAdapter.InsertMealSetDish(mealset,dish); Log.ActivityLog("Insert into MealSetDishDetail table: MealsetID = " + mealSetID + ", DishID = " + dishID); } catch (Exception ex) { Log.ErrorLog(ex.Message); } MealSetDishInfoTableAdapter mealSetDishInfoAdapter = new MealSetDishInfoTableAdapter(); DataTable mealSetDishInfoDT = mealSetDishInfoAdapter.GetDataByMealSetIDDishID(mealset, dish); model.DishID = dish; model.MealSetID = mealset; model.Dishname = mealSetDishInfoDT.Rows[0]["DishName"].ToString(); model.DishTypeID = (int)mealSetDishInfoDT.Rows[0]["DishTypeID"]; model.DishDescription = mealSetDishInfoDT.Rows[0]["DishDescription"].ToString(); model.DishImage = mealSetDishInfoDT.Rows[0]["DishImage"].ToString(); return PartialView("_MealSetDish", model); }
public PartialViewResult Remove(string mealSetID, string dishID) { int dish = int.Parse(dishID); int mealset = int.Parse(mealSetID); try { MealSetDishDetailTableAdapter mealSetDishAdapter = new MealSetDishDetailTableAdapter(); mealSetDishAdapter.DeleteMealSetDish(mealset, dish); Log.ActivityLog("Delete into MealSetDishDetail table: MealsetID = " + mealSetID + ", DishID = " + dishID); } catch (Exception ex) { Log.ErrorLog(ex.Message); } MealSetDishModel model = new MealSetDishModel(); return PartialView("_MealSetDish", model); }