private void Button_Click_4(object sender, RoutedEventArgs e) { try { connection = new SqlConnection(cs); var command = new SqlCommand("select payments.paymentId, payments.Amount, payments.Date, payments.AccountId, goals.GoalName from payments inner join goals on payments.goalId=goals.goalId where goals.goalname = @goal", connection); command.Parameters.AddWithValue("@goal", Goal.Text); connection.Open(); view.Text += "Поиск платежей по цели начат\r\n"; adapter = new SqlDataAdapter(command); dataset1 = new DataSet(); adapter.Fill(dataset1, "Founded"); view.Text += "Поиск платежей завершен\r\n"; } catch (Exception ex) { view.Text += "Ошибка: " + ex.Message; } finally { connection.Close(); } FindUser f = new FindUser(dataset1.Tables["Founded"].DefaultView); f.Show(); f.Activate(); }
private void Button_Click_5(object sender, RoutedEventArgs e) { try { connection = new SqlConnection(cs); var command = new SqlCommand("select * from goals where goalName = @goal", connection); command.Parameters.AddWithValue("@goal", Goal2.Text); connection.Open(); view.Text += "Поиск целей по названию начат\r\n"; adapter = new SqlDataAdapter(command); dataset1 = new DataSet(); adapter.Fill(dataset1, "Founded"); view.Text += "Поиск целей завершен\r\n"; } catch (Exception ex) { view.Text += "Ошибка: " + ex.Message; } finally { connection.Close(); } FindUser f = new FindUser(dataset1.Tables["Founded"].DefaultView); f.Show(); f.Activate(); }
private void Button_Click_3(object sender, RoutedEventArgs e) { try { connection = new SqlConnection(cs); var command = new SqlCommand("select * from users where users.surname = @surname", connection); command.Parameters.AddWithValue("@surname", User.Text); connection.Open(); view.Text += "Поиск пользователя по фамилии начат\r\n"; adapter = new SqlDataAdapter(command); dataset1 = new DataSet(); adapter.Fill(dataset1, "Founded"); view.Text += "Поиск завершен\r\n"; } catch (Exception ex) { view.Text += "Ошибка: " + ex.Message; } finally { connection.Close(); } FindUser f = new FindUser(dataset1.Tables["Founded"].DefaultView); f.Show(); f.Activate(); }