示例#1
0
    /// <summary>
    /// Bind data to the drop down list
    /// </summary>
    public void BindDropDownData()
    {
        //Add the manufacturers to the drop-down list
        ManufacturerAdmin manuadmin = new ManufacturerAdmin();
        dmanufacturer.DataSource = manuadmin.GetAllByPortalID(ZNodeConfigManager.SiteConfig.PortalID);
        dmanufacturer.DataTextField = "Name";
        dmanufacturer.DataValueField = "ManufacturerID";
        dmanufacturer.DataBind();
        ListItem item = new ListItem("ALL", "0");
        dmanufacturer.Items.Insert(0, item);
        //making ALL as the default value of the drop-down list box
        dmanufacturer.SelectedIndex = 0;

        //Add Producttypes to the drop-down list
        ProductTypeAdmin producttypeadmin = new ProductTypeAdmin();
        dproducttype.DataSource = producttypeadmin.GetAllProductType(ZNodeConfigManager.SiteConfig.PortalID);
        dproducttype.DataTextField = "Name";
        dproducttype.DataValueField = "Producttypeid";
        dproducttype.DataBind();
        ListItem item1 = new ListItem("ALL", "0");
        dproducttype.Items.Insert(0, item1);
        dproducttype.SelectedIndex = 0;

        //Add Product categories to the drop-down list
        CategoryAdmin categoryadmin = new CategoryAdmin();
        dproductcategory.DataSource = categoryadmin.GetAllCategories(ZNodeConfigManager.SiteConfig.PortalID);
        dproductcategory.DataTextField = "Name";
        dproductcategory.DataValueField = "Categoryid";
        dproductcategory.DataBind();
        ListItem item2 = new ListItem("ALL", "0");
        dproductcategory.Items.Insert(0, item2);
        dproductcategory.SelectedIndex = 0;
    }
示例#2
0
        //Category Index
        public ActionResult Category()
        {
            var iplCate = new CategoryAdmin();
            var model   = iplCate.ListAll();

            return(View(model));
        }
示例#3
0
 /// <summary>
 /// Bind Search data
 /// </summary>
 protected void BindSearchData()
 {
     CategoryAdmin categoryAdmin = new CategoryAdmin();
     DataSet ds = categoryAdmin.GetCategoriesBySerachData(txtCategoryName.Text.Trim());
     DataView dv = new DataView(ds.Tables[0]);
     dv.Sort = "Name";
     uxGrid.DataSource = dv;
     uxGrid.DataBind();
 }
示例#4
0
    /// <summary>
    /// Bind data to the fields on the screen
    /// </summary>
    protected void BindData()
    {
        CategoryAdmin categoryAdmin = new CategoryAdmin();
        Category category = categoryAdmin.GetByCategoryId(ItemId);

        if (category != null)
        {
            ProductCategoryName = category.Name;
        }
        else
        {
            throw (new ApplicationException("Category Requested could not be found."));
        }
    }
示例#5
0
    /// <summary>
    /// Bind data to the fields on the edit screen
    /// </summary>
    protected void BindEditData()
    {
        CategoryAdmin categoryAdmin = new CategoryAdmin();
        Category category = categoryAdmin.GetByCategoryId(ItemId);

        if (category != null)
        {
            txtName.Text = category.Name;
            txtshortdescription.Text = category.ShortDescription;
            ctrlHtmlText.Html = category.Description;
            ParentCategoryID.SelectedValue = category.ParentCategoryID.ToString();
            DisplayOrder.Text = category.DisplayOrder.ToString();
            VisibleInd.Checked = category.VisibleInd;

            txtTitle.Text = category.Title;
            chkSubCategoryGridVisibleInd.Checked = category.SubCategoryGridVisibleInd;
            txtSEOMetaDescription.Text = category.SEODescription;
            txtSEOMetaKeywords.Text = category.SEOKeywords;
            txtSEOTitle.Text = category.SEOTitle;
            txtSEOURL.Text = category.SEOURL;
            Image1.ImageUrl = ZNode.Libraries.Framework.Business.ZNodeConfigManager.EnvironmentConfig.MediumImagePath + category.ImageFile;
            txtImageAltTag.Text = category.ImageAltTag;
            try
            {
                RowDropDown.SelectedIndex = Int32.Parse(category.Custom1);
            }
            catch (Exception e)
            { RowDropDown.SelectedIndex = 0; }
            try
            {
                ColumnDropDown.SelectedIndex = Int32.Parse(category.Custom2);

            }
            catch (Exception e)
            {
                ColumnDropDown.SelectedIndex = 0;

            }
            ddlPageTemplateList.SelectedValue = category.MasterPage;
        }
        else
        {
            throw (new ApplicationException("Category Requested could not be found."));
        }
    }
