private void button_Click(object sender, RoutedEventArgs e) { Client client = comboBox.SelectedItem as Client; if (client == null) { return; } Task2.Content cont = new Task2.Content(client.Name, client.color); cont.Show(); }
private void button1_Click(object sender, RoutedEventArgs e) { sqlConnection.Open(); try { SQLiteCommand command = new SQLiteCommand("INSERT INTO client VALUES(@Name,@R,@G,@B)", sqlConnection); command.Parameters.AddWithValue("Name", textBox.Text); command.Parameters.AddWithValue("R", slider.Value); command.Parameters.AddWithValue("G", slider1.Value); command.Parameters.AddWithValue("B", slider2.Value); command.ExecuteNonQuery(); Task2.Content cont = new Task2.Content(textBox.Text, Color.FromRgb(Convert.ToByte(slider.Value), Convert.ToByte(slider1.Value), Convert.ToByte(slider2.Value))); cont.Show(); } catch { MessageBox.Show("Такое имя уже зарегестрированно", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } sqlConnection.Close(); }