コード例 #1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            var x = this.DataContext as Training;

            if (x.IsValidate())
            {
                if (x.ID == null)
                {
                    if (Training.InsertData(x))
                    {
                        foreach (var t in x.Trainees)
                        {
                            Trained.InsertData(t);
                        }
                        MyMessage.InsertMessage();
                    }
                }
                else
                {
                    foreach (var t in x.Trainees)
                    {
                        if (t.ID.HasValue)
                        {
                            Trained.UpdateData(t);
                        }
                        else
                        {
                            Trained.InsertData(t);
                        }
                    }
                    if (Training.UpdateData(x))
                    {
                        MyMessage.UpdateMessage();
                    }
                }
            }
        }
コード例 #2
0
 public TrainingControl(Training t)
 {
     InitializeComponent();
     this.DataContext = t;
 }
コード例 #3
0
 public SelectTraineesControl(Training t)
 {
     InitializeComponent();
     this.DataContext      = t;
     dgTrained.ItemsSource = t.Trainees.ToList();
 }