Example #1
0
    /// <summary>
    /// Gets the name of the Addon for this AddonId
    /// </summary>
    /// <param name="addOnId"></param>
    /// <returns></returns>
    public string GetAddOnName(object addOnId)
    {
        ProductAddOnAdmin AdminAccess = new ProductAddOnAdmin();
        AddOn _addOn = AdminAccess.GetByAddOnId(int.Parse(addOnId.ToString()));

        if (_addOn != null)
        {
            return _addOn.Name;
        }

        return "";
    }
Example #2
0
    /// <summary>
    /// Bind data to the fields on the screen
    /// </summary>
    protected void BindData()
    {
        ProductAddOnAdmin AddOnAdmin = new ProductAddOnAdmin();
        AddOn Entity = AddOnAdmin.GetByAddOnId(ItemId);

        if (Entity != null)
        {
            ProductAddOnName = Entity.Name;
        }
        else
        {
            throw (new ApplicationException("Product Add-On Requested could not be found."));
        }
    }
Example #3
0
    /// <summary>
    /// Bind data to the fields on the edit screen
    /// </summary>
    protected void BindData()
    {
        ProductAddOnAdmin AddOnAdmin = new ProductAddOnAdmin();
        AddOn addOnEntity = AddOnAdmin.GetByAddOnId(ItemId);

        if (addOnEntity != null)
        {
            lblTitle.Text = addOnEntity.Name;
            lblName.Text = addOnEntity.Name;
            lblAddOnTitle.Text = addOnEntity.Title;
            lblDisplayOrder.Text = addOnEntity.DisplayOrder.ToString();
            lblDisplayType.Text = addOnEntity.DisplayType.ToString();

            //Display Settings
            chkOptionalInd.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(bool.Parse(addOnEntity.OptionalInd.ToString()));

            //Inventory Setting - Out of Stock Options
            if ((addOnEntity.TrackInventoryInd) && (addOnEntity.AllowBackOrder == false))
            {
                chkCartInventoryEnabled.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(bool.Parse("true"));
                chkIsBackOrderEnabled.Src = SetImage();
                chkIstrackInvEnabled.Src = SetImage();

            }
            else if (addOnEntity.TrackInventoryInd && addOnEntity.AllowBackOrder)
            {
                chkCartInventoryEnabled.Src = SetImage();
                chkIsBackOrderEnabled.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(bool.Parse("true"));
                chkIstrackInvEnabled.Src = SetImage();
            }
            else if ((addOnEntity.TrackInventoryInd == false) && (addOnEntity.AllowBackOrder == false))
            {
                chkCartInventoryEnabled.Src = SetImage();
                chkIsBackOrderEnabled.Src = SetImage();
                chkIstrackInvEnabled.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(bool.Parse("true"));
            }

            //Inventory Setting - Stock Messages
            lblInStockMsg.Text = addOnEntity.InStockMsg;
            lblOutofStock.Text = addOnEntity.OutOfStockMsg;
            lblBackOrderMsg.Text = addOnEntity.BackOrderMsg;
        }
        else
        {
            throw (new ApplicationException("Add-On Requested could not be found."));
        }
    }
Example #4
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAddSelectedAddons_Click(object sender, EventArgs e)
    {
        ProductAddOnAdmin AdminAccess = new ProductAddOnAdmin();
        StringBuilder sb = new StringBuilder();

        //Loop through the grid values
        foreach (GridViewRow row in uxAddOnGrid.Rows)
        {
            CheckBox check = (CheckBox)row.Cells[0].FindControl("chkProductAddon") as CheckBox;
            //Get AddOnId
            int AddOnID = int.Parse(row.Cells[1].Text);

            if (check.Checked)
            {
                ProductAddOn ProdAddOnEntity = new ProductAddOn();

                //Set Properties
                ProdAddOnEntity.ProductID = ItemId;
                ProdAddOnEntity.AddOnID = AddOnID;

                if (AdminAccess.IsAddOnExists(ProdAddOnEntity))
                {
                    AdminAccess.AddNewProductAddOn(ProdAddOnEntity);
                    check.Checked = false;
                }
                else
                {
                    sb.Append(GetAddOnName(AddOnID) + ",");
                    lblAddOnErrorMessage.Visible = true;
                }
            }
        }

        if (sb.ToString().Length > 0)
        {
            sb.Remove(sb.ToString().Length - 1, 1);

            //Display Error message
            lblAddOnErrorMessage.Text = "The following Add-On(s) are already associated with this product.<br/>" + sb.ToString();

        }
        else
        {
            Response.Redirect(DetailsLink + "&itemid=" + ItemId);
        }
    }
