private void BindData()
        {
            AuctionProductModel model   = bll.GetModel(AuctionID);
            MagicCategoryBll    cateBll = new MagicCategoryBll();

            if (model.Status != (int)AuctionProductStatus.尚未审核)
            {
                MessageBox.Show(this, "该商品已被审核,禁止编辑!");
                Response.Redirect("List.aspx");
                return;
            }

            CategoryID = model.CategoryID;
            if (!String.IsNullOrEmpty(Request.QueryString["categoryid"]))
            {
                CategoryID = Convert.ToInt32(Request.QueryString["categoryid"]);
            }

            TextBox_Category.Text    = new MagicCategoryBll().GetModel(CategoryID).CategoryName;
            TextBox_ProductName.Text = StringUtility.RemoveHtmlTags(model.ProductName);
            TextBox_StartPrice.Text  = model.StartPrice.ToString("0.00");
            TextBox_AddPrices.Text   = model.AddPrices;
            TextBox_StartTime.Text   = model.StartTime.ToString("yyyy-MM-dd");
            TextBox_EndTime.Text     = model.EndTime.ToString("yyyy-MM-dd");
            TextBox_Brief.Text       = model.Brief;
            TextBox_TrueName.Text    = model.TrueName;
            TextBox_Phone.Text       = model.Phone;
            TextBox_CellPhone.Text   = model.CellPhone;
            TextBox_PostCode.Text    = model.PostCode;
            TextBox_Address.Text     = model.Address;

            string[] LastRegion = model.Region.Split(' ');
            ucRegion.PresetRegionInfo(RegionInfo.GetRegionPathByName(LastRegion[String.IsNullOrEmpty(LastRegion[2]) ? 1 : 2]));
        }
        private void BindData()
        {
            PawnProductModel model   = bll.GetModel(PawnProductID);
            MagicCategoryBll cateBll = new MagicCategoryBll();

            if (model.Status != (int)PawnProductStatus.尚未收当)
            {
                MessageBox.Show(this, "该商品已被审核,禁止编辑!");
                Response.Redirect("List.aspx");
                return;
            }

            CategoryID = model.CateID;
            if (!String.IsNullOrEmpty(Request.QueryString["categoryid"]))
            {
                CategoryID = Convert.ToInt32(Request.QueryString["categoryid"]);
            }

            TextBox_Category.Text    = new MagicCategoryBll().GetModel(CategoryID).CategoryName;
            TextBox_ProductName.Text = model.PawnProductName;
            TextBox_EndTime.Text     = model.DeadTime.ToString("yyyy-MM-dd");
            TextBox_Price.Text       = model.PawnPrice.ToString("0.00");
            TextBox_Brief.Text       = model.Brief;
            TextBox_TrueName.Text    = model.TrueName;
            TextBox_Phone.Text       = model.Phone;
            TextBox_CellPhone.Text   = model.CellPhone;
            TextBox_PostCode.Text    = model.PostCode;
            TextBox_Address.Text     = model.Address;
            ucRegion.PresetRegionInfo(RegionInfo.GetRegionPathByName(model.Region.Split(' ')[model.Region.Split(' ').Length - 1]));
        }
        private void BindData(int PageIndex)
        {
            DataTable dt          = new DataTable();
            int       RecordCount = 0;

            if (CategoryID == 0)
            {
                dt = bll.GetList(PageIndex, AspNetPager.PageSize, " and starttime>getdate() and status=" + (int)AuctionProductStatus.审核通过, " auctionid desc", out RecordCount);
            }
            else
            {
                MagicCategoryModel cate = new MagicCategoryBll().GetModel(CategoryID);
                if (cate != null)
                {
                    dt = bll.GetList(PageIndex, AspNetPager.PageSize, " and starttime>getdate() and catepath+'/' like '" + cate.CategoryPath + "/%' and status=" + (int)AuctionProductStatus.审核通过, " auctionid desc", out RecordCount);
                }
                else
                {
                    Response.End();
                }
            }

            foreach (DataRow row in dt.Rows)
            {
                row["mediumimage"] = MagicWorldImageRule.GetMainImageUrl(row["mediumimage"].ToString());
            }

            Repeater_ProductList.DataSource = dt;
            Repeater_ProductList.DataBind();
            AspNetPager.RecordCount = RecordCount;
        }
        private void BindData()
        {
            MagicCategoryModel Cate = new MagicCategoryBll().GetModel(CategoryID);

            Label_Category.Text       = Cate.CategoryName;
            Hidden_CategoryPath.Value = Cate.CategoryPath;
        }
        protected void BindData()
        {
            if (CategoryID != -1)
            {
                MagicCategoryBll   CategoryBll = new MagicCategoryBll();
                MagicCategoryModel Category    = CategoryBll.GetModel(CategoryID);

                TextBox_Category.Text = Category.CategoryName;
            }
            else
            {
                throw new Exception("未选择分类");
            }
        }
        protected void BindData()
        {
            if (CategoryID != -1)
            {
                MagicCategoryBll CategoryBll = new MagicCategoryBll();
                MagicCategoryModel Category = CategoryBll.GetModel(CategoryID);

                TextBox_Category.Text = Category.CategoryName;
            }
            else
            {
                throw new Exception("未选择分类");
            }
        }
        private void BindData()
        {
            RentProductModel model = bll.GetModel(RentID);
            if (model == null) Response.End();
            MagicCategoryModel cate = new MagicCategoryBll().GetModel(model.CategoryID);

            Image_Big.ImageUrl = MagicWorldImageRule.GetMainImageUrl(model.MediumImage);
            Image_Small.ImageUrl = MagicWorldImageRule.GetMainImageUrl(model.SmallImage);

            Literal_ProductName.Text = model.RentName;
            Literal_Category.Text = cate.CategoryName;
            Literal_RentPrice.Text = model.RentPrice.ToString("0.00");
            Literal_Pledge.Text = model.CashPledge.ToString("0.00");
            Literal_Brief.Text = model.Brief;

            Repeater_Comment.DataSource = new CommentBll().GetList(AppType.MagicWorld, RentID);
            Repeater_Comment.DataBind();
        }
