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

using BBWY.Client.Models;
using BBWY.Controls;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
namespace BBWY.Client.Views.Order
{
/// <summary>
/// ManualCalculationCost.xaml 的交互逻辑
/// </summary>
public partial class ManualCalculationCost : BWindow
{
public string OrderId { get; private set; }
public bool IsSetStorageType { get; private set; }
public StorageType StorageType { get; private set; }
public List<ManualEditCostOrderSku> ManualEditCostOrderSkuList { get; set; }
public ManualCalculationCost(string orderId, bool isSetStorageType, StorageType storageType, IList<ManualEditCostOrderSku> manualEditCostOrderSkuList)
{
InitializeComponent();
this.DataContext = this;
ManualEditCostOrderSkuList = new List<ManualEditCostOrderSku>();
ManualEditCostOrderSkuList.AddRange(manualEditCostOrderSkuList);
foreach (var manualEditCostOrderSku in ManualEditCostOrderSkuList)
manualEditCostOrderSku.OnAmountChanged = () =>
{
txtTotalCost.Text = ManualEditCostOrderSkuList.Sum(osku => osku.TotalCost).ToString();
txtTotalDeliveryExpressFreight.Text = ManualEditCostOrderSkuList.Sum(osku => osku.DeliveryExpressFreight).ToString();
};
this.OrderId = orderId;
this.IsSetStorageType = isSetStorageType;
this.StorageType = storageType;
this.Loaded += ManualCalculationCost_Loaded;
}
private void ManualCalculationCost_Loaded(object sender, RoutedEventArgs e)
{
txt_StorageType.Text = $"{this.StorageType}-手动计算成本";
//if (StorageType != StorageType.云仓 && StorageType != StorageType.京仓)
//{
// txtFirstFreight.Visibility = Visibility.Collapsed;
// this.Height = 290;
//}
txtTotalCost.Text = ManualEditCostOrderSkuList.Sum(osku => osku.TotalCost).ToString();
txtTotalDeliveryExpressFreight.Text = ManualEditCostOrderSkuList.Sum(osku => osku.DeliveryExpressFreight).ToString();
}
private void btn_fillFromLately_Click(object sender, System.Windows.RoutedEventArgs e)
{
}
private void btn_Save_Click(object sender, System.Windows.RoutedEventArgs e)
{
//if (!decimal.TryParse(txtSkuAmount.Text, out decimal skuAmount) ||
// !decimal.TryParse(txtFeright.Text, out decimal feright) ||
// !decimal.TryParse(txtDeliveryExpressFreight.Text, out decimal deliveryExpressFreight))
//{
// MessageBox.Show("请填写完整信息", "手动编辑成本");
// return;
//}
//decimal.TryParse(txtFirstFreight.Text, out decimal firstFreight);
//decimal.TryParse(txtOperationAmount.Text, out decimal operationAmount);
//decimal.TryParse(txtConsumableAmount.Text, out decimal consumableAmount);
//decimal.TryParse(txtStorageAmount.Text, out decimal storageAmount);
//this.PurchaseCost = skuAmount + feright + firstFreight + operationAmount + consumableAmount + storageAmount;
//this.DeliveryExpressFreight = deliveryExpressFreight;
this.DialogResult = true;
this.Close();
}
}
}