Beispiel #1
0
        //TRYIT FOR ELECTIVE SERVICE #4
        protected void CalcNumSharesBtn_Click(object sender, EventArgs e)
        {
            //store variables for stockSymbol, monthlyInvestment, and numYears
            string  stockSymbol       = OwnedSharesInput1.Value;
            decimal monthlyInvestment = Convert.ToDecimal(OwnedSharesInput2.Value);
            int     numYears          = Convert.ToInt32(OwnedSharesInput3.Value);

            //open the proxy
            StockRelatedWebServices.Service1Client proxy = new StockRelatedWebServices.Service1Client();
            //calculate number of shares owned
            double numOwnedShares = proxy.GetNumSharesWithDollarCostAvg(stockSymbol, monthlyInvestment, numYears);

            //display result
            OwnedSharesTextBox.Text = string.Format("{0:f2}", numOwnedShares);

            proxy.Close();
        }