Beispiel #8
0
        protected void BindData()
        {
            if (CategoryID != -1)
            {
                MagicCategoryBll   CategoryBll = new MagicCategoryBll();
                MagicCategoryModel Category    = CategoryBll.GetModel(CategoryID);

                TextBox_Category.Text = Category.CategoryName;

                DropDown_Usage.DataSource     = DataTableUtil.GetEnumKeyValue(typeof(SecondhandProductUsageCondition));
                DropDown_Usage.DataTextField  = "key";
                DropDown_Usage.DataValueField = "value";
                DropDown_Usage.DataBind();
            }
            else
            {
                throw new Exception("未选择分类");
            }
        }
        protected void BindData()
        {
            if (CategoryID != -1)
            {
                MagicCategoryBll CategoryBll = new MagicCategoryBll();
                MagicCategoryModel Category = CategoryBll.GetModel(CategoryID);

                TextBox_Category.Text = Category.CategoryName;

                DropDown_Usage.DataSource = DataTableUtil.GetEnumKeyValue(typeof(SecondhandProductUsageCondition));
                DropDown_Usage.DataTextField = "key";
                DropDown_Usage.DataValueField = "value";
                DropDown_Usage.DataBind();
            }
            else
            {
                throw new Exception("未选择分类");
            }
        }
        private void BindData()
        {
            RentProductModel rent = bll.GetModel(RentID);

            if (CategoryID == -1)
            {
                CategoryID = rent.CategoryID;
            }
            MagicCategoryModel Cate = new MagicCategoryBll().GetModel(CategoryID);

            Label_Category.Text       = Cate.CategoryName;
            Hidden_CategoryPath.Value = Cate.CategoryPath;

            TextBox_RentName.Text    = rent.RentName;
            TextBox_RentPrice.Text   = rent.RentPrice.ToString();
            TextBox_MaxRentDays.Text = rent.MaxRentTime.ToString();
            TextBox_Stock.Text       = rent.Stock.ToString();
            TextBox_Keywords.Text    = rent.Keywords;
            TextBox_Brief.Text       = rent.Brief;
            Image_MainImage.ImageUrl = MagicWorldImageRule.GetMainImageUrl(rent.SmallImage);
        }
Beispiel #11
0
        private void BindData()
        {
            RentProductModel model = bll.GetModel(RentID);

            if (model == null)
            {
                Response.End();
            }
            MagicCategoryModel cate = new MagicCategoryBll().GetModel(model.CategoryID);

            Image_Big.ImageUrl   = MagicWorldImageRule.GetMainImageUrl(model.MediumImage);
            Image_Small.ImageUrl = MagicWorldImageRule.GetMainImageUrl(model.SmallImage);

            Literal_ProductName.Text = model.RentName;
            Literal_Category.Text    = cate.CategoryName;
            Literal_RentPrice.Text   = model.RentPrice.ToString("0.00");
            Literal_Pledge.Text      = model.CashPledge.ToString("0.00");
            Literal_Brief.Text       = model.Brief;

            Repeater_Comment.DataSource = new CommentBll().GetList(AppType.MagicWorld, RentID);
            Repeater_Comment.DataBind();
        }
        private void BindData(int PageIndex)
        {
            DataTable dt = new DataTable();
            int RecordCount = 0;
            if (CategoryID == 0)
            {
                dt = bll.GetList(PageIndex, AspNetPager.PageSize, " and starttime>getdate() and status="+(int)AuctionProductStatus.审核通过," auctionid desc", out RecordCount);
            }
            else
            {
                MagicCategoryModel cate = new MagicCategoryBll().GetModel(CategoryID);
                if (cate != null)
                    dt = bll.GetList(PageIndex, AspNetPager.PageSize, " and starttime>getdate() and catepath+'/' like '" + cate.CategoryPath + "/%' and status=" + (int)AuctionProductStatus.审核通过," auctionid desc", out RecordCount);
                else Response.End();
            }

            foreach (DataRow row in dt.Rows) row["mediumimage"] = MagicWorldImageRule.GetMainImageUrl(row["mediumimage"].ToString());

            Repeater_ProductList.DataSource = dt;
            Repeater_ProductList.DataBind();
            AspNetPager.RecordCount = RecordCount;
        }
        private void BindData()
        {
            DemandProductModel model   = bll.GetModel(DemandID);
            MagicCategoryBll   cateBll = new MagicCategoryBll();

            if (model.Status != (int)DemandProductStatus.尚未审核)
            {
                MessageBox.Show(this, "该商品已被审核,禁止编辑!");
                Response.Redirect("List.aspx");
                return;
            }

            DropDown_Usage.DataSource     = DataTableUtil.GetEnumKeyValue(typeof(SecondhandProductUsageCondition));
            DropDown_Usage.DataTextField  = "key";
            DropDown_Usage.DataValueField = "value";
            DropDown_Usage.DataBind();

            CategoryID = model.CategoryID;
            if (!String.IsNullOrEmpty(Request.QueryString["categoryid"]))
            {
                CategoryID = Convert.ToInt32(Request.QueryString["categoryid"]);
            }

            TextBox_ProductName.Text     = model.DemandName;
            TextBox_Category.Text        = new MagicCategoryBll().GetModel(CategoryID).CategoryName;
            TextBox_Price.Text           = model.Price.ToString("0.00");
            TextBox_Count.Text           = model.Count.ToString();
            DropDown_Usage.SelectedValue = model.UsageCondition.ToString();
            TextBox_ExpireTime.Text      = model.ExpirationTime.ToString("yyyy-MM-dd");
            TextBox_Brief.Text           = model.Brief;
            TextBox_TrueName.Text        = model.TrueName;
            TextBox_Phone.Text           = model.Phone;
            TextBox_CellPhone.Text       = model.CellPhone;
            TextBox_PostCode.Text        = model.PostCode;
            TextBox_Address.Text         = model.Address;
            ucRegion.PresetRegionInfo(RegionInfo.GetRegionPathByName(model.Region.Split(' ')[model.Region.Split(' ').Length - 1]));
        }
        protected void Button_Add_Click(object sender, EventArgs e)
        {
            string ErrorMessage = String.Empty;

            if (String.IsNullOrEmpty(TextBox_ProductName.Text)) { ErrorMessage += "产品名称不能为空\\n"; }
            if (String.IsNullOrEmpty(FileUpload_ProductImage.FileName)) { ErrorMessage += "产品图片不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_EndTime.Text/* validate */)) { ErrorMessage += "绝当时间不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_Price.Text) || !PageValidate.IsDecimal(TextBox_Price.Text)) { ErrorMessage += "典当价格不正确\\n"; }
            if (String.IsNullOrEmpty(TextBox_Brief.Text)) { ErrorMessage += "简要介绍不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_TrueName.Text)) { ErrorMessage += "姓名不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_Phone.Text) && String.IsNullOrEmpty(TextBox_CellPhone.Text)) { ErrorMessage += "请输入您的电话号码或者手机号码\\n"; }
            else { /* validate */}
            if (String.IsNullOrEmpty(TextBox_PostCode.Text) || !PageValidate.IsNumber(TextBox_PostCode.Text)) { ErrorMessage += "邮政编码不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_Address.Text)) { ErrorMessage += "地址不能为空\\n"; }
            RegionInfo regionInfo = ucRegion.GetSelectedRegionInfo();
            if (String.IsNullOrEmpty(regionInfo.Province) || String.IsNullOrEmpty(regionInfo.City))
            {
                ErrorMessage += "所在地选择不完整\\n";
            }

            if (!String.IsNullOrEmpty(ErrorMessage))
            {
                MessageBox.Show(this, ErrorMessage);
                return;
            }

            int PawnProductID = CommDataHelper.GetNewSerialNum(AppType.MagicWorld);

            string[] ProductImages;
            if (MagicWorldImageRule.SaveProductMainImage(PawnProductID, FileUpload_ProductImage.PostedFile, out ProductImages))
            {
                PawnProductModel model = new PawnProductModel();
                MagicCategoryModel cate = new MagicCategoryBll().GetModel(CategoryID);

                model.PawnProductID = PawnProductID;
                model.PawnProductName = StringUtility.RemoveHtmlTags(TextBox_ProductName.Text);
                model.CateID = CategoryID;
                model.CatePath = cate.CategoryPath;
                model.PawnPrice = Convert.ToDecimal(TextBox_Price.Text);
                model.Stock = 1;
                model.Brief = TextBox_Brief.Text;
                model.SmallImage = ProductImages[0];
                model.MediumImage = ProductImages[1];
                model.SellingPrice = 0;
                model.DeadTime = Convert.ToDateTime(TextBox_EndTime.Text);

                model.InsertTime = DateTime.Now;
                model.ChangeTime = DateTime.Now;

                model.UserID = GetUserID();
                model.TrueName = TextBox_TrueName.Text;
                model.CellPhone = TextBox_CellPhone.Text;
                model.Phone = TextBox_Phone.Text;
                model.PostCode = TextBox_PostCode.Text;
                model.Region = String.Format("{0} {1} {2}", regionInfo.Province, regionInfo.City, regionInfo.County);
                model.Address = TextBox_Address.Text;

                model.SortValue = PawnProductID;
                model.Status = (int)PawnProductStatus.尚未收当;

                bll.Add(model);
                Response.Redirect("../SubmitSucc.aspx");
            }
            else
            {
                MessageBox.Show(this, "图片上传失败");
            }
        }
        protected void Button_Edit_Click(object sender, EventArgs e)
        {
            string ErrorMessage = String.Empty;

            if (String.IsNullOrEmpty(TextBox_ProductName.Text)) { ErrorMessage += "产品名称不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_StartPrice.Text) || !PageValidate.IsDecimal(TextBox_StartPrice.Text)) { ErrorMessage += "起始价格不正确\\n"; }
            if (String.IsNullOrEmpty(TextBox_AddPrices.Text)) { ErrorMessage += "每次加价不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_StartTime.Text)/* validate */) { ErrorMessage += "开始时间不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_EndTime.Text)/* validate */) { ErrorMessage += "结束时间不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_Brief.Text)) { ErrorMessage += "简要介绍不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_TrueName.Text)) { ErrorMessage += "姓名不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_Phone.Text) && String.IsNullOrEmpty(TextBox_CellPhone.Text)) { ErrorMessage += "请输入您的电话号码或者手机号码\\n"; }
            else { /* validate */}
            if (String.IsNullOrEmpty(TextBox_PostCode.Text) || !PageValidate.IsNumber(TextBox_PostCode.Text)) { ErrorMessage += "邮政编码不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_Address.Text)) { ErrorMessage += "地址不能为空\\n"; }
            RegionInfo regionInfo = ucRegion.GetSelectedRegionInfo();
            if (String.IsNullOrEmpty(regionInfo.Province) || String.IsNullOrEmpty(regionInfo.City))
            {
                ErrorMessage += "所在地选择不完整\\n";
            }

            if (!String.IsNullOrEmpty(ErrorMessage))
            {
                MessageBox.Show(this, ErrorMessage);
                return;
            }

            AuctionProductModel model = bll.GetModel(AuctionID);

            if (FileUpload_ProductImage.FileName != String.Empty)
            {
                string[] ProductImages;

                if (MagicWorldImageRule.SaveProductMainImage(model.AuctionID, FileUpload_ProductImage.PostedFile, out ProductImages))
                {
                    model.SmallImage = ProductImages[0];
                    model.MediumImage = ProductImages[1];
                }
                else
                {
                    MessageBox.Show(this, "图片上传失败");
                    return;
                }
            }

            MagicCategoryModel cate = new MagicCategoryBll().GetModel(CategoryID);

            model.ProductName = TextBox_ProductName.Text;
            model.CategoryID = CategoryID;
            model.CategoryPath = cate.CategoryPath;
            model.StartPrice = Convert.ToDecimal(TextBox_StartPrice.Text);
            model.AddPrices = TextBox_AddPrices.Text.Replace(',', ',');
            model.StartTime = Convert.ToDateTime(TextBox_StartTime.Text);
            model.EndTime = Convert.ToDateTime(TextBox_EndTime.Text);
            model.Brief = TextBox_Brief.Text;
            model.UpdateTime = DateTime.Now;

            model.TrueName = TextBox_TrueName.Text;
            model.Phone = TextBox_Phone.Text;
            model.CellPhone = TextBox_CellPhone.Text;
            model.PostCode = TextBox_PostCode.Text;
            model.Region = String.Format("{0} {1} {2}", regionInfo.Province, regionInfo.City, regionInfo.County);
            model.Address = TextBox_Address.Text;

            bll.Update(model);
            Response.Redirect("../SubmitSucc.aspx");
        }
        private void BindData()
        {
            RentProductModel rent = bll.GetModel(RentID);
            if (CategoryID == -1) CategoryID =rent.CategoryID;
            MagicCategoryModel Cate = new MagicCategoryBll().GetModel(CategoryID);

            Label_Category.Text = Cate.CategoryName;
            Hidden_CategoryPath.Value = Cate.CategoryPath;

            TextBox_RentName.Text=rent.RentName;
            TextBox_RentPrice.Text = rent.RentPrice.ToString();
            TextBox_MaxRentDays.Text = rent.MaxRentTime.ToString();
            TextBox_Stock.Text=rent.Stock.ToString();
            TextBox_Keywords.Text=rent.Keywords;
            TextBox_Brief.Text=rent.Brief;
            Image_MainImage.ImageUrl = MagicWorldImageRule.GetMainImageUrl(rent.SmallImage);
        }
        private void BindData()
        {
            PawnProductModel model = bll.GetModel(PawnProductID);
            MagicCategoryBll cateBll = new MagicCategoryBll();

            if (model.Status != (int)PawnProductStatus.尚未收当)
            {
                MessageBox.Show(this, "该商品已被审核,禁止编辑!");
                Response.Redirect("List.aspx");
                return;
            }

            CategoryID = model.CateID;
            if (!String.IsNullOrEmpty(Request.QueryString["categoryid"])) CategoryID = Convert.ToInt32(Request.QueryString["categoryid"]);

            TextBox_Category.Text = new MagicCategoryBll().GetModel(CategoryID).CategoryName;
            TextBox_ProductName.Text = model.PawnProductName;
            TextBox_EndTime.Text = model.DeadTime.ToString("yyyy-MM-dd");
            TextBox_Price.Text = model.PawnPrice.ToString("0.00");
            TextBox_Brief.Text = model.Brief;
            TextBox_TrueName.Text = model.TrueName;
            TextBox_Phone.Text = model.Phone;
            TextBox_CellPhone.Text = model.CellPhone;
            TextBox_PostCode.Text = model.PostCode;
            TextBox_Address.Text = model.Address;
            ucRegion.PresetRegionInfo(RegionInfo.GetRegionPathByName(model.Region.Split(' ')[model.Region.Split(' ').Length-1]));
        }
        protected void Button_Edit_Click(object sender, EventArgs e)
        {
            string ErrorMessage = String.Empty;
            if (String.IsNullOrEmpty(TextBox_ProductName.Text)) { ErrorMessage += "产品名称不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_Price.Text) || !PageValidate.IsDecimal(TextBox_Price.Text)) { ErrorMessage += "请输入正确的产品价格\\n"; }
            if (String.IsNullOrEmpty(TextBox_Count.Text) || !PageValidate.IsNumber(TextBox_Count.Text)) { ErrorMessage += "请输入正确的产品数量\\n"; }
            if (String.IsNullOrEmpty(TextBox_Brief.Text)) { ErrorMessage += "请输入产品简介\\n"; }
            if (String.IsNullOrEmpty(TextBox_TrueName.Text)) { ErrorMessage += "请输入您的姓名\\n"; }
            if (String.IsNullOrEmpty(TextBox_Phone.Text) && String.IsNullOrEmpty(TextBox_CellPhone.Text)) { ErrorMessage += "请输入您的电话号码或者手机号码\\n"; }
            else { /* validate */}
            if (String.IsNullOrEmpty(TextBox_PostCode.Text)/* validate */) { ErrorMessage += "请输入正确的邮政编码\\n"; }
            if (String.IsNullOrEmpty(TextBox_Address.Text)) { ErrorMessage += "请输入您的地址\\n"; }

            RegionInfo regionInfo = ucRegion.GetSelectedRegionInfo();
            if (String.IsNullOrEmpty(regionInfo.Province) || String.IsNullOrEmpty(regionInfo.City) )
            {
                ErrorMessage += "所在地选择不完整\\n";
            }

            if (!String.IsNullOrEmpty(ErrorMessage))
            {
                MessageBox.Show(this, ErrorMessage);
                return;
            }

            SecondhandProductModel model = bll.GetModel(SecondhandProductID);
            MagicCategoryModel cate = new MagicCategoryBll().GetModel(CategoryID);

            if (FileUpload_ProductImage.FileName != "")
            {
                string[] ProductImages;

                if (MagicWorldImageRule.SaveProductMainImage(SecondhandProductID, FileUpload_ProductImage.PostedFile, out ProductImages))
                {
                    model.SmallImage = ProductImages[0];
                    model.MediumImage = ProductImages[1];
                    //model.LargeImage = ProductImages[2];
                }
                else
                {
                    MessageBox.Show(this, "图片上传失败");
                    return;
                }
            }

            model.SecondhandProductName = StringUtility.RemoveHtmlTags(TextBox_ProductName.Text);
            model.CateID = CategoryID;
            model.CatePath = cate.CategoryPath;
            model.Price = Convert.ToDecimal(TextBox_Price.Text);
            model.UsageCondition = Convert.ToInt32(DropDown_Usage.SelectedValue);
            model.Stock = Convert.ToInt32(TextBox_Count.Text);
            model.Brief = TextBox_Brief.Text;

            model.UpdateTime = DateTime.Now;

            model.TrueName = TextBox_TrueName.Text;
            model.CellPhone = TextBox_CellPhone.Text;
            model.Phone = TextBox_Phone.Text;
            model.PostCode = TextBox_PostCode.Text;
            model.Region = String.Format("{0} {1} {2}", regionInfo.Province, regionInfo.City, regionInfo.County);
            model.Address = TextBox_Address.Text;

            bll.Update(model);
            Response.Redirect("../SubmitSucc.aspx");
        }
        private void BindData()
        {
            DemandProductModel model = bll.GetModel(DemandID);
            MagicCategoryBll cateBll = new MagicCategoryBll();

            if (model.Status != (int)DemandProductStatus.尚未审核)
            {
                MessageBox.Show(this, "该商品已被审核,禁止编辑!");
                Response.Redirect("List.aspx");
                return;
            }

            DropDown_Usage.DataSource = DataTableUtil.GetEnumKeyValue(typeof(SecondhandProductUsageCondition));
            DropDown_Usage.DataTextField = "key";
            DropDown_Usage.DataValueField = "value";
            DropDown_Usage.DataBind();

            CategoryID = model.CategoryID;
            if (!String.IsNullOrEmpty(Request.QueryString["categoryid"])) CategoryID = Convert.ToInt32(Request.QueryString["categoryid"]);

            TextBox_ProductName.Text = model.DemandName;
            TextBox_Category.Text = new MagicCategoryBll().GetModel(CategoryID).CategoryName;
            TextBox_Price.Text = model.Price.ToString("0.00");
            TextBox_Count.Text = model.Count.ToString();
            DropDown_Usage.SelectedValue = model.UsageCondition.ToString();
            TextBox_ExpireTime.Text = model.ExpirationTime.ToString("yyyy-MM-dd");
            TextBox_Brief.Text = model.Brief;
            TextBox_TrueName.Text = model.TrueName;
            TextBox_Phone.Text = model.Phone;
            TextBox_CellPhone.Text = model.CellPhone;
            TextBox_PostCode.Text = model.PostCode;
            TextBox_Address.Text = model.Address;
            ucRegion.PresetRegionInfo(RegionInfo.GetRegionPathByName(model.Region.Split(' ')[model.Region.Split(' ').Length-1]));
        }
        private void BindData()
        {
            AuctionProductModel model = bll.GetModel(AuctionID);
            MagicCategoryBll cateBll = new MagicCategoryBll();

            if (model.Status != (int)AuctionProductStatus.尚未审核)
            {
                MessageBox.Show(this, "该商品已被审核,禁止编辑!");
                Response.Redirect("List.aspx");
                return;
            }

            CategoryID = model.CategoryID;
            if (!String.IsNullOrEmpty(Request.QueryString["categoryid"])) CategoryID = Convert.ToInt32(Request.QueryString["categoryid"]);

            TextBox_Category.Text = new MagicCategoryBll().GetModel(CategoryID).CategoryName;
            TextBox_ProductName.Text = StringUtility.RemoveHtmlTags(model.ProductName);
            TextBox_StartPrice.Text=model.StartPrice.ToString("0.00");
            TextBox_AddPrices.Text = model.AddPrices;
            TextBox_StartTime.Text = model.StartTime.ToString("yyyy-MM-dd");
            TextBox_EndTime.Text = model.EndTime.ToString("yyyy-MM-dd");
            TextBox_Brief.Text = model.Brief;
            TextBox_TrueName.Text = model.TrueName;
            TextBox_Phone.Text = model.Phone;
            TextBox_CellPhone.Text = model.CellPhone;
            TextBox_PostCode.Text = model.PostCode;
            TextBox_Address.Text = model.Address;

            string[] LastRegion = model.Region.Split(' ');
            ucRegion.PresetRegionInfo(RegionInfo.GetRegionPathByName(LastRegion[String.IsNullOrEmpty(LastRegion[2]) ? 1 : 2]));
        }
        protected void Button_Add_Click(object sender, EventArgs e)
        {
            string ErrorMessage = String.Empty;

            if (String.IsNullOrEmpty(TextBox_ProductName.Text)) { ErrorMessage += "产品名称不能为空\\n"; }
            if (String.IsNullOrEmpty(FileUpload_ProductImage.FileName)) { ErrorMessage += "产品图片不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_StartPrice.Text) || !PageValidate.IsDecimal(TextBox_StartPrice.Text)) { ErrorMessage += "起始价格不正确\\n"; }
            if (String.IsNullOrEmpty(TextBox_AddPrices.Text))
            {
                ErrorMessage += "每次加价不能为空\\n";
            }
            else
            {
                if (TextBox_AddPrices.Text.Replace(',', ',').Split(',').Length > 7)
                {
                    ErrorMessage += "最多只能输入7个加价\\n";
                }
            }
            if (String.IsNullOrEmpty(TextBox_StartTime.Text)/* validate */) { ErrorMessage += "开始时间不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_EndTime.Text)/* validate */) { ErrorMessage += "结束时间不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_Brief.Text)) { ErrorMessage += "简要介绍不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_TrueName.Text)) { ErrorMessage += "姓名不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_Phone.Text) && String.IsNullOrEmpty(TextBox_CellPhone.Text)) { ErrorMessage += "请输入您的电话号码或者手机号码\\n"; }
            else { /* validate */}
            if (String.IsNullOrEmpty(TextBox_PostCode.Text) || !PageValidate.IsNumber(TextBox_PostCode.Text)) { ErrorMessage += "邮政编码不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_Address.Text)) { ErrorMessage += "地址不能为空\\n"; }
            RegionInfo regionInfo = ucRegion.GetSelectedRegionInfo();
            if (String.IsNullOrEmpty(regionInfo.Province) || String.IsNullOrEmpty(regionInfo.City))
            {
                ErrorMessage += "所在地选择不完整\\n";
            }

            if (!String.IsNullOrEmpty(ErrorMessage))
            {
                MessageBox.Show(this, ErrorMessage);
                return;
            }

            int AuctionID = CommDataHelper.GetNewSerialNum(AppType.MagicWorld);

            string[] ProductImages;
            if (MagicWorldImageRule.SaveProductMainImage(AuctionID, FileUpload_ProductImage.PostedFile, out ProductImages))
            {
                AuctionProductModel model = new AuctionProductModel();
                MagicCategoryModel cate = new MagicCategoryBll().GetModel(CategoryID);

                model.AuctionID = AuctionID;
                model.ProductName = StringUtility.RemoveHtmlTags(TextBox_ProductName.Text);
                model.CategoryID = CategoryID;
                model.CategoryPath = cate.CategoryPath;
                model.SmallImage = ProductImages[0];
                model.MediumImage = ProductImages[1];
                model.StartPrice = Convert.ToDecimal(TextBox_StartPrice.Text);
                model.CurPrice = model.StartPrice;
                model.AddPrices = TextBox_AddPrices.Text.Replace(',', ',').EndsWith(",") ? TextBox_AddPrices.Text.Replace(',', ',').Substring(0, TextBox_AddPrices.Text.Length - 1) : TextBox_AddPrices.Text.Replace(',', ',');
                model.StartTime = Convert.ToDateTime(TextBox_StartTime.Text);
                model.EndTime = Convert.ToDateTime(TextBox_EndTime.Text);
                model.Brief = TextBox_Brief.Text;
                model.InsertTime = DateTime.Now;
                model.UpdateTime = DateTime.Now;

                model.UserID = GetUserID();
                model.TrueName = TextBox_TrueName.Text;
                model.Phone = TextBox_Phone.Text;
                model.CellPhone = TextBox_CellPhone.Text;
                model.PostCode = TextBox_PostCode.Text;
                model.Region = String.Format("{0} {1} {2}", regionInfo.Province, regionInfo.City, regionInfo.County);
                model.Address = TextBox_Address.Text;

                model.Status = (int)AuctionProductStatus.尚未审核;
                model.OutLinkUrl = "";

                bll.Add(model);
                Response.Redirect("../SubmitSucc.aspx");
            }
            else
            {
                MessageBox.Show(this, "图片上传失败");
            }
        }
        protected void Button_Add_Click(object sender, EventArgs e)
        {
            string ErrorMessage = String.Empty;
            if (String.IsNullOrEmpty(TextBox_ProductName.Text)) { ErrorMessage += "产品名称不能为空\\n"; }
            if (String.IsNullOrEmpty(FileUpload_ProductImage.FileName)) { ErrorMessage += "产品图片不能为空\\n"; }
            if (String.IsNullOrEmpty(TextBox_Price.Text) || !PageValidate.IsDecimal(TextBox_Price.Text)) { ErrorMessage += "请输入正确的产品价格\\n"; }
            if (String.IsNullOrEmpty(TextBox_Count.Text) || !PageValidate.IsNumber(TextBox_Count.Text)) { ErrorMessage += "请输入正确的产品数量\\n"; }
            if (String.IsNullOrEmpty(TextBox_ExpireTime.Text) || !PageValidate.IsDate(TextBox_ExpireTime.Text)) { ErrorMessage += "请输入正确的有效时间\\n"; }
            if (String.IsNullOrEmpty(TextBox_Brief.Text)) { ErrorMessage += "请输入产品简介\\n"; }
            if (String.IsNullOrEmpty(TextBox_TrueName.Text)) { ErrorMessage += "请输入您的姓名\\n"; }
            if (String.IsNullOrEmpty(TextBox_Phone.Text) && String.IsNullOrEmpty(TextBox_CellPhone.Text)) { ErrorMessage += "请输入您的电话号码或者手机号码\\n"; }
            else{/* validate */}
            if (String.IsNullOrEmpty(TextBox_PostCode.Text)/* validate */) { ErrorMessage += "请输入正确的邮政编码\\n"; }
            if (String.IsNullOrEmpty(TextBox_Address.Text)) { ErrorMessage += "请输入您的地址\\n"; }

            RegionInfo regionInfo = ucRegion.GetSelectedRegionInfo();
            if (String.IsNullOrEmpty(regionInfo.Province) || String.IsNullOrEmpty(regionInfo.City))
            {
                ErrorMessage += "所在地选择不完整\\n";
            }

            if (!String.IsNullOrEmpty(ErrorMessage)) {
                MessageBox.Show(this,ErrorMessage);
                return;
            }

            DemandProductModel model = new DemandProductModel();
            MagicCategoryModel cate = new MagicCategoryBll().GetModel(CategoryID);
            int DemandID = CommDataHelper.GetNewSerialNum(AppType.MagicWorld);
            string[] ProductImages;
            if (MagicWorldImageRule.SaveProductMainImage(DemandID, FileUpload_ProductImage.PostedFile, out ProductImages))
            {
                model.DemandID = DemandID;
                model.DemandName = StringUtility.RemoveHtmlTags(TextBox_ProductName.Text);
                model.Address = TextBox_Address.Text;
                model.Brief = TextBox_Brief.Text ;
                model.CategoryID = CategoryID;
                model.CategoryPath = cate.CategoryPath;
                model.CellPhone = TextBox_CellPhone.Text;
                model.Count = Convert.ToInt32(TextBox_Count.Text);
                model.ExpirationTime = Convert.ToDateTime(TextBox_ExpireTime.Text);
                model.InsertTime = DateTime.Now;
                model.SmallImage = ProductImages[0];
                model.MediumImage = ProductImages[1];
                model.Phone = TextBox_Phone.Text;
                model.PostCode = TextBox_PostCode.Text;
                model.Price = Convert.ToDecimal(TextBox_Price.Text);
                model.Region = String.Format("{0} {1} {2}", regionInfo.Province, regionInfo.City, regionInfo.County);
                model.Status = (int)DemandProductStatus.尚未审核;
                model.TrueName = TextBox_TrueName.Text;
                model.UpdateTime = DateTime.Now;
                model.UsageCondition = Convert.ToInt32(DropDown_Usage.SelectedValue);
                model.UserID = GetUserID();

                bll.Add(model);
                Response.Redirect("../SubmitSucc.aspx");
            }
            else
            {
                MessageBox.Show(this, "图片上传失败");
            }
        }
        private void BindData()
        {
            MagicCategoryModel Cate = new MagicCategoryBll().GetModel(CategoryID);

            Label_Category.Text = Cate.CategoryName;
            Hidden_CategoryPath.Value = Cate.CategoryPath;
        }