Exemple #1
0
        public Boolean validateEmail(string email)
        {
            RegexUtilities util = new RegexUtilities();

            if (!util.IsValidEmail(email))
            {
                return(false);
            }
            return(true);
        }
        private void btnAddStock_Click(object sender, EventArgs e)
        {
            RegexUtilities util = new RegexUtilities();
             if (txtPrice.Text != "" && txtEmail.Text != "" && txtIDClient.Text != "")
            {
                if (!util.IsValidEmail(txtEmail.Text))
                {
                    MessageBox.Show("Email is not recognized as valid!", "Invalid email!", MessageBoxButtons.OK);
                    return;
                }

                Stock.transactionType type = cbType.SelectedIndex == 1 ? type = Stock.transactionType.Sell : type = Stock.transactionType.Buy;
                Stock stock = new Stock(Stock.GenerateId(), Convert.ToInt32(txtIDClient.Text), txtEmail.Text, type, Convert.ToInt32(numQuantity.Value), Convert.ToString(cbShareType.SelectedItem.ToString()), DateTime.Now, Convert.ToDouble(txtPrice.Text), false, Convert.ToString(cbCurrency.SelectedItem.ToString()));
                MessageBox.Show(proxy.AddStock(stock), "Server response:", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("All fields must be filled!", "Field is empty!", MessageBoxButtons.OK);
            }
        }
        private void btnAddStock_Click(object sender, EventArgs e)
        {
            RegexUtilities util = new RegexUtilities();

            if (txtPrice.Text != "" && txtEmail.Text != "" && txtIDClient.Text != "")
            {
                if (!util.IsValidEmail(txtEmail.Text))
                {
                    MessageBox.Show("Email is not recognized as valid!", "Invalid email!", MessageBoxButtons.OK);
                    return;
                }

                Stock.transactionType type = cbType.SelectedIndex == 1 ? type = Stock.transactionType.Sell : type = Stock.transactionType.Buy;
                Stock stock = new Stock(Stock.GenerateId(), Convert.ToInt32(txtIDClient.Text), txtEmail.Text, type, Convert.ToInt32(numQuantity.Value), Convert.ToString(cbShareType.SelectedItem.ToString()), DateTime.Now, Convert.ToDouble(txtPrice.Text), false, Convert.ToString(cbCurrency.SelectedItem.ToString()));
                MessageBox.Show(proxy.AddStock(stock), "Server response:", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("All fields must be filled!", "Field is empty!", MessageBoxButtons.OK);
            }
        }