public ActionResult Upd(ProductAdmin productAdmin)
 {
     if (Session["userId"] != null)
     {
         if (db.Users.Find(Session["userId"]).Status == Status.admin)
         {
             Product product     = db.Products.Find(productAdmin.Id);
             string  sliceOfPath = "/Content/Images/Product/";
             if (productAdmin.File.ContentLength > 0)
             {
                 string filename = Path.GetFileName(productAdmin.File.FileName);
                 string filepath = Path.Combine(Server.MapPath("~/Content/Images/Product"), filename);
                 productAdmin.File.SaveAs(filepath);
             }
             product.Brand           = productAdmin.Brand;
             product.Name            = productAdmin.Name;
             product.Price           = productAdmin.Price;
             product.ImagePath       = sliceOfPath + productAdmin.File.FileName;
             product.Description     = productAdmin.Description;
             product.FullDescription = productAdmin.FullDescription;
             product.CatalogId       = productAdmin.CatalogId;
             product.SubCatalogId    = productAdmin.SubCatalogId;
             product.SubSubCatalogId = productAdmin.SubSubCatalogId;
             if (ModelState.IsValid)
             {
                 db.Entry(product).State = EntityState.Modified;
                 db.SaveChanges();
                 return(RedirectToAction("Login"));
             }
             return(View(product));
         }
         return(HttpNotFound());
     }
     return(HttpNotFound());
 }
Esempio n. 2
0
    /// <summary>
    /// Binding Product tiered pricing for this product
    /// </summary>
    public void BindTieredPricing()
    {
        //Create Instance for Product Admin and Product entity
        ZNode.Libraries.Admin.ProductAdmin ProdAdmin = new ProductAdmin();
        TList<ProductTier> productTierList = ProdAdmin.GetTieredPricingByProductId(ItemId);

        uxGridTieredPricing.DataSource = productTierList;
        uxGridTieredPricing.DataBind();
    }
Esempio n. 3
0
 /// <summary>
 /// Bind the data for a Product id
 /// </summary>
 public void BindData()
 {
     ProductAdmin _ProductAdmin = new ProductAdmin();
     Product ProductList = _ProductAdmin.GetByProductId(ItemID);
     if (ProductList != null)
     {
         ProductName = ProductList.Name;
     }
 }
Esempio n. 4
0
    /// <summary>
    /// Bind control display based on properties set
    /// </summary>
    public void Bind()
    {
        ProductAdmin _adminAccess = new ProductAdmin();

        DataSet MyDataSet = _adminAccess.GetAttributeTypeByProductTypeID(productTypeID);

        //Repeats until Number of AttributeType for this Product
        foreach (DataRow dr in MyDataSet.Tables[0].Rows)
        {
            //Bind Attributes
            DataSet _AttributeDataSet = _adminAccess.GetByAttributeTypeID(int.Parse(dr["attributetypeid"].ToString()));

            System.Web.UI.WebControls.DropDownList lstControl = new DropDownList();
            lstControl.ID = "lstAttribute" + dr["AttributeTypeId"].ToString();

            ListItem li = new ListItem(dr["Name"].ToString(), "0");
            li.Selected = true;

            lstControl.DataSource = _AttributeDataSet;
            lstControl.DataTextField = "Name";
            lstControl.DataValueField = "AttributeId";
            lstControl.DataBind();
            lstControl.Items.Insert(0, li);

            if (!Convert.ToBoolean(dr["IsPrivate"]))
            {
                //Add Dynamic Attribute DropDownlist in the Placeholder
                ControlPlaceHolder.Controls.Add(lstControl);

                //Required Field validator to check SKU Attribute
                RequiredFieldValidator FieldValidator = new RequiredFieldValidator();
                FieldValidator.ID = "Validator" + dr["AttributeTypeId"].ToString();
                FieldValidator.ControlToValidate = "lstAttribute" + dr["AttributeTypeId"].ToString();
                FieldValidator.ErrorMessage = "Select " + dr["Name"].ToString();
                FieldValidator.Display = ValidatorDisplay.Dynamic;
                FieldValidator.CssClass = "Error";
                FieldValidator.InitialValue = "0";

                ControlPlaceHolder.Controls.Add(FieldValidator);
                Literal lit1 = new Literal();
                lit1.Text = "&nbsp;&nbsp;";
                ControlPlaceHolder.Controls.Add(lit1);
            }

        }

        //Hide the Product Attribute
        if (MyDataSet.Tables[0].Rows.Count == 0)
        {
            DivAttributes.Visible = false;
        }
    }
Esempio n. 5
0
    /// <summary>
    /// Binding Product Values into label Boxes
    /// </summary>
    public void BindViewData()
    {
        //Create Instance for Product Admin and Product entity
        ZNode.Libraries.Admin.ProductAdmin ProdAdmin = new ProductAdmin();
        Product _Product = ProdAdmin.GetByProductId(ItemId);

        DataSet ds = ProdAdmin.GetProductDetails(ItemId);

        //Check for Number of Rows
        if (ds.Tables[0].Rows.Count != 0)
        {
            //Check For Product Type
            productTypeID = int.Parse(ds.Tables[0].Rows[0]["ProductTypeId"].ToString());
            int Count = ProdAdmin.GetAttributeCount(int.Parse(ds.Tables[0].Rows[0]["ProductTypeId"].ToString()), ZNodeConfigManager.SiteConfig.PortalID);
            if (Count > 0)
            {
                //DivAddSKU.Visible = true;
                butAddNewSKU.Enabled = true;
            }
            else
            {
                lblmessage.Text = "Note: You can add multiple SKUs or Part Numbers to a product only if the product has attributes.";
                butAddNewSKU.Enabled = false;
            }

        }

        if (_Product != null)
        {
            //General Informations
            lblProdName.Text = _Product.Name;

            //Binding product Category
            DataSet dsCategory = ProdAdmin.Get_CategoryByProductID(ItemId);
            StringBuilder Builder = new StringBuilder();
            foreach (System.Data.DataRow dr in dsCategory.Tables[0].Rows)
            {
                Builder.Append(ProdAdmin.GetCategorypath(dr["Name"].ToString(), dr["Parent1CategoryName"].ToString(), dr["Parent2CategoryName"].ToString()));
                Builder.Append("<br>");
            }

            //Bind Grid - SKU
            this.BindSKU();

        }
        else
        {
            throw (new ApplicationException("Product Requested could not be found."));
        }
    }
Esempio n. 6
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        ProductAdmin _ProductAdmin = new ProductAdmin();
        bool Retvalue = _ProductAdmin.DeleteByProductID(ItemID, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.PortalID);

        if (Retvalue)
        {
            Response.Redirect(CancelLink);
        }
        else
        {
            lblErrorMessage.Text = "The product can not be deleted until all associated items are removed. Please ensure that this product does not contain cross-sell items, product images, or skus. If it does, then delete these Items first.";
        }
    }
Esempio n. 7
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAddSelectedAddons_Click(object sender, EventArgs e)
    {
        ProductAdmin AdminAccess = new ProductAdmin();
        StringBuilder sb = new StringBuilder();

        //Loop through the grid values
        foreach (GridViewRow row in uxGrid.Rows)
        {
            CheckBox check = (CheckBox)row.Cells[0].FindControl("chkProductHighlight") as CheckBox;
            //Get AddOnId
            int HighlighID = int.Parse(row.Cells[1].Text);
            int DisplayOrder = int.Parse(row.Cells[4].Text);
            string name = row.Cells[2].Text;

            if (check.Checked)
            {
                ProductHighlight entity = new ProductHighlight();

                //Set Properties
                entity.ProductID = ItemId;
                entity.HighlightID = HighlighID;
                entity.DisplayOrder = DisplayOrder;

                if (!AdminAccess.IsHighlightExists(ItemId,HighlighID))
                {
                    AdminAccess.AddProductHighlight(entity);
                    check.Checked = false;
                }
                else
                {
                    sb.Append(name + ",");
                    lblErrorMessage.Visible = true;
                }
            }
        }

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

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

        }
        else
        {
            Response.Redirect(ViewPageLink + "&itemid=" + ItemId);
        }
    }
Esempio n. 8
0
    /// <summary>
    /// Bind product to the drop down list
    /// </summary>
    public void BindProductNames()
    {
        //Bind Drop down list
        ProductAdmin productAdmin = new ProductAdmin();
        TList<Product> productList = productAdmin.GetAllProducts(ZNodeConfigManager.SiteConfig.PortalID);
        productList.Sort("Name");
        ddlProductNames.DataSource = productList;
        ddlProductNames.DataTextField = "Name";
        ddlProductNames.DataValueField = "ProductId";
        ddlProductNames.DataBind();

        ListItem li = new ListItem("All","0");
        li.Selected = true;
        ddlProductNames.Items.Insert(0, li);
    }
Esempio n. 9
0
    /// <summary>
    /// Confirm Button Click Event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        ProductAdmin _productAdmin = new ProductAdmin();

        bool Check = _productAdmin.EmptyCatalog(HttpContext.Current.User.Identity.Name);

        if (Check)
        {
            Response.Redirect("~/admin/secure/settings/default.aspx?mode=setup");
        }
        else
        {
            //Display Error Message
            lblErrorMessage.Text = " Delete action could not be completed. Please try again.";
        }
    }
Esempio n. 10
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.";
        }
    }
        public ActionResult Add(ProductAdmin productAdmin)
        {
            if (Session["userId"] != null)
            {
                try
                {
                    if (db.Users.Find(Session["userId"]).Status == Status.admin)
                    {
                        Product product     = new Product();
                        string  sliceOfPath = "/Content/Images/Product/";
                        if (productAdmin.File.ContentLength > 0)
                        {
                            string filename = Path.GetFileName(productAdmin.File.FileName);
                            string filepath = Path.Combine(Server.MapPath("~/Content/Images/Product"), filename);
                            productAdmin.File.SaveAs(filepath);
                        }
                        product.Brand           = productAdmin.Brand;
                        product.Name            = productAdmin.Name;
                        product.Price           = productAdmin.Price;
                        product.ImagePath       = sliceOfPath + productAdmin.File.FileName;
                        product.Description     = productAdmin.Description;
                        product.FullDescription = productAdmin.FullDescription;
                        product.CatalogId       = productAdmin.CatalogId;
                        product.SubCatalogId    = productAdmin.SubCatalogId;
                        product.SubSubCatalogId = productAdmin.SubSubCatalogId;

                        db.Products.Add(product);
                        db.SaveChanges();

                        ViewBag.Catalogs = db.Catalogs;

                        return(Redirect("/Admin/Home/Login"));
                    }
                    return(HttpNotFound());
                }
                catch
                {
                    return(Redirect("/Admin/Home/Login"));
                }
            }
            return(HttpNotFound());
        }
Esempio n. 12
0
    /// <summary>
    /// Event fierd when submit button is triggered.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ProductAdmin AdminAccess = new ProductAdmin();

        DigitalAsset entity = new DigitalAsset();
        entity.DigitalAsset = txtDigitalAsset.Text.Trim();
        entity.ProductID = ItemId;
        entity.OrderLineItemID = null;

        bool Check = AdminAccess.AddDigitalAsset(entity);

        if (Check)
        {
            Response.Redirect("~/admin/secure/catalog/product/view.aspx?mode=digitalAsset&itemid=" + ItemId);
        }
        else
        {
            lblMsg.Text = "Could not add the product category. Please try again.";
            return;
        }
    }
    /// <summary>
    /// Submit Button Click Event - Fires when Submit button is triggered
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ProductAdmin _ProductAdmin = new ProductAdmin();
        Product _product = new Product();
        //if edit mode then get all the values first
        if (ItemID > 0)
        {
            _product = _ProductAdmin.GetByProductId(ItemID);

        }

        _product.FeaturesDesc = ctrlHtmlPrdFeatures.Html.Trim();
        _product.Specifications = ctrlHtmlPrdSpec.Html.Trim();
        _product.AdditionalInformation = CtrlHtmlProdInfo.Html.Trim();

        bool status = false;

        try
        {
            if (ItemID > 0) //PRODUCT UPDATE
            {
                status = _ProductAdmin.Update(_product);
            }

            if (status)
            {
                Response.Redirect(ManagePageLink + ItemID);
            }
            else
            {
                lblError.Text = "Unable to update product additional information settings. Please try again.";
            }

        }
        catch (Exception)
        {
            lblError.Text = "Unable to update product additional information settings. Please try again.";
            return;
        }
    }
Esempio n. 14
0
    /// <summary>
    /// Binding Product Values into label Boxes
    /// </summary>
    public void BindViewData()
    {
        ZNode.Libraries.Admin.ProductAdmin ProdAdmin = new ProductAdmin();
        Product _Product = ProdAdmin.GetByProductId(ItemID);

        if (_Product != null)
        {
            //General Informations
            lblProdName.Text = _Product.Name;
            DataSet dsCategory = ProdAdmin.Get_CategoryByProductID(ItemID);
            StringBuilder Builder = new StringBuilder();
            foreach (System.Data.DataRow dr in dsCategory.Tables[0].Rows)
            {
                Builder.Append(ProdAdmin.GetCategorypath(dr["Name"].ToString(), dr["Parent1CategoryName"].ToString(), dr["Parent2CategoryName"].ToString()));
                Builder.Append("<br>");
            }
            this.BindProductView();
        }
        else
        {
            throw (new ApplicationException("Product Requested could not be found."));
        }
    }
