public TaxPayerTypeWindowViewModel(ChildWindow aChildWindow, TaxPayerTypeWindowType aTaxPayerTypeWindowType, TaxPayerTypeEntity aTaxPayerTypeEntity)
        {
            childWindow = aChildWindow;
            taxPayerTypeWindowType = aTaxPayerTypeWindowType;
            TaxPayerTypeEntity = aTaxPayerTypeEntity;

            if (aTaxPayerTypeWindowType == TaxPayerTypeWindowType.ADD)
            {
                Title = "添加纳税人类型";
            }
            else
            {
                Title = "修改纳税人类型";
            }

            OnOK = new DelegateCommand(onOK);
            OnCancel = new DelegateCommand(onCancel);
        }
        private void loadOperationTaxPayerType_Completed(object sender, EventArgs e)
        {
            TaxPayerTypeList.Clear();
            TaxPayerTypeEntityDictionary.Clear();

            LoadOperation loadOperation = sender as LoadOperation;
            foreach (Web.Model.taxpayertype taxpayertype in loadOperation.Entities)
            {
                TaxPayerTypeEntity lTaxPayerTypeEntity = new TaxPayerTypeEntity();
                lTaxPayerTypeEntity.TaxPayerType = taxpayertype;
                lTaxPayerTypeEntity.Update();
                TaxPayerTypeList.Add(lTaxPayerTypeEntity);
                TaxPayerTypeEntityDictionary.Add(lTaxPayerTypeEntity.TaxPayerTypeId, lTaxPayerTypeEntity);
            }

            LoadOperation<DocumentManager.Web.Model.filetype> loadOperationFileType =
                documentManagerContext.Load<DocumentManager.Web.Model.filetype>(documentManagerContext.GetFiletypeQuery());
            loadOperationFileType.Completed += loadOperationFileType_Completed;
        }
 public TaxPayerTypeWindow(TaxPayerTypeWindowType aTaxPayerTypeWindowType, TaxPayerTypeEntity aTaxPayerTypeEntity)
 {
     InitializeComponent();
     DataContext = new TaxPayerTypeWindowViewModel(this, aTaxPayerTypeWindowType, aTaxPayerTypeEntity);
 }
        void SubOperation_Completed(object sender, EventArgs e)
        {
            SubmitOperation submitOperation = sender as SubmitOperation;

            if (submitOperation.HasError)
            {
                submitOperation.MarkErrorAsHandled();
                NotifyWindow notifyWindow = new NotifyWindow("错误", "保存失败");
                notifyWindow.Show();
                if (addTaxPayerTypeEntity != null)
                {
                    TaxPayerTypeList.Remove(addTaxPayerTypeEntity);
                    addTaxPayerTypeEntity = null;
                }
            }
            else
            {
                NotifyWindow notifyWindow = new NotifyWindow("保存成功", "保存成功!");
                notifyWindow.Show();
                addTaxPayerTypeEntity = null;
                LoadData();
            }
            IsBusy = false;
        }
 private void onAddTaxPayerType()
 {
     addTaxPayerTypeEntity = new TaxPayerTypeEntity();
     DocumentManager.Web.Model.taxpayertype taxpayertype = new DocumentManager.Web.Model.taxpayertype();
     addTaxPayerTypeEntity.TaxPayerType = taxpayertype;
     addTaxPayerTypeEntity.Update();
     TaxPayerTypeWindow lTaxPayerTypeWindow = new TaxPayerTypeWindow(TaxPayerTypeWindowType.ADD, addTaxPayerTypeEntity);
     lTaxPayerTypeWindow.Closed += AddTaxPayerType_Closed;
     lTaxPayerTypeWindow.Show();
 }
 private void loadOperation_Completed(LoadOperation<DocumentManager.Web.Model.taxpayertype> sender)
 {
     TaxPayerTypeList.Clear();
     this.taxPayerTypeSource.Source = sender.Entities;
     foreach (DocumentManager.Web.Model.taxpayertype taxpayertype in sender.Entities)
     {
         TaxPayerTypeEntity taxPayerTypeEntity = new TaxPayerTypeEntity();
         taxPayerTypeEntity.TaxPayerType = taxpayertype;
         taxPayerTypeEntity.Update();
         TaxPayerTypeList.Add(taxPayerTypeEntity);
     }
     UpdateChanged("TaxPayerTypeList");
     IsBusy = false;
 }
        private void loadOperationTaxPayerType_Completed(object sender, EventArgs e)
        {
            TaxPayerTypeList.Clear();
            TaxPayerTypeEntityDictionary.Clear();

            LoadOperation loadOperation = sender as LoadOperation;
            foreach (Web.Model.taxpayertype taxpayertype in loadOperation.Entities)
            {
                TaxPayerTypeEntity lTaxPayerTypeEntity = new TaxPayerTypeEntity();
                lTaxPayerTypeEntity.TaxPayerType = taxpayertype;
                lTaxPayerTypeEntity.Update();
                TaxPayerTypeList.Add(lTaxPayerTypeEntity);
                TaxPayerTypeEntityDictionary.Add(lTaxPayerTypeEntity.TaxPayerTypeId, lTaxPayerTypeEntity);
            }

            taxPayerSource = new EntityList<Web.Model.taxpayer>(documentManagerContext.taxpayers);
            taxPayerLoader = new DomainCollectionViewLoader<Web.Model.taxpayer>(
                LoadTaxPayerEntities,
                loadOperation_Completed);
            taxPayerView = new DomainCollectionView<Web.Model.taxpayer>(taxPayerLoader, taxPayerSource);

            using (this.taxPayerView.DeferRefresh())
            {
                this.taxPayerView.MoveToFirstPage();
            }
        }