示例#1
0
        private void addPanel_importButton_Click(string title)
        {
            try {
                string            path = HKOpenFileDialog.selectFile(HKDialogFilter.Library);
                AttandanceLibrary lib  = FileSerilizeOpener <AttandanceLibrary> .open(path);

                AttandanceLibrary oldLib   = null;
                DJTUBinary        librarys = GlobalStation.shareInstance.librarys;
                librarys.isCustomize = false;
                if (librarys.containsLibrary(lib))
                {
                    handleOverwrite(lib, ref oldLib);
                }
                librarys.addLib(lib);
                GlobalStation.shareInstance.librarySave(delegate() {
                    initTableViewContent();
                    resize(null, null);
                }, delegate() {
                    if (oldLib != null)
                    {
                        librarys.addLib(oldLib);
                    }
                    librarys.removeLib(lib.UUID);
                });
            } catch (HKOpenFileDialog.CancelOpenFileException) { }
        }
示例#2
0
        private void handleOverwrite(AttandanceLibrary lib, ref AttandanceLibrary oldLib)
        {
            DJTUBinary    librarys = GlobalStation.shareInstance.librarys;
            HKConfirmForm form     = new HKConfirmForm();

            form.title = "已存在相同的库,是否覆盖?";
            if (form.showConfirm() == true)
            {
                oldLib = librarys[lib.UUID];
                librarys.removeLib(lib.UUID);
            }
            else
            {
                lib.UUID = Guid.NewGuid().ToString();
            }
        }