Esempio n. 15
0
    /// <summary>
    /// Bind value for Particular Product
    /// </summary>
    public void BindEditData()
    {
        ProductAdmin _ProductAdmin = new ProductAdmin();
        Product _Products = new Product();

        //if edit mode then get all the values first
        if (ItemID > 0)
        {
            _Products = _ProductAdmin.GetByProductId(ItemID);
        }

        lblTitle.Text += _Products.Name;
        txtProductName.Text = _Products.Name;
        txtSEOTitle.Text = _Products.SEOTitle;
        txtSEOMetaKeywords.Text = _Products.SEOKeywords;
        txtSEOMetaDescription.Text = _Products.SEODescription;
        txtSEOUrl.Text = _Products.SEOURL;
        ctrlHtmlDescription.Html = _Products.Description;
        txtshortdescription.Text = _Products.ShortDescription;
        ctrlHtmlPrdFeatures.Html = _Products.FeaturesDesc;
        ctrlHtmlProdInfo.Html = _Products.AdditionalInformation;
        ctrlHtmlPrdSpec.Html = _Products.Specifications;
    }
    private void Bind()
    {
        //Create Instance for Product Admin and Product entity
        ZNode.Libraries.Admin.ProductAdmin ProdAdmin = new ProductAdmin();
        Product _Product = ProdAdmin.GetByProductId(ItemID);

        if (_Product != null)
        {
            ctrlHtmlPrdFeatures.Html = _Product.FeaturesDesc;
            ctrlHtmlPrdSpec.Html = _Product.Specifications;
            CtrlHtmlProdInfo.Html = _Product.AdditionalInformation;
            lblTitle.Text += "\"" + _Product.Name + "\"";
        }
    }
