

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Transactions.aspx <%@ Page Language="C#" %>
Database Transactions
Database Transactions
Cash
Reload
Inventory
using System; using System.Web; using System.Data.SqlClient; /// /// Summary description for Transaction /// public class Transaction { SqlConnection myConnect = new SqlConnection(); SqlCommand myCommand = new SqlCommand(); SqlTransaction myTransaction; string status = ""; //constructor public Transaction(string ConnectionName) { string ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[ConnectionName].ToString(); myConnect.ConnectionString = ConnectionString; } public string BuyProduct() { StartTransaction(); //Transfer cash status += ExecuteUpdate("Update tblCash SET Balance = Balance + 1 where Role = 'Seller'"); status += ExecuteUpdate("Update tblCash SET Balance = Balance - 1 where Role = 'Buyer'"); //Transfer product status += ExecuteUpdate("Update tblInventory SET Inventory = Inventory + 1 where Role = 'Buyer'"); status += ExecuteUpdate("Update tblInventory SET Inventory = Inventory - 1 where Role = 'Seller'"); EndTransaction(); status += "Successful transaction!"; return status; } public string SellProduct() {