| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- //----------------------------------------------------------------
- //Module Name: $safeprojectname$
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime 2017/3/23 15:03:32
- //Author
- //Description Create
- //----------------------------------------------------------------
- using GalaSoft.MvvmLight;
- using GalaSoft.MvvmLight.Ioc;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Model.Bank;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.IService;
- namespace Muchinfo.MTPClient.Bank.ViewModels
- {
- public class BankBalanceViewModel : ViewModelBase
- {
- /// <summary>
- /// 银行接口
- /// </summary>
- private IBankService _bankService;
- private bool _isBusy;
- /// <summary>
- /// 是否忙,显示等待控件
- /// </summary>
- public bool IsBusy
- {
- get { return _isBusy; }
- set { Set(() => IsBusy, ref _isBusy, value); }
- }
- private SigningBank _currentSigningBank;
- /// <summary>
- /// 当前选中签约银行
- /// </summary>
- public SigningBank CurrentSigningBank
- {
- get
- {
- return _currentSigningBank;
- }
- set
- {
- Set(() => CurrentSigningBank, ref _currentSigningBank, value);
- }
- }
- private List<BankBalanceModel> _balanceModels;
- /// <summary>
- /// 查询银行余额
- /// </summary>
- public List<BankBalanceModel> BalanceModels
- {
- get { return _balanceModels; }
- set { Set(() => BalanceModels, ref _balanceModels, value); }
- }
- private BankBalanceModel _selectItem;
- /// <summary>
- /// 选择的项
- /// </summary>
- public BankBalanceModel SelectItem
- {
- get { return _selectItem; }
- set { Set(() => SelectItem, ref _selectItem, value); }
- }
-
- public BankBalanceViewModel(SigningBank signingBank)
- {
- _bankService = SimpleIoc.Default.GetInstance<IBankService>();
- CurrentSigningBank = signingBank;
- IsBusy = true;
- _bankService.GetBankBalace(signingBank, QueryBalanceCallBack, ErrorCallback);
- }
- private void QueryBalanceCallBack(List<BankBalanceModel> balanceModels)
- {
- IsBusy = false;
- BalanceModels = balanceModels;
- SelectItem = BalanceModels != null ? BalanceModels.FirstOrDefault() : null;
- #if DEBUG
- var balances = new List<BankBalanceModel>();
- balances.Add(new BankBalanceModel() { AccountCode = 12315555 + string.Empty, PlatBalance = 254542, Cusbankid = "fdaddd" });
- balances.Add(new BankBalanceModel() { AccountCode = 12315532455 + string.Empty, PlatBalance = 25432542, Cusbankid = "fda323ddd" });
- BalanceModels = balances;
- SelectItem = BalanceModels != null ? BalanceModels.FirstOrDefault() : null;
- #endif
- }
- public void ErrorCallback(ErrorEntity error)
- {
- #if DEBUG
- var balances = new List<BankBalanceModel>();
- balances.Add(new BankBalanceModel(){AccountCode = 12315555+string.Empty,PlatBalance = 254542,Cusbankid = "fdaddd"});
- balances.Add(new BankBalanceModel() { AccountCode = 12315532455 + string.Empty, PlatBalance = 25432542, Cusbankid = "fda323ddd" });
- BalanceModels = balances;
- SelectItem = BalanceModels != null ? BalanceModels.FirstOrDefault() : null;
- #endif
- IsBusy = false;
- System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- ErrorManager.ShowReturnError(error, Muchinfo.MTPClient.Resources.Client_Resource.Bank_Error, true);
- }));
- }
- }
- }
|