Esempio n. 17
0
    /// <summary>
    /// Submit Button Click Event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        #region Declarations
        SKUAdmin skuAdminAccess = new SKUAdmin();
        ProductAdmin productAdmin = new ProductAdmin();
        SKUAttribute skuAttribute = new SKUAttribute();
        SKU sku = new SKU();
        ProductCategory productCategory = new ProductCategory();
        ProductCategoryAdmin  productCategoryAdmin=new ProductCategoryAdmin();
        Product product = new Product();
        System.IO.FileInfo fileInfo=null;
        bool retVal = false;

        //check if category was selected
        if (CategoryTreeView.CheckedNodes.Count > 0)
        {
            lblCategoryError.Visible = false;
        }
        else
        {
            lblCategoryError.Visible = true;
            return;
        }

        #endregion

        #region Set Product Properties

        //passing Values
        product.ProductID = ItemID;
        product.PortalID = ZNodeConfigManager.SiteConfig.PortalID;

        //if edit mode then get all the values first
        if (ItemID > 0)
        {
            product = productAdmin.GetByProductId(ItemID);

            if (ViewState["productSkuId"] != null)
            {
                sku.SKUID = int.Parse(ViewState["productSkuId"].ToString());
            }
        }

        //General Info
        product.Name = txtProductName.Text;
        product.ImageFile = txtimagename.Text;
        product.ProductNum = txtProductNum.Text;
        product.PortalID = ZNodeConfigManager.SiteConfig.PortalID;

        if (ProductTypeList.SelectedIndex != -1)
        {
            product.ProductTypeID = Convert.ToInt32(ProductTypeList.SelectedValue);
        }
        else
        {
            //"Please add a product type before you add a new product";
        }
        //MANUFACTURER
        if (ManufacturerList.SelectedIndex != -1)
        {
            if (ManufacturerList.SelectedItem.Text.Equals("No Manufacturer Selected"))
            {
                product.ManufacturerID = null;
            }
            else
            {
                product.ManufacturerID = Convert.ToInt32(ManufacturerList.SelectedValue);
            }
        }

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

        product.DownloadLink = txtDownloadLink.Text.Trim();
        product.ShortDescription = txtshortdescription.Text;
        product.Description = ctrlHtmlText.Html;
        product.RetailPrice = Convert.ToDecimal(txtproductRetailPrice.Text);

        if (txtproductSalePrice.Text.Trim().Length > 0)
        {
            product.SalePrice = Convert.ToDecimal(txtproductSalePrice.Text.Trim());
        }
        else { product.SalePrice = null; }

        if (txtProductWholeSalePrice.Text.Trim().Length > 0)
        {
            product.WholesalePrice = Convert.ToDecimal(txtProductWholeSalePrice.Text.Trim());
        }
        else { product.WholesalePrice = null; }

        //Quantity Available
        product.QuantityOnHand = Convert.ToInt32(txtProductQuantity.Text);
        if (txtReOrder.Text.Trim().Length > 0)
        {
            product.ReorderLevel = Convert.ToInt32(txtReOrder.Text);
        }
        else
        {
            product.ReorderLevel = null;
        }
        if(txtMaxQuantity.Text.Equals(""))
        {
            product.MaxQty = 10;
        }
        else
        {
            product.MaxQty = Convert.ToInt32(txtMaxQuantity.Text);
        }

        // Display Settings
        product.MasterPage = ddlPageTemplateList.SelectedItem.Text;
        product.DisplayOrder = int.Parse(txtDisplayOrder.Text.Trim());

        // Tax Settings
        if(ddlTaxClass.SelectedIndex != -1)
            product.TaxClassID = int.Parse(ddlTaxClass.SelectedValue);

        //Shipping Option setting
        product.ShippingRuleTypeID = Convert.ToInt32(ShippingTypeList.SelectedValue);
        product.FreeShippingInd = chkFreeShippingInd.Checked;
        product.ShipSeparately = chkShipSeparately.Checked;

        if (txtProductWeight.Text.Trim().Length > 0)
        {
            product.Weight = Convert.ToDecimal(txtProductWeight.Text.Trim());
        }
        else { product.Weight = null; }

        //Product Height - Which will be used to determine the shipping cost
        if (txtProductHeight.Text.Trim().Length > 0)
        {
            product.Height = decimal.Parse(txtProductHeight.Text.Trim());
        }
        else { product.Height = null; }

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

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

        //Stock
        DataSet MyAttributeTypeDataSet = productAdmin.GetAttributeTypeByProductTypeID(int.Parse(ProductTypeList.SelectedValue));
        if (MyAttributeTypeDataSet.Tables[0].Rows.Count == 0)
        {
            product.SKU = txtProductSKU.Text.Trim();
            product.QuantityOnHand = Convert.ToInt32(txtProductQuantity.Text);
        }
        else
        {
            //SKU
            sku.ProductID = ItemID;
            sku.QuantityOnHand = Convert.ToInt32(txtProductQuantity.Text);
            sku.SKU = txtProductSKU.Text.Trim();
            sku.ActiveInd = true;
            product.SKU = txtProductSKU.Text.Trim();
            product.QuantityOnHand = 0; //Reset quantity available in the Product table,If SKU is selected
        }

        product.ImageAltTag = txtImageAltTag.Text.Trim();
        #endregion

        #region Image Validation

        // Validate image
        if ((ItemID == 0 || RadioProductNewImage.Checked == true) && UploadProductImage.PostedFile.FileName.Length > 0)
        {
            //Check for Product Image
            fileInfo = new System.IO.FileInfo(UploadProductImage.PostedFile.FileName);

            if (fileInfo != null)
            {
              product.ImageFile = fileInfo.Name;
              sku.SKUPicturePath = fileInfo.Name;
            }
        }
        #endregion

        #region Database & Image Updates

        //set update date
        product.UpdateDte = System.DateTime.Now;

        //create transaction
        TransactionManager tranManager = ConnectionScope.CreateTransaction();

        try
        {
            if (ItemID > 0) //PRODUCT UPDATE
            {
                //Update product Sku and Product values
                if (MyAttributeTypeDataSet.Tables[0].Rows.Count > 0) //If ProductType has SKU's
                {
                    if (sku.SKUID > 0) //For this product already SKU if on exists
                    {
                        sku.UpdateDte = System.DateTime.Now;

                        // Check whether Duplicate attributes is created
                        string Attributes = String.Empty;

                        DataSet MyAttributeTypeDataSet1 = productAdmin.GetAttributeTypeByProductTypeID(ProductTypeId);

                        foreach (DataRow MyDataRow in MyAttributeTypeDataSet1.Tables[0].Rows)
                        {
                            System.Web.UI.WebControls.DropDownList lstControl = (System.Web.UI.WebControls.DropDownList)ControlPlaceHolder.FindControl("lstAttribute" + MyDataRow["AttributeTypeId"].ToString());

                            int selValue = int.Parse(lstControl.SelectedValue);

                            Attributes += selValue.ToString() + ",";
                        }

                        // Split the string
                        string Attribute = Attributes.Substring(0, Attributes.Length - 1);

                        // To check SKU combination is already exists.
                        bool RetValue = skuAdminAccess.CheckSKUAttributes(ItemID, sku.SKUID, Attribute);

                        if (!RetValue)
                        {
                            //then Update the database with new property values
                            retVal = productAdmin.Update(product, sku);
                        }
                        else
                        {
                            //Throw error if duplicate attribute
                            lblMsg.Text = "This Attribute combination already exists for this product. Please select different combination.";
                            return;
                        }
                    }
                    else
                    {
                        retVal = productAdmin.Update(product);
                        //If Product doesn't have any SKUs yet,then create new SKU in the database
                        skuAdminAccess.Add(sku);
                    }
                }
                else
                {
                    retVal = productAdmin.Update(product);
                    // If User selectes Default product type for this product,
                    // then Remove all the existing SKUs for this product
                    skuAdminAccess.DeleteByProductId(ItemID);
                }

                if (!retVal) { throw (new ApplicationException()); }

                // Delete existing categories
                productAdmin.DeleteProductCategories(ItemID);

                // Add Product Categories
                foreach (TreeNode Node in CategoryTreeView.CheckedNodes)
                {
                    ProductCategory prodCategory = new ProductCategory();
                    ProductAdmin prodAdmin = new ProductAdmin();

                    prodCategory.CategoryID = int.Parse(Node.Value);
                    prodCategory.ProductID = ItemID;
                    prodAdmin.AddProductCategory(prodCategory);
                }

                // Delete existing SKUAttributes
                skuAdminAccess.DeleteBySKUId(sku.SKUID);

                // Add SKU Attributes
                foreach (DataRow MyDataRow in MyAttributeTypeDataSet.Tables[0].Rows)
                {
                    System.Web.UI.WebControls.DropDownList lstControl = (System.Web.UI.WebControls.DropDownList)ControlPlaceHolder.FindControl("lstAttribute" + MyDataRow["AttributeTypeId"].ToString());

                    int selValue = int.Parse(lstControl.SelectedValue);

                    if (selValue > 0)
                    {
                        skuAttribute.AttributeId = selValue;
                    }

                    skuAttribute.SKUID = sku.SKUID;

                    skuAdminAccess.AddSKUAttribute(skuAttribute);

                }

            }
            else // PRODUCT ADD
            {
                product.ActiveInd = true;

                // Add Product/SKU
                if (MyAttributeTypeDataSet.Tables[0].Rows.Count > 0)
                {
                    //if ProductType has SKUs, then insert sku with Product
                    retVal = productAdmin.Add(product, sku, out _ProductID, out SKUId);
                }
                else
                {
                    retVal = productAdmin.Add(product, out _ProductID); //if ProductType is Default
                }

                if (!retVal) { throw (new ApplicationException()); }

                // Add Category List for the Product
                foreach (TreeNode Node in CategoryTreeView.CheckedNodes)
                {
                    ProductCategory prodCategory = new ProductCategory();
                    ProductAdmin prodAdmin = new ProductAdmin();

                    prodCategory.CategoryID = int.Parse(Node.Value);
                    prodCategory.ProductID = _ProductID;
                    prodAdmin.AddProductCategory(prodCategory);
                }

                // Add SKU Attributes
                foreach (DataRow MyDataRow in MyAttributeTypeDataSet.Tables[0].Rows)
                {
                    System.Web.UI.WebControls.DropDownList lstControl = (System.Web.UI.WebControls.DropDownList)ControlPlaceHolder.FindControl("lstAttribute" + MyDataRow["AttributeTypeId"].ToString());

                    int selValue = int.Parse(lstControl.SelectedValue);

                    if (selValue > 0)
                    {
                        skuAttribute.AttributeId = selValue;
                    }

                    skuAttribute.SKUID = SKUId;

                    skuAdminAccess.AddSKUAttribute(skuAttribute);
                }

                ZNode.Libraries.Admin.ProductViewAdmin imageAdmin = new ProductViewAdmin();
                ZNode.Libraries.DataAccess.Entities.ProductImage productImage = new ProductImage();

                productImage.Name = txtimagename.Text;
                productImage.ActiveInd = false;
                productImage.ShowOnCategoryPage = false;
                productImage.ProductID = _ProductID;
                productImage.ProductImageTypeID = 1;
                productImage.DisplayOrder = 500;
                productImage.ImageAltTag = txtImageAltTag.Text.Trim();
                productImage.AlternateThumbnailImageFile = txtImageAltTag.Text.Trim();

                if (fileInfo != null)
                {
                    productImage.ImageFile = fileInfo.Name;
                }

                imageAdmin.Insert(productImage);
            }

            // Commit transaction
            tranManager.Commit();
        }
        catch // error occurred so rollback transaction
        {
            if (tranManager.IsOpen)
                tranManager.Rollback();

            lblMsg.Text = "Unable to update product. Please try again.";
            return;
        }

        // Upload File if this is a new product or the New Image option was selected for an existing product
        if (RadioProductNewImage.Checked || ItemID == 0)
        {
            if (fileInfo != null)
            {
                UploadProductImage.SaveAs(Server.MapPath(ZNodeConfigManager.EnvironmentConfig.OriginalImagePath + fileInfo.Name));

                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemLargeWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.LargeImagePath));
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemThumbnailWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.ThumbnailImagePath));
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemMediumWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.MediumImagePath));
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemSmallWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.SmallImagePath));
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemSwatchWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.SwatchImagePath));
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemCrossSellWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.CrossSellImagePath));
            }
        }

        #endregion

        #region Redirect to next page
        //Redirect to next page
        if (ItemID > 0)
        {
            string ViewLink = "~/admin/secure/catalog/product/view.aspx?itemid=" + ItemID.ToString();
            Response.Redirect(ViewLink);
        }
        else
        {
            string NextLink = "~/admin/secure/catalog/product/view.aspx?itemid=" + _ProductID.ToString();
            Response.Redirect(NextLink);
        }
        #endregion
    }
