| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- //----------------------------------------------------------------
- //Module Name: $safeprojectname$
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime 2017/1/12 22:16:38
- //Author
- //Description Create
- //----------------------------------------------------------------
- using System.Windows;
- using System.Windows.Input;
- using GalaSoft.MvvmLight.Command;
- using GalaSoft.MvvmLight.Ioc;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Data.Model;
- using Muchinfo.MTPClient.Data.Model.Delivery;
- using Muchinfo.MTPClient.Infrastructure.Helpers;
- using Muchinfo.MTPClient.Infrastructure.MessageBox;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.Infrastructure.Windows;
- using Muchinfo.MTPClient.IService;
- using Muchinfo.MTPClient.Resources;
- using Muchinfo.MTPClient.Data.Model.Account;
- namespace Muchinfo.MTPClient.Sale.ViewModels
- {
- public class QueryDepositApplyViewModel : QueryPanelModelBase
- {
- #region 开始时间
- private DateTime startTime;
- /// <summary>
- /// 开始时间
- /// </summary>
- public DateTime StartTime
- {
- get { return startTime; }
- set { Set(() => StartTime, ref startTime, value); }
- }
- #endregion
- #region 结束时间
- private DateTime _endTime;
- /// <summary>
- /// 结束时间
- /// </summary>
- public DateTime EndTime
- {
- get { return _endTime; }
- set { Set(() => EndTime, ref _endTime, value); }
- }
- private List<DepositApplyModel> _depositApplyList;
- /// <summary>
- /// 查询托管申请单据
- /// </summary>
- public List<DepositApplyModel> DepositApplyList
- {
- get { return _depositApplyList; }
- set { Set(() => DepositApplyList, ref _depositApplyList, value); }
- }
- private DepositApplyModel _curApplyModel;
- /// <summary>
- /// 当前选择的单据
- /// </summary>
- public DepositApplyModel CurApplyModel
- {
- get { return _curApplyModel; }
- set { Set(() => CurApplyModel, ref _curApplyModel, value); }
- }
- #endregion
- #region 重置查询时间命令Command
- private RelayCommand _resetCommand;
- /// <summary>
- /// Gets the ResetCommand.
- /// </summary>
- public RelayCommand ResetCommand
- {
- get
- {
- return _resetCommand
- ?? (_resetCommand = new RelayCommand(
- () =>
- {
- EndTime = ApplicationParameter.ServerTimeNow.AddDays(1);
- StartTime = ApplicationParameter.ServerTimeNow.AddDays(-29);
- }));
- }
- }
- #endregion
- #region 撤销命令Command
- private RelayCommand _cancelCommand;
- public ICommand CancelCommand
- {
- get
- {
- if (_cancelCommand == null)
- {
- _cancelCommand = new RelayCommand(() =>
- {
- CanceleOrder();
- });
- }
- return _cancelCommand;
- }
- }
- private void CanceleOrder()
- {
- if (CurApplyModel != null)
- {
- var accountId = UserManager.CurrentTradeAccount.AccountId;
- //if (UserManager.CurrentTradeAccount.FundsAccounts.Any() &&
- // UserManager.CurrentTradeAccount.FundsAccounts[0] != null)
- //{
- // accountId = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- var orderBuild = new DepositOrder()
- {
- Accountid = accountId,
- BuildType = eBuildType.BUILDTYPE_CLOSE,
- StoreinId = CurApplyModel.StoreInId,
- };
- var boxResult = MessageBoxHelper.ShowQuestion(Muchinfo.MTPClient.Resources.Client_Resource.Models_MakesureToCancel,
- Muchinfo.MTPClient.Resources.Client_Resource.Models_CancelBillTips);
- if (boxResult == MessageBoxResult.Yes)
- {
- IsBusy = true;
- _depositService.DepositApply(orderBuild, EntrurstSuccessCallBack, EntrurstErrorCallBack);
- }
- }
- }
- private RelayCommand _rightRelayCommand;
- public RelayCommand RightCancelCommand
- {
- get
- {
- if (_rightRelayCommand == null)
- {
- _rightRelayCommand = new RelayCommand(() =>
- {
- CanceleOrder();
- }, IsCanceledEnable);
- }
- return _rightRelayCommand;
- }
- }
- private bool IsCanceledEnable()
- {
- if (CurApplyModel == null)
- {
- return false;
- }
- else
- {
- return CurApplyModel.AuditStatus == eAuditStatus.AUDITSTATUS_CHECKING;
- }
- }
- #endregion
- private IDepositService _depositService;
- public QueryDepositApplyViewModel()
- {
- _depositService = SimpleIoc.Default.GetInstance<IDepositService>();
- }
- /// 撤销成功返回
- /// </summary>
- /// <param name="order"></param>
- private void EntrurstSuccessCallBack(DepositOrder order)
- {
- IsBusy = false;
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- MessageBoxHelper.ShowSuccess(Muchinfo.MTPClient.Resources.Client_Resource.Account_CancelSuccess,
- Client_Resource.Cancel_MessageBox_Title);
- //MessageBoxHelper.ShowSuccess(Client_Resource.Order_Success_Result,
- // Client_Resource.Cancel_MessageBox_Title);
- //if (_openWindow != null)
- //{
- // _openWindow.Close();
- // this.Cleanup();
- //}
- }));
- RefreshContent(); ////更新撤单状态
- }
- /// <summary>
- /// 撤销失败返回
- /// </summary>
- /// <param name="errorEntity"></param>
- private void EntrurstErrorCallBack(ErrorEntity errorEntity)
- {
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- ErrorManager.ShowReturnError(errorEntity, Client_Resource.UI2014_Tips, true);
- IsBusy = false;
- }));
- }
- public override void RegisterMessage()
- {
- EndTime = ApplicationParameter.ServerTimeNow.AddDays(1);
- StartTime = ApplicationParameter.ServerTimeNow.AddDays(-29);
- //RefreshContent();
- RefreshCommand.Execute(null);
- MessengerHelper.DefaultUnregister<TradeAccount>(this, MessengerTokens.DepositOrderToken);
- MessengerHelper.DefaultRegister<TradeAccount>(this, MessengerTokens.DepositOrderToken, (e) =>
- {
- RefreshCommand.Execute(null);
- });
-
- }
- public override void UnRegisterMessage()
- {
- this.Cleanup();
- //base.UnRegisterMessage();
- }
- public override void RefreshContent()
- {
- if (Vailed())
- {
- var accountid = UserManager.CurrentTradeAccount.AccountId;
- //if (UserManager.CurrentTradeAccount.FundsAccounts != null &&
- // UserManager.CurrentTradeAccount.FundsAccounts.Any())
- //{
- // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- _depositService.QueryDepositApply(accountid, startTime, EndTime, QueryDepositApplySuccess, ErrorQuery);
- }
- }
- private void QueryDepositApplySuccess(List<DepositApplyModel> list)
- {
- IsBusy = false;
- DepositApplyList = list;
- }
- private void ErrorQuery(ErrorEntity errorEntity)
- {
- IsBusy = false;
- ////todo:查询失败
- }
- #region "Other Methods like Validated"
- /// <summary>
- /// 数据验证
- /// </summary>
- /// <returns></returns>
- private bool Vailed()
- {
- if (StartTime > EndTime)
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.DateTimeVaided_StartEnd, Muchinfo.MTPClient.Resources.Client_Resource.Models_Tips, true);
- return false;
- }
- else if ((EndTime - StartTime).Days > 30)
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.DateTimeVaided_Over30days, Muchinfo.MTPClient.Resources.Client_Resource.Models_Tips, true);
- return false;
- }
- return true;
- }
- #endregion "Other Methods like Validated"
- }
- }
|