コード例 #1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Instructor nwInstructor = new Instructor()
            {
                Address         = txtAddress.Text,
                ContactNumber   = txtPhone1.Text,
                DefensiveExpiry = Convert.ToDateTime(dtpDefensiveExp.SelectedDate),
                DefensiveNo     = txtDefensive.Text,
                Email           = txtEmail.Text,
                IDNumber        = txtIDNumber.Text,
                LicenceNumber   = txtLicence.Text,
                Name            = txtName.Text,
                Resigned        = false,
                Surname         = txtSurname.Text
            };

            DbInsert.InsertInstructor(nwInstructor);
            MessageBox.Show("Instructor Added", "NEW INSTRUCTOR", MessageBoxButton.OK, MessageBoxImage.Information);
            var mainWindow = Application.Current.Windows.Cast <Window>().FirstOrDefault(window => window is MainWindow) as MainWindow;
            InstructorDetails newInstructor = new InstructorDetails();

            mainWindow.grdMain.Children.Clear();
            mainWindow.grdMain.Children.Add(newInstructor);
        }