| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683 |
- using GalaSoft.MvvmLight;
- using GalaSoft.MvvmLight.Ioc;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Model.Delivery;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.IService;
- using Muchinfo.MTPClient.Resources;
- using System;
- using System.Collections.Generic;
- using System.Windows;
- using System.Linq;
- using Muchinfo.MTPClient.Infrastructure.MessageBox;
- using GalaSoft.MvvmLight.Command;
- using System.Collections.ObjectModel;
- using Muchinfo.MTPClient.Infrastructure.Helpers;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Infrastructure.Cache;
- using System.Text;
- using System.Windows.Input;
- using System.Windows.Controls;
- namespace Muchinfo.MTPClient.Delivery.ViewModels
- {
- /// <summary>
- /// 交割配对
- /// <para>
- /// </para>
- /// </summary>
- public class DeliveryMatchViewModel : ViewModelBase
- {
- #region "=========私有成员/Private Data Members"
- private IDeliveryService _deliveryService;
- private Window _openWindow;
- //private decimal usableFunds = 0;
- private decimal tempOtherCanMatchQty;
- private bool _action = false;
- private bool _isCheckAction = false;
- private DeliveryEntrustOrder _deliveryEntrustOrder;
- private decimal totalQty = decimal.Zero;
- private decimal AllCanUseQty = decimal.Zero;
- private string WrCodeListStr = string.Empty;
- #endregion "Private Data Members"
- #region "=========构造函数/Constructor/Initialization"
- public DeliveryMatchViewModel(DeliveryEntrustOrder itemOrder)
- {
- this._deliveryEntrustOrder = itemOrder;
- _deliveryService = SimpleIoc.Default.GetInstance<IDeliveryService>();
- InitData();
- }
- #endregion "Constructor/Initialization"
- #region "=========接口重写/Interface implementation Or override"
- //To do interface implementation
- #endregion "Interface implementation Or override"
- #region "=========公共属性/Public Properties To Get/Set "
- #region 错误信息提示
- private string _ErrorMessage = string.Empty;
- /// <summary>
- /// 错误信息提示
- /// </summary>
- public string ErrorMessage
- {
- get
- {
- return _ErrorMessage;
- }
- set
- {
- Set(() => ErrorMessage, ref _ErrorMessage, value);
- }
- }
- #endregion
- #region 当前仓单详细
- private DeliveryWarehouse _currentWarehouseDetail;
- /// <summary>
- /// 当前仓单详细
- /// </summary>
- public DeliveryWarehouse CurrentWarehouseDetail
- {
- get
- {
- return _currentWarehouseDetail;
- }
- set
- {
- Set(() => CurrentWarehouseDetail, ref _currentWarehouseDetail, value);
- }
- }
- #endregion
- #region 所有当前用户仓单
- private List<DeliveryWarehouse> _allWarehouseOrders;
- /// <summary>
- /// 所有当前用户仓单
- /// </summary>
- public List<DeliveryWarehouse> AllWarehouseOrders
- {
- get { return _allWarehouseOrders; }
- set { Set(() => AllWarehouseOrders, ref _allWarehouseOrders, value); }
- }
- #endregion
- #region 选择预览数据
- private ObservableCollection<WrPairDetailModel> _chooseMatchOrderList = new ObservableCollection<WrPairDetailModel>();
- /// <summary>
- /// 选择预览数据
- /// </summary>
- public ObservableCollection<WrPairDetailModel> ChooseMatchOrderList
- {
- get
- {
- return _chooseMatchOrderList;
- }
- set
- {
- Set(() => ChooseMatchOrderList, ref _chooseMatchOrderList, value);
- }
- }
- #endregion
- #region 当前选择仓单
- private WrPairDetailModel _currentSelectedItem;
- /// <summary>
- /// 当前选择仓单
- /// </summary>
- public WrPairDetailModel CurrentSelectedItem
- {
- get
- {
- return _currentSelectedItem;
- }
- set
- {
- Set(() => CurrentSelectedItem, ref _currentSelectedItem, value);
- }
- }
- #endregion
- #region 主数据-是否显示
- private Visibility _isVisibility_Main = Visibility.Visible;
- /// <summary>
- /// 主数据-是否显示
- /// </summary>
- public Visibility IsVisibility_Main
- {
- get
- {
- return _isVisibility_Main;
- }
- set
- {
- Set(() => IsVisibility_Main, ref _isVisibility_Main, value);
- }
- }
- #endregion
- #region 预览数据-是否显示
- private Visibility _IsVisibility_PreView = Visibility.Collapsed;
- /// <summary>
- /// 预览数据-是否显示
- /// </summary>
- public Visibility IsVisibility_PreView
- {
- get
- {
- return _IsVisibility_PreView;
- }
- set
- {
- Set(() => IsVisibility_PreView, ref _IsVisibility_PreView, value);
- }
- }
- #endregion
- #region 仓单详细-是否显示
- private Visibility _isVisibility_Warehouse = Visibility.Collapsed;
- /// <summary>
- /// 仓单详细-是否显示
- /// </summary>
- public Visibility IsVisibility_Warehouse
- {
- get
- {
- return _isVisibility_Warehouse;
- }
- set
- {
- Set(() => IsVisibility_Warehouse, ref _isVisibility_Warehouse, value);
- }
- }
- #endregion
- #region 标题
- private string _title = Resources.Client_Resource.DeliveryEntructOrderView_Matched;
- /// <summary>
- /// 标题
- /// </summary>
- public string Title
- {
- get
- {
- return _title;
- }
- set
- {
- Set(() => Title, ref _title, value);
- }
- }
- #endregion
- #region 按钮是否可用
- private bool _oKButtonEnabled = true;
- /// <summary>
- ///按钮是否可用
- /// </summary>
- public bool OKButtonEnabled
- {
- get
- {
- return _oKButtonEnabled;
- }
- set
- {
- Set(() => OKButtonEnabled, ref _oKButtonEnabled, value);
- }
- }
- #endregion
- #region 是否繁忙
- private bool _isBusy = false;
- /// <summary>
- /// Sets and gets the IsBusy property.
- /// Changes to that property's value raise the PropertyChanged event.
- /// </summary>
- public bool IsBusy
- {
- get
- {
- return _isBusy;
- }
- set
- {
- Set(() => IsBusy, ref _isBusy, value);
- }
- }
- #endregion
- #region 交割仓单配对列表
- public List<WrPairDetailModel> TempDeliveryMatchOrderList = new List<WrPairDetailModel>();
- private List<WrPairDetailModel> _deliveryMatchOrderList = new List<WrPairDetailModel>();
- /// <summary>
- /// 交割仓单配对列表
- /// </summary>
- public List<WrPairDetailModel> DeliveryMatchOrderList
- {
- get { return _deliveryMatchOrderList; }
- set
- {
- Set(() => DeliveryMatchOrderList, ref _deliveryMatchOrderList, value);
- }
- }
- #endregion
- #region 预查询数据
- private List<WrPairDetailModel> _searchMatchOrderList;
- /// <summary>
- /// 预查询数据
- /// </summary>
- public List<WrPairDetailModel> SearchMatchOrderList
- {
- get
- {
- return _searchMatchOrderList;
- }
- set
- {
- Set(() => SearchMatchOrderList, ref _searchMatchOrderList, value);
- }
- }
- #endregion
- #region 仓库下拉列表
- private List<string> _deliveryWarehouseList = new List<string>();
- /// <summary>
- /// 仓库下拉列表
- /// </summary>
- public List<string> DeliveryWarehouseList
- {
- get { return _deliveryWarehouseList; }
- set
- {
- Set(() => DeliveryWarehouseList, ref _deliveryWarehouseList, value);
- }
- }
- #endregion
- #region 品牌下拉列表
- private ObservableCollection<string> _deliveryBrandList = new ObservableCollection<string>();
- /// <summary>
- /// 品牌下拉列表
- /// </summary>
- public ObservableCollection<string> DeliveryBrandList
- {
- get { return _deliveryBrandList; }
- set
- {
- Set(() => DeliveryBrandList, ref _deliveryBrandList, value);
- }
- }
- #endregion
- #region 等级下拉列表
- private ObservableCollection<string> _deliveryLevelList = new ObservableCollection<string>();
- /// <summary>
- /// 等级下拉列表
- /// </summary>
- public ObservableCollection<string> DeliveryLevelList
- {
- get { return _deliveryLevelList; }
- set
- {
- Set(() => DeliveryLevelList, ref _deliveryLevelList, value);
- }
- }
- #endregion
- #region 当前选中仓库
- private string _currentWarehouse;
- /// <summary>
- /// 当前选中仓库
- /// </summary>
- public string CurrentWarehouse
- {
- get { return _currentWarehouse; }
- set
- {
- Set(() => CurrentWarehouse, ref _currentWarehouse, value);
-
- }
- }
- #endregion
- #region 当前选中品牌
- private string _currentBrand;
- /// <summary>
- /// 当前选中品牌
- /// </summary>
- public string CurrentBrand
- {
- get { return _currentBrand; }
- set
- {
- Set(() => CurrentBrand, ref _currentBrand, value);
-
-
- }
- }
- #endregion
- #region 当前选中等级
- private string _currentLevel;
- /// <summary>
- /// 当前选中等级
- /// </summary>
- public string CurrentLevel
- {
- get { return _currentLevel; }
- set
- {
- Set(() => CurrentLevel, ref _currentLevel, value);
-
- }
- }
- #endregion
- #region 是否显示还需配对数量提示
- private Visibility _isVisibility_NeedMatchQty = Visibility.Collapsed;
- /// <summary>
- /// 是否显示还需配对数量提示
- /// </summary>
- public Visibility IsVisibility_NeedMatchQty
- {
- get
- {
- return _isVisibility_NeedMatchQty;
- }
- set
- {
- Set(() => IsVisibility_NeedMatchQty, ref _isVisibility_NeedMatchQty, value);
- }
- }
- #endregion
- #region 当前勾选单据LIST
- //【OrderMatchDetailModel】
- private List<OrderMatchDetailModel> _currentSelectedOrderMatchDetail = null;
- /// <summary>
- /// 当前勾选的仓单配对
- /// </summary>
- public List<OrderMatchDetailModel> CurrentSelectedOrderMatchDetail
- {
- get
- {
- return _currentSelectedOrderMatchDetail;
- }
- set
- {
- Set(() => CurrentSelectedOrderMatchDetail, ref _currentSelectedOrderMatchDetail, value);
- }
- }
- #endregion
- #region 是否勾选
- private bool _isCheckedCurrentBox = false;
- /// <summary>
- /// 是否勾选
- /// </summary>
- public bool IsCheckedCurrentBox
- {
- get
- {
- return _isCheckedCurrentBox;
- }
- set
- {
- Set(() => IsCheckedCurrentBox, ref _isCheckedCurrentBox, value);
- }
- }
- #endregion
- #region 已配对数量
- private decimal _aleadyMatchQty = decimal.Zero;
- /// <summary>
- /// 已配对数量
- /// </summary>
- public decimal AlreadyMatchQty
- {
- get
- {
- return _aleadyMatchQty;
- }
- set
- {
- //value = Math.Round(value, 0);
- Set(() => AlreadyMatchQty, ref _aleadyMatchQty, value);
- }
- }
- #endregion
- #region 剩余可配对数量
- /// <summary>
- /// 剩余可配对数量
- /// </summary>
- private decimal preOtherCanMatchQty = 0;
- private decimal _otherCanMatchQty = 0;
- /// <summary>
- /// 剩余可配对数量
- /// </summary>
- public decimal OtherCanMatchQty
- {
- get
- {
- return _otherCanMatchQty;
- }
- set
- {
- //value = Math.Round(value, 0);
- Set(() => OtherCanMatchQty, ref _otherCanMatchQty, value);
- }
- }
- #endregion
- #region 是否全选
- private bool _isSelectAll = false;
- /// <summary>
- /// 是否全选
- /// Changes to that property's value raise the PropertyChanged event.
- /// </summary>
- public bool IsSelectAll
- {
- get
- {
- return _isSelectAll;
- }
- set
- {
- Set(() => IsSelectAll, ref _isSelectAll, value);
- }
- }
- #endregion
- #region 合计点选升帖水
- private decimal _totalDeliveryPriceMove = 0;
- /// <summary>
- /// 合计点选升帖水
- /// </summary>
- public decimal TotalDeliveryPriceMove
- {
- get
- {
- return _totalDeliveryPriceMove;
- }
- set
- {
- //value = Math.Round(value, 2); ////显示两位小数
- Set(() => TotalDeliveryPriceMove, ref _totalDeliveryPriceMove, value);
- }
- }
- #endregion
- #region 交易商品名称
- private string _goodsName = string.Empty;
- /// <summary>
- /// 交易商品名称
- /// </summary>
- public string GoodsName
- {
- get
- {
- return _goodsName;
- }
- set
- {
- Set(() => GoodsName, ref _goodsName, value);
- }
- }
- #endregion
- #region 申报单号
- private string _OrderNumber = string.Empty;
- /// <summary>
- /// 申报单号
- /// </summary>
- public string OrderNumber
- {
- get
- {
- return _OrderNumber;
- }
- set
- {
- Set(() => OrderNumber, ref _OrderNumber, value);
- }
- }
- #endregion
- #region 转换单位
- private string _agreeUnitString = string.Empty;
- /// <summary>
- /// 转换单位
- /// </summary>
- public string AgreeUnitString
- {
- get
- {
- return _agreeUnitString;
- }
- set
- {
- Set(() => AgreeUnitString, ref _agreeUnitString, value);
- }
- }
- #endregion
- #region 折合数量-转换手数
- private decimal _discountNum = decimal.Zero;
- /// <summary>
- /// 折合数量
- /// </summary>
- public decimal DiscountNum
- {
- get
- {
- return _discountNum;
- }
- set
- {
- //value = Math.Round(value, 0);
- Set(() => DiscountNum, ref _discountNum, value);
- }
- }
- #endregion
- #region 申报手数
- private decimal _deliveryCount = decimal.Zero;
- /// <summary>
- /// 申报手数
- /// </summary>
- public decimal DeliveryCount
- {
- get
- {
- return _deliveryCount;
- }
- set
- {
- Set(() => DeliveryCount, ref _deliveryCount, value);
- }
- }
- #endregion
- #region 当前交割配置明细/当前交割配置List
- public List<DeliveryConfig> tempDeliveryConfigList = new List<DeliveryConfig>();
- private DeliveryConfig _currentDeliveryGoodsConfig = null;
- /// <summary>
- /// 当前交割配置明细
- /// Changes to that property's value raise the PropertyChanged event.
- /// </summary>
- public DeliveryConfig CurrentDeliveryGoodsConfig
- {
- get
- {
- return _currentDeliveryGoodsConfig;
- }
- set
- {
- Set(() => CurrentDeliveryGoodsConfig, ref _currentDeliveryGoodsConfig, value);
- }
- }
- #endregion
- #endregion "Public Properties To Get/Set "
- #region "=========公共命令/Public Commands"
- #region 窗口取消Command
- /// <summary>
- /// 窗口取消
- /// </summary>
- public RelayCommand<Window> CancelCommand
- {
- get
- {
- return new RelayCommand<Window>((dialog) =>
- {
- dialog.DialogResult = false;
- });
- }
- }
- #endregion
- #region 提交确定Command
- /// <summary>
- /// 提交确定
- /// </summary>
- public RelayCommand<Window> OKCommand
- {
- get
- {
- return new RelayCommand<Window>((dialog) =>
- {
- OKButtonEnabled = false;
- string errorMsg = string.Empty;
- bool validateBool = Validated(ref errorMsg); ////内容验证
- if (validateBool)
- {
- IsBusy = true;
- _openWindow = dialog;
- var newOrder = new DeliveryOrderMatchReqModel()
- {
- OrderId = this._deliveryEntrustOrder.DeliveryOrderId,
- MatchType = eMatchType.MATCHTYPE_NORMAL,//默认指定类型
- matchDetails = _currentSelectedOrderMatchDetail
- };
- //if (UserManager.CurrentTradeAccount.FundsAccounts.Any() &&
- // UserManager.CurrentTradeAccount.FundsAccounts[0] != null)
- //{
- // newOrder.OperatorID = newOrder.AccountId = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- //else
- //{
- // newOrder.OperatorID = newOrder.AccountId = UserManager.CurrentTradeAccount.AccountId;
- //}
- try
- {
- _deliveryService.SubmitDeliveryMatchOrder(newOrder, EntrurstSuccessCallBack, EntrurstErrorCallBack);
- }
- finally
- {
- }
- }
- else
- {
- MessageBoxHelper.ShowInfo(errorMsg, Client_Resource.MessageBox_Error_Title);
- OKButtonEnabled = true;
- }
- });
- }
- }
- #endregion
- #region 选中Command
- /// <summary>
- /// 选中
- /// </summary>
- private RelayCommand<string> selectCommand;
- public RelayCommand<string> SelectCommand
- {
- get
- {
- return selectCommand ?? (selectCommand = new RelayCommand<string>(
- (x) =>
- {
- if (_action == false)
- {
- _isCheckAction = true;
- var sourceList = DeliveryMatchOrderList.ToList().FindAll(p => p.WrCode == x);
- for (int i = 0; i < sourceList.Count(); i++)
- {
- if (sourceList[i].NumSort == int.MaxValue)
- {
- sourceList[i].NumSort = DeliveryMatchOrderList.ToList().FindAll(p => p.IsSelected == true).Count();
- }
-
- }
- SettlementDeliveryMatchNum(CommandFromType.SelectedCommand);
- }
- }));
- }
- }
- #endregion
- #region 取消选中Command
- /// <summary>
- /// 取消选中
- /// </summary>
- private RelayCommand<string> unSelectCommand;
- public RelayCommand<string> UnSelectCommand
- {
- get
- {
- return unSelectCommand ?? (unSelectCommand = new RelayCommand<string>(
- (x) =>
- {
- if (_action == false)
- {
- _isCheckAction = true;
- var sourceList = DeliveryMatchOrderList.ToList().FindAll(p => p.WrCode == x);
- for (int i = 0; i < sourceList.Count(); i++)
- {
- if (sourceList[i].NumSort != int.MaxValue)
- {
- sourceList[i].NumSort = int.MaxValue;
- }
- }
- SettlementDeliveryMatchNum(CommandFromType.UnSelectedCommand);
- }
- }));
- }
- }
- #endregion
- #region 测试提交Command
- private RelayCommand buttonCommand;
- public RelayCommand ButtonCommand
- {
- get
- {
- return buttonCommand ?? (buttonCommand = new RelayCommand(
- () =>
- {
- int count = DeliveryMatchOrderList.ToList().FindAll(p => p.IsSelected == true).Count;
- for (int i = 0; i < count; i++)
- MessageBox.Show(DeliveryMatchOrderList.ToList().FindAll(p => p.IsSelected == true)[i].WrCode + "," + DeliveryMatchOrderList.ToList().FindAll(p => p.IsSelected == true)[i].EnableQty);
- }));
- }
- }
- #endregion
- #region WarehouseSelectionChangedCommand
- private RelayCommand _warehouseSelectionChanged;
- /// <summary>
- /// Gets the WarehouseSelectionChanged.
- /// </summary>
- public RelayCommand WarehouseSelectionChanged
- {
- get
- {
- return _warehouseSelectionChanged
- ?? (_warehouseSelectionChanged = new RelayCommand(
- () =>
- {
- FilteMatchOrderListByCombox();
- }));
- }
- }
- #endregion
- #region BrandSelectionChangedCommand
- private RelayCommand _brandSelectionChanged;
- /// <summary>
- /// Gets the BrandSelectionChanged.
- /// </summary>
- public RelayCommand BrandSelectionChanged
- {
- get
- {
- return _brandSelectionChanged
- ?? (_brandSelectionChanged = new RelayCommand(
- () =>
- {
- FilteMatchOrderListByCombox();
-
- }));
- }
- }
- #endregion
- #region RankSelectionChangedCommand
- private RelayCommand _rankSelectionChanged;
- /// <summary>
- /// Gets the RankSelectionChangedCommand.
- /// </summary>
- public RelayCommand RankSelectionChanged
- {
- get
- {
- return _rankSelectionChanged
- ?? (_rankSelectionChanged = new RelayCommand(
- () =>
- {
- FilteMatchOrderListByCombox();
- }));
- }
- }
- #endregion
- #region 预览命令
- private RelayCommand _preViewCommand;
- /// <summary>
- /// 预览命令.
- /// </summary>
- public RelayCommand PreViewCommand
- {
- get
- {
- return _preViewCommand
- ?? (_preViewCommand = new RelayCommand(
- () =>
- {
- Title = Resources.Client_Resource.DeliveryEntructOrderView_ComfirmMatchWarehouse;//"确认点选仓单";
- IsVisibility_Main = Visibility.Collapsed;
- IsVisibility_PreView = Visibility.Visible;
- IsVisibility_Warehouse = Visibility.Collapsed;
- }));
- }
- }
- #endregion
- #region 返回命令
- private RelayCommand _returnCommand;
- /// <summary>
- /// 返回命令
- /// </summary>
- public RelayCommand ReturnCommand
- {
- get
- {
- return _returnCommand
- ?? (_returnCommand = new RelayCommand(
- () =>
- {
- Title = Resources.Client_Resource.DeliveryEntructOrderView_Matched;
- IsVisibility_Main = Visibility.Visible;
- IsVisibility_PreView = Visibility.Collapsed;
- IsVisibility_Warehouse = Visibility.Collapsed;
- }));
- }
- }
- #endregion
- #region 文本改变命令Command
- private RelayCommand<WrPairDetailModel> _selectQtyTextChangedCommand;
- /// <summary>
- /// 文本改变命令Command
- /// </summary>
- public RelayCommand<WrPairDetailModel> SelectQtyTextChangedCommand
- {
- get
- {
- return _selectQtyTextChangedCommand
- ?? (_selectQtyTextChangedCommand = new RelayCommand<WrPairDetailModel>(
- p =>
- {
- //if (CurrentSelectedItem != null)
- //{
- // CurrentSelectedItem.SelectQty = LeaveOnlyNumbers(p);
- //}
- //if (p != null)
- //{
- // p.IsSelected = !string.IsNullOrWhiteSpace(p.SelectQty) ||
- // !"0".Equals(p.SelectQty.Trim());
- //}
- CurrentSelectedItem = p;
- if (_action == false)
- {
- _action = true;
- _isCheckAction = false;
- SettlementDeliveryMatchNum(CommandFromType.TextCommand);
- _action = false;
- }
- }));
- }
- }
- #endregion
- #region 仓单号详细命令
- private RelayCommand<string> _WrCode_MouseLeftButtonDownCommand;
- /// <summary>
- /// 仓单号详细命令
- /// </summary>
- public RelayCommand<string> WrCode_MouseLeftButtonDownCommand
- {
- get
- {
- return _WrCode_MouseLeftButtonDownCommand
- ?? (_WrCode_MouseLeftButtonDownCommand = new RelayCommand<string>(
- p =>
- {
- Title = Resources.Client_Resource.DeliveryEntructOrderView_Warehouse;//"仓单";
- IsVisibility_Main = Visibility.Collapsed;
- IsVisibility_PreView = Visibility.Collapsed;
- IsVisibility_Warehouse = Visibility.Visible;
- #region 仓单变更流水查询
- var accountid = UserManager.CurrentTradeAccount.AccountId;
- //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
- //{
- // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- //IsBusy = true;
- //_deliveryService.SearchWRChangeFlow(accountid, p, WRChangeFlowOrderSuccess, DeliveryGoodsCallBack);
- #endregion
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- if (AllWarehouseOrders != null && AllWarehouseOrders.Any() && AllWarehouseOrders.Count() > 0)
- {
- CurrentWarehouseDetail = AllWarehouseOrders.FirstOrDefault(x => x.WRCode == p);
- }
- }));
- }));
- }
- }
- #endregion
- #region 查询命令
- private RelayCommand _searchCommand;
- /// <summary>
- /// 查询命令
- /// </summary>
- public RelayCommand SearchCommand
- {
- get
- {
- return _searchCommand
- ?? (_searchCommand = new RelayCommand(
- () =>
- {
- SearchMatchOrderList = DeliveryMatchOrderList;
- }));
- }
- }
- #endregion
- #endregion "Public Commands"
- #region "=========私有方法/Private Methods"
- /// <summary>
- /// 检查输入是否为多个小数点
- /// </summary>
- /// <param name="inString"></param>
- /// <returns></returns>
- private string LeaveOnlyNumbers(String inString)
- {
- var occur = false;
- StringBuilder ans = new StringBuilder();
- for (int i = 0; i < inString.Length; ++i)
- {
- if (System.Text.RegularExpressions.Regex.IsMatch(inString[i].ToString(), "^[0-9\\.]*$"))
- {
- if (inString[i] == '.')
- {
- if (!occur)
- {
- occur = true;
- ans.Append(inString[i]);
- }
- }
- else ans.Append(inString[i]);
- }
- }
- return ans.ToString();
- }
- /// <summary>
- /// 触发提交按钮是否可用
- /// </summary>
- private void IsEnableButtonEvent()
- {
- OKButtonEnabled = false;
- if (_currentSelectedOrderMatchDetail != null
- && _currentSelectedOrderMatchDetail.Any()
- && _currentSelectedOrderMatchDetail.Count() > 0
- && AlreadyMatchQty == preOtherCanMatchQty
- )//&& (decimal)TotalDeliveryPriceMove <= usableFunds //错误 #28975 账户可用资金小于升贴水资金,交割配对点选界面限制不允许交割点选配对
- {
- OKButtonEnabled = true;
- }
- else
- {
- OKButtonEnabled = false;
- }
- }
- /// <summary>
- /// 计算可配数量、剩余数量
- /// </summary>
- private void SettlementDeliveryMatchNum(CommandFromType commandType)
- {
- _action = true;
- try
- {
- #region 不是来自CheckCommand
- var sourceList = DeliveryMatchOrderList.OrderBy(x => x.NumSort).ToList().FindAll(p => p.IsSelected == true);
- AlreadyMatchQty = 0;
- TotalDeliveryPriceMove = 0;
- preOtherCanMatchQty = OtherCanMatchQty = (decimal)DiscountNum;//_deliveryEntrustOrder.OrderQty;
- CurrentSelectedOrderMatchDetail = new List<OrderMatchDetailModel>();
- var leaveCount = preOtherCanMatchQty;
- if (_isCheckAction != true)
- {
- if (CurrentSelectedItem != null && CurrentSelectedItem.SelectQty != string.Empty)
- {
-
- CurrentSelectedItem.IsSelected = true;
- sourceList = DeliveryMatchOrderList.OrderBy(x => x.NumSort).ToList().FindAll(p => p.IsSelected == true);
- }
- else
- {
- CurrentSelectedItem.IsSelected = false;
- }
- }
- else
- {
- if (commandType != CommandFromType.UnSelectedCommand)
- {
- if (sourceList.Count == 0)
- {
- ResetData();
- }
- else
- {
- leaveCount = GetAlreadyWriteNum(sourceList, leaveCount);
- sourceList = sourceList.Where(x => x.SelectQty == "").ToList();
- }
- }
- else
- {
- if (sourceList.Count == 0)
- {
- ResetData();
- }
- else
- {
- CurrentSelectedItem.SelectQty = "";
- leaveCount = GetAlreadyWriteNum(sourceList, leaveCount);
- sourceList = DeliveryMatchOrderList.Where(x => x.SelectQty == "").ToList();
- return;
- }
- }
- }
- #endregion
- #region 配对数量仅能大于 等于 申报数量
- // var sourceList = DeliveryMatchOrderList.OrderBy(x => x.NumSort).ToList().FindAll(p => p.IsSelected == true);
- for (int i = 0; i < sourceList.Count(); i++)
- {
- if (sourceList[i].DeliveryPriceMove == int.MinValue)
- {
- sourceList[i].DeliveryPriceMove = 0;
- }
- if (leaveCount >= (decimal)sourceList[i].EnableQty)
- {
- if (_isCheckAction != true)
- {
- //文本事件处理
- if (Convert.ToDecimal(sourceList[i].SelectQty)>0)
- CurrentSelectedOrderMatchDetail.Add(new OrderMatchDetailModel() { WRId = (sourceList[i].WrId), DeliveryQty = Convert.ToDecimal(sourceList[i].SelectQty), DeliverySellOrderId = sourceList[i].DeliverySellOrderId });
- TotalDeliveryPriceMove += (decimal)sourceList[i].DeliveryPriceMove * Convert.ToDecimal(sourceList[i].SelectQty);
- CurrentSelectedItem.IsError = "0";
- if (Convert.ToDouble(sourceList[i].SelectQty) > sourceList[i].EnableQty || Convert.ToDecimal(sourceList[i].SelectQty) > OtherCanMatchQty)
- {
- CurrentSelectedItem.IsError = "1";
- }
- }
- else
- {
- if ((decimal)sourceList[i].EnableQty > 0)
- CurrentSelectedOrderMatchDetail.Add(new OrderMatchDetailModel() { WRId = (sourceList[i].WrId), DeliveryQty = (decimal)sourceList[i].EnableQty, DeliverySellOrderId = sourceList[i].DeliverySellOrderId });
- TotalDeliveryPriceMove += (decimal)sourceList[i].DeliveryPriceMove * (decimal)sourceList[i].EnableQty;
- sourceList[i].SelectQty = sourceList[i].EnableQty.ToString();
- }
- }
- else
- {
- if (leaveCount > 0)
- {
- if (_isCheckAction != true)
- {
- //文本事件处理
- if (Convert.ToDecimal(sourceList[i].SelectQty) > 0)
- CurrentSelectedOrderMatchDetail.Add(new OrderMatchDetailModel() { WRId = (sourceList[i].WrId), DeliveryQty = Convert.ToDecimal(sourceList[i].SelectQty), DeliverySellOrderId = sourceList[i].DeliverySellOrderId });
- TotalDeliveryPriceMove += (decimal)sourceList[i].DeliveryPriceMove * Convert.ToDecimal(sourceList[i].SelectQty);
- CurrentSelectedItem.IsError = "0";
- if (Convert.ToDecimal(sourceList[i].SelectQty) > leaveCount)
- {
- CurrentSelectedItem.IsError = "1";
- }
- }
- else
- {
- if ((decimal)leaveCount > 0)
- CurrentSelectedOrderMatchDetail.Add(new OrderMatchDetailModel() { WRId = (sourceList[i].WrId), DeliveryQty = (decimal)leaveCount, DeliverySellOrderId = sourceList[i].DeliverySellOrderId });
- TotalDeliveryPriceMove += (decimal)sourceList[i].DeliveryPriceMove * leaveCount;
- sourceList[i].SelectQty = leaveCount.ToString();
-
- }
- }
- }
- if (_isCheckAction != true)
- {
- //文本事件处理
- leaveCount = leaveCount - Convert.ToDecimal(sourceList[i].SelectQty);
- AlreadyMatchQty =AlreadyMatchQty + Convert.ToDecimal(sourceList[i].SelectQty);
- }
- else
- {
- leaveCount = leaveCount - (decimal)sourceList[i].EnableQty;
- AlreadyMatchQty += (decimal)sourceList[i].EnableQty;
- }
- }
- OtherCanMatchQty = OtherCanMatchQty - AlreadyMatchQty;
- if (OtherCanMatchQty < 0)
- {
- OtherCanMatchQty = 0;
- AlreadyMatchQty = preOtherCanMatchQty;
- }
- #region 是否隐藏提示信息
- IsVisibility_NeedMatchQty = Visibility.Collapsed;
- if (sourceList != null && sourceList.Any() && sourceList.Count() > 0)
- {
- if (OtherCanMatchQty > 0)
- {
- IsVisibility_NeedMatchQty = Visibility.Visible;
- ErrorMessage = string.Format(Client_Resource.DeliveryMatchView_ErrorMessage_NeedToChoseLot, OtherCanMatchQty);//string.Format("还需选择商品数量{0},申报数量需一次选完",OtherCanMatchQty);
- }
- }
- #endregion
- #endregion
- #region 屏蔽剩余勾选框
- var sourceList_False = DeliveryMatchOrderList.ToList().FindAll(p => p.IsSelected == false);
- if (OtherCanMatchQty == 0)
- {
- for (int i = 0; i < sourceList_False.Count(); i++)
- {
- sourceList_False[i].IsEnabled = false;
- //sourceList[i].SelectQty = string.Empty;
- }
- }
- else
- {
- for (int i = 0; i < sourceList_False.Count(); i++)
- {
- sourceList_False[i].IsEnabled = true;
- }
- }
- #endregion
- IsEnableButtonEvent();
- ReCheckData();
- PreViewDataHandle();
- }
- catch (Exception ex)
- {
- _action = false;
- }
- finally
- {
- _action = false;
- }
- }
- /// <summary>
- /// 获取已经填写的数量
- /// </summary>
- private decimal GetAlreadyWriteNum(List<WrPairDetailModel> sourceList, decimal leaveCount)
- {
- sourceList = sourceList.Where(x => x.SelectQty != "").ToList();
- for (int i = 0; i < sourceList.Count(); i++)
- {
- //文本事件处理
- if (Convert.ToDecimal(sourceList[i].SelectQty) > 0)
- CurrentSelectedOrderMatchDetail.Add(new OrderMatchDetailModel() { WRId = (sourceList[i].WrId), DeliveryQty = Convert.ToDecimal(sourceList[i].SelectQty), DeliverySellOrderId = sourceList[i].DeliverySellOrderId });
- TotalDeliveryPriceMove += (decimal)sourceList[i].DeliveryPriceMove * Convert.ToDecimal(sourceList[i].SelectQty);
- //文本事件处理
- leaveCount = leaveCount - Convert.ToDecimal(sourceList[i].SelectQty);
- AlreadyMatchQty += Convert.ToDecimal(sourceList[i].SelectQty);
- }
- OtherCanMatchQty = OtherCanMatchQty - AlreadyMatchQty;
- return leaveCount;
- }
- /// <summary>
- /// 预览数据转换
- /// </summary>
- private void PreViewDataHandle()
- {
- var sourceList = DeliveryMatchOrderList.OrderBy(x => x.NumSort).ToList().FindAll(p => p.IsSelected == true);
- ChooseMatchOrderList.Clear();
- foreach (var item in sourceList)
- {
- if (!ChooseMatchOrderList.Any(x => x.WrId == item.WrId))
- {
- ChooseMatchOrderList.Add(item);
- }
- }
- }
- /// <summary>
- /// 回滚数据
- /// </summary>
- private void ResetData()
- {
- for (int i = 0; i < DeliveryMatchOrderList.Where(x=>x.IsSelected !=true).Count(); i++)
- {
- DeliveryMatchOrderList[i].SelectQty = string.Empty;
- }
- }
- /// <summary>
- /// 复查数据
- /// </summary>
- private void ReCheckData()
- {
- var sourceList = DeliveryMatchOrderList.OrderBy(x => x.NumSort).ToList().FindAll(p => p.IsSelected == true);
- #region 如果没有勾选则没有错误显示
- if (sourceList.Count() == 0)
- {
- for (int i = 0; i < DeliveryMatchOrderList.Count(); i++)
- {
- DeliveryMatchOrderList[i].IsError = "0";
- DeliveryMatchOrderList[i].SelectQty = "";
- }
- }
- #endregion
- totalQty = decimal.Zero;
- AllCanUseQty = decimal.Zero;
- for (int i = 0; i < sourceList.Count(); i++)
- {
- totalQty += Convert.ToDecimal(sourceList[i].SelectQty);
- AllCanUseQty += Convert.ToDecimal(sourceList[i].EnableQty);
- }
- if (totalQty == DiscountNum && AllCanUseQty >= totalQty)
- {
- for (int i = 0; i < DeliveryMatchOrderList.Count(); i++)
- {
- DeliveryMatchOrderList[i].IsError = "0";
- }
- }
- if (totalQty > DiscountNum || AllCanUseQty < totalQty)
- {
- OKButtonEnabled = false;
- IsVisibility_NeedMatchQty = Visibility.Visible;
- ErrorMessage = Client_Resource.DeliveryMatchView_ErrorMessage_ChoseLotBiggerThanLeave;//"选择数量大于可选数量";
- }
- }
- /// <summary>
- /// 初始化数据
- /// </summary>
- private void InitData()
- {
- if (_deliveryEntrustOrder.DeliveryGoodsId != 0)
- {
- IsBusy = true;
- //加载-仓单配对-数据
- _deliveryService.SearchMatchWarehouseReq(BuildEntrustOrder(), SearchSuccessCallBack, SearchErrorCallBack);
- }
- //手动添加默认选择数据
- TempDeliveryMatchOrderList.Add(new WrPairDetailModel() { StorePlace = Client_Resource.DeliveryMatchView_AllWareHouse, Brand = Client_Resource.DeliveryMatchView_AllBrand, Rank = Client_Resource.DeliveryMatchView_AllRank });
- #region 测试数据
- //for (int i = 0; i < 5; i++)
- //{
- // TempDeliveryMatchOrderList.Add(new WrPairDetailModel() { StorePlace = "仓库" + i.ToString(), DeliveryGoodsName = "商品" + i.ToString(), Brand = i.ToString(), Rank = i.ToString(), WrId = i + 1003, WrCode = (i + 1).ToString(), EnableQty = i + 1 });
- // DeliveryMatchOrderList.Add(new WrPairDetailModel() { StorePlace = "仓库" + i.ToString(), DeliveryGoodsName = "商品" + i.ToString(), Brand = i.ToString(), Rank = i.ToString(), WrId = i + 1003, WrCode = (i + 1).ToString(), EnableQty = i + 1 });
- //}
- //FilteMatchOrderListByCombox();
- #endregion
-
- IsEnableButtonEvent();
-
-
- }
- /// <summary>
- /// 交割商品关系配置成功返回
- /// </summary>
- /// <param name="itemList"></param>
- protected void DeliveryGoodsRelationConfigSuccess(List<DeliveryConfig> itemList)
- {
- if (itemList != null && itemList.Count() > 0)
- {
-
- tempDeliveryConfigList = itemList;
- CurrentDeliveryGoodsConfig = itemList.FirstOrDefault();
- if (CurrentDeliveryGoodsConfig != null)
- {
- DiscountNum = _deliveryEntrustOrder.DeliveryQty;
- //关联交割商品-单位
- AgreeUnitString = CacheManager.TradeGoodsUnit.Where(x => x.UNITID == CurrentDeliveryGoodsConfig.GoodsUnitId).Select(x => x.GOODSUNITNAME).FirstOrDefault();
- OtherCanMatchQty = (decimal)DiscountNum;
- tempOtherCanMatchQty = (decimal)DiscountNum;
- }
- }
- }
- /// <summary>
- /// 查询成功返回
- /// </summary>
- /// <param name="orders"></param>
- protected void MarketOrderSuccess(List<DeliveryWarehouse> orders)
- {
- UpdateItemSource(orders);
- IsBusy = false;
- }
- /// <summary>
- /// 更新数据源
- /// </summary>
- /// <param name="orders"></param>
- private void UpdateItemSource(List<DeliveryWarehouse> orders)
- {
- if (orders != null)
- {
- //foreach (var item in orders)
- //{
- // #region 合约单位转换
- // var goodsUnit = CacheManager.TradeGoodsUnit.FirstOrDefault((x) => x.GOODSUNITID == item.GoodsUnitId);
- // if (goodsUnit != null)
- // {
- // item.GoodsUnitIdDisplay = goodsUnit.NAME;
- // }
- // #endregion
- // #region 是否可提货
- // if (item.Status == eWRStatus.Normal && (item.Qty - item.FreezeQty - item.PayQty) > 0)
- // {
- // item.IsVisibility = Visibility.Visible;
- // }
- // #endregion
- //}
- AllWarehouseOrders = orders; //所有单据
- }
- }
- /// <summary>
- /// 交割商品关系配置失败返回
- /// </summary>
- /// <param name="errorEntity"></param>
- private void DeliveryGoodsCallBack(ErrorEntity errorEntity)
- {
- IsBusy = false;
- }
- /// <summary>
- /// 查询配对仓单实体
- /// </summary>
- /// <returns></returns>
- private WrPairReqModel BuildEntrustOrder()
- {
- var newOrder = new WrPairReqModel();
- //if (UserManager.CurrentTradeAccount.FundsAccounts.Any() &&
- // UserManager.CurrentTradeAccount.FundsAccounts[0] != null)
- //{
- // newOrder.OperatorId = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- //else
- //{
- // newOrder.OperatorId = UserManager.CurrentTradeAccount.AccountId;
- //}
- return newOrder;
- }
-
- /// <summary>
- /// 过滤仓单数据BY下拉列表
- /// </summary>
- private void FilteMatchOrderListByCombox()
- {
- #region 重置勾选单据
- _currentSelectedOrderMatchDetail = null;
- var sourceList = DeliveryMatchOrderList.ToList();
- for (int i = 0; i < sourceList.Count(); i++)
- {
- sourceList[i].IsSelected = false;
- sourceList[i].IsEnabled = true;
- }
- OtherCanMatchQty = tempOtherCanMatchQty;
- AlreadyMatchQty = 0;
- TotalDeliveryPriceMove = 0;
- #endregion
- #region 数据过滤条件
- DeliveryMatchOrderList = new List<WrPairDetailModel>(TempDeliveryMatchOrderList);//数据回归
- DeliveryWarehouseList = DeliveryMatchOrderList.Where(x => x.StorePlace != "").Select(x => x.StorePlace).Distinct().ToList();
- if (CurrentWarehouse != null && CurrentWarehouse != Client_Resource.DeliveryMatchView_AllWareHouse)//全部仓库
- {
- DeliveryMatchOrderList = DeliveryMatchOrderList.Where(x => x.StorePlace == CurrentWarehouse || x.StorePlace == Client_Resource.DeliveryMatchView_AllWareHouse).ToList();
- DeliveryBrandList = new ObservableCollection<string>(DeliveryMatchOrderList.Where(x => x.Brand != "").Select(x => x.Brand).Distinct());
- }
- else
- {
- DeliveryBrandList = new ObservableCollection<string>(DeliveryMatchOrderList.Where(x => x.Brand != "").Select(x => x.Brand).Distinct()); ;
- }
- if (CurrentBrand != null && CurrentBrand != Client_Resource.DeliveryMatchView_AllBrand)//全部品牌
- {
- DeliveryMatchOrderList = DeliveryMatchOrderList.Where(x => x.Brand == CurrentBrand || x.Brand == Client_Resource.DeliveryMatchView_AllBrand).ToList();
- DeliveryLevelList = new ObservableCollection<string>(DeliveryMatchOrderList.Where(x => x.Rank != "").Select(x => x.Rank).Distinct());
- }
- else
- {
- DeliveryLevelList = new ObservableCollection<string>(DeliveryMatchOrderList.Where(x => x.Rank != "").Select(x => x.Rank).Distinct());
- }
- if (CurrentLevel != null && CurrentLevel != Client_Resource.DeliveryMatchView_AllRank)//全部等级
- {
- DeliveryMatchOrderList = DeliveryMatchOrderList.Where(x => x.Rank == CurrentLevel || x.Rank == Client_Resource.DeliveryMatchView_AllRank).ToList();
- }
-
- #endregion
- #region 默认选择
- DeliveryMatchOrderList = DeliveryMatchOrderList.FindAll(x => x.StorePlace != Client_Resource.DeliveryMatchView_AllWareHouse);//过滤手动添加数据
- if (CurrentWarehouse == null)
- {
- CurrentWarehouse = DeliveryWarehouseList.FirstOrDefault(x => x == Client_Resource.DeliveryMatchView_AllWareHouse);//默认选择
- }
- if (CurrentLevel == null)
- {
- CurrentLevel = DeliveryLevelList.FirstOrDefault(x => x == Client_Resource.DeliveryMatchView_AllRank);//默认选择
- }
- if (CurrentBrand == null)
- {
- CurrentBrand = DeliveryBrandList.FirstOrDefault(x => x == Client_Resource.DeliveryMatchView_AllBrand);//默认选择
- }
- #endregion
- IsEnableButtonEvent();
- }
-
- /// <summary>
- /// 查询成功返回,绑定数据源
- /// </summary>
- /// <param name="itemList">The item list.</param>
- protected void SearchSuccessCallBack(WrPairRspModel itemList)
- {
-
- if (itemList.WrPairDetails != null && itemList.WrPairDetails.Any() && itemList.WrPairDetails.Count() > 0)
- {
- foreach (var item in itemList.WrPairDetails)
- {
- #region 合约单位转换
- var goodsUnit = CacheManager.TradeGoodsUnit.FirstOrDefault((x) => x.UNITID == item.GoodsUnitId);
- if (goodsUnit != null)
- {
- item.GoodsUnitIdDisplay = goodsUnit.GOODSUNITNAME;
- }
- #endregion
- #region 当前仓单WrCode列表
- if (WrCodeListStr == string.Empty)
- {
- WrCodeListStr = "'" + item.WrCode + "'";
- }
- else
- {
- WrCodeListStr += "," + "'" + item.WrCode + "'";
- }
- #endregion
- }
-
- TempDeliveryMatchOrderList = itemList.WrPairDetails.Where(x => x.EnableQty != 0).ToList();
- SearchMatchOrderList = itemList.WrPairDetails.Where(x => x.EnableQty != 0).ToList();
- //手动添加默认选择数据
- TempDeliveryMatchOrderList.Add(new WrPairDetailModel() { StorePlace = Client_Resource.DeliveryMatchView_AllWareHouse, Brand = Client_Resource.DeliveryMatchView_AllBrand, Rank = Client_Resource.DeliveryMatchView_AllRank });
- DeliveryMatchOrderList = TempDeliveryMatchOrderList;
- FilteMatchOrderListByCombox();
- }
- IsBusy = false;
- #region 仓单查询
- var accountid = UserManager.CurrentTradeAccount.AccountId;
- //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
- //{
- // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- if (WrCodeListStr != string.Empty)
- {
- _deliveryService.QueryDeliveryWarehouseOrders(SearchWarehouseOrdersType.WRCode, WrCodeListStr, accountid, DateTime.MinValue, DateTime.Now.AddDays(1), MarketOrderSuccess, DeliveryGoodsCallBack);
- }
- #endregion
- }
- /// <summary>
- /// 查询失败返回
- /// </summary>
- /// <param name="itemList">The item list.</param>
- protected void SearchErrorCallBack(ErrorEntity errorEntity)
- {
-
- IsBusy = false;
- //Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- //{
- // ErrorManager.ShowReturnError(errorEntity, Client_Resource.APP_Tips, false);
- //}));
- }
- /// <summary>
- /// 提交配对成功返回
- /// </summary>
- /// <param name="order"></param>
- private void EntrurstSuccessCallBack(DeliveryOrderMatchRspModel order)
- {
- IsBusy = false;
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- OKButtonEnabled = true;
- MessageBoxHelper.ShowSuccess(Client_Resource.OrderMatch_Success_Result,
- Client_Resource.UI2014_Tips);
- if (_openWindow != null)
- {
- _openWindow.Close();
- this.Cleanup();
- }
- }));
- //刷新正常单
- MessengerHelper.DefaultSend(UserManager.CurrentTradeAccount, MessengerTokens.OrderNoticeToken);
- }
- /// <summary>
- /// 委托失败返回
- /// </summary>
- /// <param name="errorEntity"></param>
- private void EntrurstErrorCallBack(ErrorEntity errorEntity)
- {
- IsBusy = false;
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- OKButtonEnabled = true;
- ErrorManager.ShowReturnError(errorEntity, Client_Resource.UI2014_Tips, true);
- if (_openWindow != null)
- {
- _openWindow.Close();
- this.Cleanup();
- }
- }));
- }
- #endregion "Private Methods"
- #region "=========其它方法/Other Methods"
- /// <summary>
- /// 数据验证
- /// </summary>
- /// <param name="msg"></param>
- /// <returns></returns>
- public bool Validated(ref string msg)
- {
- ////申报数量 > 持仓数量
- if (AlreadyMatchQty > preOtherCanMatchQty)
- {
- msg = string.Format(Muchinfo.MTPClient.Resources.Client_Resource.EntrustOrderViewModel_OpenLotGreatThanMaxLot, preOtherCanMatchQty);
- return false;
- }
- return true;
- }
- #endregion "Other Methods"
-
-
-
- }
- }
|