| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
- using GalaSoft.MvvmLight;
- using GalaSoft.MvvmLight.Command;
- using GalaSoft.MvvmLight.Ioc;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Data.Model.Delivery;
- using Muchinfo.MTPClient.Infrastructure.MessageBox;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.IService;
- using System.Windows;
- using System.Linq;
- using Muchinfo.MTPClient.Resources;
- using System;
- using Muchinfo.MTPClient.Infrastructure.Helpers;
- using Muchinfo.MTPClient.Data;
- namespace Muchinfo.MTPClient.Delivery.ViewModels
- {
- /// <summary>
- /// 确认货票窗口
- /// </summary>
- public class ComfirmGoodsTicketsViewModel : ViewModelBase
- {
-
- #region "=========私有成员/Private Data Members"
- private DryHoldDetail _itemModel;
- private IDeliveryService _deliveryService;
- private Window _openWindow;
- private ePerformanceType _currentePerformanceType;
- private bool _isCheckGoods = false;
- private bool _isCheckTickets = false;
- #endregion "Private Data Members"
- #region "=========构造函数/Constructor/Initialization"
- public ComfirmGoodsTicketsViewModel(DryHoldDetail itemOrder)
- {
- this._itemModel = 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 "
- public int countNum { get; set; }
- public string pValue_hValue_countNum { get; set; }
- public eDeliveryStatus DeliveryStatus { get; set; }
- private bool _isBusy;
- /// <summary>
- /// 是否在忙
- /// </summary>
- public bool IsBusy
- {
- get { return _isBusy; }
- set
- {
- Set(() => IsBusy, ref _isBusy, value);
- }
- }
-
- #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
- private RelayCommand<Window> _confirmPayCommand;
- /// <summary>
- /// Gets the ConfirmPayCommand.
- /// </summary>
- public RelayCommand<Window> ConfirmPayCommand
- {
- get
- {
- return _confirmPayCommand
- ?? (_confirmPayCommand = new RelayCommand<Window>(
- (dialog) =>
- {
- #region 待审核处理
- if (_itemModel != null)
- {
- var orderBuild = BuildEntrustOrder();
- _openWindow = dialog;
- if (_isCheckGoods == false && _isCheckTickets == false)
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.DeliveryHolderViewModel_MustCheckOneGoodsOrTicket, Muchinfo.MTPClient.Resources.Client_Resource.Models_Tips, true);
- return;
- }
- ////勾选货
- //if (_isCheckGoods== true)
- //{
- // orderBuild.ConfirmType = (int)ePerformanceType.Confirm_Goods;
- // _currentePerformanceType = ePerformanceType.Confirm_Goods;
- //}
- ////勾选票
- //if (_isCheckTickets == true)
- //{
- // orderBuild.ConfirmType = (int)ePerformanceType.PERFORMANCETYPE_DELIVERY;
- // _currentePerformanceType = ePerformanceType.PERFORMANCETYPE_DELIVERY;
- //}
- ////同时勾选
- //if (_isCheckGoods == true && _isCheckTickets == true)
- //{
- // _currentePerformanceType = ePerformanceType.PERFORMANCETYPE_DELIVERY;
- //}
- long orderNumber = orderBuild.DeliveryId;
- var boxResult = MessageBoxHelper.ShowQuestion(Muchinfo.MTPClient.Resources.Client_Resource.Models_MakesureToCommit,
- Muchinfo.MTPClient.Resources.Client_Resource.Models_Tips);
- if (boxResult == MessageBoxResult.Yes && orderBuild!=null)
- {
- IsBusy = true;
- _deliveryService.SubmitReceiveConfirmReq(orderBuild, EntrurstSuccessCallBack, EntrurstErrorCallBack);
- }
- }
- #endregion
- }));
- }
- }
- #endregion
- #region 选中GoodsCommand
- /// <summary>
- /// 选中
- /// </summary>
- private RelayCommand selectGoodsCommand;
- public RelayCommand SelectGoodsCommand
- {
- get
- {
- return selectGoodsCommand ?? (selectGoodsCommand = new RelayCommand(
- () =>
- {
- _isCheckGoods = true;
- }));
- }
- }
- #endregion
- #region 取消选中GoodsCommand
- /// <summary>
- /// 取消选中
- /// </summary>
- private RelayCommand unSelectGoodsCommand;
- public RelayCommand UnSelectGoodsCommand
- {
- get
- {
- return unSelectGoodsCommand ?? (unSelectGoodsCommand = new RelayCommand(
- () =>
- {
- _isCheckGoods = false;
- }));
- }
- }
- #endregion
- #region 选中TicketCommand
- /// <summary>
- /// 选中
- /// </summary>
- private RelayCommand selectTicketCommand;
- public RelayCommand SelectTicketCommand
- {
- get
- {
- return selectTicketCommand ?? (selectTicketCommand = new RelayCommand(
- () =>
- {
- _isCheckTickets = true;
- }));
- }
- }
- #endregion
- #region 取消选中TicketCommand
- /// <summary>
- /// 取消选中
- /// </summary>
- private RelayCommand unSelectTicketCommand;
- public RelayCommand UnSelectTicketCommand
- {
- get
- {
- return unSelectTicketCommand ?? (unSelectTicketCommand = new RelayCommand(
- () =>
- {
- _isCheckTickets = false;
- }));
- }
- }
- #endregion
- #endregion "Public Commands"
- #region "=========私有方法/Private Methods"
-
- /// <summary>
- /// 数据初始化
- /// </summary>
- private void InitData()
- {
- if (_itemModel != null)
- {
- countNum = this._itemModel.countNum;
- pValue_hValue_countNum = this._itemModel.pValue_hValue_countNum;
- DeliveryStatus = this._itemModel.DeliveryStatus;
- }
-
- }
- #region 创建下单委托对象
- /// <summary>
- /// 创建下单委托对象
- /// </summary>
- /// <returns>下单委托对象</returns>
- private ReceiveConfirmReqModel BuildEntrustOrder()
- {
- if (_itemModel != null)
- {
- var newOrder = new ReceiveConfirmReqModel()
- {
- DeliveryId = _itemModel.DeliveryId,
- //ConfirmType=(int)ePerformanceType.Confirm_Goods,
- GoodsId = (uint)_itemModel.DeliveryGoodsId,
- OperatorID = UserManager.CurrentTradeAccount.AccountId,
- AccountType = UserManager.CurrentTradeAccount.AccountType,
- //BuildType = eBuildType.BUILDTYPE_CANCEL,
- EntrurstTime = ApplicationParameter.ServerTimeNow,
- //OrderQty = SelectEntrustOrder.DeliveryQty,
- ValidType = ExpirationType.AlwaysValid,
- //RelateOrderID = SelectEntrustOrder.DeliveryOrderId,
- AccountId = UserManager.CurrentTradeAccount.AccountId,
- };
- //if (UserManager.CurrentTradeAccount.FundsAccounts.Any() &&
- // UserManager.CurrentTradeAccount.FundsAccounts[0] != null)
- //{
- // newOrder.AccountId = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- //else
- //{
- // newOrder.AccountId = UserManager.CurrentTradeAccount.AccountId;
- //}
- return newOrder;
-
- }
- return null;
-
- }
- #endregion
- /// 确认收货、票成功返回
- /// </summary>
- /// <param name="order"></param>
- private void EntrurstSuccessCallBack(ReceiveConfirmRspModel order)
- {
- IsBusy = false;
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- // var orderBuild = BuildEntrustOrder();
- if (_currentePerformanceType == ePerformanceType.PERFORMANCETYPE_DELIVERY)
- {
- MessageBoxHelper.ShowSuccess(Muchinfo.MTPClient.Resources.Client_Resource.Order_ReceiveConfirmGoods_Success_Result,
- Client_Resource.Models_Tips);
- }
- else if (_currentePerformanceType == ePerformanceType.PERFORMANCETYPE_DELIVERY)
- {
- MessageBoxHelper.ShowSuccess(Muchinfo.MTPClient.Resources.Client_Resource.Order_ReceiveConfirmTicket_Success_Result,
- Client_Resource.Models_Tips);
- }
- else if (_currentePerformanceType == ePerformanceType.PERFORMANCETYPE_DELIVERY)
- {
- MessageBoxHelper.ShowSuccess(Muchinfo.MTPClient.Resources.Client_Resource.Order_ReceiveConfirmTicketAndGoods_Success_Result1,
- Client_Resource.Models_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)
- {
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- ErrorManager.ShowReturnError(errorEntity, Client_Resource.UI2014_Tips, true);
- IsBusy = false;
- if (_openWindow != null)
- {
- _openWindow.Close();
- this.Cleanup();
- }
- }));
- }
- #endregion "Private Methods"
- #region "=========其它方法/Other Methods"
- //To to something
- #endregion "Other Methods"
-
- }
- }
|