예제 #1
0
    /// <summary>
    /// Submit Button Click event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ProductAdmin productTierAdmin = new ProductAdmin();
        ProductTier _productTier = new ProductTier();

        if (productTierID > 0)
        {
            _productTier = productTierAdmin.GetByProductTierId(productTierID);
        }

        if (ddlProfiles.SelectedValue == "0")
        {
            _productTier.ProfileID = null;
        }
        else { _productTier.ProfileID = int.Parse(ddlProfiles.SelectedValue); }

        _productTier.TierStart = int.Parse(txtTierStart.Text.Trim());
        _productTier.TierEnd = int.Parse(txtTierEnd.Text.Trim());
        _productTier.Price = decimal.Parse(txtPrice.Text.Trim());
        _productTier.ProductID = ItemID; //Set ProductId field

        bool status = false;

        //if Edit mode, then update fields
        if (productTierID > 0)
        {
           status = productTierAdmin.UpdateProductTier(_productTier);
        }
        else
        {
            status = productTierAdmin.AddProductTier(_productTier);
        }

        if (status)
        {
            Response.Redirect(viewLink + ItemID + "&mode=tieredPricing");
        }
        else
        {
            lblError.Text = "Could not update the product Tiered pricing. Please try again.";
        }
    }