⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 productlist.aspx.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.WebSite.Admin.Shop
{
    using PowerEasy.Common;
    using PowerEasy.CommonModel;
    using PowerEasy.Components;
    using PowerEasy.Controls;
    using PowerEasy.Enumerations;
    using PowerEasy.Model.Shop;
    using PowerEasy.Shop;
    using PowerEasy.Web.UI;
    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class ProductList : AdminPage
    {
        protected Button BtnSearch;
        protected DataList DlstProduct;
        protected HtmlForm form1;
        protected HiddenField HdnModelId;
        protected HtmlHead Head1;
        private string m_FunctionName;
        private int m_ModelId;
        private string m_ProductId;
        private string m_ProductName;
        private string m_ProductType;
        private bool m_ShowPropertyProduct;
        protected AspNetPager Pager;
        protected Repeater RptModelList;
        protected Table TbEmpty;
        protected TextBox TxtKeyWord;

        protected void BtnSearch_Click(object sender, EventArgs e)
        {
            this.m_ProductName = this.TxtKeyWord.Text;
            this.m_ModelId = DataConverter.CLng(this.HdnModelId.Value);
            IList<ProductInfo> infoList = Product.GetProductInfoList((this.Pager.CurrentPageIndex - 1) * this.Pager.PageSize, this.Pager.PageSize, this.m_ProductName, this.m_ProductType);
            this.CommonProductBindData(infoList);
        }

        private void CommonProductBindData(IList<ProductInfo> infoList)
        {
            IList<ProductInfo> list = new List<ProductInfo>();
            int num = 0;
            if (!this.m_ShowPropertyProduct && string.IsNullOrEmpty(this.m_ProductId))
            {
                list = infoList;
            }
            else
            {
                foreach (ProductInfo info in infoList)
                {
                    if (!string.IsNullOrEmpty(this.m_ProductId) && (info.ProductId == DataConverter.CLng(this.m_ProductId)))
                    {
                        num++;
                        continue;
                    }
                    if (this.m_ShowPropertyProduct && !string.IsNullOrEmpty(info.Properties))
                    {
                        foreach (string str in Product.GetProductPropertiesList(info.Properties, '#'))
                        {
                            ProductInfo item = new ProductInfo();
                            item.ProductId = info.ProductId;
                            item.TableName = info.TableName;
                            item.ProductName = info.ProductName + "(" + str.Replace('#', '|') + ")";
                            item.Properties = str;
                            item.PriceInfo.Price = info.PriceInfo.Price;
                            item.ProductThumb = info.ProductThumb;
                            list.Add(item);
                        }
                        continue;
                    }
                    list.Add(info);
                }
            }
            this.DlstProduct.DataSource = list;
            this.Pager.RecordCount = Product.GetTotalOfProducts() - num;
            this.DlstProduct.DataBind();
            this.DlstProduct.Visible = list.Count != 0;
            this.TbEmpty.Visible = !this.DlstProduct.Visible;
        }

        protected void DlstProduct_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
            {
                ImageButton button = e.Item.FindControl("Imgbtn") as ImageButton;
                LinkButton button2 = e.Item.FindControl("LbtnProductName") as LinkButton;
                ProductInfo dataItem = e.Item.DataItem as ProductInfo;
                if (!dataItem.IsNull)
                {
                    if (button != null)
                    {
                        int thumbsWidth = SiteConfig.ThumbsConfig.ThumbsWidth;
                        int thumbsHeight = SiteConfig.ThumbsConfig.ThumbsHeight;
                        if (thumbsWidth != 0)
                        {
                            button.Width = thumbsWidth;
                        }
                        if (thumbsHeight != 0)
                        {
                            button.Height = thumbsHeight;
                        }
                        if (!string.IsNullOrEmpty(dataItem.ProductThumb))
                        {
                            button.ImageUrl = Utility.ConvertAbsolutePath(SiteConfig.SiteInfo.VirtualPath + VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir), dataItem.ProductThumb);
                        }
                        button.OnClientClick = this.GetReturnValue(dataItem);
                    }
                    if (button2 != null)
                    {
                        button2.Text = dataItem.ProductName;
                        button2.OnClientClick = this.GetReturnValue(dataItem);
                    }
                }
            }
        }

        private void DlstProductBindData()
        {
            IList<ProductInfo> infoList = Product.GetProductInfoList(this.m_ModelId, (this.Pager.CurrentPageIndex - 1) * this.Pager.PageSize, this.Pager.PageSize, this.m_ProductName, this.m_ProductType);
            this.CommonProductBindData(infoList);
        }

        private string GetReturnValue(ProductInfo info)
        {
            if (this.m_ShowPropertyProduct)
            {
                return string.Format("window.opener." + this.m_FunctionName + "('{0}$$${1}|{2}');window.close();", DataSecurity.HtmlDecode(info.ProductName), info.ProductId, info.Properties);
            }
            return string.Format("window.opener." + this.m_FunctionName + "('{0}$$${1}');window.close();", DataSecurity.HtmlDecode(info.ProductName), info.ProductId);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.m_ProductType = BasePage.RequestString("ProductType");
            this.m_ProductName = BasePage.RequestString("ProductName");
            this.m_FunctionName = BasePage.RequestString("FunctionName");
            this.m_ProductId = BasePage.RequestString("ProductID");
            if (string.IsNullOrEmpty(this.m_FunctionName))
            {
                this.m_FunctionName = "DoProductListPostBack";
            }
            if (BasePage.RequestString("ShowProperty") == "False")
            {
                this.m_ShowPropertyProduct = false;
            }
            else
            {
                this.m_ShowPropertyProduct = true;
            }
            this.m_ModelId = BasePage.RequestInt32("ModelID");
            this.Pager.PageSize = 20;
            if (!this.Page.IsPostBack)
            {
                this.HdnModelId.Value = this.m_ModelId.ToString();
                this.RptModelListBindData();
                this.DlstProductBindData();
            }
        }

        protected void Pager_PageChanged(object src, PageChangedEventArgs e)
        {
            this.Pager.CurrentPageIndex = e.NewPageIndex;
            this.DlstProductBindData();
        }

        protected void RptModelList_ItemCommand(object sender, CommandEventArgs e)
        {
            if (e.CommandName == "ShowPresentList")
            {
                this.m_ModelId = DataConverter.CLng(e.CommandArgument);
                this.DlstProductBindData();
                this.HdnModelId.Value = this.m_ModelId.ToString();
            }
        }

        private void RptModelListBindData()
        {
            this.RptModelList.DataSource = ModelManager.GetShopModelList(ModelShowType.None);
            this.RptModelList.DataBind();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -