/// <summary>
        /// Create child instance of StudentInfoWindow for editting a student's note.
        /// </summary>
        /// <param name="mainViewModel">Reference to main window view model.</param>
        /// <param name="studentData">Current info about target student's note.</param>
        public void OpenChangeStudentWindow(MainWindowViewModel mainViewModel, Student studentData)
        {
            MainWindowViewModel = mainViewModel;
            var window = new StudentInfoWindow(StudentInfoWindowRole.Edit, studentData);

            window.Show();
        }
        /// <summary>
        /// Create child instance of StudentInfoWindow for adding a new student's note.
        /// </summary>
        /// <param name="mainViewModel">Reference to main window view model.</param>
        public void OpenAddStudentWindow(MainWindowViewModel mainViewModel)
        {
            MainWindowViewModel = mainViewModel;
            var window = new StudentInfoWindow();

            window.Show();
        }
Пример #3
0
        private void _F_AddStudent()
        {
            var sInstance = ServiceLocator.Current.GetInstance <StudentModifyViewModel>();

            sInstance.studentInfo = new StudentInfo();
            sInstance.classInfo   = Classes.FirstOrDefault();
            if (sInstance.classInfo == null)
            {
                return;
            }
            sInstance.Title = "添加学生信息";
            StudentInfoWindow studentInfoWindow = new StudentInfoWindow();

            studentInfoWindow.ShowDialog();
            if (studentInfoWindow.DialogResult == true)
            {
                var target = sInstance.studentInfo;
                target.Age = DateTime.Now.Year - target.DateOfBirth.Year;
                _StudentInfoDal.Insert(target);
                _StudentInfoDal.Save();
                _RelationShipDal.Insert(new Student_Class_Relation()
                {
                    StudentId = sInstance.studentInfo.ID, ClassId = sInstance.classInfo.ID
                });
                _RelationShipDal.Save();
                StudentList.Add(new StudentInfoViewModel(target));
            }
        }
Пример #4
0
        public void ContinueMethod()
        {
            var wnd = new StudentInfoWindow();

            wnd.Show();
            foreach (Window window in Application.Current.Windows)
            {
                if (window is ResultWindow resultWindow)
                {
                    resultWindow.Close();
                }
            }
        }
Пример #5
0
        private void _F_UpdateStudent(StudentInfoViewModel s)
        {
            var sInstance = ServiceLocator.Current.GetInstance <StudentModifyViewModel>();

            sInstance.studentInfo = s.StudentInfo;
            sInstance.Title       = "修改学生信息";
            sInstance.classInfo   = (from citem in _EFDataContext.classes
                                     from item in _EFDataContext.relations
                                     where item.StudentId == s.ID && item.ClassId == citem.ID
                                     select citem).ToList()?.FirstOrDefault();

            StudentInfoWindow studentInfoWindow = new StudentInfoWindow();

            studentInfoWindow.ShowDialog();
            if (studentInfoWindow.DialogResult == true)
            {
                _StudentInfoDal.Update(s.StudentInfo);
                var target = (from item in Relation where item.StudentId == s.ID select item).ToList();
                if (target != null && target.Count > 0)
                {
                    target[0].ClassId = sInstance.classInfo.ID;
                    _RelationShipDal.Update(target[0]);
                }
                else
                {
                    _RelationShipDal.Insert(new Student_Class_Relation()
                    {
                        StudentId = s.ID, ClassId = sInstance.classInfo.ID
                    });
                }

                _StudentInfoDal.Save();
                _RelationShipDal.Save();

                s.Update();
                //RefreshData();
                //RaisePropertyChanged("Students");
            }
        }