示例#6
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        Category category = new Category();
        category.CategoryID = ItemId;
        category.PortalID = ZNodeConfigManager.SiteConfig.PortalID;

        CategoryAdmin categoryAdmin = new CategoryAdmin();
        bool retval = categoryAdmin.Delete(category);

        if (retval)
        {
            Response.Redirect("~/admin/secure/catalog/product_category/list.aspx");
        }
        else
        {
            lblMsg.Text = "An error occurred and the category could not be deleted. Please ensure that this category does not contain sub-categories or products. If it does, then delete the sub-categories and products first.";
        }
    }
    /// <summary>
    /// Bind data to the fields on the edit screen
    /// </summary>
    protected void BindEditData()
    {
        CategoryAdmin categoryAdmin = new CategoryAdmin();
        Category category = categoryAdmin.GetByCategoryId(ItemId);

        if (category != null)
        {
            lblTitle.Text += category.Title;
            txtTitle.Text = category.Title;
            txtshortdescription.Text = category.ShortDescription;
            ctrlHtmlText.Html = category.Description;
            txtSEOMetaDescription.Text = category.SEODescription;
            txtSEOMetaKeywords.Text = category.SEOKeywords;
            txtSEOTitle.Text = category.SEOTitle;
            txtSEOURL.Text = category.SEOURL;
        }
        else
        {
            throw (new ApplicationException("Category Requested could not be found."));
        }
    }
示例#8
0
 public ActionResult CreateCat(Category collection)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var model = new CategoryAdmin();
             int res   = model.CreateCat(collection.Name, collection.Alias, collection.ParentID, collection.Order, collection.Status);
             if (res > 0)
             {
                 return(RedirectToAction("Category"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm mới không thành công");
             }
         }
         return(View(collection));
     }
     catch (Exception ex)
     {
         return(View());
     }
 }
示例#9
0
        // --------------
        // Index
        // --------------

        public async Task <IActionResult> Index(int id)
        {
            //if (!await _authorizationService.AuthorizeAsync(User, PermissionsProvider.ManageRoles))
            //{
            //    return Unauthorized();
            //}

            IEnumerable <CategoryAdmin> parents = null;

            if (id > 0)
            {
                parents = await _categoryStore.GetParentsByIdAsync(id);
            }

            _breadCrumbManager.Configure(builder =>
            {
                builder.Add(S["Home"], home => home
                            .Action("Index", "Admin", "Plato.Admin")
                            .LocalNav())
                .Add(S["Docs"], docs => docs
                     .Action("Index", "Admin", "Plato.Docs")
                     .LocalNav());

                if (parents == null)
                {
                    builder.Add(S["Categories"]);
                }
                else
                {
                    builder.Add(S["Categories"], c => c
                                .Action("Index", "Admin", "Plato.Docs.Categories", new RouteValueDictionary {
                        ["Id"] = 0
                    })
                                .LocalNav()
                                );
                    foreach (var parent in parents)
                    {
                        if (parent.Id != id)
                        {
                            builder.Add(S[parent.Name], channel => channel
                                        .Action("Index", "Admin", "Plato.Docs.Categories", new RouteValueDictionary {
                                ["Id"] = parent.Id
                            })
                                        .LocalNav()
                                        );
                        }
                        else
                        {
                            builder.Add(S[parent.Name]);
                        }
                    }
                }
            });

            // Get optional current category
            CategoryAdmin currentCategory = null;

            if (id > 0)
            {
                currentCategory = await _categoryStore.GetByIdAsync(id);
            }

            // Return view
            return(View((LayoutViewModel)await _viewProvider.ProvideIndexAsync(currentCategory ?? new CategoryAdmin(), this)));
        }
