590 lines
30 KiB
C#
590 lines
30 KiB
C#
using System;
|
||
using System.Security.Cryptography;
|
||
using System.IO;
|
||
using System.Text;
|
||
using System.Web;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
namespace Mtxfw.DAL
|
||
{
|
||
|
||
//公共函数
|
||
public class ShoppingCart0
|
||
{
|
||
static P_Product daoProduct = new P_Product();
|
||
static order_info daoorder = new order_info();
|
||
public static int TotalNum()
|
||
{
|
||
int intTotalNum = 0;
|
||
if (HttpContext.Current.Request.Cookies["0x120xxx"] != null)
|
||
{
|
||
HttpCookie myCookie = HttpContext.Current.Request.Cookies["0x120xxx"];
|
||
string strCookie = myCookie.Value;
|
||
string[] strACookie;
|
||
strACookie = strCookie.Split('|');
|
||
intTotalNum = 0;
|
||
for (int i = 0; i < strACookie.LongLength - 1; i++)
|
||
{
|
||
string[] strA = strACookie[i].Split(',');
|
||
if (strA.LongLength > 1)
|
||
{
|
||
if (strA[1] != "")
|
||
{
|
||
intTotalNum = intTotalNum + Convert.ToInt32(strA[1]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return intTotalNum;
|
||
}
|
||
public static int BTotalNum()
|
||
{
|
||
int intTotalNum = 0;
|
||
if (HttpContext.Current.Request.Cookies["0x120xxx"] != null)
|
||
{
|
||
HttpCookie myCookie = HttpContext.Current.Request.Cookies["0x120xxx"];
|
||
string strCookie = myCookie.Value;
|
||
string[] strACookie = strCookie.Split('|');
|
||
intTotalNum = strACookie.Length - 1;
|
||
|
||
}
|
||
return intTotalNum;
|
||
}
|
||
//定义一个静态函数,用来返回购物总金额
|
||
public static Double TotalMoney()
|
||
{
|
||
|
||
Double sglTotalMoney = 0;
|
||
if (HttpContext.Current.Request.Cookies["0x120xxx"] != null)
|
||
{
|
||
HttpCookie myCookie = HttpContext.Current.Request.Cookies["0x120xxx"];
|
||
string strCookie = myCookie.Value;
|
||
string[] strACookie;
|
||
strACookie = strCookie.Split('|');
|
||
for (int i = 0; i < strACookie.LongLength - 1; i++)
|
||
{
|
||
string[] strA = strACookie[i].Split(',');
|
||
if (strA.LongLength == 3)
|
||
{
|
||
if (strA[0] != "")
|
||
{
|
||
Mtxfw.Model.P_Product ModelProduct = daoProduct.GetModel(int.Parse(strA[0]));
|
||
if (ModelProduct != null)
|
||
{
|
||
sglTotalMoney = sglTotalMoney + ModelProduct.P_VIP_P * Convert.ToInt32(strA[1]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return sglTotalMoney;
|
||
}
|
||
|
||
|
||
//该过程用来返回购物车中的所有商品,注意,这里是将HashTable中的数据转换到了一个DataTable中,最后返回一个DataView对象
|
||
//转换成DataTable的原因是为了显示购物车时方便的帮定到DataGrid控件
|
||
public static DataView Getprod()
|
||
{
|
||
//从Cookie中获取购物车中的货物栏目信息
|
||
DataTable dt = new DataTable();
|
||
if (HttpContext.Current.Request.Cookies["0x120xxx"] != null)
|
||
{
|
||
HttpCookie myCookie = HttpContext.Current.Request.Cookies["0x120xxx"];
|
||
string strCookie = myCookie.Value;
|
||
if (strCookie.Trim() != "")
|
||
{
|
||
string[] strACookie;
|
||
dt = new DataTable("0x120xxx");
|
||
|
||
strACookie = strCookie.Split('|');
|
||
dt = new DataTable("0x120xxx"); //声明并建立DataTable对象,表的名称为 Books
|
||
DataColumn dc; //声明DataColumn对象变量
|
||
DataRow dr; //声明DataRow对象变量
|
||
//下面开始建立表格的结构
|
||
//建立第0列,商品编号id
|
||
dc = new DataColumn("id", System.Type.GetType("System.Int32"));
|
||
dt.Columns.Add(dc);
|
||
//建立第1列,商品名称prodName
|
||
dc = new DataColumn("prodName", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第2列,商品颜色selcolor
|
||
dc = new DataColumn("selcolor", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第2列,商品颜色selcolor
|
||
dc = new DataColumn("guige", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第3列,商品图片prodimg
|
||
dc = new DataColumn("prodimg", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第4列,商品IDprodid
|
||
dc = new DataColumn("prodid", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第5列,商品单价prodPrice
|
||
dc = new DataColumn("prodPrice", System.Type.GetType("System.Double"));
|
||
dt.Columns.Add(dc);
|
||
|
||
//建立第6列,购商品数量prodNum
|
||
dc = new DataColumn("prodNum", System.Type.GetType("System.Int32"));
|
||
dt.Columns.Add(dc);
|
||
//建立第7列,购商品请允许购买数量TotalNum
|
||
dc = new DataColumn("TotalNum", System.Type.GetType("System.Int32"));
|
||
dt.Columns.Add(dc);
|
||
//建立第8列,这是一个计算列,为商品的价格 * 商品数量
|
||
dc = new DataColumn("SubTotal", System.Type.GetType("System.Double"), "prodPrice*prodNum");
|
||
dt.Columns.Add(dc);
|
||
//建立第9列,这是一个计算列,为是否买家承担运费
|
||
dc = new DataColumn("IFMJCDYH", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第10列,这是一个计算列,为商品运费1
|
||
dc = new DataColumn("SPYH1", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第11列,这是一个计算列,为商品运费2
|
||
dc = new DataColumn("SPYH2", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第12列,这是一个计算列,为商品运费3
|
||
dc = new DataColumn("SPYH3", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第13列,商品所有者
|
||
dc = new DataColumn("SUserID", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第14列,商品类型
|
||
dc = new DataColumn("utype", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第15列,套餐商品列表
|
||
dc = new DataColumn("P_CATEGORYs", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第16列,商品成本
|
||
dc = new DataColumn("TotalCB", System.Type.GetType("System.Double"));
|
||
dt.Columns.Add(dc);
|
||
//建立第17列,积分
|
||
dc = new DataColumn("prodPrice0", System.Type.GetType("System.Double"));
|
||
dt.Columns.Add(dc);
|
||
//建立第17列,积分
|
||
dc = new DataColumn("prodPrice1", System.Type.GetType("System.Double"));
|
||
dt.Columns.Add(dc);
|
||
//建立第17列,积分
|
||
dc = new DataColumn("prodPrice2", System.Type.GetType("System.Double"));
|
||
dt.Columns.Add(dc);
|
||
//建立第18列,商品成本
|
||
dc = new DataColumn("qgproduct", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//下面根据HashTable中的商品栏目信息添加每一行
|
||
if (strACookie.LongLength > 0)
|
||
{
|
||
for (int i = 0; i < strACookie.Length - 1; i++)
|
||
{
|
||
//逐行赋值
|
||
string[] strA = strACookie[i].Split(',');
|
||
if (strA.Length > 2)
|
||
{
|
||
dr = dt.NewRow(); //新建1行,注意和新建列的区别
|
||
if (strA[0] != "")
|
||
{
|
||
dr["id"] = strA[0]; //商品编号
|
||
string guige = strA.Length > 3 ? strA[3] : "";
|
||
//HttpContext.Current.Response.Write(strA[0]);
|
||
int TNum = 0;
|
||
Mtxfw.Model.P_Product ModelProduct = daoProduct.GetModel(int.Parse(strA[0]));
|
||
if (ModelProduct != null)
|
||
{
|
||
TNum = ModelProduct.P_Orders; //返回已经购买总数
|
||
string selcolor = (strA[2] != "" ? Mtxfw.Utility.Security.DecryptString(strA[2]) : strA[2]);
|
||
dr["selcolor"] = selcolor; //返回商品颜色
|
||
dr["guige"] = guige; //返回商品规格
|
||
dr["prodimg"] = ModelProduct.P_images; //返回商品名称
|
||
dr["prodid"] = ModelProduct.P_ID; //返回商品名称
|
||
dr["SUserID"] = ModelProduct.P_UserID; //返回商品所有者
|
||
dr["utype"] = ModelProduct.utype; //返回商品类型
|
||
dr["P_CATEGORYs"] = ModelProduct.P_CATEGORYs; //返回套餐商品列表
|
||
dr["TotalCB"] = ModelProduct.P_CB_P; //返回商品成本
|
||
int intNum = ModelProduct.P_Inventory;
|
||
|
||
dr["prodPrice"] = ModelProduct.P_VIP_P;//返回商品折扣价格
|
||
dr["SPYH1"] = ModelProduct.P_YH_P;//返回商品运费strAuthor[1]
|
||
dr["qgproduct"] = ModelProduct.P_qgproduct.ToString();//返回抢购标志
|
||
string prodName = ModelProduct.P_NAME;
|
||
if (guige != "")
|
||
{
|
||
Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guige));
|
||
if (gmodel != null)
|
||
{
|
||
intNum = gmodel.G_KC;
|
||
dr["SPYH1"] = gmodel.G_ZL;//返回商品运费
|
||
string[] acolors = gmodel.G_Color.Split(',');
|
||
for (int j = 0; j < acolors.Length; j++)
|
||
{
|
||
if (acolors[j] != "")
|
||
{
|
||
var ac = acolors[j].Split('|');
|
||
if (ac[0] == selcolor)
|
||
{
|
||
if (ac.Length > 1)
|
||
{
|
||
if (ac[1] != "")
|
||
{
|
||
intNum = Convert.ToInt32(ac[1]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
dr["prodPrice"] = Convert.ToDouble(gmodel.G_JG).ToString("f2").Replace(",", "");
|
||
if (ModelProduct.utype == "5")
|
||
{
|
||
dr["prodPrice"] = Convert.ToDouble(gmodel.G_JG2).ToString("f2").Replace(",", "");
|
||
}
|
||
dr["prodPrice0"] = Convert.ToDouble(gmodel.G_JG0).ToString("f2").Replace(",", "");
|
||
dr["prodPrice1"] = Convert.ToDouble(gmodel.G_JG1).ToString("f2").Replace(",", "");
|
||
dr["prodPrice2"] = Convert.ToDouble(gmodel.G_JF).ToString("f2").Replace(",", "");
|
||
prodName += " " + gmodel.G_Name;
|
||
}
|
||
}
|
||
prodName += " " + (strA[2] != "" ? Mtxfw.Utility.Security.DecryptString(strA[2]) : strA[2]);
|
||
if (intNum == 0)
|
||
{
|
||
dr["TotalNum"] = 0; //返回商品剩余数量
|
||
}
|
||
else
|
||
{
|
||
dr["TotalNum"] = intNum - TNum; //返回商品剩余数量
|
||
}
|
||
dr["prodName"] = prodName; //返回商品名称
|
||
|
||
|
||
/*if (IFStores == 1)
|
||
{
|
||
dr["prodPrice"] = ModelProduct.P_VIP_P1;//返回同行商品价格
|
||
}
|
||
else if (IFStores == 2)
|
||
{
|
||
dr["prodPrice"] = ModelProduct.P_VIP_P2;//返回同行商品价格
|
||
}
|
||
else if (IFStores == 3)
|
||
{
|
||
dr["prodPrice"] = ModelProduct.P_VIP_P3;//返回同行商品价格
|
||
}*/
|
||
//string[] strAuthor = dv.Table.Rows[0]["N_Author"].ToString().Split('|');//返回商品运费
|
||
string[] strAuthor = "1|0|0|0".Split('|'); ; //返回商品运费
|
||
dr["IFMJCDYH"] = strAuthor[0];
|
||
|
||
dr["SPYH2"] = strAuthor[2];
|
||
dr["SPYH3"] = strAuthor[3];
|
||
}
|
||
//dv.Table.Clear();
|
||
}
|
||
dr["prodNum"] = 0;
|
||
if (strA[1] != "")//商品数量
|
||
{
|
||
dr["prodNum"] = Convert.ToInt32(strA[1]);
|
||
}
|
||
dt.Rows.Add(dr); //将该行加到表dt中
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//返回函数值,注意返回的是DataView
|
||
}
|
||
return dt.DefaultView;
|
||
}
|
||
//返回浏览过的商品
|
||
public static DataTable GetViewedProd()
|
||
{
|
||
//从Cookie中获取购物车中的货物栏目信息
|
||
DataTable dt = new DataTable();
|
||
if (HttpContext.Current.Request.Cookies["view_id"] != null)
|
||
{
|
||
HttpCookie myCookie = HttpContext.Current.Request.Cookies["view_id"];
|
||
string strCookie = myCookie.Value;
|
||
if (strCookie.Trim() != "")
|
||
{
|
||
string[] strACookie;
|
||
|
||
strACookie = strCookie.Split(',');
|
||
dt = new DataTable("view_id"); //声明并建立DataTable对象,表的名称为 Books
|
||
DataColumn dc; //声明DataColumn对象变量
|
||
DataRow dr; //声明DataRow对象变量
|
||
//下面开始建立表格的结构
|
||
//建立第0列,商品编号id
|
||
dc = new DataColumn("id", System.Type.GetType("System.Int32"));
|
||
dt.Columns.Add(dc);
|
||
//建立第1列,商品名称prodName
|
||
dc = new DataColumn("prodName", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第2列,商品颜色selcolor
|
||
dc = new DataColumn("selcolor", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第3列,商品图片prodimg
|
||
dc = new DataColumn("prodimg", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第4列,商品IDprodid
|
||
dc = new DataColumn("prodid", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第5列,商品单价prodPrice
|
||
dc = new DataColumn("prodPrice", System.Type.GetType("System.Double"));
|
||
dt.Columns.Add(dc);
|
||
//建立第6列,购商品数量prodNum
|
||
dc = new DataColumn("prodNum", System.Type.GetType("System.Int32"));
|
||
dt.Columns.Add(dc);
|
||
//建立第7列,购商品请允许购买数量TotalNum
|
||
dc = new DataColumn("TotalNum", System.Type.GetType("System.Int32"));
|
||
dt.Columns.Add(dc);
|
||
//建立第8列,这是一个计算列,为商品的价格 * 商品数量
|
||
dc = new DataColumn("SubTotal", System.Type.GetType("System.Double"), "prodPrice*prodNum");
|
||
dt.Columns.Add(dc);
|
||
//建立第9列,这是一个计算列,为是否买家承担运费
|
||
dc = new DataColumn("IFMJCDYH", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第10列,这是一个计算列,为商品运费1
|
||
dc = new DataColumn("SPYH1", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第11列,这是一个计算列,为商品运费2
|
||
dc = new DataColumn("SPYH2", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第12列,这是一个计算列,为商品运费3
|
||
dc = new DataColumn("SPYH3", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第13列,商品所有者
|
||
dc = new DataColumn("SUserID", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第14列,商品类型
|
||
dc = new DataColumn("utype", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//建立第15列,套餐商品列表
|
||
dc = new DataColumn("P_CATEGORYs", System.Type.GetType("System.String"));
|
||
dt.Columns.Add(dc);
|
||
//下面根据HashTable中的商品栏目信息添加每一行
|
||
if (strACookie.LongLength > 0)
|
||
{
|
||
int jj = 0;
|
||
for (int i = strACookie.Length - 1; i > 0; i--)
|
||
{
|
||
//逐行赋值
|
||
if (strACookie[i] != "" && jj < 5)
|
||
{
|
||
dr = dt.NewRow(); //新建1行,注意和新建列的区别
|
||
|
||
dr["id"] = strACookie[i]; //商品编号
|
||
//HttpContext.Current.Response.Write(strA[0]);
|
||
int TNum = 0;
|
||
Mtxfw.Model.P_Product ModelProduct = daoProduct.GetModel(int.Parse(strACookie[i]));
|
||
if (ModelProduct != null)
|
||
{
|
||
TNum = ModelProduct.P_Orders; //返回已经购买总数
|
||
dr["prodName"] = ModelProduct.P_NAME; //返回商品名称
|
||
dr["selcolor"] = ""; //返回商品颜色
|
||
dr["prodimg"] = ModelProduct.P_images; //返回商品名称
|
||
dr["prodid"] = ModelProduct.P_ID; //返回商品名称
|
||
dr["SUserID"] = ModelProduct.P_UserID; //返回商品所有者
|
||
dr["utype"] = ModelProduct.utype; //返回商品类型
|
||
dr["P_CATEGORYs"] = ModelProduct.P_CATEGORYs; //返回套餐商品列表
|
||
int intNum = ModelProduct.P_Inventory;
|
||
if (intNum == 0)
|
||
{
|
||
dr["TotalNum"] = 0; //返回商品剩余数量
|
||
}
|
||
else
|
||
{
|
||
dr["TotalNum"] = intNum - TNum; //返回商品剩余数量
|
||
}
|
||
dr["prodPrice"] = ModelProduct.P_VIP_P;//返回商品折扣价格
|
||
//string[] strAuthor = dv.Table.Rows[0]["N_Author"].ToString().Split('|');//返回商品运费
|
||
string[] strAuthor = "1|0|0|0".Split('|'); ; //返回商品运费
|
||
dr["IFMJCDYH"] = strAuthor[0];
|
||
dr["SPYH1"] = strAuthor[1];
|
||
dr["SPYH2"] = strAuthor[2];
|
||
dr["SPYH3"] = strAuthor[3];
|
||
}
|
||
dr["prodNum"] = 0;
|
||
dt.Rows.Add(dr);
|
||
jj += 1;
|
||
}
|
||
//将该行加到表dt中
|
||
}
|
||
}
|
||
}
|
||
//返回函数值,注意返回的是DataView
|
||
}
|
||
return dt;
|
||
}
|
||
//该函数用来判断该商品是否已经在购物车中
|
||
public static bool IsExist(string strProdId, string selcolor, string guige)
|
||
{
|
||
//从Cookie中获取购物车中的货物栏目信息
|
||
string strCookie = "";
|
||
bool b = false;
|
||
if (HttpContext.Current.Request.Cookies["0x120xxx"] != null)
|
||
{
|
||
HttpCookie myCookie = HttpContext.Current.Request.Cookies["0x120xxx"];
|
||
strCookie = myCookie.Value;
|
||
}
|
||
string[] strACookie = strCookie.Split('|');
|
||
if (strACookie.LongLength > 0)
|
||
{
|
||
for (int i = 0; i < strACookie.Length - 1; i++)
|
||
{
|
||
string[] strA = strACookie[i].Split(',');
|
||
if (strA.Length > 2)
|
||
{
|
||
if (strA[0] != "")
|
||
{
|
||
string stra = strA[2];
|
||
string strb = strA.Length > 3 ? strA[3] : "";
|
||
if (strA[0] == strProdId && selcolor == stra && strb == guige)
|
||
{
|
||
b = true; //表示该商品已经存在
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return b;
|
||
}
|
||
//向购物车中添加一商品,如果该商品已经存在,只要修改数量即可,如果不存在,则需要添加一项
|
||
public static void Addprod(string strProdId, int num, string selcolor, string guige)
|
||
{
|
||
//从Cookie中获取购物车中的货物栏目信息
|
||
|
||
|
||
|
||
string[] AProdId = strProdId.Split(',');
|
||
for (int j = 0; j < AProdId.Length; j++)
|
||
{
|
||
string strCookie = "";
|
||
if (AProdId.Length > 0)
|
||
{
|
||
|
||
if (AProdId[j] != "")
|
||
{
|
||
HttpCookie myCookie = new HttpCookie("0x120xxx");
|
||
if (IsExist(AProdId[j], selcolor, guige))
|
||
{
|
||
if (HttpContext.Current.Request.Cookies["0x120xxx"] != null)
|
||
{
|
||
myCookie = HttpContext.Current.Request.Cookies["0x120xxx"];
|
||
strCookie = myCookie.Value;
|
||
string[] strACookie;
|
||
strACookie = strCookie.Split('|');
|
||
//下面根据HashTable中的商品栏目信息添加每一行
|
||
for (int i = 0; i < strACookie.Length - 1; i++)
|
||
{
|
||
string[] strA = strACookie[i].Split(',');
|
||
if (strA.Length > 2)
|
||
{
|
||
if (strA[0] != "")
|
||
{
|
||
if (strA[0] == AProdId[j] && strA[2] == selcolor && strA[3] == guige)
|
||
{
|
||
strCookie = strCookie.Replace(strA[0] + "," + strA[1] + "," + strA[2] + "," + strA[3], strA[0] + "," + (Convert.ToInt32(strA[1]) + num).ToString() + "," + strA[2] + "," + strA[3]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (HttpContext.Current.Request.Cookies["0x120xxx"] != null)
|
||
{
|
||
myCookie = HttpContext.Current.Request.Cookies["0x120xxx"];
|
||
strCookie = myCookie.Value;
|
||
}
|
||
strCookie += AProdId[j] + "," + num + "," + selcolor + "," + guige + "|";
|
||
}
|
||
//最后将新的购物栏目信息保存到Cookie中
|
||
myCookie.Value = strCookie;
|
||
myCookie.Expires = DateTime.Now.AddYears(1);
|
||
//myCookie.Domain = "vip.lscxwl.com";
|
||
HttpContext.Current.Response.Cookies.Add(myCookie);
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
//从购物车中删除一本书
|
||
public static void RemoveProd(string OrdersIDs)
|
||
{
|
||
HttpCookie myCookie = new HttpCookie("0x120xxx");
|
||
string strCookie = "";
|
||
//从Cookie中获取购物车中的货物栏目信息
|
||
if (HttpContext.Current.Request.Cookies["0x120xxx"] != null)
|
||
{
|
||
myCookie = HttpContext.Current.Request.Cookies["0x120xxx"];
|
||
strCookie = myCookie.Value;
|
||
string[] strACookie;
|
||
strACookie = strCookie.Split('|');
|
||
for (int i = 0; i < strACookie.Length - 1; i++)
|
||
{
|
||
//下面更改数量
|
||
string[] strA = strACookie[i].Split(',');
|
||
if (strA.Length > 2)
|
||
{
|
||
if (strA[0] != "")
|
||
{
|
||
string stra = strA[2];
|
||
if (OrdersIDs.IndexOf("," + strA[0] + ",") != -1)
|
||
{
|
||
strCookie = strCookie.Replace(strACookie[i] + "|", "");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//最后将新的购物栏目信息保存到Cookie中
|
||
myCookie.Value = strCookie;
|
||
myCookie.Expires = DateTime.Now.AddYears(1);
|
||
//myCookie.Domain = "vip.lscxwl.com";
|
||
HttpContext.Current.Response.Cookies.Add(myCookie);
|
||
}
|
||
|
||
//更改购物车中的货物数量
|
||
public static void UpdateProd(string strProdId, string intprodNum, string selcolor, string guige)
|
||
{
|
||
HttpCookie myCookie = new HttpCookie("0x120xxx");
|
||
string strCookie = "";
|
||
//从Cookie中获取购物车中的货物栏目信息
|
||
if (HttpContext.Current.Request.Cookies["0x120xxx"] != null)
|
||
{
|
||
myCookie = HttpContext.Current.Request.Cookies["0x120xxx"];
|
||
strCookie = myCookie.Value;
|
||
string[] strACookie;
|
||
strACookie = strCookie.Split('|');
|
||
for (int i = 0; i < strACookie.Length - 1; i++)
|
||
{
|
||
//下面更改数量
|
||
string[] strA = strACookie[i].Split(',');
|
||
if (strA.Length > 2)
|
||
{
|
||
if (strA[0] != "")
|
||
{
|
||
string stra = strA[2];
|
||
if (strA[0] == strProdId && stra == selcolor && strA[3] == guige)
|
||
{
|
||
if (intprodNum == "" || intprodNum == "0")
|
||
{
|
||
strCookie = strCookie.Replace(strACookie[i] + "|", "");
|
||
}
|
||
else
|
||
{
|
||
strCookie = strCookie.Replace(strA[0] + "," + strA[1] + "," + strA[2] + "," + strA[3], strA[0] + "," + intprodNum + "," + strA[2] + "," + strA[3]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//最后将新的购物栏目信息保存到Cookie中
|
||
myCookie.Value = strCookie;
|
||
myCookie.Expires = DateTime.Now.AddYears(1);
|
||
//myCookie.Domain = "vip.lscxwl.com";
|
||
HttpContext.Current.Response.Cookies.Add(myCookie);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
}
|