using BBWY.Client.APIServices; using BBWY.Client.Models; using BBWY.Client.Models.APIModel.Request; using BBWY.Controls; using GalaSoft.MvvmLight.Command; using System; using System.Collections.Generic; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace BBWY.Client.Views.PackTask { /// /// SetBarCode.xaml 的交互逻辑 /// public partial class SetBarCodeWindow : BWindow { public SetBarCodeWindow() { InitializeComponent(); BarLabelCheckCommand = new RelayCommand(BarLabelCheck); } public void LoadData(BarCodeModel barCodeModel, PackTaskService PackTaskService) { BarCodeModel = barCodeModel; packTaskService = PackTaskService; this.DataContext = this; } public BarCodeModel BarCodeModel { get; set; } public PackTaskService packTaskService { get; set; } public Action SaveResult { get; set; } private void BButton_Click(object sender, RoutedEventArgs e) { if (BarCodeModel.LabelModel == BarcodeLabelModel.标准模板)//标准版 判断数据是否异常 { if (string.IsNullOrEmpty(BarCodeModel.ProductNo) || BarCodeModel.ProductNo == "待填写") { TipsWindow tips = new TipsWindow("该SKU无货号信息,将影响条形码打印\r\n请先设置好货号信息或调整打印模板类型"); tips.Show(); return; } } //保存到服务器中 返回id var resData = packTaskService.SaveBarCode(new BarCodeRequest { Brand = BarCodeModel.Brand, BrandName = BarCodeModel.BrandName, ProductNo = BarCodeModel.ProductNo, SkuId = BarCodeModel.SkuId, SkuName = BarCodeModel.SkuName, LabelModel = BarCodeModel.LabelModel, ShopName = BarCodeModel.ShopName, }); if (resData == null) { MessageBox.Show("网络异常!"); return; } if (!resData.Success) { MessageBox.Show(resData.Msg); return; } BarCodeModel.Id = resData.Data; if (SaveResult != null) SaveResult(BarCodeModel); this.Close(); } public ICommand BarLabelCheckCommand { get; set; } public void BarLabelCheck(BarcodeLabelModel labelModel) { if (BarCodeModel != null && labelModel == BarcodeLabelModel.标准模板)//标准版 判断数据是否异常 { if (string.IsNullOrEmpty(BarCodeModel.ProductNo) || BarCodeModel.ProductNo == "待填写") { TipsWindow tips = new TipsWindow("该SKU无货号信息,将影响条形码打印\r\n请先设置好货号信息或调整打印模板类型"); tips.ShowDialog(); } } } } }