Example #5
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        ProductAddOnAdmin AddOnAdmin = new ProductAddOnAdmin();
        AddOn AddOn = new AddOn();
        AddOn.AddOnID = ItemId;

        bool retval = AddOnAdmin.DeleteAddOn(AddOn);

        if (retval)
        {
            Response.Redirect("~/admin/secure/catalog/product_addons/list.aspx");
        }
        else
        {
            lblMsg.Text = "An error occurred and the product Add-On could not be deleted. Please ensure that this Add-On does not contain Add-On Values or products. If it does, then delete the Add-On values and products first.";
        }
    }
Example #6
0
    /// <summary>
    /// Bind data to the fields on the edit screen
    /// </summary>
    protected void BindEditData()
    {
        ProductAddOnAdmin AddOnAdmin = new ProductAddOnAdmin();
        AddOn addOnEntity = AddOnAdmin.GetByAddOnId(ItemId);

        if (addOnEntity != null)
        {
            lblTitle.Text += addOnEntity.Name;
            txtName.Text = addOnEntity.Name;
            txtAddOnTitle.Text = addOnEntity.Title;
            txtDisplayOrder.Text = addOnEntity.DisplayOrder.ToString();
            chkOptionalInd.Checked = addOnEntity.OptionalInd;
            ctrlHtmlText.Html = addOnEntity.Description;
            //if (addOnEntity.DisplayType != null)
                ddlDisplayType.SelectedValue = addOnEntity.DisplayType;
            //else
            //    ddlDisplayType.SelectedIndex = 0;

            //Inventory Setting - Out of Stock Options

            if ((addOnEntity.TrackInventoryInd) && (addOnEntity.AllowBackOrder == false))
            {
                InvSettingRadiobtnList.Items[0].Selected = true;
            }
            else if (addOnEntity.TrackInventoryInd && addOnEntity.AllowBackOrder)
            {
                InvSettingRadiobtnList.Items[1].Selected = true;
            }
            else if ((addOnEntity.TrackInventoryInd == false) && (addOnEntity.AllowBackOrder == false))
            {
                InvSettingRadiobtnList.Items[2].Selected = true;
            }

            //Inventory Setting - Stock Messages
            txtInStockMsg.Text = addOnEntity.InStockMsg;
            txtOutofStock.Text = addOnEntity.OutOfStockMsg;
            txtBackOrderMsg.Text = addOnEntity.BackOrderMsg;
        }
        else
        {
            throw (new ApplicationException("Add-On Requested could not be found."));
        }
    }