Esempio n. 18
0
    /// <summary>
    /// Bind edit data fields
    /// </summary>
    private void BindData()
    {
        ProductAdmin productTierAdmin = new ProductAdmin();
        ProductTier productTier = productTierAdmin.GetByProductTierId(productTierID);

        if (productTier != null)
        {
            txtPrice.Text = productTier.Price.ToString("N");
            txtTierStart.Text = productTier.TierStart.ToString();
            txtTierEnd.Text = productTier.TierEnd.ToString();
            if (productTier.ProfileID.HasValue)
                ddlProfiles.SelectedValue = productTier.ProfileID.Value.ToString();
        }
    }
Esempio n. 19
0
    /// <summary>
    /// Bind control display based on properties set-Dynamically adds DropDownList for Each AttributeType
    /// </summary>
    public void Bind(int productTypeID)
    {
        ProductTypeId = productTypeID;

        //Bind Attributes
        ProductAdmin adminAccess = new ProductAdmin();

        DataSet MyDataSet = adminAccess.GetAttributeTypeByProductTypeID(productTypeID);

        //Repeat until Number of Attributetypes for this Product
        foreach (DataRow dr in MyDataSet.Tables[0].Rows)
        {
            //Get all the Attribute for this Attribute
            DataSet _AttributeDataSet = new DataSet();
            _AttributeDataSet = adminAccess.GetByAttributeTypeID(int.Parse(dr["attributetypeid"].ToString()));
            DataView dv = new DataView(_AttributeDataSet.Tables[0]);
            //Create Instance for the DropDownlist
            System.Web.UI.WebControls.DropDownList lstControl = new DropDownList();
            lstControl.ID = "lstAttribute" + dr["AttributeTypeId"].ToString();

            ListItem li = new ListItem(dr["Name"].ToString(), "0");
            li.Selected = true;
            dv.Sort = "DisplayOrder ASC";
            lstControl.DataSource = dv;//_AttributeDataSet;
            lstControl.DataTextField = "Name";
            lstControl.DataValueField = "AttributeId";
            lstControl.DataBind();
            lstControl.Items.Insert(0, li);

            if (!Convert.ToBoolean(dr["IsPrivate"]))
            {
                //Add the Control to Place Holder
                ControlPlaceHolder.Controls.Add(lstControl);

                RequiredFieldValidator FieldValidator = new RequiredFieldValidator();
                FieldValidator.ID = "Validator" + dr["AttributeTypeId"].ToString();
                FieldValidator.ControlToValidate = "lstAttribute" + dr["AttributeTypeId"].ToString();
                FieldValidator.ErrorMessage = "Select " + dr["Name"].ToString();
                FieldValidator.Display = ValidatorDisplay.Dynamic;
                FieldValidator.CssClass = "Error";
                FieldValidator.InitialValue = "0";

                ControlPlaceHolder.Controls.Add(FieldValidator);
                Literal lit1 = new Literal();
                lit1.Text = "&nbsp;&nbsp;";
                ControlPlaceHolder.Controls.Add(lit1);
            }

        }

        if (MyDataSet.Tables[0].Rows.Count == 0)
        {
            DivAttributes.Visible = false;
            pnlquantity.Visible = true;
            pnlSupplier.Visible = true;
        }
        else
        {
            DivAttributes.Visible = true;
            pnlquantity.Visible = false;
            pnlSupplier.Visible = false;
        }
    }
Esempio n. 20
0
    protected DataSet BindSearchData()
    {
        #region Local Variables
        string Attributes = String.Empty;
        string AttributeList = string.Empty;
        DataSet MyDatas = new DataSet();
        SKUAdmin _SkuAdmin = new SKUAdmin();
        ProductAdmin _adminAccess = new ProductAdmin();
        #endregion

        productId = Convert.ToInt16(lstProduct.SelectedValue);

        if (productId != 0)
        {
            DataSet ds = _adminAccess.GetProductDetails(productId);

            //Check for Number of Rows
            if (ds.Tables[0].Rows.Count != 0)
            {
                //Check For Product Type
                productTypeID = int.Parse(ds.Tables[0].Rows[0]["ProductTypeId"].ToString());
            }

            //GetAttribute for this ProductType
            DataSet MyAttributeTypeDataSet = _adminAccess.GetAttributeTypeByProductTypeID(productTypeID);

            foreach (DataRow MyDataRow in MyAttributeTypeDataSet.Tables[0].Rows)
            {
                System.Web.UI.WebControls.DropDownList lstControl = (System.Web.UI.WebControls.DropDownList)ControlPlaceHolder.FindControl("lstAttribute" + MyDataRow["AttributeTypeId"].ToString());

                if (lstControl != null)
                {
                    int selValue = int.Parse(lstControl.SelectedValue);

                    if (selValue > 0)
                    {
                        Attributes += selValue.ToString() + ",";
                    }
                }
            }

            if (Attributes != "")
            {
                // Split the string
                AttributeList = Attributes.Substring(0, Attributes.Length - 1);
            }
        }

        if (Attributes.Length == 0 && productId == 0)
        {
            MyDatas = _SkuAdmin.GetallSkuData();
        }
        else
        {
            MyDatas = _SkuAdmin.GetBySKUAttributes(productId, AttributeList);
        }

        return MyDatas;
    }