示例#10
0
 /// <summary>
 /// Bind data to grid
 /// </summary>
 private void BindGridData()
 {
     CategoryAdmin categoryAdmin = new CategoryAdmin();
     DataSet ds = categoryAdmin.GetAllCategories(ZNodeConfigManager.SiteConfig.PortalID).ToDataSet(true);
     DataView dv = new DataView(ds.Tables[0]);
     dv.Sort = "Name";
     uxGrid.DataSource = dv;
     uxGrid.DataBind();
 }
示例#11
0
    protected void uxGrid_Sorting(object sender, GridViewSortEventArgs e)
    {
        if (IsSearchEnabled)
        {
            CategoryAdmin categoryAdmin = new CategoryAdmin();
            DataSet ds = categoryAdmin.GetCategoriesBySerachData(txtCategoryName.Text.Trim());
            uxGrid.DataSource = SortDataTable(ds, e.SortExpression, true);
            uxGrid.DataBind();
        }
        else
        {
            CategoryAdmin categoryAdmin = new CategoryAdmin();
            DataSet categoryList = categoryAdmin.GetAllCategories(ZNodeConfigManager.SiteConfig.PortalID).ToDataSet(true);
            uxGrid.DataSource = SortDataTable(categoryList, e.SortExpression, true);
            uxGrid.DataBind();
        }

        if (GetSortDirection() == "DESC")
        {
            e.SortDirection = SortDirection.Descending;
        }
        else
        {
            e.SortDirection = SortDirection.Ascending;
        }
    }
示例#12
0
    /// <summary>
    /// Bind category list box
    /// </summary>
    protected void BindListData()
    {
        CategoryAdmin categoryAdmin = new CategoryAdmin();
        CategoryHelper categoryHelper = new CategoryHelper();
        DataSet dsCategory=categoryHelper.GetCategoryHierarchy(ZNodeConfigManager.SiteConfig.PortalID);

        ListItem defaultitem = new ListItem("NONE - Add Category to Root Level", "0");
        defaultitem.Selected = true;
        ParentCategoryID.Items.Add(defaultitem);

        foreach (System.Data.DataRow dr in dsCategory.Tables[0].Rows)
        {
            ListItem item = new ListItem();
            item.Text = CategoryAdmin.GetCategoryPath(dr["Name"].ToString(), dr["Parent1CategoryName"].ToString(), dr["Parent2CategoryName"].ToString());
            item.Value = dr["categoryid"].ToString();
            ParentCategoryID.Items.Add(item);
        }
    }
