예제 #1
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;
     }
 }
예제 #2
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."));
        }
    }
예제 #3
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();
        //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;
        }
    }
예제 #4
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."));
        }
    }
예제 #5
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;
    }
예제 #6
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.";
        }
    }
예제 #7
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 + "\"";
        }
    }
예제 #8
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)
        {
            ctrlHtmlPrdFeatures.Html = _Product.FeaturesDesc;
            ctrlHtmlPrdSpec.Html = _Product.Specifications;
            CtrlHtmlProdInfo.Html = _Product.AdditionalInformation;
            lblTitle.Text += "\"" + _Product.Name + "\"";
        }
    }
예제 #9
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();
        }
    }
예제 #12
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
    }
예제 #13
0
    /// <summary>
    /// Bind value for Particular Product
    /// </summary>
    public void BindEditData()
    {
        ProductAdmin productAdmin = new ProductAdmin();
        Product product = new Product();
        SKUAdmin skuAdmin = new SKUAdmin();

        if (ItemID > 0)
        {
            product = productAdmin.GetByProductId(ItemID);

            // General Information - Section1
            lblTitle.Text += product.Name;
            txtProductName.Text = product.Name;
            txtProductNum.Text = product.ProductNum;
            if (ProductTypeList.SelectedIndex != -1)
            {
                ProductTypeList.SelectedValue = product.ProductTypeID.ToString();
            }
            if (ManufacturerList.SelectedIndex != -1)
            {
                ManufacturerList.SelectedValue = product.ManufacturerID.ToString();
            }

            if (ddlSupplier.SelectedIndex != -1)
            {
                ddlSupplier.SelectedValue = product.SupplierID.ToString();
            }

            // Product Description and Image - Section2
            txtshortdescription.Text = product.ShortDescription;
            ctrlHtmlText.Html = product.Description;
            Image1.ImageUrl = ZNode.Libraries.Framework.Business.ZNodeConfigManager.EnvironmentConfig.MediumImagePath + product.ImageFile;
            // Displaying the Image file name in a textbox
            txtimagename.Text = product.ImageFile;
            txtImageAltTag.Text = product.ImageAltTag;

            // Product properties
            if(product.RetailPrice.HasValue)
                txtproductRetailPrice.Text = product.RetailPrice.Value.ToString("N");
            if (product.SalePrice.HasValue)
                txtproductSalePrice.Text = product.SalePrice.Value.ToString("N");
            if (product.WholesalePrice.HasValue)
                txtProductWholeSalePrice.Text = product.WholesalePrice.Value.ToString("N");
            txtDownloadLink.Text = product.DownloadLink;

            // Tax Classes
            if(product.TaxClassID.HasValue)
                ddlTaxClass.SelectedValue = product.TaxClassID.Value.ToString();

            // Category List
            this.BindEditCategoryList();

            //Display Settings
            txtDisplayOrder.Text = product.DisplayOrder.ToString();
            ddlPageTemplateList.SelectedValue = product.MasterPage;

            // Inventory
            DataSet MySKUDataSet = skuAdmin.GetByProductID(ItemID);
            if (MySKUDataSet.Tables[0].Rows.Count != 0)
            {
                ViewState["productSkuId"] = MySKUDataSet.Tables[0].Rows[0]["skuid"].ToString();
                txtProductSKU.Text = MySKUDataSet.Tables[0].Rows[0]["sku"].ToString();
                txtProductQuantity.Text = MySKUDataSet.Tables[0].Rows[0]["quantityonhand"].ToString();

                this.BindAttributes(product.ProductTypeID);
            }
            else
            {
                if (product.QuantityOnHand.HasValue)
                {
                    txtProductQuantity.Text = product.QuantityOnHand.Value.ToString();
                }
                if (product.ReorderLevel.HasValue)
                {
                    txtReOrder.Text = product.ReorderLevel.Value.ToString();
                }
                txtProductSKU.Text = product.SKU;
            }

            if (product.MaxQty.HasValue)
            {
                txtMaxQuantity.Text = product.MaxQty.Value.ToString();
            }

            // Shipping settings
            ShippingTypeList.SelectedValue = product.ShippingRuleTypeID.ToString();
            EnableValidators(); //This method will enable or disable validators based on the shippingtype
            if(product.FreeShippingInd.HasValue)
                chkFreeShippingInd.Checked = product.FreeShippingInd.Value;

            chkShipSeparately.Checked = product.ShipSeparately;

            if (product.Weight.HasValue)
                txtProductWeight.Text = product.Weight.Value.ToString("N2");

            if (product.Height.HasValue)
                txtProductHeight.Text = product.Height.Value.ToString("N2");

            if (product.Width.HasValue)
                txtProductWidth.Text = product.Width.Value.ToString("N2");

            if (product.Length.HasValue)
                txtProductLength.Text = product.Length.Value.ToString("N2");

            // Release the Resources
            MySKUDataSet.Dispose();
        }
    }
