public FileTypeWindowViewModel(ChildWindow aChildWindow, FileTypeWindowType aFileTypeWindowType, FileTypeEntity aFileTypeEntity)
        {
            childWindow = aChildWindow;
            fileTypeWindowType = aFileTypeWindowType;
            FileTypeEntity = aFileTypeEntity;

            if (aFileTypeWindowType == FileTypeWindowType.ADD)
            {
                Title = "添加档案类型";
            }
            else
            {
                Title = "修改档案类型";
            }

            OnOK = new DelegateCommand(onOK);
            OnCancel = new DelegateCommand(onCancel);
        }
        private void loadOperationFileType_Completed(object sender, EventArgs e)
        {
            FileTypeList.Clear();
            FileTypeDictionary.Clear();
            LoadOperation loadOperation = sender as LoadOperation;
            foreach (Web.Model.filetype filetype in loadOperation.Entities)
            {
                FileTypeEntity lFileTypeEntity = new FileTypeEntity();
                lFileTypeEntity.FileType = filetype;
                lFileTypeEntity.Update();
                FileTypeList.Add(lFileTypeEntity);
                FileTypeDictionary.Add(lFileTypeEntity.FileTypeId, lFileTypeEntity);
            }

            DocumentViewModel.FileTypeEntityDictionary = FileTypeDictionary;
            DocumentViewModel.FileTypeEntityList = FileTypeList;

            LoadOperation<DocumentManager.Web.Model.user> loadOperationUser =
                documentManagerContext.Load<DocumentManager.Web.Model.user>(documentManagerContext.GetUserQuery());
            loadOperationUser.Completed += loadOperationUser_Completed;
        }
        private void loadOperationFileType_Completed(object sender, EventArgs e)
        {
            FileTypeEntityList.Clear();

            LoadOperation loadOperation = sender as LoadOperation;
            foreach (Web.Model.filetype filetype in loadOperation.Entities)
            {
                FileTypeEntity lFileTypeEntity = new FileTypeEntity();
                lFileTypeEntity.FileType = filetype;
                lFileTypeEntity.Update();
                FileTypeEntityList.Add(lFileTypeEntity);
            }

            LoadOperation<DocumentManager.Web.Model.taxpayer> loadOperationTaxPayer =
                documentManagerContext.Load<DocumentManager.Web.Model.taxpayer>(documentManagerContext.GetTaxpayerQuery());
            loadOperationTaxPayer.Completed += loadOperationTaxPayer_Completed;
        }
        void SubOperation_Completed(object sender, EventArgs e)
        {
            SubmitOperation submitOperation = sender as SubmitOperation;

            if (submitOperation.HasError)
            {
                submitOperation.MarkErrorAsHandled();
                NotifyWindow notifyWindow = new NotifyWindow("错误", "保存失败");
                notifyWindow.Show();
                if (addFileTypeEntity != null)
                {
                    FileTypeList.Remove(addFileTypeEntity);
                    addFileTypeEntity = null;
                }
            }
            else
            {
                NotifyWindow notifyWindow = new NotifyWindow("保存成功", "保存成功!");
                notifyWindow.Show();
                addFileTypeEntity = null;
                LoadData();
            }
            IsBusy = false;
        }
 private void onAddFileType()
 {
     addFileTypeEntity = new FileTypeEntity();
     Web.Model.filetype fileType = new Web.Model.filetype();
     addFileTypeEntity.FileType = fileType;
     addFileTypeEntity.Update();
     FileTypeWindow lFileTypeWindow = new FileTypeWindow(FileTypeWindowType.ADD, addFileTypeEntity);
     lFileTypeWindow.Closed += AddFileType_Closed;
     lFileTypeWindow.Show();
 }
 private void loadOperation_Completed(LoadOperation<DocumentManager.Web.Model.filetype> sender)
 {
     FileTypeList.Clear();
     fileTypeSource.Source = sender.Entities;
     foreach (DocumentManager.Web.Model.filetype filetype in sender.Entities)
     {
         FileTypeEntity fileTypeEntity = new FileTypeEntity();
         fileTypeEntity.FileType = filetype;
         fileTypeEntity.Update();
         FileTypeList.Add(fileTypeEntity);
     }
     UpdateChanged("FileTypeList");
     IsBusy = false;
 }