/// <summary> /// 获取购物车总额 /// </summary> /// <param name="cartType"></param> /// <param name="userId"></param> /// <returns></returns> public decimal GetTotalAmount(int cartType, string userId) { DBExtend helper = dbHelper; string sql = "select sum(num*price) from $ICartItem where userid=" + userId + " and selected=1 and cartType=" + cartType; object obj = helper.ExecScalar(sql, typeof(ICartItem)); if (obj is DBNull) { obj = 0; } return(Convert.ToDecimal(obj)); }
//static void SetCartCount(int type, int num) //{ // CoreHelper.LocalCookie c = new CoreHelper.LocalCookie(cookieName); // if (num < 0) // num = 0; // c[cookieName + type] = num.ToString(); //} /// <summary> /// 购物车数量,用COOKIE存 /// </summary> public static int GetCartCount(int type) { DBExtend helper = dbHelper; var user = Person.PersonAction <TType> .CurrentUser; if (user != null) { string sql = "select sum(num) from $ICartItem where userid=" + user.Id + " and cartType=" + type; object obj = helper.ExecScalar(sql, typeof(ICartItem)); if (obj is DBNull) { obj = 0; } return((int)obj); } else { return(0); } //CoreHelper.LocalCookie c = new CoreHelper.LocalCookie(cookieName); //if (string.IsNullOrEmpty(c[cookieName + type])) //{ // DBExtend helper = dbHelper; // var user = Person.PersonAction<TType>.CurrentUser; // if (user != null) // { // string sql = "select sum(num) from $ICartItem where userid=" + user.Id + " and cartType=" + type; // object obj = helper.ExecScalar(sql, typeof(ICartItem)); // if (obj is DBNull) // { // obj = 0; // } // c[cookieName + type] = obj.ToString(); // return (int)obj; // } // else // { // return 0; // } //} //return Convert.ToInt32(c[cookieName + type]); }
/// <summary> /// 获取主数据表自增 /// </summary> /// <returns></returns> public int GetSequence() { string sql = "update DataSequence set Sequence=Sequence+1 select Sequence from DataSequence"; return(DBExtend.ExecScalar <int>(sql)); }