예제 #1
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;
        }
    }
예제 #2
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;
    }
예제 #3
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();

                    }
                }
            }
        }
    }
예제 #4
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;
        }
    }
예제 #5
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;
        }
    }
예제 #6
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
    }
예제 #7
0
    /// <summary>
    /// Clear button click event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnClear_Click(object sender, EventArgs e)
    {
        ProductAdmin _adminAccess = new ProductAdmin();
        DataSet ds = _adminAccess.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());
        }

        // For Attribute value.
        string Attributes = String.Empty;

        //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());
            lstControl.SelectedIndex = 0;
        }

        this.BindSKU();
    }
예제 #8
0
    /// <summary>
    /// Bind Attributes List.
    /// </summary>
    protected void BindSkuAttributes()
    {
        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.GetAttributesByAttributeTypeIdandProductID(int.Parse(dr["attributetypeid"].ToString()),ItemId);

            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);
        }
    }
예제 #9
0
    /// <summary>
    /// Binds the Search data
    /// </summary>
    private void BindSearchData()
    {
        ProductAdmin adminAccess = new ProductAdmin();
        DataSet ds = adminAccess.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());
        }

        // For Attribute value.
        string Attributes = String.Empty;

        //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 length is more than zero.
        if (Attributes.Length > 0)
        {
            // Split the string
            string Attribute = Attributes.Substring(0, Attributes.Length - 1);

            if (Attribute.Length > 0)
            {
                SKUAdmin _SkuAdmin = new SKUAdmin();
                DataSet MyDatas = _SkuAdmin.GetBySKUAttributes(ItemId, Attribute);

                DataView Sku = new DataView(MyDatas.Tables[0]);
                Sku.Sort = "SKU";
                uxGridInventoryDisplay.DataSource = Sku;
                uxGridInventoryDisplay.DataBind();
            }
        }
        else
        {
            this.BindSKU();
        }
    }