Esempio n. 21
0
    /// <summary>
    /// Submit Button Click Event - Fires when Submit button is triggered
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ProductAdmin productAdmin = new ProductAdmin();
        Product product = new Product();
        string mappedSEOUrl = "";

        // If edit mode then get all the values first
        if (ItemID > 0)
        {
            product = productAdmin.GetByProductId(ItemID);

            if (product.SEOURL != null)
                mappedSEOUrl = product.SEOURL;
        }

        // Set properties
        product.SEOTitle = txtSEOTitle.Text.Trim();
        product.SEOKeywords = txtSEOMetaKeywords.Text.Trim();
        product.SEODescription = txtSEOMetaDescription.Text.Trim();
        product.SEOURL = null;

        if (txtSEOUrl.Text.Trim().Length > 0)
        {
            product.SEOURL = txtSEOUrl.Text.Trim().Replace(" ", "-");
        }

        bool status = false;

        // create transaction
        TransactionManager tranManager = ConnectionScope.CreateTransaction();

        try
        {
            if (ItemID > 0) //PRODUCT UPDATE
            {
                status = productAdmin.Update(product);
            }

        }
        catch (Exception)
        {
            //error occurred so rollback transaction
            tranManager.Rollback();
            lblError.Text = "Unable to update product SEO settings. Please try again.";
            return;
        }

        if (status)
        {

            UrlRedirectAdmin urlRedirectAdmin = new UrlRedirectAdmin();
            bool retval = false;

            try
            {
                retval = urlRedirectAdmin.UpdateUrlRedirectTable(SEOUrlType.Product, mappedSEOUrl, product.SEOURL, ItemID.ToString(), chkAddURLRedirect.Checked);
            }
            catch
            {
                // error occurred so rollback transaction
                tranManager.Rollback();

                lblError.Text = "The SEO Friendly URL you entered is already in use on another page. Please select another name for your URL";

                return;
            }

            if (retval)
            {
                //Commit transaction
                tranManager.Commit();

                Response.Redirect(ManagePageLink + ItemID);
            }
            else
            {
                lblError.Text = "Could not update the product SEO Url. Please try again.";
            }
        }
        else
        {
            lblError.Text = "Unable to update product SEO settings. Please try again.";
        }
    }
Esempio n. 22
0
    /// <summary>
    /// Search a Product by name,productnumber,sku,manufacturer,category,producttype
    /// </summary>
    private void BindSearchProduct()
    {
        ProductAdmin prodadmin = new ProductAdmin();
        DataSet ds = prodadmin.SearchProduct(txtproductname.Text.Trim(), txtproductnumber.Text.Trim(), txtsku.Text.Trim(), dmanufacturer.SelectedValue, dproducttype.SelectedValue, dproductcategory.SelectedValue);

        if (ds.Tables[0].Rows.Count > 0)
        {
            pnlProductList.Visible = true;
            uxGrid.DataSource = ds;
            uxGrid.DataBind();
        }
        else { pnlProductList.Visible = false; }
    }
Esempio n. 23
0
 private void BindProductName()
 {
     ProductAdmin ProductAdminAccess = new ProductAdmin();
     Product entity = ProductAdminAccess.GetByProductId(ItemId);
     if (entity != null)
     {
         lblTitle.Text = lblTitle.Text + " for \"" + entity.Name + "\"";
     }
 }
    /// <summary>
    /// Submit Button Click Event - Fires when Submit button is triggered
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ProductAdmin _ProductAdmin = new ProductAdmin();
        Product _product = new Product();

        //if edit mode then get all the values first
        if (ItemID > 0)
        {
            _product = _ProductAdmin.GetByProductId(ItemID);

        }

        //Set properties
        //Display Settings
        _product.ActiveInd = CheckEnabled.Checked;
        _product.HomepageSpecial = CheckHomeSpecial.Checked;
        _product.InventoryDisplay = Convert.ToByte(false);
        _product.CallForPricing = CheckCallPricing.Checked;
        _product.NewProductInd = CheckNewItem.Checked;
        _product.FeaturedInd = ChkFeaturedProduct.Checked;

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

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

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

        bool status = false;

        try
        {
            if (ItemID > 0) //PRODUCT UPDATE
            {
                status = _ProductAdmin.Update(_product);
            }

            if (status)
            {
                Response.Redirect(ManagePageLink + ItemID);
            }
            else
            {
                lblError.Text = "Unable to update product advanced settings. Please try again.";
            }

        }
        catch (Exception)
        {
            lblError.Text = "Unable to update product advanced settings. Please try again.";
            return;
        }
    }
    /// <summary>
    /// 
    /// </summary>
    private void Bind()
    {
        //Create Instance for Product Admin and Product entity
        ZNode.Libraries.Admin.ProductAdmin ProdAdmin = new ProductAdmin();
        Product _product = ProdAdmin.GetByProductId(ItemID);

        if (_product != null)
        {
            //Display Settings
            CheckEnabled.Checked = _product.ActiveInd;
            CheckHomeSpecial.Checked = _product.HomepageSpecial;
            CheckCallPricing.Checked = _product.CallForPricing;
            ChkFeaturedProduct.Checked = _product.FeaturedInd;

            if (_product.NewProductInd.HasValue)
            {
                CheckNewItem.Checked = _product.NewProductInd.Value;
            }

            //Inventory Setting - Out of Stock Options
            if (_product.AllowBackOrder.HasValue && _product.TrackInventoryInd.HasValue)
            {
                if ((_product.TrackInventoryInd.Value) && (_product.AllowBackOrder.Value == false))
                {
                    InvSettingRadiobtnList.Items[0].Selected = true;
                }
                else if (_product.TrackInventoryInd.Value && _product.AllowBackOrder.Value)
                {
                    InvSettingRadiobtnList.Items[1].Selected = true;
                }
                else if ((_product.TrackInventoryInd.Value == false) && (_product.AllowBackOrder.Value == false))
                {
                    InvSettingRadiobtnList.Items[2].Selected = true;
                }
            }

            //Inventory Setting - Stock Messages
            txtInStockMsg.Text = _product.InStockMsg;
            txtOutofStock.Text = _product.OutOfStockMsg;
            txtBackOrderMsg.Text = _product.BackOrderMsg;

            if (_product.DropShipInd.HasValue)
                chkDropShip.Checked = _product.DropShipInd.Value;

            lblTitle.Text += "\"" + _product.Name + "\"";

            // Recurring Billing
            chkRecurringBillingInd.Checked = _product.RecurringBillingInd;
            pnlRecurringBilling.Visible = _product.RecurringBillingInd;
            ddlBillingPeriods.SelectedValue = _product.RecurringBillingPeriod;
            ddlBillingFrequency.SelectedValue = _product.RecurringBillingFrequency;
            txtSubscrptionCycles.Text = _product.RecurringBillingTotalCycles.GetValueOrDefault(0).ToString();
        }
    }
