Exemple #1
0
        public static Int32 CartUpSert(SqlConnection dbcon, Cart_Lineitem cart)
        {
            SqlCommand cmd = new SqlCommand("sp_cart_upsert", dbcon);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@cartid", SqlDbType.Int).Value     = cart.CartNumber;
            cmd.Parameters.Add("@prodid", SqlDbType.VarChar).Value = cart.ProductId;
            cmd.Parameters.Add("@qty", SqlDbType.Int).Value        = cart.Quantity;
            int intCnt = cmd.ExecuteNonQuery();

            return(intCnt);
        }
Exemple #2
0
        public static int CUDCartLineItem(SqlConnection dbcon, string CUDAction, Cart_Lineitem obj)
        {
            SqlCommand cmd = new SqlCommand();

            if (CUDAction.ToLower() == "update")
            {
                cmd.CommandText = @"update cart_lineitems set Quantity = @Quantity Where CartNumber = @CartNumber and ProductId = @ProductId";
                cmd.Parameters.AddWithValue("@CartNumber", SqlDbType.Int).Value    = obj.CartNumber;
                cmd.Parameters.AddWithValue("@ProductId", SqlDbType.VarChar).Value = obj.ProductId;
                cmd.Parameters.AddWithValue("@Quantity", SqlDbType.Int).Value      = obj.Quantity;
            }
            else if (CUDAction.ToLower() == "delete")
            {
                cmd.CommandText = "delete cart_lineitems Where CartNumber = @CartNumber and ProductId = @ProductId";
                cmd.Parameters.AddWithValue("@CartNumber", SqlDbType.Int).Value    = obj.CartNumber;
                cmd.Parameters.AddWithValue("@ProductId", SqlDbType.VarChar).Value = obj.ProductId;
            }

            cmd.Connection = dbcon;
            int intResult = cmd.ExecuteNonQuery();

            cmd.Dispose();
            return(intResult);
        }