asnet实现购物车详细代码二节能
2020-10-09 02:38:37 双城汽车网
public void UpdateShoppingCart( )
{
if( Session["myCartTable"]==null )//Session["myCartTable"]==null
{
CreateCartTable( );
//调用函数CreateCartTable( )新建一个DataTable WriteShoppingCart( );
}
else
{
//如果购物蓝中已有商品,则需要对购物信息表DataTable进行更新,并将其棒定到ShoppingCartDlt WriteShoppingCart( );
}
}
public void ViewShoppingCart( ) //查看购物车
{
if( Session["myCartTable"]!=null )
{
DataTable viewTable=new DataTable( "nowCartTable" );
viewTable=( DataTable )Session["myCartTable"];
taSource = faultView;
//购物车棒定到ShoppingCartDlt taBind( );
}
}
public void WriteShoppingCart( )
{
if( rams["mode"]!="view" ) //检查是否是直接查看购物车,如果直接查看,就不再写MYCARTTABLE
{
DataTable nowTable=new DataTable( "nowCartTable" );
nowTable=( DataTable )Session["myCartTable"];
int pn=unt;
int i=0;
bool hasone=false;
int nowProdID;
while( i<pn !hasone )
{
nowProdID=rse( ws[i][0].ToString( ) );
if( nowProdID==rse( AddProID ) ) //判断购物信息表中,是否存有当前放入商品. if( nowProdID==rse( AddProID ) )
{
hasone=true;
}
else
{
i++;
}
}
if( hasone )
{
//如果已有该商品,则 hasone=true,更改该数据行 DataRow oldDR;
oldDR=ws[i];
oldDR["ProdCount"]=rse服务员会非常迅速和熟练的进行刷卡消费。”民警称( oldDR["ProdCount"].ToString( ) )+1;
oldDR["TotalPrice"]=rse( oldDR["ProdCount"].ToString( ) )*rse( oldDR["UnitPrice"].ToString( ) );
}
else
{
//如果没有该商品,在表中新加如一行. DataRow newDR;
double unitp;
String strcon="provider=EDB.4.0;
data Source="+pPath( pSettings["MDBpath2"] )+";
";
OleDbConnection myConnection = new OleDbConnection( strcon );
string strSQL= "select * from pro where product_id="+AddProID+"";
OleDbDataAdapter myCommand = new OleDbDataAdapter( strSQL, myConnection );
DataSet ds = new DataSet( );
ll( ds, "AddP" );
newDR=wRow( );
newDR[0]=AddProID;
newDR[2]=bles["Addp"].Rows[0]["product_name"].ToString( );
unitp=rse( bles["AddP"].Rows[0]["product_memprice"].ToString( ) );
//会员价 newDR[3]=unitp;
newDR[4]=unitp;
//第一次读库,所以总价格和单价是一样的. //newDR[5]="0";
d( newDR );
ose( );
}
taSource = faultView;
//将更新后的 DataTable棒定到ShoppingCartDlt taBind( );
Session["myCartTable"] = nowTable;
//重新保存更新过的DataTable
}
}
public void Caculator( )
{
if( Session["myCartTable"]!=null ) //购物车是否为空
{
int h;
Double TotalPri;
TotalPri=0;
DataTab为广大玩家提供口碑甚好的游戏赚钱le nowTable3=new DataTable( "nowCartTable3" );
nowTable3=( DataTable )Session["myCartTable"];
if( unt>0 ) //返回购物车中是否有货物
{
for( h=0;
h<=unt-1;
h++ )
{
TotalPri=TotalPri+rse( ws[h][4].ToString( ) );
//rse( ( string )xt );
}
xt="总计: "+String( )+" 元" ;
}
}
}
查看本文来源
铜陵哪里治疗白癜风好保山看白癜风的医院先声药业再上市