📄 product.aspx.cs
字号:
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 YXShop.Model;
using YXShop.BLL;
using YXShop.Common;
using YXShop.DBUtility;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Shop.Web.UI;
namespace YXShop.Web.Admin.Product
{
public partial class Product : System.Web.UI.Page
{
BasePage bp = new BasePage();
YXShop.BLL.Pro_Categories datam = new YXShop.BLL.Pro_Categories();
YXShop.BLL.Pro_Categories pc = new YXShop.BLL.Pro_Categories();
YXShop.BLL.Product BLL = new YXShop.BLL.Product();
YXShop.Model.Product model = new YXShop.Model.Product();
//商品一级分类字符串
protected string StairSelectList;
protected string ProvinceList, Province_ID;
//构建会员等级价格的表单输入框
public string rankPriceList = "您尚未添加会员等级";
//商品的相关商品ID列表
public string Pro_RelatingProID = "<select size=\"14\" id=\"selPro_RelatingProIDSelect\" multiple=\"multiple\" name=\"selPro_RelatingProIDSelect\" style=\"width: 98%\"> </select>\"";
//商品的相关文章ID列表
public string Pro_RelatingArtID = "<select size=\"14\" id=\"selPro_RelatingArtIDSelect\" multiple=\"multiple\" name=\"selPro_RelatingArtIDSelect\" style=\"width: 98%\"> </select>";
//商品品牌列表
public string pro_Brand_ID = "请选择商品分类";
//商品分类列表
public string pro_Pro_PValues = "请选择商品分类";
//商品分类ID
public string proClass_ID ;
//商品出售方式
public string saleType = "1";
//提交按钮的名称,添加商品时,该按钮的文本为“添 加”,当修改时,该按钮的文本为“修 改”
public string commandName = "添 加";
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(YXShop.Web.Admin.Product.Product));
if (YXShop.Common.WebUtility.isNumeric(Request.QueryString["ID"]))
{
if (!PowerTree.PowerPass.isPass("001008004", PowerTree.PowerPanel.PowerType.update))
{
bp.PageError("对不起,你没有修改商品的权限!", "../index.aspx");
}
}
else
{
if (!PowerTree.PowerPass.isPass("001008002", PowerTree.PowerPanel.PowerType.add))
{
bp.PageError("对不起,你没有添加商品的权限!", "../index.aspx");
}
}
if (!this.IsPostBack)
{
rankPriceListString();
firstClass(0);
rankPriceListString();
bindddlProU_ID();
updateBind();
}
//点击提交时,将相关文章和相关商品全选
this.btnAdd.Attributes.Add("OnClick", "selectAll();");
}
#region 添加与修改
protected void btnAdd_Click(object sender, EventArgs e)
{
if (Convert.ToDateTime(txtPro_AutoUp.Date.ToString()) > Convert.ToDateTime(txtPro_AutoDown.Date.ToString()))
{
YXShop.Common.alert.Show(this, "下架时间小于上架时间请重新选择!");
return;
}
//if (Convert.ToDouble(txtPro_ShopPrice.ToString()) < Convert.ToDouble(txtPro_CostPrice.ToString()))
//{
// YXShop.Common.alert.Show(this, "提示!!商品价低于成本价格");
//}
#region 商品扩展属性
string Pro_PValues = "";
try
{
string parmTemp = Request["hdparmName"];
if (parmTemp.IndexOf(",") != -1)
{
foreach (string pTemp in parmTemp.Split(','))
{
Pro_PValues += pTemp + "," + Request[pTemp] + "|";
}
}
else
{
Pro_PValues = parmTemp + "," + Request[parmTemp] + "|";
}
}
catch
{
Pro_PValues = "0,0";
}
#endregion
#region 商品分类
string Pro_CID = "0";
try
{
Pro_CID = Request["txtPro_CID"];
}
catch
{
Pro_CID = "0";
}
string tempFather = "";
List<YXShop.Model.Pro_Categories> p = pc.GetId(Int32.Parse(Pro_CID));
List<YXShop.Model.Pro_Categories> MP = pc.GetAll();
foreach (YXShop.Model.Pro_Categories m in MP)
{
tempFather += m.ProC_CategroiesID + ",";
}
if (p.Count > 0)
{
foreach (YXShop.Model.Pro_Categories c in p)
{
if (tempFather.IndexOf(Convert.ToString(c.ProC_ID)) != -1)
{
YXShop.Common.alert.show("请选择最下层的商品分类");
}
}
}
else
{
YXShop.Common.alert.Show(this, "请选择商品分类");
}
#endregion
#region 商品品牌
int Brand_ID = 0;
try
{
Brand_ID = int.Parse(Request["ddlBrand_ID"]);
}
catch
{
Brand_ID = 0;
}
#endregion
string Pro_Name = this.txtPro_Name.Text;//商品名称
string Pro_MOdel = this.txtPro_MOdel.Text;//商品型号
string Pro_NO = this.txtPro_NO.Text;//商品编码
string Pro_KeyWord = this.txtPro_KeyWord.Text;//商品关键字
string Pro_Description = this.txtPro_Description.Text;//商品简介
decimal Pro_MarketPrice = decimal.Parse(this.txtPro_MarketPrice.Text);//商品市场价
int Pro_SaleType = int.Parse(this.ddlSaleType.SelectedValue);//商品出售方式:1:只能使用现金购买;2:只能使用积分购买;3:现金或积分均可
decimal Pro_ShopPrice = 0;//商品商城价
decimal Pro_IntegralPrice = 0;//商品积分价
#region 根据出售方式来绑定商品商城价格和积分价格
if (Pro_SaleType == 1)
{
Pro_ShopPrice = decimal.Parse(this.txtPro_ShopPrice.Text);
Pro_IntegralPrice = 0;
}
else if (Pro_SaleType == 2)
{
Pro_ShopPrice = 0;
Pro_IntegralPrice = decimal.Parse(this.txtPro_IntegralPrice.Text);
}
else
{
Pro_ShopPrice = decimal.Parse(this.txtPro_ShopPrice.Text);
try
{
Pro_IntegralPrice = decimal.Parse(this.txtPro_IntegralPrice.Text);
}
catch
{
Pro_IntegralPrice = 0;
}
}
//Response.Write(Pro_ShopPrice);
//Response.End();
#endregion
string Pro_RatingDiscount = Request["txtPro_RatingDiscount"];//会员等级价格折扣列表
decimal Pro_VirtualCurrencies =this.txtPro_VirtualCurrencies.Text!=string.Empty?decimal.Parse(this.txtPro_VirtualCurrencies.Text):0;//商品的虚拟币售价,为0表示不支持虚拟币购买
decimal Pro_Integral = decimal.Parse(this.txtPro_Integral.Text);//赠送积分
#region 商品详细图
string[] Pro_MarkPicList = null;
string Pro_MarkPic = "";
//如果是修改商品信息
if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
{
//如果修改商品时,并没有上传新的图片
if (!fuPro_MarkPic.HasFile)
{
Pro_MarkPic = Convert.ToString(ViewState["ProDetailImg"]);
}
else
{
Pro_MarkPicList = YXShop.Common.WaterImage.waterImage(fuPro_MarkPic, "../../YXUploadFile/YXProduct/Image/", "../../YXUploadFile/YXProduct/ThumbnailImg/", "../../YXUploadFile/YXProduct/waterCharater/", "../../YXUploadFile/YXProduct/waterImg/", "易想商城YXShop", 232, 232, 0.5, 0.5, 0.5, 0.5, false, false, true).Split('|');
Pro_MarkPic = Pro_MarkPicList[0];
}
}
else
{
if (fuPro_MarkPic.HasFile)
{
Pro_MarkPicList = YXShop.Common.WaterImage.waterImage(fuPro_MarkPic, "../../YXUploadFile/YXProduct/Image/", "../../YXUploadFile/YXProduct/ThumbnailImg/", "../../YXUploadFile/YXProduct/waterCharater/", "../../YXUploadFile/YXProduct/waterImg/", "易想商城YXShop", 232, 232, 0.5, 0.5, 0.5, 0.5, false, false, true).Split('|');
Pro_MarkPic = Pro_MarkPicList[0];
}
else
{
Pro_MarkPic = "";
}
}
#endregion
#region 商品缩略图
string[] Pro_SmallImagesArray = null;
string Pro_SmallImages = "";
//如果是修改商品
if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
{
#region 如果是修改商品
if (cbBreviary.Checked)//如果选择了自动生成商品缩略图
{
if (fuPro_MarkPic.HasFile)
{
try
{
Pro_SmallImages = Pro_MarkPicList[1];
}
catch (Exception ex)
{
alert.show("商品详细图片上传失败,请重试!详细信息:" + ex.ToString());
Pro_SmallImages = "default.gif";
}
}
else
{
Pro_SmallImages = "";
}
}
else
{
if (fuPro_SmallImages.HasFile)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -