using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Ioc; using Muchinfo.MTPClient.Data; using Muchinfo.MTPClient.Data.Model.Bank; using Muchinfo.MTPClient.Infrastructure.MessageBox; using Muchinfo.MTPClient.Infrastructure.Utilities; using Muchinfo.MTPClient.IService; using Muchinfo.MTPClient.Resources; using Muchinfo.WPF.Controls.Windows; using System; using System.Collections.Generic; using System.Linq; namespace Muchinfo.MTPClient.Account.ViewModels { public class AmountQueryViewModel : RegisterMessageBase { /// 查询开始时间 private DateTime _startDateTime; /// /// 查询开始时间 /// public DateTime StartDateTime { get { return _startDateTime; } set { Set(() => StartDateTime, ref _startDateTime, new DateTime(value.Year, value.Month, value.Day, 0, 0, 0)); } } /// 查询结束时间 private DateTime _endDateTime; /// /// 查询结束时间 /// public DateTime EndDateTime { get { return _endDateTime; } set { Set(() => EndDateTime, ref _endDateTime, new DateTime(value.Year, value.Month, value.Day, 23, 59, 59)); } } private List _amountQueryList; public List AmountQueryList { get { return _amountQueryList; } set { Set(() => AmountQueryList, ref _amountQueryList, value); } } private IBankService _bankService; public AmountQueryViewModel() { _bankService = SimpleIoc.Default.GetInstance(); DateTime time = ApplicationParameter.ServerTimeNow; //this.StartDateTime = time.AddDays(1 - time.Day); this.StartDateTime = time.AddDays(-7); this.EndDateTime = time; SelectBankOutIn(); } public RelayCommand QuetyCommand { get { return new RelayCommand(() => { if (this.EndDateTime < this.StartDateTime) { MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Models_EndDateLessBegin, Muchinfo.MTPClient.Resources.Client_Resource.Models_Tips, true); return; } int number = (StartDateTime.Year - EndDateTime.Year) * 12 + StartDateTime.Month - EndDateTime.Month; if (number < -3) { MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.Models_CanNotGreatThan3Month, Muchinfo.MTPClient.Resources.Client_Resource.Models_Tips, true); return; } SelectBankOutIn(); }); } } public void SelectBankOutIn() { var queryCommons = new List(); var accountid = UserManager.CurrentTradeAccount.AccountId; //if (UserManager.CurrentTradeAccount.FundsAccounts!=null && UserManager.CurrentTradeAccount.FundsAccounts.Any()) //{ // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId; //} queryCommons.Add(new QueryCommonParam() { ParamKey = "accountId", ParamValue = accountid + string.Empty }); queryCommons.Add(new QueryCommonParam() { ParamKey = "beginDate", ParamValue = StartDateTime.ToString("yyyy-MM-dd") }); queryCommons.Add(new QueryCommonParam() { ParamKey = "endDate", ParamValue = EndDateTime.Date.AddHours(24).ToString("yyyy-MM-dd HH:mm:ss") }); // IsBusy = true; //this.AmountQueryList = _bankService.QueryBankOutIn(this.StartDateTime, this.EndDateTime, UserManager.CurrentTradeAccount); _bankService.QueryBankOutIn(QueryStatement.SearchClientMoneyOutIn, queryCommons, QueryBankOutInCallBack, QueryErrorCallback); } private void QueryBankOutInCallBack(List amountQueryList) { IsBusy = false; this.AmountQueryList = amountQueryList; } public virtual void QueryErrorCallback(ErrorEntity errorEntity) { IsBusy = false; System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => { ErrorManager.ShowReturnError(errorEntity, Client_Resource.APP_Tips, false); })); } //注册消息 public override void RegisterMessage() { SelectBankOutIn(); } public override void RefreshContent() { QuetyCommand.Execute(null); } } }