using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; //---------------------------------------------------------------- //Module Name: $safeprojectname$ //Purpose: //CopyRight: Muchinfo //History: //---------------------------------------------------------------- //DateTime 2017/1/11 23:53:59 //Author //Description Create //---------------------------------------------------------------- using System.Windows; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Ioc; using Microsoft.Practices.ServiceLocation; using Muchinfo.MTPClient.Data; using Muchinfo.MTPClient.Data.Enums; using Muchinfo.MTPClient.Data.Helper; using Muchinfo.MTPClient.Data.Model; using Muchinfo.MTPClient.Data.Model.Sale; using Muchinfo.MTPClient.Infrastructure.Cache; using Muchinfo.MTPClient.Infrastructure.Helpers; using Muchinfo.MTPClient.Infrastructure.Utilities; using Muchinfo.MTPClient.IService; using Muchinfo.MTPClient.Resources; using Muchinfo.MTPClient.Sale.Views; namespace Muchinfo.MTPClient.Sale.ViewModels { public class DepositPlanViewModel:ViewModelBase { private IDepositService _iDepositService; #region 构造函数 public DepositPlanViewModel() { _iDepositService = SimpleIoc.Default.GetInstance(); QueryDesositPlan(); } #endregion #region 成员变量 private DepositPlan _currentDataGridItem; /// /// 当前选中DataGridItem /// public DepositPlan CurrentDataGridItem { get { return _currentDataGridItem; } set { Set(() => CurrentDataGridItem, ref _currentDataGridItem, value); } } /// /// 发行托管 /// private List _depositPlanList; public List DepositPlanList { get { return _depositPlanList; } set { Set(() => DepositPlanList, ref _depositPlanList, value); } } #endregion /// /// 查询 /// public RelayCommand SelectCommand { get { return new RelayCommand(() => { QueryDesositPlan(); }); } } /// /// 申购 /// public RelayCommand DetailCommand { get { return new RelayCommand(() => { if (CurrentDataGridItem == null) { //todo:提示无选择商品 return; } var win = new DepositApplyView(CurrentDataGridItem, DepositPlanList) { Owner = Application.Current.MainWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner }; win.ShowDialog(); }); } } /// /// 错误处理 /// /// 错误内容 private void QueryErrorFunc(ErrorEntity error) { DepositPlanList = null; Application.Current.Dispatcher.BeginInvoke(new Action(() => { ErrorManager.ShowReturnError(error, Client_Resource.UI2014_Tips, true); })); } public void QueryDesositPlan() { _iDepositService.QueryDepositPlanGoods(QuerySuccess,QueryErrorFunc); } public void QuerySuccess(List list) { DepositPlanList = list; } } }