예제 #14
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);
        int Count = 0;

        //Check for Number of Rows
        if (ds.Tables[0].Rows.Count != 0)
        {
            //Bind ProductType,Manufacturer,Supplier
            lblProdType.Text = ds.Tables[0].Rows[0]["producttype name"].ToString();
            lblManufacturerName.Text = ds.Tables[0].Rows[0]["MANUFACTURER NAME"].ToString();

            //Check For Product Type
            productTypeID = int.Parse(ds.Tables[0].Rows[0]["ProductTypeId"].ToString());
            Count = prodAdmin.GetAttributeCount(int.Parse(ds.Tables[0].Rows[0]["ProductTypeId"].ToString()), ZNodeConfigManager.SiteConfig.PortalID);
            //Check product atributes count
            if (Count > 0)
            {
                tabProductDetails.Tabs[2].Enabled = true; // Enable Manage inventory tab
            }
            else
            {
                tabProductDetails.Tabs[2].Enabled = false;// Disable Manage inventory tab
            }
        }

        if (product != null)
        {
            //General Information
            lblProdName.Text = product.Name;
            lblProdNum.Text  =  product.ProductNum.ToString();
            if (Count > 0)
            {
                lblProductSKU.Text = "See Manage SKUs tab";
                lblQuantity.Text = "See Manage SKUs tab";
                lblReOrder.Text = "See Manage SKUs tab";
                lblSupplierName.Text = "See Manage SKUs tab";
            }
            else
            {
                lblProductSKU.Text = product.SKU;

                if(product.QuantityOnHand.HasValue)
                lblQuantity.Text = product.QuantityOnHand.Value.ToString();
                if(product.ReorderLevel.HasValue)
                lblReOrder.Text = product.ReorderLevel.Value.ToString();
                lblSupplierName.Text = ds.Tables[0].Rows[0]["Supplier Name"].ToString();
            }

            if (product.MaxQty.HasValue)
                lblMaxQuantity.Text = product.MaxQty.Value.ToString();

            //image
            if (product.ImageFile.Trim().Length > 0)
            {
                string ImageFilePath = ZNodeConfigManager.EnvironmentConfig.MediumImagePath + product.ImageFile;
                ItemImage.ImageUrl = ImageFilePath;
            }
            else
            {
                ItemImage.ImageUrl = ZNodeConfigManager.SiteConfig.ImageNotAvailablePath;
            }

            //Product Description and Features
            lblShortDescription.Text = product.ShortDescription;
            lblProductDescription.Text = product.Description;
            lblProductFeatures.Text = product.FeaturesDesc;
            lblproductspecification.Text = product.Specifications;
            lbladditionalinfo.Text = product.AdditionalInformation;
            lblDownloadLink.Text = product.DownloadLink;

            //Product Attributes
            if (product.RetailPrice.HasValue)
                lblRetailPrice.Text = product.RetailPrice.Value.ToString("c");
            if (product.WholesalePrice.HasValue)
                lblWholeSalePrice.Text = product.WholesalePrice.Value.ToString("c");
            lblSalePrice.Text = FormatPrice(product.SalePrice);
            lblWeight.Text = this.FormatProductWeight(product.Weight);
            if (product.Height.HasValue)
                lblHeight.Text = product.Height.Value.ToString("N2") + " " + ZNodeConfigManager.SiteConfig.DimensionUnit;
            if (product.Width.HasValue)
                lblWidth.Text = product.Width.Value.ToString("N2") + " " + ZNodeConfigManager.SiteConfig.DimensionUnit;
            if (product.Length.HasValue)
                lblLength.Text = product.Length.Value.ToString("N2") + " " + ZNodeConfigManager.SiteConfig.DimensionUnit;

            //Display Settings
            chkProductEnabled.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(bool.Parse(product.ActiveInd.ToString()));
            lblProdDisplayOrder.Text = product.DisplayOrder.ToString();
            chkIsSpecialProduct.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(this.DisplayVisible(product.HomepageSpecial));
            chkIsNewItem.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(this.DisplayVisible(product.NewProductInd));
            chkProductPricing.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(this.DisplayVisible(product.CallForPricing));
            chkproductInventory.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(this.DisplayVisible(product.InventoryDisplay));

            // Display Tax Class Name
            if (product.TaxClassID.HasValue)
            {

                TaxRuleAdmin taxRuleAdmin = new TaxRuleAdmin();
                TaxClass taxClass = taxRuleAdmin.GetByTaxClassID(product.TaxClassID.Value);

                if(taxClass != null)
                    lblTaxClass.Text = taxClass.Name;
            }

            // Recurring Billing
            imgRecurringBillingInd.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(this.DisplayVisible(product.RecurringBillingInd));
            lblBillingPeriod.Text = product.RecurringBillingPeriod;
            lblFrequency.Text = product.RecurringBillingFrequency;
            lblTotalCycles.Text = product.RecurringBillingTotalCycles.GetValueOrDefault(0).ToString();

            shipSeparatelyInd.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(product.ShipSeparately);
            lblMastePageName.Text = product.MasterPage;

            //seo
            lblSEODescription.Text = product.SEODescription;
            lblSEOKeywords.Text = product.SEOKeywords;
            lblSEOTitle.Text = product.SEOTitle;
            lblSEOURL.Text = product.SEOURL;

            //checking whether the image is active or not
            //ZNode.Libraries.Admin.ProductViewAdmin pp = new ProductViewAdmin();

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

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

            //Inventory Setting - Stock Messages
            lblInStockMsg.Text = product.InStockMsg;
            lblOutofStock.Text = product.OutOfStockMsg;
            lblBackOrderMsg.Text = product.BackOrderMsg;

            if (product.DropShipInd.HasValue)
            {
                IsDropShipEnabled.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(product.DropShipInd.Value);
            }
            else
            {
                IsDropShipEnabled.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(bool.Parse("false"));
            }
            //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>");
            }

            if (product.FeaturedInd)
            {
                FeaturedProduct.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(true);
            }
            else
            {
                FeaturedProduct.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(false);
            }
            lblProductCategories.Text = Builder.ToString();

            //Bind ShippingRule type
            if(product.ShippingRuleTypeID.HasValue)
            lblShippingRuleTypeName.Text = GetShippingRuleTypeName(product.ShippingRuleTypeID.Value);
            if (product.FreeShippingInd.HasValue)
                freeShippingInd.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(product.FreeShippingInd.Value);
            else
                freeShippingInd.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(false);

            //Bind Grid - Product Related Items
            this.BindRelatedItems();
            //this.BindImage();
            this.BindImageDatas();
            //Bind Grid - Product Addons
            BindProductAddons();
            //Bind Grid - Inventory
            BindSKU();
            //Tiered Pricing
            BindTieredPricing();
            //Digital Asset
            BindDigitalAssets();
            //Bind product highlights
            BindProductHighlights();
        }
        else
        {
            throw (new ApplicationException("Product Requested could not be found."));
        }
    }