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

📄 addshop.aspx.cs

📁 易想商城系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using System.IO;
using Shop.Web.UI;

namespace YXShop.Web.Membercenter.Shop
{
    public partial class AddShop : System.Web.UI.Page
    {
        YXShop.BLL.YXShop_Shop sBll = new YXShop.BLL.YXShop_Shop();
        BasePage bp = new BasePage();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["MemberID"] == null) 
            {
                Response.Redirect("MemberCenter/index.aspx");
            }
            if (!Page.IsPostBack)
            {
                if (YXShop.Common.WebUtility.isNumeric(Request.QueryString["ID"]))
                {
                    List<YXShop.Model.YXShop_Shop> sList = sBll.GetListByColumn("UID", Session["MemberID"]);
                    if (sList.Count > 0)
                    {
                        BindSTInfo(Convert.ToInt32(sList[0].SID));
                    }
                    else 
                    {
                        Response.Redirect("MemberCenter/index.aspx",true);
                    }
                }
                else
                {
                    BindDropDownList(DropDownList3, -1);
                    BindRadionList(RadioButtonList1, -1, -1);
                    BindDropDownList2(DropDownList2, -1);
                }
            }
        }
        private void BindSTInfo(int sid)
        {
            List<YXShop.Model.YXShop_Shop> sList = sBll.GetListByColumn("sid", sid);
            if (sList.Count == 1)
            {
                if (DateTime.Now.CompareTo(sList[0].EndDate) > 0)
                {
                    bp.PageRight("店铺时间已过期!<font color=\"red\">现在就去申请更多时间!</font></a></li>", "ShopTypeManager.aspx");
                }
                Button1.Text = "修改";
                lbtilte.Text = "修改我的店铺";
                //用户店铺的开始时间早已当前时间,自动转换为当前时间
                //用户店铺的开始时间已经开始,则用户不能修改当前的开始时间
                //用户店铺的开始时间还没有到,则用户可以修改为本地时间或之后的任意时间
                //StartTime.Value = sList[0].StartDate.ToString();
                //AddTime.Value = sList[0].AddTime.ToString();

                imgUrlHid1.Value = sList[0].ShopSign;
                imgUrlHid2.Value = sList[0].AttestationPic;

                Button1.CommandArgument = sid.ToString();
                TextBox1.Enabled = false;
                TextBox1.Text = sList[0].ShopName;
                BindDropDownList2(DropDownList2, Convert.ToInt32(sList[0].ShopType));
                BindDropDownList(DropDownList3, Convert.ToInt32(sList[0].Categories));
                //检查开始时间
                //int i = DateTime.Now.CompareTo(sList[0].StartDate);
                //if (i > 0) //当前时间晚于指定的开始时间,则时间不能更改
                //{
                //    Panel1.Visible = false;
                //    Label2.Text = sList[0].StartDate.ToString();
                //}

                TextBox4.Text = sList[0].ShopStyle.ToString();
                TextBox2.Text = sList[0].TWODomainName;

                //int aDay = ((TimeSpan)(sList[0].EndDate - sList[0].StartDate)).Days;//原始的天数
                //int bDay = (Convert.ToDateTime(sList[0].EndDate) - DateTime.Now).Days;//剩余的天数
                //int cDay = (aDay - bDay) > 0 ? (aDay - bDay) : 0;//已使用的天数
                //修改后的使用天数,要比已使用的天数大,
                int changeRadionState = -1;
                if (sList[0].ShopState == 1) 
                {
                    changeRadionState = 1;
                }

                BindRadionList(RadioButtonList1, Convert.ToInt32(sList[0].ShopRank), changeRadionState);
                TextBox3.Text = sList[0].Discription;

                if (!String.IsNullOrEmpty(sList[0].ShopSign))
                {
                    Image1.Visible = true;
                    Image1.Width = Unit.Pixel(100);
                    Image1.ImageUrl = "../../" + sList[0].ShopSign;
                    Image1.AlternateText = "店标";
                    Image1.ToolTip = "店标";
                }
                if (!String.IsNullOrEmpty(sList[0].AttestationPic) && sList[0].AttestationState == 0)
                {
                    Image2.Visible = true;
                    Image2.Width = Unit.Pixel(100);
                    Image2.ImageUrl = "../../" + sList[0].AttestationPic;
                    Image2.AlternateText = "认证";
                    Image2.ToolTip = "认证图片";
                }
                else
                {
                    Image2.Visible = false;
                }
                if (sList[0].AttestationState == 1 && !String.IsNullOrEmpty(sList[0].AttestationPic))
                {
                    FileUpload2.Visible = false;
                    Image2.Visible = true;
                    Image2.Width = Unit.Pixel(100);
                    Image2.ImageUrl = "../../" + sList[0].AttestationPic;
                    Image2.AlternateText = "认证";
                    Image2.ToolTip = "认证图片";
                    Label1.Text = "已经通过认证!";
                }
            }
            else
            {
                bp.PageError("该店铺不存在!<font color=\"red\">返回用户首页!</font></a></li>", "MemberCenter.aspx");
            }
        }
        private void BindRadionList(RadioButtonList rBtnList, int shopRank, int minDay)
        {
            //用户不能修改为比已使用天数更少的规模方案
            rBtnList.Items.Clear();
            YXShop.BLL.YXShop_ShopType stBll = new YXShop.BLL.YXShop_ShopType();
            List<YXShop.Model.YXShop_ShopType> stList = stBll.GetListByColumn();
            ListItem lItem = null;
            foreach (YXShop.Model.YXShop_ShopType stModel in stList)
            {
                lItem = new ListItem();

                lItem.Value = String.Format("{0},{1}", stModel.STID, stModel.ExpendDays);
                lItem.Text = String.Format("<font style='color:red;'>{0}</font> 租金:{1}元,经营商品数量为{2}个,空间大小{3}kb,可使用[{4}]天数", stModel.STName, stModel.STPrice, stModel.ProCount, stModel.ShopSpace, stModel.ExpendDays);
                if (shopRank == stModel.STID)
                {
                    lItem.Selected = true;
                }
                if (minDay == 1) //隐藏所有项,用户不能修改
                {
                    lItem.Enabled = false;
                }
                //if (minDay >= stModel.ExpendDays)
                //{
                //    lItem.Enabled = false;
                //}
                rBtnList.Items.Add(lItem);
                lItem = null;
            }
        }
        private void BindDropDownList(DropDownList ddl, int TypeID)
        {
            List<YXShop.Model.Pro_Categories> pcList = ItemsSort();
            ListItem lItem = null;

            foreach (YXShop.Model.Pro_Categories pcModel in pcList)
            {
                string pre = "";
                for (int i = 1; i < pcModel.ProC_ParentPath.Split(',').Length; i++)
                {
                    pre += "|__";
                }
                lItem = new ListItem();
                lItem.Value = pcModel.ProC_ID.ToString();
                lItem.Text = pre + pcModel.ProC_CategroiesName;
                if (TypeID == pcModel.ProC_ID)
                {
                    lItem.Selected = true;
                }
                ddl.Items.Add(lItem);
                lItem = null;
            }
        }
        private void BindDropDownList2(DropDownList ddl, int TypeID)
        {
            YXShop.BLL.ShopCategory scBll = new YXShop.BLL.ShopCategory();
            List<YXShop.Model.ShopCategory> scList = scBll.GetAll();
            ListItem lItem = null;

            foreach (YXShop.Model.ShopCategory scModel in scList)
            {
                lItem = new ListItem();
                lItem.Value = scModel.scID.ToString();
                lItem.Text = scModel.scName;
                if (TypeID == scModel.scID)
                {
                    lItem.Selected = true;
                }
                ddl.Items.Add(lItem);
                lItem = null;
            }
        }
        private List<YXShop.Model.Pro_Categories> ItemsSort()
        {
            YXShop.BLL.Pro_Categories pcBll = new YXShop.BLL.Pro_Categories();
            List<YXShop.Model.Pro_Categories> pcList = pcBll.GetAll();

            List<YXShop.Model.Pro_Categories> newPcList = new List<YXShop.Model.Pro_Categories>(pcList.Count + 5);

            foreach (YXShop.Model.Pro_Categories pcModel in pcList)
            {
                if (pcModel.ProC_CategroiesID == 0)
                {
                    newPcList.Add(pcModel);
                    GetChildItems(ref newPcList, ref pcList, pcModel.ProC_ID);
                }
            }
            return newPcList;
        }
        private void GetChildItems(ref List<YXShop.Model.Pro_Categories> newPcList, ref List<YXShop.Model.Pro_Categories> oldPcList, int parID)
        {
            foreach (YXShop.Model.Pro_Categories pcModel in oldPcList)
            {
                if (pcModel.ProC_CategroiesID == parID)
                {
                    //if (newPcList.Find(IsTrue) == null)
                    //{
                    newPcList.Add(pcModel);
                    GetChildItems(ref newPcList, ref oldPcList, pcModel.ProC_ID);

⌨️ 快捷键说明

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