using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using Microsoft.Practices.ServiceLocation; using Muchinfo.MTPClient.Data.Model.Sale; using Muchinfo.MTPClient.Infrastructure.MessageBox; using Muchinfo.MTPClient.Infrastructure.Utilities; using Muchinfo.MTPClient.IService; using Muchinfo.MTPClient.Resources; using Muchinfo.PC.Common.Extensions; using Muchinfo.WPF.Controls.Windows; using System.Collections.Generic; using System.Threading.Tasks; namespace Muchinfo.MTPClient.Sale.ViewModels { public class QueryDealPurchaseViewModel : ViewModelBase { private ISaleService _saleService; #region 构造函数 public QueryDealPurchaseViewModel() { _saleService = ServiceLocator.Current.GetInstance(); } #endregion #region 成员变量 private List _saleGoodsApplyList; public List SaleGoodsApplyList { get { return _saleGoodsApplyList; } set { Set(() => SaleGoodsApplyList, ref _saleGoodsApplyList, value); } } private string _goodCode = string.Empty; /// /// 商品代码 /// public string GoodCode { get { return _goodCode.Trim(); } set { Set(() => GoodCode, ref _goodCode, value); } } private bool _isBusy; /// /// 是否在查询 /// public bool IsBusy { get { return _isBusy; } set { Set(() => IsBusy, ref _isBusy, value); } } /// /// 是否显示撤单 /// private bool _isCancelSaleCammand = false; public bool IsCancelSaleCammand { get { return _isCancelSaleCammand; } set { Set(() => IsCancelSaleCammand, ref _isCancelSaleCammand, value); } } #endregion #region 私有方法 /// /// 查询 /// public RelayCommand SelectCommand { get { return new RelayCommand(() => { if (string.IsNullOrEmpty(GoodCode)) { MessageBoxHelper.ShowInfo("请输入准确的商品代码!", Client_Resource.MessageBox_Error_Title); return; } IsBusy = true; Task.Factory.TryStartNew(() => { SaleGoodsApplyList = _saleService.QuerySaleApplyRpt(UserManager.CurrentTradeAccount, GoodCode); }, () => { IsBusy = false; }); }); } } /// /// 重置 /// public RelayCommand ResetCommand { get { return new RelayCommand(() => { GoodCode = string.Empty; }); } } #endregion } }