步步为盈
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.

81 lines
3.1 KiB

using BBWY.Client.Models;
using BBWY.Controls;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
namespace BBWY.Client.Views.Order
{
/// <summary>
/// RelationPurchaseOrder.xaml 的交互逻辑
/// </summary>
public partial class RelationPurchaseOrder : BWindow
{
public IList<OrderDropShipping> OrderDropShippingList { get; set; }
public IList<RelationPurchaseOrderSku> RelationPurchaseOrderSkuList { get; set; }
public IList<PurchaseAccount> PurchaseAccountList { get; set; }
public string OrderId { get; set; }
public decimal TotalCost { get => totalCost; set { Set(ref totalCost, value); } }
private decimal totalCost;
public RelationPurchaseOrder(string orderId, IList<PurchaseAccount> purchaseAccountList, IList<OrderDropShipping> orderDropShippingList, IList<RelationPurchaseOrderSku> relationPurchaseOrderSkuList)
{
InitializeComponent();
this.DataContext = this;
this.PurchaseAccountList = purchaseAccountList;
this.OrderId = orderId;
OrderDropShippingList = new ObservableCollection<OrderDropShipping>();
if (orderDropShippingList != null)
{
foreach (var ods in orderDropShippingList)
{
var ods1 = ods.Clone() as OrderDropShipping;
ods1.PurchaseFreightStr = ods1.PurchaseFreight.ToString();
var currentOdsSkuList = relationPurchaseOrderSkuList.Where(rsku => rsku.OrderDropShippingId == ods1.Id);
foreach (var rsku in currentOdsSkuList)
ods.RelationPurchaseOrderSkuList.Add(rsku);
OrderDropShippingList.Add(ods1);
ods1.OnPurchaseAmountChanged = OnPurchaseAmountChanged;
}
}
this.RelationPurchaseOrderSkuList = relationPurchaseOrderSkuList;
foreach (var sku in RelationPurchaseOrderSkuList)
sku.OnSkuAmountChanged = OnSkuAmountChanged;
OnPurchaseAmountChanged();
}
private void OnSkuAmountChanged()
{
foreach (var ods in OrderDropShippingList)
ods.SkuAmount = ods.RelationPurchaseOrderSkuList.Sum(sku => sku.SkuAmount);
}
private void OnPurchaseAmountChanged()
{
TotalCost = OrderDropShippingList.Sum(ods => ods.PurchaseAmount);
}
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();
}
}
}