TakaDeliveryGoodsApplyViewModel.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. using GalaSoft.MvvmLight;
  2. using GalaSoft.MvvmLight.Command;
  3. using GalaSoft.MvvmLight.Ioc;
  4. using Muchinfo.MTPClient.Data;
  5. using Muchinfo.MTPClient.Data.Enums;
  6. using Muchinfo.MTPClient.Data.Model.Account;
  7. using Muchinfo.MTPClient.Data.Model.Delivery;
  8. using Muchinfo.MTPClient.Infrastructure.Cache;
  9. using Muchinfo.MTPClient.Infrastructure.Helpers;
  10. using Muchinfo.MTPClient.Infrastructure.MessageBox;
  11. using Muchinfo.MTPClient.Infrastructure.Utilities;
  12. using Muchinfo.MTPClient.Infrastructure.Windows;
  13. using Muchinfo.MTPClient.IService;
  14. using Muchinfo.MTPClient.Resources;
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Linq;
  18. using System.Windows;
  19. namespace Muchinfo.MTPClient.Delivery.ViewModels
  20. {
  21. /// <summary>
  22. /// 提货申请
  23. /// </summary>
  24. public class TakaDeliveryGoodsApplyViewModel : ViewModelBase
  25. {
  26. #region "=========私有成员/Private Data Members"
  27. protected IDeliveryService _deliveryService;
  28. private Window _openWindow;
  29. #endregion "Private Data Members"
  30. #region "=========构造函数/Constructor/Initialization"
  31. public TakaDeliveryGoodsApplyViewModel()
  32. {
  33. _deliveryService = SimpleIoc.Default.GetInstance<IDeliveryService>();
  34. InitData();
  35. }
  36. #endregion "Constructor/Initialization"
  37. #region "=========接口重写/Interface implementation Or override"
  38. #endregion "Interface implementation Or override"
  39. #region "=========公共属性/Public Properties To Get/Set "
  40. #region 当前账号提货人信息
  41. private DepositPersonalInfoRspModel _currentDepositPersonalInfo;
  42. /// <summary>
  43. /// 当前账号提货人信息
  44. /// </summary>
  45. public DepositPersonalInfoRspModel CurrentDepositPersonalInfo
  46. {
  47. get
  48. {
  49. return _currentDepositPersonalInfo;
  50. }
  51. set
  52. {
  53. Set(() => CurrentDepositPersonalInfo, ref _currentDepositPersonalInfo, value);
  54. }
  55. }
  56. #endregion
  57. #region 标题
  58. public string Title
  59. {
  60. get
  61. {
  62. return Resources.Client_Resource.Resources_Service_SubmitOutStoreReq;
  63. }
  64. }
  65. #endregion
  66. #region 是否忙
  67. private bool _isBusy;
  68. /// <summary>
  69. /// 是否忙
  70. /// </summary>
  71. public bool IsBusy
  72. {
  73. get { return _isBusy; }
  74. set { Set(() => IsBusy, ref _isBusy, value); }
  75. }
  76. #endregion
  77. #region 按钮是否可用
  78. private bool _oKButtonEnabled = true;
  79. /// <summary>
  80. ///按钮是否可用
  81. /// </summary>
  82. public bool OKButtonEnabled
  83. {
  84. get
  85. {
  86. return _oKButtonEnabled;
  87. }
  88. set
  89. {
  90. Set(() => OKButtonEnabled, ref _oKButtonEnabled, value);
  91. }
  92. }
  93. #endregion
  94. #region 当前选择仓库
  95. private TakaDeliveryGoodsApplyModel _currentWarehouse = null;
  96. /// <summary>
  97. /// Sets and gets the CurrentWarehouse property.
  98. /// Changes to that property's value raise the PropertyChanged event.
  99. /// </summary>
  100. public TakaDeliveryGoodsApplyModel CurrentWarehouse
  101. {
  102. get
  103. {
  104. return _currentWarehouse;
  105. }
  106. set
  107. {
  108. Set(() => CurrentWarehouse, ref _currentWarehouse, value);
  109. }
  110. }
  111. #endregion
  112. #region 仓库列表
  113. private List<TakaDeliveryGoodsApplyModel> _warehouseList = new List<TakaDeliveryGoodsApplyModel>();
  114. /// <summary>
  115. /// 仓库列表
  116. /// Changes to that property's value raise the PropertyChanged event.
  117. /// </summary>
  118. public List<TakaDeliveryGoodsApplyModel> WarehouseList
  119. {
  120. get
  121. {
  122. return _warehouseList;
  123. }
  124. set
  125. {
  126. Set(() => WarehouseList, ref _warehouseList, value);
  127. }
  128. }
  129. #endregion
  130. #region 收货人
  131. private string _RecievePerson = string.Empty;
  132. /// <summary>
  133. /// 收货人
  134. /// </summary>
  135. public string RecievePerson
  136. {
  137. get
  138. {
  139. return _RecievePerson;
  140. }
  141. set
  142. {
  143. Set(() => RecievePerson, ref _RecievePerson, value);
  144. }
  145. }
  146. #endregion
  147. #region 收货地址
  148. private string _RecieveAddress = string.Empty;
  149. /// <summary>
  150. /// 收货地址
  151. /// </summary>
  152. public string RecieveAddress
  153. {
  154. get
  155. {
  156. return _RecieveAddress;
  157. }
  158. set
  159. {
  160. Set(() => RecieveAddress, ref _RecieveAddress, value);
  161. }
  162. }
  163. #endregion
  164. #region 联系方式
  165. private string _PhoneNum = string.Empty;
  166. /// <summary>
  167. /// 联系方式
  168. /// </summary>
  169. public string PhoneNum
  170. {
  171. get
  172. {
  173. return _PhoneNum;
  174. }
  175. set
  176. {
  177. Set(() => PhoneNum, ref _PhoneNum, value);
  178. }
  179. }
  180. #endregion
  181. #region 提货方式
  182. private TakeGoodsWay _takeGoodsWay;
  183. /// <summary>
  184. /// 提货方式
  185. /// </summary>
  186. public TakeGoodsWay TakeGoodsWay
  187. {
  188. get { return _takeGoodsWay; }
  189. set { Set(() => TakeGoodsWay, ref _takeGoodsWay, value); }
  190. }
  191. #endregion
  192. #region 身份证
  193. private string _idCardNum;
  194. /// <summary>
  195. /// 身份证号
  196. /// </summary>
  197. public string IdCardNum
  198. {
  199. get { return _idCardNum; }
  200. set { Set(() => IdCardNum, ref _idCardNum, value); }
  201. }
  202. #endregion
  203. #region 所有提货仓单ListSource
  204. public List<TakaDeliveryGoodsApplyModel> TempTakaDeliveryGoodsOrderList = new List<TakaDeliveryGoodsApplyModel>();
  205. private List<TakaDeliveryGoodsApplyModel> _allTakaDeliveryGoodsOrderList= new List<TakaDeliveryGoodsApplyModel>();
  206. /// <summary>
  207. /// 所有提货仓单ListSource
  208. /// </summary>
  209. public List<TakaDeliveryGoodsApplyModel> AllTakaDeliveryGoodsOrderList
  210. {
  211. get { return _allTakaDeliveryGoodsOrderList; }
  212. set { Set(() => AllTakaDeliveryGoodsOrderList, ref _allTakaDeliveryGoodsOrderList, value); }
  213. }
  214. #endregion
  215. #region 当前勾选单据
  216. private List<OutStoreReqDetailModel> _currentSelectedOutStore = null;
  217. /// <summary>
  218. /// 当前勾选的提货单据LIST
  219. /// </summary>
  220. public List<OutStoreReqDetailModel> CurrentSelectedOutStore
  221. {
  222. get
  223. {
  224. return _currentSelectedOutStore;
  225. }
  226. set
  227. {
  228. Set(() => CurrentSelectedOutStore, ref _currentSelectedOutStore, value);
  229. }
  230. }
  231. #endregion
  232. #endregion "Public Properties To Get/Set "
  233. #region "=========公共命令/Public Commands"
  234. #region 窗口取消Command
  235. /// <summary>
  236. /// 窗口取消
  237. /// </summary>
  238. public RelayCommand<Window> CancelCommand
  239. {
  240. get
  241. {
  242. return new RelayCommand<Window>((dialog) =>
  243. {
  244. dialog.DialogResult = false;
  245. });
  246. }
  247. }
  248. #endregion
  249. #region 选中Command
  250. /// <summary>
  251. /// 选中
  252. /// </summary>
  253. private RelayCommand selectCommand;
  254. public RelayCommand SelectCommand
  255. {
  256. get
  257. {
  258. return selectCommand ?? (selectCommand = new RelayCommand(
  259. () =>
  260. {
  261. SettlementSelectedOutStore();
  262. }));
  263. }
  264. }
  265. #endregion
  266. #region 取消选中Command
  267. /// <summary>
  268. /// 取消选中
  269. /// </summary>
  270. private RelayCommand unSelectCommand;
  271. public RelayCommand UnSelectCommand
  272. {
  273. get
  274. {
  275. return unSelectCommand ?? (unSelectCommand = new RelayCommand(
  276. () =>
  277. {
  278. SettlementSelectedOutStore();
  279. }));
  280. }
  281. }
  282. #endregion
  283. #region 提交确定Command
  284. /// <summary>
  285. /// 提交确定
  286. /// </summary>
  287. public RelayCommand<Window> OKCommand
  288. {
  289. get
  290. {
  291. return new RelayCommand<Window>((dialog) =>
  292. {
  293. OKButtonEnabled = false;
  294. string errorMsg = string.Empty;
  295. bool validateBool = Validated(ref errorMsg); ////内容验证
  296. if (validateBool)
  297. {
  298. IsBusy = true;
  299. _openWindow = dialog;
  300. var newOrder = new OutStoreReqModel()
  301. {
  302. //申请
  303. OperateType = (int) TakaGoodsOperateType.Apply,
  304. RecievePerson = RecievePerson,
  305. RecieveAddress = string.IsNullOrWhiteSpace(RecieveAddress) ? "-" : RecieveAddress,
  306. PhoneNum = PhoneNum,
  307. OutStoreDetail = CurrentSelectedOutStore,
  308. TakeGoodsWay=TakeGoodsWay,
  309. OperatorID = UserManager.CurrentTradeAccount.AccountId,
  310. IdCardNum = IdCardNum,
  311. };
  312. if (UserManager.CurrentTradeAccount.FundsAccounts.Any() &&
  313. UserManager.CurrentTradeAccount.FundsAccounts[0] != null)
  314. {
  315. newOrder.AccountID = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
  316. }
  317. else
  318. {
  319. newOrder.AccountID = UserManager.CurrentTradeAccount.AccountId;
  320. }
  321. _deliveryService.SubmitOutStoreReq(newOrder, EntrurstSuccessCallBack, EntrurstErrorCallBack);
  322. }
  323. else
  324. {
  325. MessageBoxHelper.ShowInfo(errorMsg, Client_Resource.MessageBox_Error_Title);
  326. OKButtonEnabled = true;
  327. }
  328. });
  329. }
  330. }
  331. #endregion
  332. #region 出库选择-发生改变-发送命令
  333. private RelayCommand _warehouseSelectionChangedCommand;
  334. /// <summary>
  335. /// Gets the WarehouseSelectionChangedCommand.
  336. /// </summary>
  337. public RelayCommand WarehouseSelectionChangedCommand
  338. {
  339. get
  340. {
  341. return _warehouseSelectionChangedCommand
  342. ?? (_warehouseSelectionChangedCommand = new RelayCommand(
  343. () =>
  344. {
  345. #region 处理事件ChangedEvent
  346. FilteOutStoreOrderListByCombox();
  347. #endregion
  348. }));
  349. }
  350. }
  351. #endregion
  352. #endregion "Public Commands"
  353. #region "=========私有方法/Private Methods"
  354. /// <summary>
  355. /// 处理选择提货
  356. /// </summary>
  357. private void SettlementSelectedOutStore()
  358. {
  359. _currentSelectedOutStore = new List<OutStoreReqDetailModel>();
  360. var sourceList = AllTakaDeliveryGoodsOrderList.ToList().FindAll(p => p.IsSelected == true);
  361. if (sourceList != null && sourceList.Count == 1) ///选择一条数据时显示
  362. {
  363. RecieveAddress = sourceList[0].Address;
  364. RecievePerson = sourceList[0].PersonName;
  365. PhoneNum = sourceList[0].Telphone;
  366. TakeGoodsWay = sourceList[0].TakeGoodsWay;
  367. IdCardNum = sourceList[0].IdCardNum;
  368. }
  369. long tempDeliveryGoodsId=0;
  370. for (int i = 0; i < sourceList.Count(); i++)
  371. {
  372. _currentSelectedOutStore.Add(new OutStoreReqDetailModel() { WRId = (sourceList[i].WRID), StoreOutQty = ((sourceList[i].Qty - sourceList[i].FreezeQty -sourceList[i].PayQty)) });
  373. if (tempDeliveryGoodsId == 0)
  374. {
  375. tempDeliveryGoodsId = sourceList[i].DeliveryGoodsId;
  376. }
  377. }
  378. #region 只能提取相同的交割商品[注销]
  379. //if (sourceList.Count() > 0)
  380. //{
  381. // var sourceListSame = AllTakaDeliveryGoodsOrderList.ToList().FindAll(p => p.IsSelected != true && p.DeliveryGoodsId != tempDeliveryGoodsId);
  382. // for (int i = 0; i < sourceListSame.Count(); i++)
  383. // {
  384. // sourceListSame[i].IsEnabled = false;
  385. // }
  386. //}
  387. //else
  388. //{
  389. // var sourceListAll = AllTakaDeliveryGoodsOrderList.ToList();
  390. // for (int i = 0; i < sourceListAll.Count(); i++)
  391. // {
  392. // sourceListAll[i].IsEnabled = true;
  393. // }
  394. //}
  395. #endregion
  396. IsEnableButtonEvent();
  397. }
  398. /// <summary>
  399. /// 初始化数据
  400. /// </summary>
  401. private void InitData()
  402. {
  403. var accountid = UserManager.CurrentTradeAccount.AccountId;
  404. //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
  405. //{
  406. // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
  407. //}
  408. IsBusy = true;
  409. _deliveryService.QueryTakaDeliveryGoodsOrdersAppy(accountid, MarketOrderSuccess, QueryErrorCallback);
  410. //赋默赋值给下拉列表
  411. _warehouseList.Add(new TakaDeliveryGoodsApplyModel() { WareHouseName = Client_Resource.DeliveryMatchView_AllWareHouse });
  412. CurrentWarehouse = _warehouseList.FirstOrDefault();//默认选择
  413. IsEnableButtonEvent();
  414. //读取登录人基本信息
  415. GetDepositPersonalInfo();
  416. #region 测试数据
  417. //for (int i = 0; i < 5; i++)
  418. //{
  419. // _allTakaDeliveryGoodsOrderList.Add(new TakaDeliveryGoodsApplyModel() { WRID = 10003 + i, WRCode = DateTime.Now.ToShortTimeString(),WareHouseName="仓库"+i });
  420. //}
  421. //TempTakaDeliveryGoodsOrderList = _allTakaDeliveryGoodsOrderList;
  422. //BindingWarehouseComBoxList(_allTakaDeliveryGoodsOrderList);
  423. #endregion
  424. }
  425. /// <summary>
  426. /// 获取交割提货个人信息
  427. /// </summary>
  428. private void GetDepositPersonalInfo()
  429. {
  430. var accountid = UserManager.CurrentTradeAccount.AccountId;
  431. //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
  432. //{
  433. // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
  434. //}
  435. var ReqModel = new DepositPersonalInfoReqModel();
  436. ReqModel.accountId = (long)accountid;
  437. IsBusy = true;
  438. //交割提货个人信息查询
  439. _deliveryService.SearchDepositPersonalInfoReq(ReqModel, QueryDepositPersonalInfoSuccess, QueryDepositPersonalInfoCallBack);
  440. }
  441. /// <summary>
  442. /// 交割提货个人信息-成功返回
  443. /// </summary>
  444. /// <param name="orders"></param>
  445. protected void QueryDepositPersonalInfoSuccess(DepositPersonalInfoRspModel itemModel)
  446. {
  447. if (itemModel != null)
  448. {
  449. CurrentDepositPersonalInfo = itemModel;
  450. if (CurrentDepositPersonalInfo != null)
  451. {
  452. RecieveAddress = CurrentDepositPersonalInfo.address;
  453. RecievePerson = CurrentDepositPersonalInfo.personName;
  454. PhoneNum = CurrentDepositPersonalInfo.telphone;
  455. }
  456. }
  457. IsBusy = false;
  458. }
  459. /// <summary>
  460. /// 获取交割提货个人信息失败返回
  461. /// </summary>
  462. /// <param name="errorEntity"></param>
  463. private void QueryDepositPersonalInfoCallBack(ErrorEntity errorEntity)
  464. {
  465. IsBusy = false;
  466. }
  467. /// <summary>
  468. /// 过滤出库数据BY下拉列表
  469. /// </summary>
  470. private void FilteOutStoreOrderListByCombox()
  471. {
  472. #region 重置勾选单据
  473. var sourceList = AllTakaDeliveryGoodsOrderList.ToList().FindAll(p => p.IsSelected == true);
  474. for (int i = 0; i < sourceList.Count(); i++)
  475. {
  476. sourceList[i].IsSelected = false;
  477. }
  478. #endregion
  479. AllTakaDeliveryGoodsOrderList = TempTakaDeliveryGoodsOrderList;//回归数据
  480. if (_currentWarehouse.WareHouseName != Client_Resource.DeliveryMatchView_AllWareHouse)//全部仓库
  481. {
  482. AllTakaDeliveryGoodsOrderList = AllTakaDeliveryGoodsOrderList.Where(x => x.WareHouseName == _currentWarehouse.WareHouseName).ToList();
  483. }
  484. }
  485. /// <summary>
  486. /// 触发提交按钮是否可用
  487. /// </summary>
  488. private void IsEnableButtonEvent()
  489. {
  490. if (_currentSelectedOutStore != null && _currentSelectedOutStore.Any() && _currentSelectedOutStore.Count() > 0)
  491. {
  492. OKButtonEnabled = true;
  493. }
  494. else
  495. {
  496. OKButtonEnabled = false;
  497. }
  498. }
  499. /// <summary>
  500. /// 绑定-仓库-下拉列表数据
  501. /// </summary>
  502. /// <param name="itemList"></param>
  503. private void BindingWarehouseComBoxList(List<TakaDeliveryGoodsApplyModel> itemList)
  504. {
  505. if (itemList != null && itemList.Any())
  506. {
  507. foreach (var item in itemList)
  508. {
  509. //绑定-仓库-下拉列表数据
  510. if (!WarehouseList.Exists(x => x.WareHouseName == item.WareHouseName))
  511. {
  512. WarehouseList.Add(item);
  513. }
  514. }
  515. }
  516. }
  517. /// <summary>
  518. /// 查询成功返回
  519. /// </summary>
  520. /// <param name="orders"></param>
  521. protected void MarketOrderSuccess(List<TakaDeliveryGoodsApplyModel> orders)
  522. {
  523. UpdateItemSource(orders);
  524. IsBusy = false;
  525. }
  526. /// <summary>
  527. /// 查询失败返回
  528. /// </summary>
  529. /// <param name="errorEntity"></param>
  530. public void QueryErrorCallback(ErrorEntity errorEntity)
  531. {
  532. IsBusy = false;
  533. //var errorMsg = string.Format("{0}:{1}", errorEntity.RequestFunc, ErrorManager.FormatErrorMsg(errorEntity)); //错误信息显示到状态
  534. //MessengerHelper.DefaultSend(errorMsg, MessengerTokens.ErrorMessage);
  535. // base.QueryErrorCallback();
  536. }
  537. /// <summary>
  538. /// 更新数据源-绑定数据源
  539. /// </summary>
  540. /// <param name="orders"></param>
  541. private void UpdateItemSource(List<TakaDeliveryGoodsApplyModel> orders)
  542. {
  543. if (orders != null)
  544. {
  545. foreach (var item in orders)
  546. {
  547. #region 合约单位转换
  548. var goodsUnit = CacheManager.TradeGoodsUnit.FirstOrDefault((x) => x.UNITID == item.GoodsUnitId);
  549. if (goodsUnit != null)
  550. {
  551. item.GoodsUnitIdDisplay = goodsUnit.GOODSUNITNAME;
  552. }
  553. #endregion
  554. #region 是否可以提货逻辑
  555. //可用数量 = 注册数量-冻结数量-兑付数量
  556. var canTakeGoodsNum = item.Qty - item.FreezeQty - item.PayQty;
  557. //正常状态 且 可用数量大于零 可以提货
  558. if (canTakeGoodsNum > 0 && item.Status == eWRStatus.Normal)
  559. {
  560. item.CanTakeGoods = Visibility.Visible;
  561. }
  562. #endregion
  563. }
  564. AllTakaDeliveryGoodsOrderList = TempTakaDeliveryGoodsOrderList = orders.Where(x => x.Status == eWRStatus.Normal && x.CanTakeGoods == Visibility.Visible).ToList();//所有单据
  565. BindingWarehouseComBoxList(AllTakaDeliveryGoodsOrderList);
  566. }
  567. }
  568. /// <summary>
  569. /// 提交提货成功返回
  570. /// </summary>
  571. /// <param name="order"></param>
  572. private void EntrurstSuccessCallBack(OutStoreRspModel order)
  573. {
  574. IsBusy = false;
  575. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  576. {
  577. OKButtonEnabled = true;
  578. //提货成功
  579. MessageBoxHelper.ShowSuccess(Client_Resource.Order_TakaDeliveryGoods_Success_Result,
  580. Client_Resource.UI2014_Tips);
  581. if (_openWindow != null)
  582. {
  583. _openWindow.Close();
  584. this.Cleanup();
  585. }
  586. }));
  587. //刷新正常单
  588. MessengerHelper.DefaultSend(UserManager.CurrentTradeAccount, MessengerTokens.OrderNoticeToken);
  589. }
  590. /// <summary>
  591. /// 提货委托失败返回
  592. /// </summary>
  593. /// <param name="errorEntity"></param>
  594. private void EntrurstErrorCallBack(ErrorEntity errorEntity)
  595. {
  596. IsBusy = false;
  597. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  598. {
  599. OKButtonEnabled = true;
  600. ErrorManager.ShowReturnError(errorEntity, Client_Resource.UI2014_Tips, true);
  601. if (_openWindow != null)
  602. {
  603. _openWindow.Close();
  604. this.Cleanup();
  605. }
  606. }));
  607. }
  608. #endregion "Private Methods"
  609. #region "=========其它方法/Other Methods"
  610. /// <summary>
  611. /// 数据验证
  612. /// </summary>
  613. /// <param name="msg"></param>
  614. /// <returns></returns>
  615. public bool Validated(ref string msg)
  616. {
  617. if (RecievePerson.Trim() == "")
  618. {
  619. msg = Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_RecievePerson + Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_NeedToWrite;
  620. return false;
  621. }
  622. if (TakeGoodsWay == TakeGoodsWay.Express && RecieveAddress.Trim() == "")
  623. {
  624. msg = Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_RecieveAddress + Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_NeedToWrite;
  625. return false;
  626. }
  627. if (PhoneNum.Trim() == "")
  628. {
  629. msg = Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_PhoneNum + Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_NeedToWrite;
  630. return false;
  631. }
  632. if (PhoneNum.Trim() != "" && !PhoneNum.StartsWith("1") || PhoneNum.Length != 11 || !ValidationHelper.IsMobile(PhoneNum))
  633. {
  634. msg = Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_PhoneNumErrFormat;
  635. return false;
  636. }
  637. if (string.IsNullOrWhiteSpace(IdCardNum) || !ValidationHelper.IsIDcard(IdCardNum.Trim()))
  638. {
  639. msg = Muchinfo.MTPClient.Resources.Client_Resource.TakaDeliveryGoodsApplyViewModel_IDCardNumErrFormat;
  640. return false;
  641. }
  642. return true;
  643. }
  644. #endregion "Other Methods"
  645. }
  646. }