示例#13
0
    /// <summary>
    /// Submit button click event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        System.IO.FileInfo fileInfo = null;
        CategoryAdmin categoryAdmin = new CategoryAdmin();
        Category category = new Category();
        string mappedSEOUrl = "";

        if (ItemId > 0)
        {
            category = categoryAdmin.GetByCategoryId(ItemId);

            if (category.SEOURL != null)
                mappedSEOUrl = category.SEOURL;
        }
        category.CategoryID = ItemId;
        category.PortalID = ZNodeConfigManager.SiteConfig.PortalID ;
        category.Name = txtName.Text;
        category.ShortDescription = txtshortdescription.Text;
        category.Description = ctrlHtmlText.Html;
        category.Title = txtTitle.Text;
        category.SubCategoryGridVisibleInd = chkSubCategoryGridVisibleInd.Checked;
        category.SEOTitle = txtSEOTitle.Text;
        category.SEOKeywords = txtSEOMetaKeywords.Text;
        category.SEODescription = txtSEOMetaDescription.Text;
        category.SEOURL = null;
        if(txtSEOURL.Text.Trim().Length > 0)
            category.SEOURL = txtSEOURL.Text.Trim().Replace(" ","-");

        if (int.Parse(ParentCategoryID.SelectedValue) > 0)
        {
            category.ParentCategoryID = int.Parse(ParentCategoryID.SelectedValue);
        }
        else
        {
            category.ParentCategoryID = null;
        }

        category.ImageAltTag = txtImageAltTag.Text.Trim();
        category.MasterPage = ddlPageTemplateList.SelectedItem.Text;
        category.DisplayOrder = int.Parse(DisplayOrder.Text);
        category.VisibleInd = VisibleInd.Checked;
        category.Custom1 = RowDropDown.SelectedItem.ToString();
        category.Custom2 = ColumnDropDown.SelectedIndex.ToString();

        #region Image Validation

        //Validate image
        if ((ItemId == 0) || (RadioCategoryNewImage.Checked == true))
        {
            if(UploadCategoryImage.PostedFile.FileName != "")
            {
                //Check for Product Image
                fileInfo = new System.IO.FileInfo(UploadCategoryImage.PostedFile.FileName);

                if (fileInfo != null)
                {
                  category.ImageFile = fileInfo.Name;
                }
            }
        }
        else
        {
            category.ImageFile = category.ImageFile;
        }
        #endregion

        //Upload File if this is a new product or the New Image option was selected for an existing product
        if (RadioCategoryNewImage.Checked || ItemId == 0)
        {
            if (fileInfo != null)
            {
                UploadCategoryImage.SaveAs(Server.MapPath(ZNodeConfigManager.EnvironmentConfig.OriginalImagePath + fileInfo.Name));
                ZNodeImage image = new ZNodeImage();
                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));
            }
        }
        bool retval = false;

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

        if (ItemId > 0)
        {
            retval = categoryAdmin.Update(category);
        }
        else
        {
            retval = categoryAdmin.Add(category);
        }

        if (retval)
        {
            UrlRedirectAdmin urlRedirectAdmin = new UrlRedirectAdmin();
            bool status = false;

            try
            {
                status = urlRedirectAdmin.UpdateUrlRedirectTable(SEOUrlType.Category, mappedSEOUrl, category.SEOURL, category.CategoryID.ToString(), chkAddURLRedirect.Checked);
            }
            catch
            {
                //error occurred so rollback transaction
                tranManager.Rollback();
                lblMsg.Text = "The SEO Friendly URL you entered is already in use on another page. Please select another name for your URL.";

                return;
            }

            if (status) //check status whether urlmapping table updated successfully
            {
                //Commit transaction
                tranManager.Commit();

                if (ItemId > 0)
                    Response.Redirect("~/admin/secure/catalog/product_category/list.aspx");
                else
                    Response.Redirect("~/admin/secure/catalog/product_category/add_next.aspx");
            }
            else
            {
                //error occurred so rollback transaction
                tranManager.Rollback();

                lblMsg.Text = "Could not update the product category SEO Url. Please try again.";
            }
        }
        else
        {
            if (ItemId > 0)
                lblMsg.Text = "Could not update the product category. Please try again.";
            else
                lblMsg.Text = "Could not add the product category. Please try again.";

            return;
        }
    }
    /// <summary>
    /// Submit button click event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        CategoryAdmin categoryAdmin = new CategoryAdmin();
        Category category = new Category();
        string mappedSEOUrl = "";

        if (ItemId > 0)
        {
            category = categoryAdmin.GetByCategoryId(ItemId);

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

        category.CategoryID = ItemId;
        category.PortalID = ZNodeConfigManager.SiteConfig.PortalID;
        category.ShortDescription = txtshortdescription.Text;
        category.Description = ctrlHtmlText.Html;
        category.Title = txtTitle.Text;
        category.SEOTitle = txtSEOTitle.Text;
        category.SEOKeywords = txtSEOMetaKeywords.Text;
        category.SEODescription = txtSEOMetaDescription.Text;
        category.SEOURL = null;
        if (txtSEOURL.Text.Trim().Length > 0)
            category.SEOURL = txtSEOURL.Text.Trim().Replace(" ", "-");

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

        if (ItemId > 0)
        {
            retval = categoryAdmin.Update(category);
        }

        if (retval)
        {
            UrlRedirectAdmin urlRedirectAdmin = new UrlRedirectAdmin();
            bool status = false;

            try
            {
                status = urlRedirectAdmin.UpdateUrlRedirectTable(SEOUrlType.Category, mappedSEOUrl, category.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 (status) // check status whether urlmapping table updated successfully
            {
                // Commit transaction
                tranManager.Commit();

                Response.Redirect(ManagePageLink);

            }
            else
            {
                //error occurred so rollback transaction
                tranManager.Rollback();

                lblError.Text = "Could not update the product category SEO Url. Please try again.";
            }
        }
        else
        {
            if (ItemId > 0)
                lblError.Text = "Could not update the product category. Please try again.";

            return;
        }
    }