using System; using System.Web; using System.Web.Security; using System.Text; using Trade.StockTraderWebApplicationServiceClient; using Trade.StockTraderWebApplicationModelClasses; using Trade.StockTraderWebApplicationSettings; using Trade.Utility; namespace Trade.Web { /// /// Allows users to enter number of shares for a buy/sell operation. /// public partial class StockTrade : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Date.Text = DateTime.Now.ToString("f"); string userid = HttpContext.Current.User.Identity.Name; BSLClient businessServicesClient = new BSLClient(); string action = Input.InputText(Request["action"], 5); string returnUrl = Input.InputText(Request["return"], 25); if (action == StockTraderUtility.ORDER_TYPE_BUY) { string quoteSymbol = Input.InputText(Request["symbol"], StockTraderUtility.QUOTESYMBOL_MAX_LENGTH); QuoteDataUI quote = businessServicesClient.getQuote(quoteSymbol); LinkButtonBuy.PostBackUrl = Settings.PAGE_ORDER + "?action=buy" + "&symbol=" + quote.symbol; LinkButtonCancel.PostBackUrl = LinkButtonCancel.PostBackUrl + "?symbols=" + quoteSymbol; TradeOperation.Text = "You have requested to buy shares of " + quote.quoteLink + " which is currently trading at " + quote.priceWithArrow; } else { LinkButtonCancel.PostBackUrl = returnUrl; string holdingID = Request["holdingid"]; int holdingid = Convert.ToInt32(holdingID); if (action == StockTraderUtility.ORDER_TYPE_SELL) { if (Settings.interfaceMode == StockTraderUtility.ACCESS_WebService_WSHttp_WSO2) { TradeOperation.Text = "You have requested to sell your holding " + holdingID + ". Please confirm this request."; //indicate for postback we are running against WebSphere Trade 6.1 which does not implement the functionality/business logic //to sell a portion of a holding--only the entire holding can be sold at once. quantity.Text = "-1"; quantity.Visible = false; LinkButtonBuy.Text = "Sell"; LinkButtonBuy.PostBackUrl = Settings.PAGE_ORDER + "?action=sell" + "&holdingid=" + holdingID; } else { HoldingDataUI holding = businessServicesClient.getHolding(userid, holdingid); StringBuilder strBldr = new StringBuilder("You have requested to sell all or part of your holding "); strBldr.Append(holdingID); strBldr.Append(". This holding has a total of "); strBldr.Append(holding.quantity); strBldr.Append(" shares of stock "); strBldr.Append(holding.quoteID); strBldr.Append(". Please indicate how many shares to sell."); TradeOperation.Text = strBldr.ToString(); quantity.Text = holding.quantity; LinkButtonBuy.Text = "Sell"; LinkButtonBuy.PostBackUrl = Settings.PAGE_ORDER + "?action=sell" + "&holdingid=" + holdingID; } } } } } }