Example #7
0
    /// <summary>
    /// Submit button click event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ProductAddOnAdmin AddonAdmin = new ProductAddOnAdmin();
        AddOn AddOnEntityObject = new AddOn();

        if (ItemId > 0)
        {
            AddOnEntityObject = AddonAdmin.GetByAddOnId(ItemId);
        }
        //Set properties - General settings
        AddOnEntityObject.Name = txtName.Text.Trim();
        AddOnEntityObject.Title = txtAddOnTitle.Text.Trim();
        AddOnEntityObject.DisplayOrder = int.Parse(txtDisplayOrder.Text.Trim());
        AddOnEntityObject.OptionalInd = chkOptionalInd.Checked;
        AddOnEntityObject.Description = ctrlHtmlText.Html;
        AddOnEntityObject.DisplayType = ddlDisplayType.SelectedItem.Value;

        //Set properties - Inventory settings
        //Out of Stock Options
        if (InvSettingRadiobtnList.SelectedValue.Equals("1"))
        {
            //Only Sell if Inventory Available - Set values
            AddOnEntityObject.TrackInventoryInd = true;
            AddOnEntityObject.AllowBackOrder = false;
        }
        else if (InvSettingRadiobtnList.SelectedValue.Equals("2"))
        {
            //Allow Back Order - Set values
            AddOnEntityObject.TrackInventoryInd = true;
            AddOnEntityObject.AllowBackOrder = true;
        }
        else if (InvSettingRadiobtnList.SelectedValue.Equals("3"))
        {
            //Don't Track Inventory - Set property values
            AddOnEntityObject.TrackInventoryInd = false;
            AddOnEntityObject.AllowBackOrder = false;
        }

        //Inventory Setting - Stock Messages
        if (txtOutofStock.Text.Trim().Length == 0)
        {
            AddOnEntityObject.OutOfStockMsg = "Out of Stock";
        }
        else
        {
            AddOnEntityObject.OutOfStockMsg = txtOutofStock.Text.Trim();
        }
        AddOnEntityObject.InStockMsg = txtInStockMsg.Text.Trim();
        AddOnEntityObject.BackOrderMsg = txtBackOrderMsg.Text.Trim();

        bool retval = false;

        if (ItemId > 0)
        {
            retval = AddonAdmin.UpdateNewProductAddOn(AddOnEntityObject);
        }
        else
        {
            retval = AddonAdmin.CreateNewProductAddOn(AddOnEntityObject,out ItemId);
        }

        if (retval)
        {
            if (mode)
            {
                Response.Redirect(ViewLink);
            }

            Response.Redirect(ViewLink + ItemId);
        }
        else
        {
            lblMsg.Text = "Could not update the product Add-On. Please try again.";
            lblMsg.CssClass = "Error";
            return;
        }
    }
Example #8
0
    /// <summary>
    /// Bind Addon Grid - all Addons
    /// </summary>
    private void BindAddons()
    {
        ProductAddOnAdmin ProdAddonAdminAccess = new ProductAddOnAdmin();

        //List of Addons
        uxAddOnGrid.DataSource = ProdAddonAdminAccess.GetAllAddOns();
        uxAddOnGrid.DataBind();
    }
Example #9
0
 /// <summary>
 /// Bind AddOn grid with filtered data
 /// </summary>
 protected void SearchAddons()
 {
     ProductAddOnAdmin AdminAccess = new ProductAddOnAdmin();
     uxAddOnGrid.DataSource = AdminAccess.SearchAddOns(txtAddonName.Text.Trim(),txtAddOnTitle.Text.Trim(), txtAddOnsku.Text.Trim());
     uxAddOnGrid.DataBind();
 }
Example #10
0
    /// <summary>
    /// Bind data to grid
    /// </summary>
    private void BindGridData()
    {
        ProductAddOnAdmin ProdAddonAdminAccess = new ProductAddOnAdmin();

        uxGrid.DataSource = ProdAddonAdminAccess.GetAllAddOns();
        uxGrid.DataBind();
    }
Example #11
0
 /// <summary>
 ///  Bind data to grid
 /// </summary>
 private void BindGrid()
 {
     ProductAddOnAdmin AddOnValueAdmin = new ProductAddOnAdmin();
     TList<AddOnValue> ValueList = AddOnValueAdmin.GetAddOnValuesByAddOnId(ItemId);
     if(ValueList != null)
         ValueList.Sort("DisplayOrder");
     uxGrid.DataSource = ValueList;
     uxGrid.DataBind();
 }
Example #12
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")
            {
                EditLink = AddOnValuepageLink + ItemId + "&AddOnValueId=" + Id;
                Response.Redirect(EditLink);
            }
            if (e.CommandName == "Delete")
            {
                ProductAddOnAdmin AdminAccess = new ProductAddOnAdmin();
                bool Status = AdminAccess.DeleteAddOnValue(int.Parse(Id));

                if (Status)
                {
                    BindGrid();
                }
            }

        }
    }
