using BBWY.Client.APIServices.QiKu; using BBWY.Client.Models.PackTask; using BBWY.Controls; 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; using WebSocketSharp; namespace BBWY.Client.Views.PackTask { /// /// AddExpressWindow.xaml 的交互逻辑 /// public partial class AddExpressWindow : BWindow { public AddExpressWindow(Action addExpressData, List expressNameList, PackTaskExpressService packTaskExpressService, PackTaskExpress updateData=null) { InitializeComponent(); AddExpressData = addExpressData; ExpressNameList = expressNameList; this.packTaskExpressService = packTaskExpressService; this.DataContext = this; if (updateData!=null) { WaybillNo=updateData.WaybillNo; ExpressName = updateData.SourceExpressName; NewGuid = updateData.NewGuid; } } PackTaskExpressService packTaskExpressService; private string waybillNo; public string WaybillNo { get => waybillNo; set { Set(ref waybillNo, value); } } public string expressName; public string ExpressName { get => expressName; set { Set(ref expressName, value); } } public string NewGuid { get; set; } public List ExpressNameList { get; set; } public Action AddExpressData { get; set; } /// /// 取消 /// /// /// private void BButton_Click(object sender, RoutedEventArgs e) { this.Close(); } /// /// 确定 /// /// /// private void BButton_Click_1(object sender, RoutedEventArgs e) { if (WaybillNo.IsNullOrEmpty()) { MessageBox.Show("快递单号不能为空"); return; } if (ExpressName.IsNullOrEmpty()) { MessageBox.Show("快递公司不能为空不能为空"); return; } var res = packTaskExpressService.SubscribeKuaiDi100(WaybillNo, ExpressName); if (res.Success) { if (NewGuid.IsNullOrEmpty()) { AddExpressData?.Invoke(Guid.NewGuid().ToString(), WaybillNo, ExpressName); } else { AddExpressData?.Invoke(NewGuid, WaybillNo, ExpressName); } this.Close(); return; } MessageBox.Show(res.Msg); } private void tbShop_TextChanged(object sender, TextChangedEventArgs e) { try { var textBoxt = (TextBox)sender; //创建一个ListBox if (tipBoxShop != null && tipBoxShop.Items.Count > 0) { tipBoxShop.Items.Clear(); } if (string.IsNullOrEmpty(textBoxt.Text)) { tipBoxShop.Visibility = Visibility.Collapsed; return; } if (ExpressNameList == null || ExpressNameList.Count < 0) { try { var res = packTaskExpressService.GetExpressNameList(); if (res.Success) { ExpressNameList = res.Data; } } catch (Exception ex) { } } foreach (var department in ExpressNameList) { if (department.Contains(textBoxt.Text)) { ListBoxItem item = new ListBoxItem(); Label lb = new Label(); lb.BorderThickness = new Thickness(0); lb.HorizontalAlignment = HorizontalAlignment.Left; lb.VerticalAlignment = VerticalAlignment.Center; lb.Background = Brushes.Transparent; lb.Margin = (new Thickness(0)); lb.Content = department; item.Content = lb; tipBoxShop.Items.Add(item); } } if (tipBoxShop != null) tipBoxShop.Visibility = Visibility.Visible; } catch (Exception) { } } private void tipBoxShop_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { var list = (ListBox)sender; if (list.Items.Count <= 0) { return; } var value = (ListBoxItem)list.SelectedValue; var content = (Label)value.Content; tbShop.Text = content.Content.ToString(); tipBoxShop.Visibility = Visibility.Collapsed; } catch (Exception) { } } private void tbShop_LostFocus(object sender, RoutedEventArgs e) { try { if (tipBoxShop != null && tipBoxShop.Items.Count > 0) { tipBoxShop.Items.Clear(); } } catch (Exception) { } } } }