步步为盈
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.7 KiB

using BBWY.Client.APIServices;
using BBWY.Client.Models;
using BBWY.Client.Models.FallWare;
using BBWY.Controls;
using System;
using System.Threading.Tasks;
using System.Windows;
namespace BBWY.Client.Views.FallWare
{
/// <summary>
/// SetJDWareBoxWindow2.xaml 的交互逻辑
/// </summary>
public partial class SetJDWareBoxWindow2 : BWindow
{
public JDWareBoxModel JDWareBoxModel { get; set; }
private SealBoxService sealBoxService;
private Action reflashWindow;
private WareType wareType;
public bool IsEnabled { get; set; }
public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } }
private bool isLoading;
public SetJDWareBoxWindow2(JDWareBoxModel model, SealBoxService sealBoxService, WareType wareType, Action reflashWindow, bool isEnabled = true)
{
InitializeComponent();
this.sealBoxService = sealBoxService;
this.wareType = wareType;
this.reflashWindow = reflashWindow;
JDWareBoxModel = model;
this.IsEnabled = isEnabled;
this.DataContext = this;
}
private void btn_save_Click(object sender, System.Windows.RoutedEventArgs e)
{
if (string.IsNullOrEmpty(JDWareBoxModel.ProductTitle) ||
string.IsNullOrEmpty(JDWareBoxModel.PrewOrder) ||
string.IsNullOrEmpty(JDWareBoxModel.PurchaseOrder))
{
MessageBox.Show("信息不完整", "提示");
return;
}
IsLoading = true;
Task.Factory.StartNew(() =>
{
var getDetailResponse = sealBoxService.GetJDSupplierNameAndStoreName(JDWareBoxModel.PurchaseOrder);
if (!getDetailResponse.Success)
{
IsLoading = false;
this.Dispatcher.Invoke(() => MessageBox.Show(getDetailResponse.Msg, "提示"));
return;
}
var res = sealBoxService.SetFallWareConfigure(JDWareBoxModel.SealBoxId, JDWareBoxModel.ProductTitle, JDWareBoxModel.PurchaseOrder, JDWareBoxModel.PrewOrder, JDWareBoxModel.WaybillNo, getDetailResponse.Data.SupplierName, getDetailResponse.Data.StoreName);
if (!res.Success)
{
IsLoading = false;
this.Dispatcher.Invoke(() => MessageBox.Show(res.Msg, "提示"));
return;
}
IsLoading = false;
this.Dispatcher.Invoke(() =>
{
reflashWindow?.Invoke();
this.Close();
});
});
}
}
}