예제 #1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (dtpDate.SelectedDate == null)
            {
                MessageBox.Show("Please select the date first", "Date Missing", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            else if (cmbInstructorName.SelectedValue == null)
            {
                MessageBox.Show("Please select the instructor first", "Instructor Missing", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            else
            {
                if (dtgData.Items.OfType <InstructorLearnerSchedule>().Where(x => x.Complete == false && x.Cancel == false && x.NoShow == false).Any())
                {
                    MessageBox.Show("The schedule is incomplete", "INCOMPLETE DATA", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
                else
                {
                    var completedList = dtgData.Items.OfType <InstructorLearnerSchedule>().Where(x => x.Complete == true || x.NoShow == true || x.Cancel == true).ToList();
                    DbInsert.ScheduleRecons(completedList, Globals.LogInID);
                    MessageBox.Show("Schedule data saved", "DATA SAVED", MessageBoxButton.OK, MessageBoxImage.Information);

                    //Reload window
                    var        mainWindow   = Application.Current.Windows.Cast <Window>().FirstOrDefault(window => window is MainWindow) as MainWindow;
                    DailySheet nwDailySheet = new DailySheet();
                    mainWindow.grdMain.Children.Clear();
                    mainWindow.grdMain.Children.Add(nwDailySheet);
                }
            }
        }
        private void btnDailyLog_Click(object sender, RoutedEventArgs e)
        {
            DailySheet daySheet = new DailySheet();

            this.grdMain.Children.Clear();
            this.grdMain.Children.Add(daySheet);
        }