protected void Page_Load(object sender, EventArgs e) { Member currUser = (Member)Session["userLogin"]; if (Session["userLogin"] == null) { Response.Redirect("Login.aspx"); } else if (currUser.Type == "Customer") { Response.Redirect("Login.aspx"); } else { loadData(); String promoTitle = Request.QueryString["promoTitle"]; if (promoTitle != null) { editPromo = PromotionRepositories.getPromo(promoTitle); if (!Page.IsPostBack) { txtTitle.Text = editPromo.Title; txtDiscount.Text = editPromo.Discount.ToString(); txtDescription.Text = editPromo.Description; } } } }
protected void btnAddPromotion_Click(object sender, EventArgs e) { String title = txtTitle.Text; String description = txtDescription.Text; int discount = Int32.Parse(txtDiscount.Text); Promotion x = PromotionFactory.create(title, description, discount); PromotionRepositories.insertPromo(x); erMessage.Text = "Successfully added new Promotion!"; }
protected void viewPromotion_RowDeleting(object sender, GridViewDeleteEventArgs e) { String promoTitle = viewPromotion.Rows[e.RowIndex].Cells[0].Text; Promotion x = PromotionRepositories.getPromo(promoTitle); int row = PromotionRepositories.deletePromot(x); lblErrProm.Text = "Deletion Success!"; if (row > 0) { loadData(); } }
protected void btnUpdatePromotion_Click(object sender, EventArgs e) { String title = txtTitle.Text; String descrption = txtDescription.Text; int discount = Int32.Parse(txtDiscount.Text); List <Promotion> x = PromotionRepositories.getAllPromoByTitle(editPromo.Title); if (editPromo == null) { erMessage.Text = "Cake doesn't exist!"; } else { int row = PromotionRepositories.updatePromo(x, title, descrption, discount); loadData(); erMessage.Text = "Update Success!"; } }
void loadData() { viewPromotion.DataSource = PromotionRepositories.getAllPromo(); viewPromotion.DataBind(); }
public static List <Promotion> getAll() { return(PromotionRepositories.getAllPromo()); }
public static Promotion getPromo(String title) { return(PromotionRepositories.getPromo(title)); }
public static void create(Promotion promo) { PromotionRepositories.insertPromo(promo); }