예제 #1
0
        //Update Discounts with exception handling
        protected void DiscountGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                GridViewRow row              = DiscountGridView.Rows[e.RowIndex];
                string      discountId       = (row.FindControl("Label1") as Label).Text;
                short       discountAmt      = short.Parse((row.FindControl("TextBox2") as TextBox).Text);
                DateTime    validStart       = (row.FindControl("Calendar3") as Calendar).SelectedDate;
                int         discountDuration = Convert.ToInt32((row.FindControl("TextBox4") as TextBox).Text);
                int         catID            = Convert.ToInt32((row.FindControl("DDL5") as TextBox).Text);

                BusinessLogic.UpdateCategoryDiscount(discountId, discountAmt, validStart, discountDuration, catID);

                DiscountGridView.EditIndex = -1;

                DiscountGridView.DataSource = BusinessLogic.CDiscount();
                DiscountGridView.DataBind();
                Label8.Text = "Update success!";
            }
            catch (Exception)
            {
                Label8.Text = "Please input a valid discount amount, duration and category.";
            }
        }