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); }
public static Int32 CUDCart_Lineitem(SqlConnection dbcon, string CUDAction, Cart_Lineitem cart) { SqlCommand cmd = new SqlCommand(); if (CUDAction == "update") { cmd.CommandText = "update Cart_LineItems set Quantity = @Quantity " + "where ProductId = @ProductId"; cmd.Parameters.AddWithValue("@CartNumber", SqlDbType.Int).Value = cart.CartNumber; cmd.Parameters.AddWithValue("@ProductId", SqlDbType.VarChar).Value = cart.ProductId; cmd.Parameters.AddWithValue("@Quantity", SqlDbType.Int).Value = cart.Quantity; } else if (CUDAction == "delete") { cmd.CommandText = "delete Cart_LineItems where ProductId = @ProductId"; cmd.Parameters.AddWithValue("@ProductId", SqlDbType.Int).Value = cart.ProductId; } cmd.Connection = dbcon; int intCnt = cmd.ExecuteNonQuery(); cmd.Dispose(); return(intCnt); }