Пример #1
0
        private void overwriteOrCreateNew(AttandanceLibrary lib, Model.Course course)
        {
            HKConfirmForm form = new HKConfirmForm();

            form.title = "已存在该课程Id,是否覆盖?";
            if (form.showConfirm() == true)
            {
                lib.removeCourse(lib[course.id]);
                lib.addCourse(course);
            }
            else
            {
                course.id = Guid.NewGuid().ToString();
                lib.addCourse(course);
            }
        }
Пример #2
0
        private void deleteTheCourseFromLibrary(string courseId)
        {
            AttandanceLibrary lib = libHall.libraryRef;

            if (lib.containsCourse(courseId))
            {
                Model.Course course = lib[courseId];
                lib.removeCourse(course);
                GlobalStation.shareInstance.librarySave(null, delegate() {
                    lib.addCourse(course);
                });
                libHall.contentInit();
            }
        }
Пример #3
0
        private void bar_deleteBtn_Click(object sender, EventArgs e)
        {
            AttandanceLibrary lib = GlobalStation.shareInstance.librarys[libraryUUID];

            Model.Course  course = courseRef;
            HKConfirmForm form   = new HKConfirmForm();

            form.title = string.Format("确定要删除课程《{0}》?", course.name);
            if (form.showConfirm() != true)
            {
                return;
            }
            if (lib.containsCourse(course.id))
            {
                lib.removeCourse(course);
            }
            GlobalStation.shareInstance.librarySave(delegate() {
                bar_backBtn_Click(null, null);
            }, delegate() {
                lib.addCourse(course);
            });
        }
Пример #4
0
        private void addPanel_importCourseBtn_Click(string title)
        {
            try {
                string       path   = HKOpenFileDialog.selectFile(HKDialogFilter.Course);
                Model.Course course = FileSerilizeOpener <Model.Course> .open(path);

                AttandanceLibrary lib = libraryRef;
                if (!lib.containsCourse(course.id))
                {
                    lib.addCourse(course);
                }
                else
                {
                    overwriteOrCreateNew(lib, course);
                }
                GlobalStation.shareInstance.librarySave(delegate() {
                    contentInit();
                }, null);
            }catch (HKOpenFileDialog.CancelOpenFileException e) {
                Console.WriteLine(e.Message);
            }catch (FileSerilizeOpener <Model.Course> .FileOpenException e) {
                HKConfirmForm.showConfirmForm(e.Message);
            }
        }