private void LoadDishTable() { try { List <DishData> ListDish = new DishSystem().GetDishList(); rptDish.DataSource = ListDish; rptDish.DataBind(); } catch (Exception ex) { notifDish.Show($"ERROR LOAD TABLE: {ex.Message}", NotificationType.Danger); } }
protected void btnSave_Click(object sender, EventArgs e) { try { DishData dish = GetFormData(); int rowAffected = new DishSystem().InsertUpdateDish(dish); if (rowAffected <= 0) { throw new Exception("No Data Recorded"); } Session["save-success"] = 1; Response.Redirect("Dish.aspx"); } catch (Exception ex) { notifDish.Show($"ERROR SAVE DATA: {ex.Message}", NotificationType.Danger); } }
protected void btnDelete_Click(object sender, EventArgs e) { try { string strDeletedIDs = hdfDeletedDishes.Value; IEnumerable <int> deletedIDs = strDeletedIDs.Split(',').Select(Int32.Parse); int rowAffected = new DishSystem().DeleteDishes(deletedIDs); if (rowAffected <= 0) { throw new Exception("No Data Deleted"); } Session["delete-success"] = 1; Response.Redirect("Dish.aspx"); } catch (Exception ex) { notifDish.Show($"ERROR DELETE DATA: {ex.Message}", NotificationType.Danger); } }
protected void rptDish_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "EDIT") { LinkButton lbDishName = (LinkButton)e.Item.FindControl("lbDishName"); Literal litDishType = (Literal)e.Item.FindControl("litDishType"); Literal litPrice = (Literal)e.Item.FindControl("litPrice"); int dishID = Convert.ToInt32(e.CommandArgument.ToString()); DishData dish = new DishSystem().GetDishByID(dishID); FillForm(new DishData { DishID = dish.DishID, DishName = dish.DishName, DishTypeID = dish.DishTypeID, DishPrice = dish.DishPrice }); litFormType.Text = $"UBAH: {lbDishName.Text}"; pnlFormDish.Visible = true; txtDishName.Focus(); } }