QueryDealPurchaseViewModel.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using GalaSoft.MvvmLight;
  2. using GalaSoft.MvvmLight.Command;
  3. using Microsoft.Practices.ServiceLocation;
  4. using Muchinfo.MTPClient.Data.Model.Sale;
  5. using Muchinfo.MTPClient.Infrastructure.MessageBox;
  6. using Muchinfo.MTPClient.Infrastructure.Utilities;
  7. using Muchinfo.MTPClient.IService;
  8. using Muchinfo.MTPClient.Resources;
  9. using Muchinfo.PC.Common.Extensions;
  10. using Muchinfo.WPF.Controls.Windows;
  11. using System.Collections.Generic;
  12. using System.Threading.Tasks;
  13. namespace Muchinfo.MTPClient.Sale.ViewModels
  14. {
  15. public class QueryDealPurchaseViewModel : ViewModelBase
  16. {
  17. private ISaleService _saleService;
  18. #region 构造函数
  19. public QueryDealPurchaseViewModel()
  20. {
  21. _saleService = ServiceLocator.Current.GetInstance<ISaleService>();
  22. }
  23. #endregion
  24. #region 成员变量
  25. private List<SaleApply> _saleGoodsApplyList;
  26. public List<SaleApply> SaleGoodsApplyList
  27. {
  28. get
  29. {
  30. return _saleGoodsApplyList;
  31. }
  32. set
  33. {
  34. Set(() => SaleGoodsApplyList, ref _saleGoodsApplyList, value);
  35. }
  36. }
  37. private string _goodCode = string.Empty;
  38. /// <summary>
  39. /// 商品代码
  40. /// </summary>
  41. public string GoodCode
  42. {
  43. get
  44. {
  45. return _goodCode.Trim();
  46. }
  47. set
  48. {
  49. Set(() => GoodCode, ref _goodCode, value);
  50. }
  51. }
  52. private bool _isBusy;
  53. /// <summary>
  54. /// 是否在查询
  55. /// </summary>
  56. public bool IsBusy
  57. {
  58. get { return _isBusy; }
  59. set { Set(() => IsBusy, ref _isBusy, value); }
  60. }
  61. /// <summary>
  62. /// 是否显示撤单
  63. /// </summary>
  64. private bool _isCancelSaleCammand = false;
  65. public bool IsCancelSaleCammand
  66. {
  67. get
  68. {
  69. return _isCancelSaleCammand;
  70. }
  71. set
  72. {
  73. Set(() => IsCancelSaleCammand, ref _isCancelSaleCammand, value);
  74. }
  75. }
  76. #endregion
  77. #region 私有方法
  78. /// <summary>
  79. /// 查询
  80. /// </summary>
  81. public RelayCommand SelectCommand
  82. {
  83. get
  84. {
  85. return new RelayCommand(() =>
  86. {
  87. if (string.IsNullOrEmpty(GoodCode))
  88. {
  89. MessageBoxHelper.ShowInfo("请输入准确的商品代码!", Client_Resource.MessageBox_Error_Title);
  90. return;
  91. }
  92. IsBusy = true;
  93. Task.Factory.TryStartNew(() =>
  94. {
  95. SaleGoodsApplyList = _saleService.QuerySaleApplyRpt(UserManager.CurrentTradeAccount, GoodCode);
  96. }, () =>
  97. {
  98. IsBusy = false;
  99. });
  100. });
  101. }
  102. }
  103. /// <summary>
  104. /// 重置
  105. /// </summary>
  106. public RelayCommand ResetCommand
  107. {
  108. get
  109. {
  110. return new RelayCommand(() =>
  111. {
  112. GoodCode = string.Empty;
  113. });
  114. }
  115. }
  116. #endregion
  117. }
  118. }