Esempio n. 26
0
    /// <summary>
    /// Binds the Sku Attributes for this Product
    /// </summary>
    /// <param name="productTypeID"></param>
    private void BindAttributes(int productTypeID)
    {
        SKUAdmin adminSKU = new SKUAdmin();
        ProductAdmin adminAccess = new ProductAdmin();

        if (ViewState["productSkuId"] != null)
        {
            //Get SKUID from the ViewState
            DataSet SkuDataSet = adminSKU.GetBySKUId(int.Parse(ViewState["productSkuId"].ToString()));
            DataSet MyDataSet = adminAccess.GetAttributeTypeByProductTypeID(productTypeID);

            foreach (DataRow dr in MyDataSet.Tables[0].Rows)
            {
                foreach (DataRow Dr in SkuDataSet.Tables[0].Rows)
                {
                    System.Web.UI.WebControls.DropDownList lstControl = (System.Web.UI.WebControls.DropDownList)ControlPlaceHolder.FindControl("lstAttribute" + dr["AttributeTypeId"].ToString());

                    if (lstControl != null)
                    {
                        lstControl.SelectedValue = Dr["Attributeid"].ToString();

                    }
                }
            }
        }
    }
Esempio n. 27
0
 /// <summary>
 /// Search a Product by name,productnumber,sku,manufacturer,category,producttype
 /// </summary>
 private void BindSearchProduct()
 {
     ProductAdmin prodadmin = new ProductAdmin();
     uxGrid.DataSource = prodadmin.SearchProduct(txtproductname.Text.Trim(), txtproductnumber.Text.Trim(), txtsku.Text.Trim(), dmanufacturer.SelectedValue, dproducttype.SelectedValue, dproductcategory.SelectedValue);
     uxGrid.DataBind();
 }
Esempio n. 28
0
    /// <summary>
    /// Bind Attributes List.
    /// </summary>
    protected void BindSkuAttributes()
    {
        // Set ProductId
        productId = Convert.ToInt16(lstProduct.SelectedValue);

        if (productId != 0)
        {
            ProductAdmin _adminAccess = new ProductAdmin();

            DataSet ds = _adminAccess.GetProductDetails(productId);

            //Check for Number of Rows
            if (ds.Tables[0].Rows.Count != 0)
            {
                //Check For Product Type
                productTypeID = int.Parse(ds.Tables[0].Rows[0]["ProductTypeId"].ToString());
            }

            DataSet MyDataSet = _adminAccess.GetAttributeTypeByProductTypeID(productTypeID);

            if (MyDataSet.Tables[0].Rows.Count > 0)
            {
                //Repeats until Number of AttributeType for this Product
                foreach (DataRow dr in MyDataSet.Tables[0].Rows)
                {
                    //Bind Attributes
                    DataSet _AttributeDataSet = _adminAccess.GetAttributesByAttributeTypeIdandProductID(int.Parse(dr["attributetypeid"].ToString()), productId);

                    System.Web.UI.WebControls.DropDownList lstControl = new DropDownList();
                    lstControl.ID = "lstAttribute" + dr["AttributeTypeId"].ToString();

                    ListItem li = new ListItem(dr["Name"].ToString(), "0");
                    li.Selected = true;

                    lstControl.DataSource = _AttributeDataSet;
                    lstControl.DataTextField = "Name";
                    lstControl.DataValueField = "AttributeId";
                    lstControl.DataBind();
                    lstControl.Items.Insert(0, li);

                    //Add Dynamic Attribute DropDownlist in the Placeholder
                    ControlPlaceHolder.Controls.Add(lstControl);

                    Literal lit1 = new Literal();
                    lit1.Text = "&nbsp;&nbsp;";
                    ControlPlaceHolder.Controls.Add(lit1);
                }

                pnlAttribteslist.Visible = true;
            }
            else
            {
                pnlAttribteslist.Visible = false;
            }
        }
        else
        {
            pnlAttribteslist.Visible = false;
        }
    }
Esempio n. 29
0
    private void Bind()
    {
        //Create Instance for Product Admin and Product entity
        ZNode.Libraries.Admin.ProductAdmin ProdAdmin = new ProductAdmin();
        Product _Product = ProdAdmin.GetByProductId(ItemID);

        if (_Product != null)
        {
            txtSEOTitle.Text = _Product.SEOTitle;
            txtSEOMetaKeywords.Text = _Product.SEOKeywords;
            txtSEOMetaDescription.Text = _Product.SEODescription;
            txtSEOUrl.Text = _Product.SEOURL;
            lblTitle.Text += "\"" + _Product.Name + "\"";
        }
    }
