Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int minQty = string.IsNullOrEmpty(MinQuantityTextBox.Text) ? -1 : Int32.Parse(MinQuantityTextBox.Text);
            int maxQty = string.IsNullOrEmpty(MaxQuantityTextBox.Text) ? -1 : Int32.Parse(MaxQuantityTextBox.Text);

            DataTable dt = new DataTable();

            dt.Columns.Add("Company Symbol");
            dt.Columns.Add("Quantity", typeof(int));

            String username = Session["Username"].ToString();

            SharesBrokeringWSReference.SharesBrokeringWSClient javaWSclient = new SharesBrokeringWSReference.SharesBrokeringWSClient();

            SharesBrokeringWSReference.ShareInfo[] shareInfos = javaWSclient.GetUserShares(username, SymbolTextBox.Text, minQty, maxQty);

            if (shareInfos != null)
            {
                NoSharesFoundLabel.Visible = false;

                foreach (SharesBrokeringWSReference.ShareInfo s in shareInfos)
                {
                    DataRow row = dt.NewRow();
                    row[0] = s.CompanySymbol;
                    row[1] = s.Quantity;
                    dt.Rows.Add(row);
                }
            }
            else
            {
                NoSharesFoundLabel.Visible = true;
            }
            MySharesGridView.DataSource = dt;
            MySharesGridView.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CompanySymbolValueLabel.Text = Session["sellCompanySymbol"].ToString();
            QuantityValueLabel.Text      = Session["sellQuantity"].ToString();

            SharesBrokeringWSReference.SharesBrokeringWSClient javaWSclient = new SharesBrokeringWSReference.SharesBrokeringWSClient();
            SharesBrokeringWSReference.Share s = javaWSclient.getShare(Session["sellCompanySymbol"].ToString(), Session["currency"].ToString());
            if (s != null)
            {
                CompanyNameValueLabel.Text = s.CompanyName;
                PriceValueLabel.Text       = s.Price.Value.ToString();
            }
            else
            {
                ShareFailedLabel.Visible          = true;
                QuantityToSellLabel.Visible       = false;
                QuantityToSellTextBox.Visible     = false;
                CalculateTotalPriceButton.Visible = false;
            }


            String news = javaWSclient.getNews(Session["sellCompanySymbol"].ToString());

            if (news == "")
            {
                NewsLabel.Text = "Couldn't find news for " + Session["sellCompanySymbol"].ToString();

                Headline1Label.Visible = false;
                URL1Label.Visible      = false;
                Summary1Label.Visible  = false;
                Headline2Label.Visible = false;
                URL2Label.Visible      = false;
                Summary2Label.Visible  = false;
                Headline3Label.Visible = false;
                URL3Label.Visible      = false;
                Summary3Label.Visible  = false;
            }
            else
            {
                news = news.Replace("^//", "\"").Replace("^/", "'");
                String[] sep       = { "###" };
                String[] newsSplit = news.Split(sep, StringSplitOptions.RemoveEmptyEntries);

                Headline1ValueLabel.Text  = newsSplit[0];
                URL1HyperLink.Text        = newsSplit[1];
                URL1HyperLink.NavigateUrl = newsSplit[1];
                Summary1ValueLabel.Text   = newsSplit[2];
                Headline2ValueLabel.Text  = newsSplit[3];
                URL2HyperLink.Text        = newsSplit[4];
                URL2HyperLink.NavigateUrl = newsSplit[4];
                Summary2ValueLabel.Text   = newsSplit[5];
                Headline3ValueLabel.Text  = newsSplit[6];
                URL3HyperLink.Text        = newsSplit[7];
                URL3HyperLink.NavigateUrl = newsSplit[7];
                Summary3ValueLabel.Text   = newsSplit[8];
            }
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SharesBrokeringWSReference.SharesBrokeringWSClient javaWSclient = new SharesBrokeringWSReference.SharesBrokeringWSClient();

            String[] currencies = javaWSclient.GetCurrencyList();
            foreach (String currency in currencies)
            {
                CurrencyListBox.Items.Add(currency);
            }
        }
        protected void ChangeCurrencyButton_Click(object sender, EventArgs e)
        {
            CurrencyListBox.Visible       = true;
            ConfirmCurrencyButton.Visible = true;
            SharesBrokeringWSReference.SharesBrokeringWSClient javaWSclient = new SharesBrokeringWSReference.SharesBrokeringWSClient();

            String[] currencies = javaWSclient.GetCurrencyList();
            foreach (String currency in currencies)
            {
                CurrencyListBox.Items.Add(currency);
            }
        }
        protected void ConfirmWithdrawButton_Click(object sender, EventArgs e)
        {
            SharesBrokeringWSReference.SharesBrokeringWSClient javaWSclient = new SharesBrokeringWSReference.SharesBrokeringWSClient();

            if (!javaWSclient.adjustWallet(Session["username"].ToString(), Double.Parse(AmountTextBox.Text), false))
            {
                MessageBox.Show("Failed to withdraw funds, please try again", "Withdraw failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("Your funds have successfully been withdrew", "Funds successfully withdrew", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Page_Load(sender, e);
            }
        }
        protected void ConfirmDepositButton_Click(object sender, EventArgs e)
        {
            SharesBrokeringWSReference.SharesBrokeringWSClient javaWSclient = new SharesBrokeringWSReference.SharesBrokeringWSClient();

            if (!javaWSclient.adjustWallet(Session["username"].ToString(), Double.Parse(AmountTextBox.Text), true))
            {
                MessageBox.Show("Failed to deposit funds, please try again", "Deposit failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("Your deposit has successfully been added", "Deposit successfully added", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Page_Load(sender, e);
            }
        }
        protected void ConfirmCurrencyButton_Click(object sender, EventArgs e)
        {
            SharesBrokeringWSReference.SharesBrokeringWSClient javaWSclient = new SharesBrokeringWSReference.SharesBrokeringWSClient();

            if (!javaWSclient.ExchangeWallet(Session["username"].ToString(), CurrencyListBox.SelectedValue.Substring(0, 3)))
            {
                MessageBox.Show("Failed to convert currency and wallet amount", "Currency conversion failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("Your currency and wallet amount has successfully been converted", "Currency conversion successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Page_Load(sender, e);
            }
        }
        protected void AddUser(object sender, EventArgs e)
        {
            SharesBrokeringWSReference.SharesBrokeringWSClient javaWSclient = new SharesBrokeringWSReference.SharesBrokeringWSClient();

            if (!javaWSclient.AddNewUser(UsernameTextBox.Text, PasswordTextBox.Text, CurrencyListBox.SelectedValue.Substring(0, 3), Double.Parse(WalletTextBox.Text)))
            {
                MessageBox.Show("That Username already exists", "Failed to add new User", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("The User has successfully been added", "User successfully added", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Response.Redirect("Login.aspx");
            }
        }
Beispiel #9
0
        protected void LogIn(object sender, EventArgs e)
        {
            SharesBrokeringWSReference.SharesBrokeringWSClient javaWSclient = new SharesBrokeringWSReference.SharesBrokeringWSClient();

            if (!javaWSclient.Login(UsernameTextBox.Text, PasswordTextBox.Text))
            {
                MessageBox.Show("Either the Username or Password entered is incorrect", "Failed to log in", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("You have successfully logged in", "Login successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Session["username"] = UsernameTextBox.Text;
                Response.Redirect("AvailableShares.aspx");
            }
        }
Beispiel #10
0
        protected void AddShare(object sender, EventArgs e)
        {
            SharesBrokeringWSReference.SharesBrokeringWSClient javaWSclient = new SharesBrokeringWSReference.SharesBrokeringWSClient();

            if (!javaWSclient.AddShare(CompanySymbolTextBox.Text, CompanyNameTextBox.Text, Int32.Parse(QuantityAvailableTextBox.Text),
                                       CurrencyListBox.SelectedValue.Substring(0, 3), Double.Parse(PriceTextBox.Text)))
            {
                MessageBox.Show("That company symbol already exists", "Failed to add new share", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("The share has successfully been added", "Share successfully added", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Response.Redirect("AvailableShares.aspx");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Company Symbol");
            dt.Columns.Add("Company Name");
            dt.Columns.Add("Quantity Available", typeof(int));
            dt.Columns.Add("Price", typeof(Double));
            dt.Columns.Add("Update Date", typeof(DateTime));

            String companySymbol   = SymbolTextBox.Text;
            String companyName     = CompanyNameTextBox.Text;
            int    minQtyAvailable = string.IsNullOrEmpty(MinQuantityTextBox.Text) ? -1 : Int32.Parse(MinQuantityTextBox.Text);
            int    maxQtyAvailable = string.IsNullOrEmpty(MaxQuantityTextBox.Text) ? -1 : Int32.Parse(MaxQuantityTextBox.Text);
            Double minPrice        = string.IsNullOrEmpty(MinPriceTextBox.Text) ? -1 : Double.Parse(MinPriceTextBox.Text);
            Double maxPrice        = string.IsNullOrEmpty(MaxPriceTextBox.Text) ? -1 : Double.Parse(MaxPriceTextBox.Text);

            SharesBrokeringWSReference.SharesBrokeringWSClient javaWSclient = new SharesBrokeringWSReference.SharesBrokeringWSClient();

            SharesBrokeringWSReference.user u = javaWSclient.getUser(Session["username"].ToString());
            Session["currency"] = u.Currency;

            SharesBrokeringWSReference.Share[] shares = javaWSclient.GetFilteredShares(companySymbol, companyName, minQtyAvailable, maxQtyAvailable, minPrice, maxPrice, u.Currency);

            if (shares != null)
            {
                NoSharesFoundLabel.Visible = false;

                foreach (SharesBrokeringWSReference.Share s in shares)
                {
                    DataRow row = dt.NewRow();
                    row[0] = s.CompanySymbol;
                    row[1] = s.CompanyName;
                    row[2] = s.QtyAvailable;
                    row[3] = s.Price.Value;
                    row[4] = s.UpdateDate;
                    dt.Rows.Add(row);
                }
            }
            else
            {
                NoSharesFoundLabel.Visible = true;
            }
            SharesGridView.DataSource = dt;
            SharesGridView.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CurrencyListBox.Visible       = false;
            ConfirmCurrencyButton.Visible = false;
            AmountLabel.Visible           = false;
            AmountTextBox.Visible         = false;
            ConfirmDepositButton.Visible  = false;
            ConfirmWithdrawButton.Visible = false;

            SharesBrokeringWSReference.SharesBrokeringWSClient javaWSclient = new SharesBrokeringWSReference.SharesBrokeringWSClient();

            SharesBrokeringWSReference.user u = javaWSclient.getUser(Session["username"].ToString());

            CurrentCurrencyValueLabel.Text = u.Currency;
            Session["currency"]            = u.Currency;
            CurrentWalletValueLabel.Text   = u.Wallet.ToString();
            Session["wallet"] = u.Wallet;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CompanySymbolValueLabel.Text     = Session["buyCompanySymbol"].ToString();
            CompanyNameValueLabel.Text       = Session["buyCompanyName"].ToString();
            QuantityAvailableValueLabel.Text = Session["buyQuantityAvailable"].ToString();
            PriceValueLabel.Text             = Session["buyPrice"].ToString();

            SharesBrokeringWSReference.SharesBrokeringWSClient javaWSclient = new SharesBrokeringWSReference.SharesBrokeringWSClient();
            String news = javaWSclient.getNews(Session["buyCompanySymbol"].ToString());

            if (news == "")
            {
                NewsLabel.Text = "Couldn't find news for " + Session["buyCompanySymbol"].ToString();

                Headline1Label.Visible = false;
                URL1Label.Visible      = false;
                Summary1Label.Visible  = false;
                Headline2Label.Visible = false;
                URL2Label.Visible      = false;
                Summary2Label.Visible  = false;
                Headline3Label.Visible = false;
                URL3Label.Visible      = false;
                Summary3Label.Visible  = false;
            }
            else
            {
                news = news.Replace("^//", "\"").Replace("^/", "'");
                String[] sep       = { "###" };
                String[] newsSplit = news.Split(sep, StringSplitOptions.RemoveEmptyEntries);

                Headline1ValueLabel.Text  = newsSplit[0];
                URL1HyperLink.Text        = newsSplit[1];
                URL1HyperLink.NavigateUrl = newsSplit[1];
                Summary1ValueLabel.Text   = newsSplit[2];
                Headline2ValueLabel.Text  = newsSplit[3];
                URL2HyperLink.Text        = newsSplit[4];
                URL2HyperLink.NavigateUrl = newsSplit[4];
                Summary2ValueLabel.Text   = newsSplit[5];
                Headline3ValueLabel.Text  = newsSplit[6];
                URL3HyperLink.Text        = newsSplit[7];
                URL3HyperLink.NavigateUrl = newsSplit[7];
                Summary3ValueLabel.Text   = newsSplit[8];
            }
        }
        protected void ConfirmSaleButton_Click(object sender, EventArgs e)
        {
            int QuantityToSell = Int32.Parse(QuantityToSellTextBox.Text);

            if (QuantityToSell < 1 || QuantityToSell > Int32.Parse(Session["sellQuantity"].ToString()))
            {
                MessageBox.Show("Please enter a Quantity to sell within the Quantity owned", "Incorrect Quantity to sell", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ConfirmSaleButton.Visible = false;
            }
            else
            {
                SharesBrokeringWSReference.SharesBrokeringWSClient javaWSclient = new SharesBrokeringWSReference.SharesBrokeringWSClient();
                if (!javaWSclient.SellShare(Session["username"].ToString(), CompanySymbolValueLabel.Text, QuantityToSell, Double.Parse(TotalPriceValueLabel.Text)))
                {
                    MessageBox.Show("Your Share sale failed, please try again", "Failed to sell Share", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Your Share sale was successful", "Share sale successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Response.Redirect("MyShares.aspx");
                }
            }
        }