// Create a new order with customer ID public static string CreateCommerceLibOrder() { // get a configured DbCommand object DbCommand comm = GenericDataAccess.CreateCommand(); // set the stored procedure name comm.CommandText = "CreateCustomerOrder"; // create parameters DbParameter param = comm.CreateParameter(); param.ParameterName = "@CartID"; param.Value = shoppingCartId; param.DbType = DbType.String; param.Size = 36; comm.Parameters.Add(param); // create a new parameter param = comm.CreateParameter(); param.ParameterName = "@CustomerId"; param.Value = Membership.GetUser( HttpContext.Current.User.Identity.Name) .ProviderUserKey; param.DbType = DbType.Guid; param.Size = 16; comm.Parameters.Add(param); // return the result table return(GenericDataAccess.ExecuteScalar(comm)); }
// Counts old shopping carts public static int CountOldCarts(byte days) { // get a configured DbCommand object DbCommand comm = GenericDataAccess.CreateCommand(); // set the stored procedure name comm.CommandText = "ShoppingCartCountOldCarts"; // create a new parameter DbParameter param = comm.CreateParameter(); param.ParameterName = "@Days"; param.Value = days; param.DbType = DbType.Byte; comm.Parameters.Add(param); // execute the procedure and return number of old shopping carts try { return(Byte.Parse(GenericDataAccess.ExecuteScalar(comm))); } catch { return(-1); } }
// Create a new order from the shopping cart public static string CreateOrder() { // get a configured DbCommand object DbCommand comm = GenericDataAccess.CreateCommand(); // set the stored procedure name comm.CommandText = "CreateOrder"; // create a new parameter DbParameter param = comm.CreateParameter(); param.ParameterName = "@CartID"; param.Value = shoppingCartId; param.DbType = DbType.String; param.Size = 36; comm.Parameters.Add(param); // return the result table return(GenericDataAccess.ExecuteScalar(comm)); }