Esempio n. 30
0
    /// <summary>
    /// Submit Button Click event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ProductAdmin prodAdmin = new ProductAdmin();
        PromotionAdmin promotionAdmin = new ZNode.Libraries.Admin.PromotionAdmin();
        ZNode.Libraries.DataAccess.Entities.Promotion promotionEnity = null;

        if (ItemID > 0)
        {
            promotionEnity = promotionAdmin.GetByPromotionId(ItemID);
        }
        else
        {
            promotionEnity = new ZNode.Libraries.DataAccess.Entities.Promotion();
        }

        // set properties
        promotionEnity.ProductID = null;
        promotionEnity.SKUID = null;
        promotionEnity.AddOnValueID = null;
        promotionEnity.AccountID = null;

        // General Info section properties
        promotionEnity.Name = PromotionName.Text.Trim();
        promotionEnity.Description = Description.Text.Trim();
        promotionEnity.StartDate = Convert.ToDateTime(StartDate.Text.Trim());
        promotionEnity.EndDate = Convert.ToDateTime(EndDate.Text.Trim());
        promotionEnity.DisplayOrder = int.Parse(DisplayOrder.Text.Trim());

        // DiscountType
        if (DiscountType.SelectedIndex != -1)
        {
            promotionEnity.DiscountTypeID = promotionAdmin.GetDiscountTypeId(DiscountType.SelectedItem.Text, DiscountType.SelectedValue);
        }

        decimal decDiscountAmt = Convert.ToDecimal(Discount.Text);
        promotionEnity.OrderMinimum = Convert.ToDecimal(OrderMinimum.Text);

        string className = DiscountType.SelectedValue;

        // Product Level Promotions
        if (className.Equals("ZNodePromotionPercentOffProduct", StringComparison.OrdinalIgnoreCase)
                    || className.Equals("ZNodePromotionAmountOffProduct", StringComparison.OrdinalIgnoreCase))
        {
            promotionEnity.QuantityMinimum = int.Parse(ddlMinimumQty.SelectedValue);

            if (txtReqProductId.Text != "0")
                promotionEnity.ProductID = int.Parse(txtReqProductId.Text.Trim());
            else
            {
                promotionEnity.ProductID = prodAdmin.GetProductIdByName(txtRequiredProduct.Text.Trim());
            }
        }
        else if (className.Equals("ZNodePromotionPercentXifYPurchased", StringComparison.OrdinalIgnoreCase)
                    || className.Equals("ZNodePromotionAmountOffXifYPurchased", StringComparison.OrdinalIgnoreCase))
        {
            promotionEnity.QuantityMinimum = int.Parse(ddlMinimumQty.SelectedValue);
            promotionEnity.PromotionProductQty = int.Parse(ddlQuantity.SelectedValue);

            if (txtReqProductId.Text != "0")
                promotionEnity.ProductID = int.Parse(txtReqProductId.Text.Trim());
            else
                promotionEnity.ProductID = prodAdmin.GetProductIdByName(txtRequiredProduct.Text.Trim()); ;

            if (txtPromProductId.Text != "0")
                promotionEnity.PromotionProductID = int.Parse(txtPromProductId.Text.Trim());
            else
                promotionEnity.PromotionProductID = prodAdmin.GetProductIdByName(txtPromoProduct.Text.Trim()); ;
        }

        // Set Discount field
        promotionEnity.Discount = Convert.ToDecimal(Discount.Text);

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

        // Coupon Info section
        promotionEnity.CouponInd = chkCouponInd.Checked;
        if (chkCouponInd.Checked)
        {
            promotionEnity.CouponCode = CouponCode.Text;
            promotionEnity.CouponQuantityAvailable = int.Parse(Quantity.Text);
            promotionEnity.PromotionMessage = txtPromotionMessage.Text;
        }
        else
        {
            promotionEnity.CouponCode = "";
            promotionEnity.PromotionMessage = "";
        }

        bool check = false;

        if (ItemID > 0)
        {
            check = promotionAdmin.UpdatePromotion(promotionEnity);
        }
        else
        {
            check = promotionAdmin.AddPromotion(promotionEnity);
        }

        if (check)
        {
            // Replace the Promtion Cache application object with new active promotions
            HttpContext.Current.Application["PromotionCache"] = promotionAdmin.GetActivePromotions();

            Response.Redirect("list.aspx");
        }
        else
        {
            lblError.Text = "An error occurred while updating. Please try again.";
        }
    }
Esempio n. 31
0
    /// <summary>
    /// Search a Product for a Keyword
    /// </summary>
    protected void BindSearchData()
    {
        ZNode.Libraries.Admin.ProductAdmin _ProdAdmin =new ProductAdmin();

           uxGrid.DataSource = _ProdAdmin.FindProducts(ZNodeConfigManager.SiteConfig.PortalID, txtproductname.Text.Trim());
           uxGrid.DataBind();
    }
Esempio n. 32
0
    /// <summary>
    /// Bind Edit mode fields
    /// </summary>
    public void BindEditData()
    {
        ZNode.Libraries.Admin.PromotionAdmin couponAdmin = new ZNode.Libraries.Admin.PromotionAdmin();
        ZNode.Libraries.DataAccess.Entities.Promotion promotion = couponAdmin.DeepLoadByPromotionId(ItemID);

        if (promotion != null)
        {
            // General Section
            PromotionName.Text = promotion.Name;
            Description.Text = promotion.Description;
            StartDate.Text = promotion.StartDate.ToShortDateString();
            EndDate.Text = promotion.EndDate.ToShortDateString();
            DisplayOrder.Text = promotion.DisplayOrder.ToString();

            // Discount
            Discount.Text = promotion.Discount.ToString();
            DiscountType.SelectedValue = promotion.DiscountTypeIDSource.ClassName.ToString();
            ToggleDiscountValidator();

            if (!string.IsNullOrEmpty(promotion.DiscountTypeIDSource.ClassName))
            {
                if (promotion.ProfileID.HasValue)
                {
                    ddlProfileTypes.SelectedValue = promotion.ProfileID.Value.ToString();
                }

                if (promotion.ProductID.HasValue)
                {
                    txtReqProductId.Text = promotion.ProductID.Value.ToString();
                    txtRequiredProduct.Text = promotion.ProductIDSource.Name;
                }

                if (promotion.PromotionProductID.HasValue)
                {
                    txtPromProductId.Text = promotion.PromotionProductID.Value.ToString();

                    ProductAdmin prodAdmin = new ProductAdmin();
                    txtPromoProduct.Text = prodAdmin.GetProductName(promotion.PromotionProductID.Value);

                    ddlQuantity.SelectedValue = promotion.PromotionProductQty.GetValueOrDefault(1).ToString();

                }

                txtPromProductId.Text = promotion.PromotionProductID.GetValueOrDefault(0).ToString();
                ddlQuantity.SelectedValue = promotion.PromotionProductQty.GetValueOrDefault(0).ToString();
                ddlMinimumQty.SelectedValue = promotion.QuantityMinimum.GetValueOrDefault(1).ToString();

                // Coupon Info
                chkCouponInd.Checked = promotion.CouponInd;
                if (chkCouponInd.Checked)
                    pnlCouponInfo.Visible = true;

                CouponCode.Text = promotion.CouponCode;
                txtPromotionMessage.Text = promotion.PromotionMessage;

                if (promotion.CouponQuantityAvailable.HasValue)
                    Quantity.Text = promotion.CouponQuantityAvailable.Value.ToString();
                if (promotion.OrderMinimum.HasValue)
                    OrderMinimum.Text = promotion.OrderMinimum.Value.ToString("N2");

                // Set page Title
                lblTitle.Text += promotion.Name;
            }
            else
            {

            }
        }
    }