public static ShippingRuleRecord FromShippingRule(ShippingRule rule)
 {
     return(new ShippingRuleRecord
     {
         ZipCodeOrigin = rule.Origin.ToString(),
         ZipCodeRangeFrom = rule.RangeFrom.ToString(),
         ZipCodeRangeTo = rule.RangeTo.ToString(),
         MinWeightGrams = rule.MinWeight,
         MaxWeightGrams = rule.MaxWeight,
         MaxVolume = rule.MaxVolume,
         DeliveryTimeDays = rule.DeliveryTime,
         PriceCents = rule.Price,
         AdValorem = rule.AdValorem
     });
 }
Ejemplo n.º 2
0
    /// <summary>
    /// Event triggered when a command button is clicked on the grid
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void uxGrid_RowCommand(Object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "page")
        {
        }
        else
        {
            // Convert the row index stored in the CommandArgument
            // property to an Integer.
            int index = Convert.ToInt32(e.CommandArgument);

            // Get the values from the appropriate
            // cell in the GridView control.
            GridViewRow selectedRow = uxGrid.Rows[index];

            TableCell Idcell = selectedRow.Cells[0];
            string Id = Idcell.Text;

            if (e.CommandName == "Edit")
            {
                AddRuleLink = AddRuleLink + "?itemid=" + Id + "&sid=" + ItemId.ToString();
                Response.Redirect(AddRuleLink);
            }
            else if (e.CommandName == "Delete")
            {

                ShippingAdmin shipAdmin = new ShippingAdmin();
                ShippingRule shipRule = new ShippingRule();
                shipRule.ShippingRuleID = int.Parse(Id);

                shipAdmin.DeleteShippingRule(shipRule);

            }
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Submit button click event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ShippingAdmin shipAdmin = new ShippingAdmin();
        ShippingRule shipRule = new ShippingRule();

        //set shipping id for this rule
        shipRule.ShippingID = ShippingId;

        //If edit mode then retrieve data first
        if (ItemId > 0)
        {
            shipRule = shipAdmin.GetShippingRule(ItemId);
        }

        //set values
        shipRule.ShippingRuleTypeID = int.Parse(lstShippingRuleType.SelectedValue);
        shipRule.BaseCost = decimal.Parse(txtBaseCost.Text);

        // "PerItemCost" field is not saving for Quantity and Weight based Rules
        //So i have commented this out.
        //if (int.Parse(lstShippingRuleType.SelectedValue) == 0)
        //{
            shipRule.PerItemCost = decimal.Parse(txtPerItemCost.Text);
        //}

        if (int.Parse(lstShippingRuleType.SelectedValue) > 0)
        {
            shipRule.LowerLimit = decimal.Parse(txtLowerLimit.Text);
            shipRule.UpperLimit = decimal.Parse(txtUpperLimit.Text);
        }
        else
        {
            shipRule.LowerLimit = null;
            shipRule.UpperLimit = null;
        }

        //Update or Add
        bool retval = false;

        if (ItemId > 0)
        {
            retval = shipAdmin.UpdateShippingRule(shipRule);
        }
        else
        {
            retval = shipAdmin.AddShippingRule(shipRule);
        }

        if (retval)
        {
            //redirect to main page
            Response.Redirect("~/admin/secure/settings/shipping/view.aspx?itemid=" + ShippingId.ToString() );
        }
        else
        {
            //display error message
            lblMsg.Text = "An error occurred while updating. Please try again.";
        }
    }