Example #13
0
    /// <summary>
    /// Submit Button Click Event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAddOnValueSubmit_Click(object sender, EventArgs e)
    {
        ProductAddOnAdmin AddOnValueAdmin = new ProductAddOnAdmin();
        AddOnValue addOnValue = new AddOnValue();

        if (AddOnValueId > 0)
        {
            addOnValue = AddOnValueAdmin.GetByAddOnValueID(AddOnValueId);
        }

        // Set Properties
        // General Settings
        addOnValue.AddOnID = ItemId; // AddOnId from querystring
        addOnValue.Name = txtAddOnValueName.Text.Trim();
        addOnValue.RetailPrice = decimal.Parse(txtAddOnValueRetailPrice.Text.Trim());
        addOnValue.SalePrice = null;
        addOnValue.WholesalePrice = null;

        if(txtSalePrice.Text.Trim().Length > 0)
        addOnValue.SalePrice = decimal.Parse(txtSalePrice.Text.Trim());
        if(txtWholeSalePrice.Text.Trim().Length > 0)
        addOnValue.WholesalePrice = decimal.Parse(txtWholeSalePrice.Text.Trim());

        // Display Settings
        addOnValue.DisplayOrder = int.Parse(txtAddonValueDispOrder.Text.Trim());
        addOnValue.DefaultInd = chkIsDefault.Checked;

        // Inventory Settings
        addOnValue.SKU = txtAddOnValueSKU.Text.Trim();
        addOnValue.QuantityOnHand = int.Parse(txtAddOnValueQuantity.Text.Trim());
        if (txtReOrder.Text.Trim().Length > 0)
        {
            addOnValue.ReorderLevel = int.Parse(txtReOrder.Text.Trim());
        }
        else
        { addOnValue.ReorderLevel = null; }
        if (txtAddOnValueWeight.Text.Trim().Length > 0)
        {
            addOnValue.Weight = decimal.Parse(txtAddOnValueWeight.Text.Trim());
        }

        # region Add-On Package Dimensions
        if (Height.Text.Trim().Length > 0)
        {
            addOnValue.Height = decimal.Parse(Height.Text.Trim());
        }
        else { addOnValue.Height = null; }

        if (Width.Text.Trim().Length > 0)
        {
            addOnValue.Width = decimal.Parse(Width.Text.Trim());
        }
        else { addOnValue.Width = null; }

        if (Length.Text.Trim().Length > 0)
        {
            addOnValue.Length = decimal.Parse(Length.Text.Trim());
        }
        else
        { addOnValue.Length = null; }
        #endregion

        // set shipping type for this add-on item
        addOnValue.ShippingRuleTypeID = int.Parse(ShippingTypeList.SelectedValue);
        addOnValue.FreeShippingInd = chkFreeShippingInd.Checked;

        if (chkRecurringBillingInd.Checked)
        {
            // Recurring Billing
            addOnValue.RecurringBillingInd = chkRecurringBillingInd.Checked;
            addOnValue.RecurringBillingPeriod = ddlBillingPeriods.SelectedItem.Value;
            addOnValue.RecurringBillingFrequency = ddlBillingFrequency.SelectedItem.Text;
            addOnValue.RecurringBillingTotalCycles = int.Parse(txtSubscrptionCycles.Text.Trim());
        }
        else
        {
            addOnValue.RecurringBillingInd = false;
            addOnValue.RecurringBillingInstallmentInd = false;
        }

        // Supplier
        if (ddlSupplier.SelectedIndex != -1)
        {
            if (ddlSupplier.SelectedItem.Text.Equals("None"))
            {
                addOnValue.SupplierID = null;
            }
            else
            {
                addOnValue.SupplierID = Convert.ToInt32(ddlSupplier.SelectedValue);
            }
        }

        // Tax Class
        if (ddlTaxClass.SelectedIndex != -1)
        {
            addOnValue.TaxClassID = int.Parse(ddlTaxClass.SelectedValue);
        }

        bool status = false;

        if (AddOnValueId > 0)
        {
            // set update date
            addOnValue.UpdateDte = System.DateTime.Now;

            // Update option values
            status = AddOnValueAdmin.UpdateAddOnValue(addOnValue);
        }
        else
        {
            // Add new option values
            status = AddOnValueAdmin.AddNewAddOnValue(addOnValue);
        }

        if (status)
        {
            Response.Redirect(ViewLink + ItemId);
        }
        else
        {
            lblAddonValueMsg.Text = "Could not update the Add-On Value. Please try again.";
            return;
        }
    }
