using BBWY.Client.Models; using BBWY.Controls; using System.Collections.Generic; using System.Linq; using System.Windows; namespace BBWY.Client.Views.Order { /// /// RelationPurchaseOrder.xaml 的交互逻辑 /// public partial class RelationPurchaseOrder : BWindow { public OrderDropShipping OrderDropShipping { get; set; } public IList RelationPurchaseOrderSkuList { get; set; } public RelationPurchaseOrder(string orderId, OrderDropShipping orderDropShipping, IList relationPurchaseOrderSkuList) { InitializeComponent(); this.DataContext = this; OrderDropShipping = new OrderDropShipping() { OrderId = orderId }; if (orderDropShipping != null) { OrderDropShipping.BuyerAccount = orderDropShipping.BuyerAccount; OrderDropShipping.PurchaseAmount = orderDropShipping.PurchaseAmount; OrderDropShipping.PurchaseOrderId = orderDropShipping.PurchaseOrderId; OrderDropShipping.DeliveryFreight = orderDropShipping.DeliveryFreight; OrderDropShipping.PurchasePlatform = orderDropShipping.PurchasePlatform; OrderDropShipping.SellerAccount = orderDropShipping.SellerAccount; } this.RelationPurchaseOrderSkuList = relationPurchaseOrderSkuList; foreach (var sku in RelationPurchaseOrderSkuList) sku.OnSkuAmountChanged = OnSkuAmountChanged; } private void OnSkuAmountChanged() { OrderDropShipping.PurchaseAmount = RelationPurchaseOrderSkuList.Sum(sku => sku.SkuAmount); } private void btn_Save_Click(object sender, System.Windows.RoutedEventArgs e) { if (string.IsNullOrEmpty(OrderDropShipping.PurchaseOrderId) || string.IsNullOrEmpty(OrderDropShipping.SellerAccount) || string.IsNullOrEmpty(OrderDropShipping.BuyerAccount) || OrderDropShipping.PurchaseAmount == 0) { MessageBox.Show("关联订单信息不全", "提示"); return; } this.DialogResult = true; this.Close(); } } }