コード例 #1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Appointment ap = DataContext as Appointment;

            if (ap == null || ap.Id == 0)
            {
                //NEW DATA
                ap         = new Appointment();
                ap.Subject = txtSubject.Text;
                ap.Notes   = txtNotes.Text;
                ap.ApDate  = dtAppDate.DisplayDate.Date;
                ap.Aptime  = txtTime.Text;
                Dentist dent = cbDentist.SelectedItem as Dentist;
                ap.Dentist = dent;
                ap.Patient = App.patient;
                ap.Room    = (string)cbRoom.SelectedValue;
                DB.insertAppointment(ap);
            }
            else
            {
                ap.Subject = txtSubject.Text;
                ap.Notes   = txtNotes.Text;
                ap.ApDate  = dtAppDate.DisplayDate.Date;
                ap.Aptime  = txtTime.Text;
                Dentist dent = cbDentist.SelectedItem as Dentist;
                ap.Dentist = dent;
                ap.Patient = App.patient;
                ap.Room    = (string)cbRoom.SelectedValue;
                DB.updateAppointment(ap);
            }
            this.Close();
        }