Example #14
0
    /// <summary>
    /// Bind data to the fields on the edit screen
    /// </summary>
    protected void BindEditData()
    {
        ProductAddOnAdmin AddOnAdmin = new ProductAddOnAdmin();
        AddOnValue AddOnValueEntity = AddOnAdmin.GetByAddOnValueID(AddOnValueId);

        if (AddOnValueEntity != null)
        {
            //General Settings
            lblTitle.Text += AddOnValueEntity.Name;
            txtAddOnValueName.Text = AddOnValueEntity.Name;
            txtAddOnValueRetailPrice.Text = AddOnValueEntity.RetailPrice.ToString("N");
            if (AddOnValueEntity.SalePrice.HasValue)
                txtSalePrice.Text = AddOnValueEntity.SalePrice.Value.ToString("N");

            if (AddOnValueEntity.WholesalePrice.HasValue)
                txtWholeSalePrice.Text = AddOnValueEntity.WholesalePrice.Value.ToString("N");
            if (ddlSupplier.SelectedIndex != -1)
            {
                ddlSupplier.SelectedValue = AddOnValueEntity.SupplierID.ToString();
            }

            if (ddlTaxClass.SelectedIndex != -1)
                ddlTaxClass.SelectedValue = AddOnValueEntity.TaxClassID.GetValueOrDefault(0).ToString();

            // Display Settings
            txtAddonValueDispOrder.Text = AddOnValueEntity.DisplayOrder.ToString();
            chkIsDefault.Checked = AddOnValueEntity.DefaultInd;

            // Inventory Settings
            txtAddOnValueSKU.Text = AddOnValueEntity.SKU;
            txtAddOnValueQuantity.Text = AddOnValueEntity.QuantityOnHand.ToString();
            if(AddOnValueEntity.ReorderLevel.HasValue)
            txtReOrder.Text = AddOnValueEntity.ReorderLevel.ToString();
            txtAddOnValueWeight.Text = AddOnValueEntity.Weight.ToString();
            if (AddOnValueEntity.Height.HasValue)
                Height.Text = AddOnValueEntity.Height.Value.ToString("N2");
            if (AddOnValueEntity.Width.HasValue)
                Width.Text = AddOnValueEntity.Width.Value.ToString("N2");
            if (AddOnValueEntity.Length.HasValue)
                Length.Text = AddOnValueEntity.Length.Value.ToString("N2");

            // Shipping Settings
            if (AddOnValueEntity.ShippingRuleTypeID.HasValue)
                ShippingTypeList.SelectedValue = AddOnValueEntity.ShippingRuleTypeID.Value.ToString();
            EnableValidators();

            if (AddOnValueEntity.FreeShippingInd.HasValue)
                chkFreeShippingInd.Checked = AddOnValueEntity.FreeShippingInd.Value;

            // Recurring Billing
            pnlRecurringBilling.Visible = AddOnValueEntity.RecurringBillingInd;
            chkRecurringBillingInd.Checked = AddOnValueEntity.RecurringBillingInd;
            txtSubscrptionCycles.Text = AddOnValueEntity.RecurringBillingTotalCycles.GetValueOrDefault(0).ToString();
            ddlBillingPeriods.SelectedValue = AddOnValueEntity.RecurringBillingPeriod;
            ddlBillingFrequency.SelectedValue = AddOnValueEntity.RecurringBillingFrequency;
        }
        else
        {
            throw (new ApplicationException("Add-On Value Requested could not be found."));
        }
    }
Example #15
0
    /// <summary>
    /// Product Add On Row command event - occurs when delete button is fired.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void uxGridProductAddOns_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 = uxGridProductAddOns.Rows[index];

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

            if (e.CommandName == "Remove")
            {
                ProductAddOnAdmin AdminAccess = new ProductAddOnAdmin();
                if(AdminAccess.DeleteProductAddOn(int.Parse(Id)))
                BindProductAddons();
            }
        }
    }
Example #16
0
    /// <summary>
    /// Bind data to grid
    /// </summary>
    private void BindProductAddons()
    {
        ProductAddOnAdmin ProdAddonAdminAccess = new ProductAddOnAdmin();

        //Bind Associated Addons for this product
        uxGridProductAddOns.DataSource = ProdAddonAdminAccess.GetByProductId(ItemId);
        uxGridProductAddOns.DataBind();
    }