public EditStudentWindowViewModel(Student student, Window window)
        {
            if (student == null)
            {
                _currentStudent = new Student();
                _currentStudent.StartTime = DateTime.Now;
                this.IsForNew = true;

                _studyProcesses = new StudyProcessEntryCollection();
            }
            else
            {
                _currentStudent = student;
                this.IsForNew = false;

                _studyProcesses = new StudyProcessEntryCollection();
            }

            foreach (StudyItem key in Enum.GetValues(typeof(StudyItem)))
            {
                string value = _currentStudent.StudyItemGetter(key);
                if (value != null)
                {
                    _studyProcesses.Add(new StudyProcessEntry(key, value.Trim()));
                }
                else
                {
                    _studyProcesses.Add(new StudyProcessEntry(key, ""));
                }
            }

            this.CurrentWindow = window;
        }
Esempio n. 2
0
        public void CloneFrom(Student item)
        {
            this.Name = item.Name;
            this.Identity = item.Identity;
            this.StartTime = item.StartTime;
            this.Contact = item.Contact;
            this.EndTime = item.EndTime;
            this.Note = item.Note;

            foreach (StudyItem key in Enum.GetValues(typeof(StudyItem)))
            {
                this.StudyItemSetter(key, "");
                string newValue = item.StudyItemGetter(key);
                this.StudyItemSetter(key, newValue);
            }
        }
Esempio n. 3
0
 public void Insert(Student student)
 {
     this.dataContext.StudentTable.InsertOnSubmit(student);
 }
Esempio n. 4
0
 public void Delete(Student student)
 {
     this.dataContext.StudentTable.DeleteOnSubmit(student);
 }
Esempio n. 5
0
        public void TestInsert()
        {
            Student stu1 = new Student() { Name = "stu''1", Identity = "2202014986146513541", Contact = "1212", StartTime = DateTime.Parse("2012-1-1"), EndTime = DateTime.Parse("2012-2-1") };
            Student stu2 = new Student() { Name = "stu2", Identity = "2202014981212113541", Contact = "1212", StartTime = DateTime.Parse("2012-1-1") };
            StudentCollection _allStudents = new StudentCollection();

            StudentDataContext dc = new StudentDataContext(this.connection);
            dc.StudentTable.InsertOnSubmit(stu2);

            dc.SubmitChanges();
        }
Esempio n. 6
0
 void EditExecute()
 {
     EditStudentWindow window = new EditStudentWindow();
     Student editItem = new Student();
     editItem.CloneFrom(this.SelectedItem);
     EditStudentWindowViewModel vm = new EditStudentWindowViewModel(editItem, window);
     window.DataContext = vm;
     window.ShowDialog();
     OnEditComplete(vm);
 }