//读取购物车
function readCart(){
    loading("CartProductAjax","购物车");
    Ajax.requestURL("CartAjax.aspx?Action=Read",dealReadCart)
}
function dealReadCart(data){
    o("CartProductAjax").innerHTML=data;
}
//清空购物车
function clearCart(){
    Ajax.requestURL("CartAjax.aspx?Action=ClearCart",dealClearCart)
}
function dealClearCart(data){
    o("CartProductAjax").innerHTML="";
    o("ProductBuyCount").innerHTML=0;
    o("ProductTotalPrice").innerHTML=0;
}
//改变购买数量
function changeOrderProductBuyCount(strCartID,buyCountObj,oldCount,price,productCount,leftStorageCount){
    var buyCount=buyCountObj.value;
    if(Validate.isInt(buyCount) &&  parseInt(buyCount)>0){
        if(parseInt(buyCount)<=leftStorageCount){
            Ajax.requestURL("CartAjax.aspx?Action=ChangeBuyCount&StrCartID="+strCartID+"&BuyCount="+buyCount+"&OldCount="+oldCount+"&Price="+price+"&ProductCount="+productCount,dealOperateCart);
        }
        else{
            buyCountObj.value=oldCount;
            alertMessage("当前库存不能满足您的购买数量");
        }
    }
    else{
        alertMessage("数量填写有错误");
    }
}
//删除购物车
function deleteOrderProduct(strCartID,oldCount,price,productCount){
    Ajax.requestURL("CartAjax.aspx?Action=Delete&StrCartID="+strCartID+"&OldCount="+oldCount+"&Price="+price+"&ProductCount="+productCount,dealOperateCart);
}
function dealOperateCart(data){
    var dataArray=data.split("|");
    o("ProductBuyCount").innerHTML=dataArray[0];
    o("ProductTotalPrice").innerHTML=dataArray[1];
    readCart();
}
readCart();