예제 #1
0
        private void Btn_ViewResults_Click(object sender, RoutedEventArgs e)
        {
            int selectedId;

            selectedId = Convert.ToInt32(ListBox_SearchResults.SelectedValue);

            vetWin = new VeteranInfo();
            vetWin.SetMultiRecord(searchResultIds);
            vetWin.BuildAndShowDialog(selectedId);
        }
예제 #2
0
        private void LoadSingleSearchResult(string searchTerm)
        {
            int veteranNumber = 0;

            try
            {
                using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString))
                {
                    conn.OpenAsync();

                    using (MySqlCommand command = conn.CreateCommand())
                    {
                        command.CommandText = @"SELECT ID FROM Veterans WHERE LName=@searchTerm";
                        command.Parameters.Add("@searchTerm", MySqlDbType.VarChar).Value = searchTerm;

                        using (MySqlDataReader reader = command.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                veteranNumber = reader.GetInt32(0);
                            }
                        }
                    }
                }
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show(Tools.DBErrorMessage, Tools.DBErrorTitle);
            }
            catch (MySqlException e)
            {
                Tools.HandleSQLExceptions(e);
            }

            vetWin = new VeteranInfo();
            vetWin.SetSingleRecord();
            vetWin.BuildAndShowDialog(veteranNumber);
        }