| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- //----------------------------------------------------------------
- //Module Name: $safeprojectname$
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime 2016/11/4 9:17:27
- //Author
- //Description Create
- //----------------------------------------------------------------
- using System.Windows;
- using GalaSoft.MvvmLight.Command;
- using GalaSoft.MvvmLight.Ioc;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Data.Helper;
- using Muchinfo.MTPClient.Data.Model.Account;
- using Muchinfo.MTPClient.Infrastructure.MessageBox;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.IService;
- namespace Muchinfo.MTPClient.Account.ViewModels
- {
- public class DealCloseViewModel : RegisterMessageBase
- {
- private IOrderService _iOrderService;
- public DealCloseViewModel()
- {
- _iOrderService = SimpleIoc.Default.GetInstance<IOrderService>();
- }
- private RelayCommand _comfrimCommand;
- public RelayCommand ComfrimCommand
- {
- get
- {
- if (_comfrimCommand != null)
- {
- return _comfrimCommand;
- }
- _comfrimCommand=new RelayCommand(() =>
- {
- if (SelectItem != null)
- {
-
- var titips = string.Format(Resources.Client_Resource.Content_DealClosedComfrim_Tips, SelectItem.DealNum, SelectItem.Direction.Discription());
- var message = MessageBoxHelper.ShowQuestion(titips, Resources.Client_Resource.Content_DealClosedComfrim);
- if (message == MessageBoxResult.Yes)
- {
- IsBusy = true;
- var dealCloseModel = new DealCloseOrder()
- {
- Direction = SelectItem.Direction,
- autoId = SelectItem.DealNum,
- AccountId = SelectItem.SelfAccountId,
- Status = ComfrimStatus.Comfrim
- };
- _iOrderService.DealCloseComfirm(dealCloseModel, ComfirmSuccessAction, ReceiveError);
- }
- }
- });
- return _comfrimCommand;
- }
- }
- private List<DealCloseModel> _dealCloseModels;
- /// <summary>
- /// 查询条件
- /// </summary>
- public List<DealCloseModel> DealCloseModels
- {
- get { return _dealCloseModels; }
- set { Set(() => DealCloseModels, ref _dealCloseModels, value); }
- }
- private DealCloseModel _selectItem;
- public DealCloseModel SelectItem
- {
- get { return _selectItem; }
- set { _selectItem = value; }
- }
-
-
- public override void RefreshContent()
- {
- IsBusy = true;
- var accountId = UserManager.CurrentTradeAccount.AccountId;
- //if (UserManager.CurrentTradeAccount.FundsAccounts != null &&
- // UserManager.CurrentTradeAccount.FundsAccounts.Any())
- //{
- // accountId = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- _iOrderService.QueryDealCloseSetting(accountId, QueryDealSuccess, ReceiveError);
- }
- #region 请求回应
- private void QueryDealSuccess(List<DealCloseModel> dealCloseModels)
- {
- IsBusy = false;
- var accountId = UserManager.CurrentTradeAccount.AccountId;
- //if (UserManager.CurrentTradeAccount.FundsAccounts != null &&
- // UserManager.CurrentTradeAccount.FundsAccounts.Any())
- //{
- // accountId = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- foreach (var dealCloseModel in dealCloseModels) ////设置己方账号
- {
- dealCloseModel.SelfAccountId = accountId;
- }
- DealCloseModels = dealCloseModels.FindAll(x => x.AuditStatus != eAuditStatus.AUDITSTATUS_REJECT);
- }
- private void ComfirmSuccessAction(DealCloseOrder dealClose)
- {
- IsBusy = false;
- ////确认成功后刷新
- RefreshContent();
- }
- private void ReceiveError(ErrorEntity errorEntity)
- {
- IsBusy = false;
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- ErrorManager.ShowReturnError(errorEntity, Resources.Client_Resource.MessageBox_Error_Title);
- }));
- }
- #endregion
- public override void RegisterMessage()
- {
- RefreshContent();
- }
- }
- }
-
|