QueryPanelModelBase.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using GalaSoft.MvvmLight;
  2. using GalaSoft.MvvmLight.Command;
  3. using Muchinfo.MTPClient.Data;
  4. using Muchinfo.MTPClient.Infrastructure.Helpers;
  5. using Muchinfo.MTPClient.Infrastructure.Utilities;
  6. using Muchinfo.MTPClient.IService;
  7. using Muchinfo.MTPClient.Resources;
  8. using System;
  9. //----------------------------------------------------------------
  10. //Module Name: $safeprojectname$
  11. //Purpose:
  12. //CopyRight: Muchinfo
  13. //History:
  14. //----------------------------------------------------------------
  15. //DateTime 2016/4/16 13:44:50
  16. //Author
  17. //Description Create
  18. //----------------------------------------------------------------
  19. using System.Windows;
  20. namespace Muchinfo.MTPClient.Infrastructure.Windows
  21. {
  22. public abstract class QueryPanelModelBase : ViewModelBase, IOrderRefresh
  23. {
  24. private bool _isBusy;
  25. /// <summary>
  26. /// 是否在忙
  27. /// </summary>
  28. public bool IsBusy
  29. {
  30. get { return _isBusy; }
  31. set
  32. {
  33. Set(() => IsBusy, ref _isBusy, value);
  34. }
  35. }
  36. /// <summary>
  37. /// 刷新
  38. /// </summary>
  39. public virtual RelayCommand RefreshCommand
  40. {
  41. get
  42. {
  43. return new RelayCommand(() =>
  44. {
  45. RefreshContent();
  46. });
  47. }
  48. }
  49. /// <summary>
  50. /// 单据注册消息
  51. /// </summary>
  52. public abstract void RegisterMessage();
  53. /// <summary>
  54. /// 销毁消息
  55. /// </summary>
  56. public virtual void UnRegisterMessage()
  57. {
  58. // MessengerHelper.DefaultUnregister(this);
  59. }
  60. /// <summary>
  61. /// 刷新数据
  62. /// </summary>
  63. public abstract void RefreshContent();
  64. public virtual void QueryErrorCallback(ErrorEntity errorEntity)
  65. {
  66. IsBusy = false;
  67. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  68. {
  69. ErrorManager.ShowReturnError(errorEntity, Client_Resource.APP_Tips, false);
  70. }));
  71. }
  72. /// <summary>
  73. /// 刷新数据
  74. /// </summary>
  75. public void Refresh()
  76. {
  77. RefreshContent();
  78. }
  79. /// <summary>
  80. /// Cleanups this instance.
  81. /// </summary>
  82. public override void Cleanup()
  83. {
  84. ////取消注册消息
  85. base.Cleanup();
  86. MessengerHelper.QuoteUnregister(this);
  87. }
  88. }
  89. }