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(); } 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 _dealCloseModels; /// /// 查询条件 /// public List 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 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(); } } }