Example #1
0
        protected void btnDiscountModalSave_Click(object sender, EventArgs e)
        {
            string   response = "";
            Discount discount = new Discount();

            discount.DiscountId      = lblDiscountModalDiscountId.Text.ToString() != "" ? Convert.ToInt32(lblDiscountModalDiscountId.Text) : 0;
            discount.ProductId       = Convert.ToInt32(lblDiscountModalProductId.Text);
            discount.DiscountPercent = Convert.ToDouble(tbDisocountModalDiscountPer.Text);
            if (discount.DiscountId == 0)
            {
                response = productServices.AddDiscount(discount);
                if (response == "Success")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "showAlert('Success','Discount is added.')", true);
                    Clear();
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "showAlert('Error!','" + response + "')", true);
                }
            }
            else
            {
                response = productServices.UpdateDiscount(discount);
                if (response == "Success")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "showAlert('Success','Discount is updated.')", true);
                    Clear();
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "showAlert('Error!','" + response + "')", true);
                }
            }
        }