DepositPlanViewModel.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. //----------------------------------------------------------------
  7. //Module Name: $safeprojectname$
  8. //Purpose:
  9. //CopyRight: Muchinfo
  10. //History:
  11. //----------------------------------------------------------------
  12. //DateTime 2017/1/11 23:53:59
  13. //Author
  14. //Description Create
  15. //----------------------------------------------------------------
  16. using System.Windows;
  17. using GalaSoft.MvvmLight;
  18. using GalaSoft.MvvmLight.Command;
  19. using GalaSoft.MvvmLight.Ioc;
  20. using Microsoft.Practices.ServiceLocation;
  21. using Muchinfo.MTPClient.Data;
  22. using Muchinfo.MTPClient.Data.Enums;
  23. using Muchinfo.MTPClient.Data.Helper;
  24. using Muchinfo.MTPClient.Data.Model;
  25. using Muchinfo.MTPClient.Data.Model.Sale;
  26. using Muchinfo.MTPClient.Infrastructure.Cache;
  27. using Muchinfo.MTPClient.Infrastructure.Helpers;
  28. using Muchinfo.MTPClient.Infrastructure.Utilities;
  29. using Muchinfo.MTPClient.IService;
  30. using Muchinfo.MTPClient.Resources;
  31. using Muchinfo.MTPClient.Sale.Views;
  32. namespace Muchinfo.MTPClient.Sale.ViewModels
  33. {
  34. public class DepositPlanViewModel:ViewModelBase
  35. {
  36. private IDepositService _iDepositService;
  37. #region 构造函数
  38. public DepositPlanViewModel()
  39. {
  40. _iDepositService = SimpleIoc.Default.GetInstance<IDepositService>();
  41. QueryDesositPlan();
  42. }
  43. #endregion
  44. #region 成员变量
  45. private DepositPlan _currentDataGridItem;
  46. /// <summary>
  47. /// 当前选中DataGridItem
  48. /// </summary>
  49. public DepositPlan CurrentDataGridItem
  50. {
  51. get { return _currentDataGridItem; }
  52. set
  53. {
  54. Set(() => CurrentDataGridItem, ref _currentDataGridItem, value);
  55. }
  56. }
  57. /// <summary>
  58. /// 发行托管
  59. /// </summary>
  60. private List<DepositPlan> _depositPlanList;
  61. public List<DepositPlan> DepositPlanList
  62. {
  63. get { return _depositPlanList; }
  64. set { Set(() => DepositPlanList, ref _depositPlanList, value); }
  65. }
  66. #endregion
  67. /// <summary>
  68. /// 查询
  69. /// </summary>
  70. public RelayCommand SelectCommand
  71. {
  72. get
  73. {
  74. return new RelayCommand(() =>
  75. {
  76. QueryDesositPlan();
  77. });
  78. }
  79. }
  80. /// <summary>
  81. /// 申购
  82. /// </summary>
  83. public RelayCommand DetailCommand
  84. {
  85. get
  86. {
  87. return new RelayCommand(() =>
  88. {
  89. if (CurrentDataGridItem == null)
  90. {
  91. //todo:提示无选择商品
  92. return;
  93. }
  94. var win = new DepositApplyView(CurrentDataGridItem, DepositPlanList)
  95. {
  96. Owner = Application.Current.MainWindow,
  97. WindowStartupLocation = WindowStartupLocation.CenterOwner
  98. };
  99. win.ShowDialog();
  100. });
  101. }
  102. }
  103. /// <summary>
  104. /// 错误处理
  105. /// </summary>
  106. /// <param name="error">错误内容</param>
  107. private void QueryErrorFunc(ErrorEntity error)
  108. {
  109. DepositPlanList = null;
  110. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  111. {
  112. ErrorManager.ShowReturnError(error, Client_Resource.UI2014_Tips, true);
  113. }));
  114. }
  115. public void QueryDesositPlan()
  116. {
  117. _iDepositService.QueryDepositPlanGoods(QuerySuccess,QueryErrorFunc);
  118. }
  119. public void QuerySuccess(List<DepositPlan> list)
  120. {
  121. DepositPlanList = list;
  122. }
  123. }
  124. }