private void getStock()
        {
            // Hide the search result message.
            lblSearchResultMessage.Visible = false;

            // Get the stock code and check if it is an integer.
            string stockCode = txtStockCode.Text.Trim();
            int    n;

            if (!int.TryParse(stockCode, out n) && stockCode != "")
            {
                lblSearchResultMessage.Text    = "Invalid stock code.";
                lblSearchResultMessage.Visible = true;
                return;
            }

            // Construct and execute the SQL statement.
            string sql = "select cast([code] as int) as [code], [name], [close] from [Stock]";

            if (stockCode != "")
            {
                sql = sql + "where ([code]=" + stockCode + ")";
            }
            sql = sql + " order by [code]";
            DataTable dtStock = new DataTable();

            dtStock = myExternalData.getData(sql);

            // If no result is returned, then display a message.
            if (dtStock == null || dtStock.Rows.Count == 0)
            {
                lblSearchResultMessage.Text    = "No such stock.";
                lblSearchResultMessage.Visible = true;
                gvStock.Visible = false;
            }
            // Otherwise, if a sort direction and sort expression are set in ViewState,
            // then first sort the result and then set and bind the GridView.
            else
            {
                string   sortDirection = null, sortExpression = null;
                DataView dvStock = new DataView(dtStock);
                if (ViewState["SortDirection"] != null)
                {
                    sortDirection = ViewState["SortDirection"].ToString();
                }

                if (ViewState["SortExpression"] != null)
                {
                    sortExpression = ViewState["SortExpression"].ToString();
                    dvStock.Sort   = string.Concat(sortExpression, " ", sortDirection);
                }
                gvStock.DataSource = dvStock.ToTable();;
                gvStock.DataBind();
                gvStock.Visible = true;
            }
        }
예제 #2
0
        private void getBondBuyOrders()
        {
            lblBuyMessage.Visible = false;
            // Get the bond buy orders.
            string sql = "select 0.00 as [currentPrice], [referenceNumber], [securityCode], [dateSubmitted], [status], [amount] from [Order] " +
                         "where [buyOrSell]='buy' and [securityType]='bond' and [status]='pending' order by referenceNumber, securityCode";
            DataTable dtBuyBond = myExternalData.getData(sql);

            // If no result is returned, then display a message.
            if (dtBuyBond == null || dtBuyBond.Rows.Count == 0)
            {
                showMessage("buy", "There are no buy orders.", "info");
                gvBondBuyOrder.Visible = false;
                return;
            }
            gvBondBuyOrder.DataSource = dtBuyBond;
            gvBondBuyOrder.DataBind();
            gvBondBuyOrder.Visible = true;
        }
예제 #3
0
        private void getStockBuyOrders()
        {
            lblBuyMessage.Visible = false;
            // Get the stock buy orders.
            string sql = "select [status], [referenceNumber], [securityCode], [dateSubmitted], [amount], [stockOrderType], [expiryDay], [allOrNone], [limitPrice], [stopPrice] from [Order] " +
                         "where [buyOrSell]='buy' and [securityType]='stock' and ([status]='pending' or [status]='partial') order by referenceNumber, securityCode";
            DataTable dtBuyStock = myExternalData.getData(sql);

            // If no result is returned, then display a message.
            if (dtBuyStock == null || dtBuyStock.Rows.Count == 0)
            {
                showMessage("buy", "There are no buy orders.", "info");
                gvStockBuyOrder.Visible = false;
                return;
            }
            gvStockBuyOrder.DataSource = dtBuyStock;
            gvStockBuyOrder.DataBind();
            gvStockBuyOrder.Visible = true;
        }
예제 #4
0
        protected void search1_Click(object sender, EventArgs e)
        {
            ddlSort.SelectedValue = "Sort by Name (Default)";
            string type = securityType.SelectedValue;

            //string method = searchMethod.SelectedValue;

            if (type == "Bond")
            {
                DataTable dtBond = new DataTable();
                dtBond = myExternalData.getData("select * from [Bond] order by [name]");
                if (dtBond == null)
                {
                    result.Visible = false; return;
                }
                else
                {
                    gvSecurityDetails.DataSource = dtBond;
                    gvSecurityDetails.DataBind();
                    result.Visible = true;
                }
            }
            else if (type == "Unit Trust")
            {
                DataTable dtUnitTrust = new DataTable();
                dtUnitTrust = myExternalData.getData("select * from [UnitTrust] order by [name]");
                if (dtUnitTrust == null)
                {
                    result.Visible = false; return;
                }
                else
                {
                    gvSecurityDetails.DataSource = dtUnitTrust;
                    gvSecurityDetails.DataBind();
                    result.Visible = true;
                }
            }
            else if (type == "Stock")
            {
                DataTable dtStock = new DataTable();
                dtStock = myExternalData.getData("select * from [Stock] order by [name]");
                if (dtStock == null)
                {
                    result.Visible = false; return;
                }
                else
                {
                    gvSecurityDetails.DataSource = dtStock;
                    gvSecurityDetails.DataBind();
                    result.Visible = true;
                }
            }
        }