Example #1
0
        private bool ValidateSymbol()
        {
            status = false;
            TradeProcessor   tp               = new TradeProcessor();
            MySqlCommand     sqlCommand       = new MySqlCommand(query, connection);
            MySqlDataAdapter MysqlDataAdapter = new MySqlDataAdapter(sqlCommand);

            using (MysqlDataAdapter)
            {
                sqlCommand.Parameters.AddWithValue("@symbol", Symbol.Text.ToString());

                try
                {
                    SelectedSymbol = Symbol.Text.ToString();
                }
                catch      //NullReferenceException e
                {
                    MessageBox.Show("Please select Symbol");
                }

                if (SelectedSymbol.Length <= 5)
                {
                    if (!CheckForSQLInjection(SelectedSymbol))
                    {
                        string query = "SELECT count(distinct `SecurityName`) FROM `algotrade`.`symbols` where `Symbol` = '" + SelectedSymbol + "' ;";


                        if (tp.DBA(query) > 0)
                        {
                            status = true;
                        }
                    }
                    else
                    {
                        status = false;
                        Symbol.Clear();
                    }
                }
                else
                {
                    status = false;
                    MessageBox.Show("Please enter Symbol with correct number of characters!");
                    Symbol.Clear();
                }
            }
            return(status);
        }