void UpdateBtn_Click(object sender, RoutedEventArgs e) { //get the selected item from the datagrid. var selected_info = StudentRecord_dataGrid.SelectedItem as PlayerInfo; if (current_player_id != selected_info.Player_id) { MessageBox.Show("Sorry, you can only change your current account's information!", "Error"); return; } if (selected_info != null) { //create student_window and pass the database instance. var student_window = new PlayerForm(database_); //set the datacontext of the selected info. student_window.DataContext = selected_info; //setup button parameters and event. student_window.button1.Opacity = 0; student_window.button1.IsEnabled = false; student_window.editBtn.Content = "Update Player Data"; student_window.editBtn.Click += student_window.updateData_Click; student_window.ShowDialog(); //this will display the data. ViewBtn_Click(null, null); } }
//sql stuff void InsertBtn_Click(object sender, RoutedEventArgs e) { //create student_window and pass the database instance. var student_window = new PlayerForm(database_); //setup button parameters and event. student_window.editBtn.Content = "Create New Player Data"; student_window.editBtn.Click += student_window.insertData_Click; student_window.ShowDialog(); //this will display the data. ViewBtn_Click(null, null); }