| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- 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;
- /// <summary>
- /// 查询开始时间
- /// </summary>
- 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;
- /// <summary>
- /// 查询结束时间
- /// </summary>
- public DateTime EndDateTime
- {
- get { return _endDateTime; }
- set
- {
- Set(() => EndDateTime, ref _endDateTime, new DateTime(value.Year, value.Month, value.Day, 23, 59, 59));
- }
- }
- private List<AmountQuery> _amountQueryList;
- public List<AmountQuery> AmountQueryList
- {
- get { return _amountQueryList; }
- set { Set(() => AmountQueryList, ref _amountQueryList, value); }
- }
- private IBankService _bankService;
- public AmountQueryViewModel()
- {
- _bankService = SimpleIoc.Default.GetInstance<IBankService>();
- 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<QueryCommonParam>();
- 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<AmountQuery> 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);
- }
- }
- }
|