|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Configuration;
|
|
|
using System.Linq;
|
|
|
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 CowOutputClient.Utils;
|
|
|
using Forks.JsonRpc.Client;
|
|
|
using Forks.JsonRpc.Client.Data;
|
|
|
using KeyPad;
|
|
|
using SerialPortWebSocketAdapter;
|
|
|
using WeighBusiness.BL;
|
|
|
using WeighBusiness.BO;
|
|
|
using WeighBusiness.Utils.SqlUtils;
|
|
|
|
|
|
namespace CowOutputClient
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// Interaction logic for OperateWindow.xaml
|
|
|
/// </summary>
|
|
|
public partial class OperateWindow : Window
|
|
|
{
|
|
|
MyThread thread1;
|
|
|
string param;
|
|
|
WpfUser wpfUser;
|
|
|
ProductTeam mTeam;
|
|
|
DateTime mProduceDate;
|
|
|
DateTime mProduceStartDate;
|
|
|
string accountingUnit_ID = ConfigurationManager.AppSettings["AccountingUnit_ID"];
|
|
|
string domain_ID = ConfigurationManager.AppSettings["Domain_ID"];
|
|
|
string clientNode = ConfigurationManager.AppSettings["ClientNode"];
|
|
|
ButcherDetailData mButcherDetailData;
|
|
|
bool IsLoad = true;
|
|
|
decimal? tare = null;
|
|
|
|
|
|
public OperateWindow()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
}
|
|
|
|
|
|
private void btnLogOut_Click_1(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
thread1.CloseThread();
|
|
|
App.Current.MainWindow = new MainWindow();
|
|
|
App.Current.MainWindow.Show();
|
|
|
this.Close();
|
|
|
}
|
|
|
|
|
|
private void SyncData_Click_1(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
WpfUserBL.SyncWpfUser();
|
|
|
ProductCatalogBL.SyncProductCatalog();
|
|
|
ProductPlanBL.SyncProductPlan();
|
|
|
ProductTeamBL.SyncProductTeam();
|
|
|
BindCombProductBatch();
|
|
|
BindGridProductPlan();
|
|
|
BindProductCatalogs();
|
|
|
WindowUtil.Inf("同步成功");
|
|
|
}
|
|
|
|
|
|
private void CreateOutPut_Click_1(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
if (combProductBatch.SelectedValue == null)
|
|
|
throw new ApplicationException("请选择分割生产批次");
|
|
|
var weightInfos = gridWeightInfo.ItemsSource as List<WeightInfo>;
|
|
|
var selectedItems = weightInfos.Where(x=>x.IsSelected);
|
|
|
if (selectedItems.Count() <= 0)
|
|
|
throw new ApplicationException("请先勾选称重记录");
|
|
|
var output = new RpcObject("/MainSystem/B3CowButcherManage/BO/Output");
|
|
|
output.Set<long?>("AccountingUnit_ID", long.Parse(accountingUnit_ID));
|
|
|
output.Set<long?>("Department_ID", wpfUser.Department_ID);
|
|
|
output.Set<long?>("Domain_ID", long.Parse(domain_ID));
|
|
|
output.Set<long?>("Employee_ID", wpfUser.Employee_ID ?? 0);
|
|
|
output.Set<long?>("ProductTeam_ID", mTeam.ProductTeam_ID);
|
|
|
var batch = (ProductBatch)combProductBatch.SelectedItem;
|
|
|
output.Set<long?>("ProductBatch_ID", batch.Batch_ID);
|
|
|
output.Set<string>("Product_Batch", batch.Batch);
|
|
|
output.Set<DateTime?>("Date", DateTime.Now);
|
|
|
|
|
|
var details = new ManyList("/MainSystem/B3CowButcherManage/BO/Output_Detail");
|
|
|
foreach (var item in selectedItems) {
|
|
|
var inputDetail = new RpcObject("/MainSystem/B3CowButcherManage/BO/Output_Detail");
|
|
|
inputDetail.Set<long?>("Goods_ID", item.Goods_ID);
|
|
|
inputDetail.Set<decimal?>("Number", item.NetWeight);
|
|
|
inputDetail.Set<decimal?>("SecondNumber", item.SecondNum);
|
|
|
inputDetail.Set<long?>("ButcDetailID", item.ButcDetailID);
|
|
|
inputDetail.Set<decimal?>("ProductNum", item.ProductNum);
|
|
|
inputDetail.Set<DateTime?>("Time", item.CreateTime);
|
|
|
details.Add(inputDetail);
|
|
|
}
|
|
|
output.Set("Details", details);
|
|
|
long? inStoreTypeId = null;
|
|
|
if (btnYesOrNo.Content.ToString() == "是")
|
|
|
inStoreTypeId = long.Parse(ConfigurationManager.AppSettings["InStoreType_ID1"]);
|
|
|
else
|
|
|
inStoreTypeId = long.Parse(ConfigurationManager.AppSettings["InStoreType_ID2"]);
|
|
|
|
|
|
var list = RpcFacade.Call<List<long?>>("/MainSystem/B3_HaoYue/Rpcs/B3CowButcherManageRpc/CreateOutput", output, mTeam.ProductTeam_ID, false, null, mTeam.Name, inStoreTypeId);
|
|
|
if (list.Count() > 0) {
|
|
|
var outputId = list[0].Value;
|
|
|
WeightInfoBL.UpdateOutputId(selectedItems.Select(x => x.ID).ToArray(),outputId);
|
|
|
BindGridWeightInfo();
|
|
|
var butDetails = gridProductPlan.ItemsSource as List<ButcherDetailData>;
|
|
|
if (list.Count > 1) {
|
|
|
for (int i = 1; i < list.Count; i++) {
|
|
|
ProductPlanBL.UpdateButhcerDetailFinish(list[i].Value);
|
|
|
var result = butDetails.Where(x => x.DetailID == list[i].Value);
|
|
|
if (result.Count() > 0)
|
|
|
butDetails.Remove(result.First());
|
|
|
}
|
|
|
var resultList = new List<ButcherDetailData>();
|
|
|
foreach (var item in butDetails) {
|
|
|
resultList.Add(item);
|
|
|
}
|
|
|
gridProductPlan.ItemsSource = null;
|
|
|
gridProductPlan.ItemsSource = resultList;
|
|
|
}
|
|
|
|
|
|
WindowUtil.Inf("创建产出单No." + outputId);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
List<ProCataGoods> catalogsDetails = new List<ProCataGoods>();
|
|
|
private void BindBaseData()
|
|
|
{
|
|
|
|
|
|
mProduceDate = DateTime.Now.Date;
|
|
|
txtProductDate.Text = DateTime.Now.Date.ToString("yyyy-MM-dd");
|
|
|
txtProduceStartDate.Text = txtProductDate.Text;
|
|
|
mProduceStartDate = mProduceDate;
|
|
|
BindProductCatalogs();
|
|
|
BindCombProductBatch();
|
|
|
BindGridProductPlan();
|
|
|
BindGridWeightInfo();
|
|
|
}
|
|
|
|
|
|
private void BindProductCatalogs()
|
|
|
{
|
|
|
ProductCatalogPanel.Children.Clear();
|
|
|
var catalogs = ProductCatalogBL.GetProductCatalogs();
|
|
|
catalogsDetails = ProductCatalogBL.GetProductCatalogDetails(true);
|
|
|
if (catalogs.Count() > 0) {
|
|
|
foreach (var catalog in catalogs) {
|
|
|
var txtCatalog = new TextBlock() { Text = catalog.Name, FontSize = 20, TextWrapping = TextWrapping.Wrap, TextAlignment = TextAlignment.Center };
|
|
|
txtCatalog.Tag = catalog;
|
|
|
txtCatalog.MouseDown += (object sende, MouseButtonEventArgs args) => {
|
|
|
if (ProductCatalogPanel.Children != null && ProductCatalogPanel.Children.Count > 0) {
|
|
|
foreach (var item in ProductCatalogPanel.Children) {
|
|
|
var bor = item as Border;
|
|
|
if (bor != null) {
|
|
|
var block = bor.Child as TextBlock;
|
|
|
if (block != null) {
|
|
|
block.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff"));
|
|
|
block.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#000"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
txtCatalog.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#3598fe"));
|
|
|
txtCatalog.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff"));
|
|
|
var result = (ProductCatalog)txtCatalog.Tag;
|
|
|
BindProductCatalogsDetails(result.ProductCatalog_ID);
|
|
|
};
|
|
|
var border = new Border();
|
|
|
border.BorderThickness = new Thickness(1, 1, 1, 1);
|
|
|
border.BorderBrush = Brushes.Black;
|
|
|
border.Child = txtCatalog;
|
|
|
border.Margin = new Thickness(10, 10, 0, 0);
|
|
|
ProductCatalogPanel.Children.Add(border);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void BindProductCatalogsDetails(long productCatalog_ID)
|
|
|
{
|
|
|
CatalogDetails.Children.Clear();
|
|
|
if (catalogsDetails.Count() > 0) {
|
|
|
var details = catalogsDetails.Where(x => x.ProductCatalog_ID == productCatalog_ID);
|
|
|
foreach (var catalog in details) {
|
|
|
var txtCatalog = new TextBlock() { Text = catalog.Goods_Name, FontSize = 15, TextWrapping = TextWrapping.Wrap, TextAlignment = TextAlignment.Center };
|
|
|
txtCatalog.Tag = catalog;
|
|
|
txtCatalog.MouseDown += (object sende, MouseButtonEventArgs args) => {
|
|
|
if (CatalogDetails.Children != null && CatalogDetails.Children.Count > 0) {
|
|
|
foreach (var item in CatalogDetails.Children) {
|
|
|
var bor = item as Border;
|
|
|
if (bor != null) {
|
|
|
var block = bor.Child as TextBlock;
|
|
|
if (block != null) {
|
|
|
block.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff"));
|
|
|
block.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#000"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
txtCatalog.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#3598fe"));
|
|
|
txtCatalog.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff"));
|
|
|
ReadWeight((ProCataGoods)txtCatalog.Tag);
|
|
|
};
|
|
|
var border = new Border();
|
|
|
border.BorderThickness = new Thickness(1, 1, 1, 1);
|
|
|
border.BorderBrush = Brushes.Black;
|
|
|
border.Child = txtCatalog;
|
|
|
border.Margin = new Thickness(8, 8, 0, 0);
|
|
|
CatalogDetails.Children.Add(border);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private bool SetStandardWeight(GoodsWeightFloat_Detail floatData, ProCataGoods detail, decimal? num, WeightInfo weight)
|
|
|
{
|
|
|
if (floatData != null && floatData.StandardWeight != null) {
|
|
|
if (!CheckGoodsWeight(detail, num, floatData)) {
|
|
|
return false;
|
|
|
} else {
|
|
|
weight.Weight = floatData.StandardWeight.Value;
|
|
|
}
|
|
|
} else {
|
|
|
weight.Weight = num.Value;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private void ReadWeight(ProCataGoods detail)
|
|
|
{
|
|
|
bool isSecondNum = false;
|
|
|
var w = ConfigurationManager.AppSettings["Weight"];
|
|
|
decimal? goodsWeight = null;
|
|
|
decimal? num = null;
|
|
|
if (!string.IsNullOrEmpty(w)) {
|
|
|
goodsWeight = decimal.Parse(w);
|
|
|
}
|
|
|
if (rbSingleWeight.IsChecked == true) {
|
|
|
if (goodsWeight == null && string.IsNullOrEmpty(ComWeight.Text))
|
|
|
WindowUtil.Err("没称重不能读入");
|
|
|
else if (!string.IsNullOrEmpty(ComWeight.Text))
|
|
|
goodsWeight = decimal.Parse(ComWeight.Text);
|
|
|
} else {
|
|
|
var keypadWindow = new Keypad(this);
|
|
|
if (keypadWindow.ShowDialog() == true && !string.IsNullOrEmpty(keypadWindow.Result)) {
|
|
|
goodsWeight = decimal.Parse(keypadWindow.Result);
|
|
|
}
|
|
|
if (rbFixedNum.IsChecked == true) {
|
|
|
isSecondNum = true;
|
|
|
} else {
|
|
|
if (string.IsNullOrEmpty(ComWeight.Text)) {
|
|
|
WindowUtil.Err("没称重不能读入");
|
|
|
return;
|
|
|
}
|
|
|
num = decimal.Parse(ComWeight.Text);
|
|
|
}
|
|
|
}
|
|
|
var weight = new WeightInfo();
|
|
|
weight.Goods_Name = detail.Goods_Name;
|
|
|
weight.Goods_Spec = detail.Goods_Spec;
|
|
|
weight.Goods_ID = detail.Goods_ID;
|
|
|
var floatData = GoodsWeightFloatBL.GetGoodsWeightFloatData(detail.Goods_ID);
|
|
|
if (isSecondNum) {
|
|
|
if (detail.UnitConvertDirection == "双向转换" || detail.UnitConvertDirection == "由辅至主") {
|
|
|
weight.Weight = (goodsWeight / (detail.SecondUnitRatio ?? 1) * (detail.MainUnitRatio ?? 1)) ?? 0;
|
|
|
weight.SecondNum = goodsWeight;
|
|
|
}
|
|
|
} else if (rbSelectedNum.IsChecked == true) {
|
|
|
if (!SetStandardWeight(floatData, detail, num, weight))
|
|
|
return;
|
|
|
weight.SecondNum = goodsWeight;
|
|
|
} else {
|
|
|
if (!SetStandardWeight(floatData, detail, goodsWeight ?? 0, weight))
|
|
|
return;
|
|
|
}
|
|
|
//var keypadWindow2 = new Keypad(this);
|
|
|
//if (keypadWindow2.ShowDialog() == true && !string.IsNullOrEmpty(keypadWindow2.Result)) {
|
|
|
// goodsWeight = decimal.Parse(keypadWindow2.Result);
|
|
|
//}
|
|
|
//weight.Weight = goodsWeight.Value;
|
|
|
weight.SubWeight = tare;
|
|
|
weight.NetWeight = weight.Weight - (weight.SubWeight??0);
|
|
|
if (weight.NetWeight < 0)
|
|
|
throw new ApplicationException("毛重"+weight.Weight+",皮重"+weight.SubWeight+",净重"+weight.NetWeight+"小于零,不能录入");
|
|
|
weight.CreateTime = DateTime.Now;
|
|
|
if (rbSingleWeight.IsChecked == true)
|
|
|
weight.ProductNum = 1;
|
|
|
decimal? finishNum = null;
|
|
|
using (var she = new SqlHelperEx()) {
|
|
|
she.CreateTransaction();
|
|
|
if (mButcherDetailData != null && detail.Goods_ID == mButcherDetailData.Goods_ID) {
|
|
|
weight.ButcDetailID = mButcherDetailData.DetailID;
|
|
|
finishNum = (mButcherDetailData.FinishNum ?? 0) + weight.NetWeight;
|
|
|
if (finishNum > mButcherDetailData.PlanNumber) {
|
|
|
var infoWindow = new AutoCloseWindow("计划数量【" + mButcherDetailData.PlanNumber + "】完工数量【" + finishNum + "】超出【" + (finishNum - mButcherDetailData.PlanNumber) + "】");
|
|
|
infoWindow.ShowDialog();
|
|
|
}
|
|
|
ProductPlanBL.UpdateButhcerDetailFinishNum(mButcherDetailData,finishNum, mButcherDetailData.DetailID, mButcherDetailData.Goods_ID, she);
|
|
|
//weight.DetailSequence = WeightInfoBL.GetCurrentSequence(mButcherDetailData.DetailID);
|
|
|
}
|
|
|
WeightInfoBL.Insert(weight,she);
|
|
|
she.Commit();
|
|
|
}
|
|
|
//待事务提交后再更新UI的值
|
|
|
if (mButcherDetailData != null && detail.Goods_ID == mButcherDetailData.Goods_ID) {
|
|
|
mButcherDetailData.FinishNum = finishNum;
|
|
|
mButcherDetailData.SurplusNum = (mButcherDetailData.PlanNumber ?? 0) - (mButcherDetailData.DeliveryNumber ?? 0);
|
|
|
}
|
|
|
BindGridWeightInfo(weight.ButcDetailID);
|
|
|
gridWeightInfo.ScrollIntoView(gridWeightInfo.Items[0]);
|
|
|
var items = gridWeightInfo.ItemsSource as List<WeightInfo>;
|
|
|
var closeWindow = new AutoCloseWindow("【" + weight.Goods_Name + "】序号【" + items.Where(x=>x.ButcDetailID == weight.ButcDetailID).FirstOrDefault().DetailSequence + "】");
|
|
|
closeWindow.ShowDialog();
|
|
|
|
|
|
}
|
|
|
|
|
|
private static bool CheckGoodsWeight(ProCataGoods detail, decimal? num, GoodsWeightFloat_Detail floatData)
|
|
|
{
|
|
|
var result = floatData.StandardWeight + (floatData.UpWeight ?? 0);
|
|
|
if (num < floatData.StandardWeight) {
|
|
|
WindowUtil.Err("【" + detail.Goods_Name + "】低于标准重量【" + floatData.StandardWeight + "】");
|
|
|
return false;
|
|
|
} else if (num > result) {
|
|
|
WindowUtil.Err("【" + detail.Goods_Name + "】高于上浮后重量【" + result + "】");
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private void Window_Loaded_1(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
thread1 = new MyThread();
|
|
|
thread1.ReadParam += this.OnRead;
|
|
|
thread1.Start();
|
|
|
wpfUser = WpfUserBL.Load(UserBL.CurrentUser.ERP_User_ID);
|
|
|
mTeam = ProductTeamBL.GetProductTeam(clientNode);
|
|
|
BindBaseData();
|
|
|
//IsLoad = false;
|
|
|
}
|
|
|
|
|
|
private void OnRead(string sParam)
|
|
|
{
|
|
|
param = sParam;
|
|
|
Object[] list = { this, System.EventArgs.Empty };
|
|
|
ComWeight.Dispatcher.Invoke(new EventHandler(ComWeight_Loaded), list);
|
|
|
}
|
|
|
|
|
|
private void ComWeight_Loaded(object sender, EventArgs e)
|
|
|
{
|
|
|
ComWeight.Text = param;
|
|
|
}
|
|
|
|
|
|
private void BindCombProductBatch()
|
|
|
{
|
|
|
var batchs = ProductPlanBL.GetProductBatch(mProduceDate,mProduceStartDate,IsLoad);
|
|
|
combProductBatch.ItemsSource = batchs;
|
|
|
combProductBatch.SelectedValuePath = "Batch_ID";
|
|
|
combProductBatch.DisplayMemberPath = "Batch";
|
|
|
}
|
|
|
|
|
|
private void BindGridProductPlan()
|
|
|
{
|
|
|
if (mTeam != null) {
|
|
|
var details = ProductPlanBL.GetButcherDetails(mProduceDate,mProduceStartDate, mTeam.ProductTeam_ID);
|
|
|
gridProductPlan.ItemsSource = details;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void BindGridWeightInfo(long? detailId = null)
|
|
|
{
|
|
|
var details = WeightInfoBL.GetWeightInfos(false,detailId);
|
|
|
gridWeightInfo.ItemsSource = details;
|
|
|
}
|
|
|
|
|
|
private void cb_Click_1(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
var a = sender as CheckBox;
|
|
|
var b = a.DataContext as WeightInfo;
|
|
|
b.IsSelected = a.IsChecked ?? false;
|
|
|
}
|
|
|
|
|
|
private void CheckAll_Click_1(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
var chbox = sender as CheckBox;
|
|
|
var items = gridWeightInfo.ItemsSource as List<WeightInfo>;
|
|
|
foreach (var item in items) {
|
|
|
item.IsSelected = chbox.IsChecked ?? false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void Button_Click_1(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
if (MessageBox.Show("确认完毕吗?", "温馨提示:", MessageBoxButton.OKCancel,MessageBoxImage.Information) == MessageBoxResult.Cancel) {
|
|
|
return;
|
|
|
}
|
|
|
var selectedItem = (sender as Button).Tag as ButcherDetailData;
|
|
|
|
|
|
if (combProductBatch.SelectedValue == null)
|
|
|
throw new ApplicationException("请选择分割生产批次");
|
|
|
var weightInfos = WeightInfoBL.GetWeightInfosByDetailId(selectedItem.DetailID);
|
|
|
RpcObject output = null;
|
|
|
if (weightInfos.Count > 0) {
|
|
|
output = new RpcObject("/MainSystem/B3CowButcherManage/BO/Output");
|
|
|
output.Set<long?>("AccountingUnit_ID", long.Parse(accountingUnit_ID));
|
|
|
output.Set<long?>("Department_ID", wpfUser.Department_ID);
|
|
|
output.Set<long?>("Domain_ID", long.Parse(domain_ID));
|
|
|
output.Set<long?>("Employee_ID", wpfUser.Employee_ID ?? 0);
|
|
|
var batch = (ProductBatch)combProductBatch.SelectedItem;
|
|
|
output.Set<long?>("ProductBatch_ID", batch.Batch_ID);
|
|
|
output.Set<string>("Product_Batch", batch.Batch);
|
|
|
output.Set<DateTime?>("Date", DateTime.Now);
|
|
|
output.Set<long?>("ProductTeam_ID", mTeam.ProductTeam_ID);
|
|
|
var details = new ManyList("/MainSystem/B3CowButcherManage/BO/Output_Detail");
|
|
|
foreach (var item in weightInfos) {
|
|
|
var inputDetail = new RpcObject("/MainSystem/B3CowButcherManage/BO/Output_Detail");
|
|
|
inputDetail.Set<long?>("Goods_ID", item.Goods_ID);
|
|
|
inputDetail.Set<decimal?>("Number", item.NetWeight);
|
|
|
inputDetail.Set<decimal?>("SecondNumber", item.SecondNum);
|
|
|
inputDetail.Set<long?>("ButcDetailID", item.ButcDetailID);
|
|
|
inputDetail.Set<decimal?>("ProductNum", item.ProductNum);
|
|
|
inputDetail.Set<DateTime?>("Time", item.CreateTime);
|
|
|
details.Add(inputDetail);
|
|
|
}
|
|
|
output.Set("Details", details);
|
|
|
}
|
|
|
long? inStoreTypeId = null;
|
|
|
if (btnYesOrNo.Content.ToString() == "是")
|
|
|
inStoreTypeId = long.Parse(ConfigurationManager.AppSettings["InStoreType_ID1"]);
|
|
|
else
|
|
|
inStoreTypeId = long.Parse(ConfigurationManager.AppSettings["InStoreType_ID2"]);
|
|
|
var list = RpcFacade.Call<List<long?>>("/MainSystem/B3_HaoYue/Rpcs/B3CowButcherManageRpc/CreateOutput", output, mTeam.ProductTeam_ID, true, selectedItem.DetailID,mTeam.Name,inStoreTypeId);
|
|
|
if (list == null) {
|
|
|
ProductPlanBL.UpdateButhcerDetailFinish(selectedItem.DetailID);
|
|
|
var butDetails = gridProductPlan.ItemsSource as List<ButcherDetailData>;
|
|
|
var result = butDetails.Where(x => x.DetailID == selectedItem.DetailID);
|
|
|
butDetails.Remove(result.First());
|
|
|
var resultList = new List<ButcherDetailData>();
|
|
|
foreach (var item in butDetails) {
|
|
|
resultList.Add(item);
|
|
|
}
|
|
|
gridProductPlan.ItemsSource = null;
|
|
|
gridProductPlan.ItemsSource = resultList;
|
|
|
}
|
|
|
else if (list.Count() > 0) {
|
|
|
var outputId = list[0].Value;
|
|
|
WeightInfoBL.UpdateOutputIdByButcDetailID(selectedItem.DetailID, outputId);
|
|
|
BindGridWeightInfo();
|
|
|
var butDetails = gridProductPlan.ItemsSource as List<ButcherDetailData>;
|
|
|
if (list.Count > 1) {
|
|
|
for (int i = 1; i < list.Count; i++) {
|
|
|
ProductPlanBL.UpdateButhcerDetailFinish(list[i].Value);
|
|
|
var result = butDetails.Where(x => x.DetailID == list[i].Value);
|
|
|
if(result.Count() > 0)
|
|
|
butDetails.Remove(result.First());
|
|
|
}
|
|
|
var resultList = new List<ButcherDetailData>();
|
|
|
foreach (var item in butDetails) {
|
|
|
resultList.Add(item);
|
|
|
}
|
|
|
gridProductPlan.ItemsSource = null;
|
|
|
gridProductPlan.ItemsSource = resultList;
|
|
|
}
|
|
|
|
|
|
WindowUtil.Inf("生成产出单No." + outputId);
|
|
|
}
|
|
|
if (mButcherDetailData!=null && mButcherDetailData.DetailID == selectedItem.DetailID) {
|
|
|
mButcherDetailData = null;
|
|
|
}
|
|
|
//var num = RpcFacade.Call<int>("/MainSystem/B3_HaoYue/Rpcs/B3CowButcherManageRpc/FinishButcherDetail", selectedItem.DetailID);
|
|
|
//if (num == 1) {
|
|
|
// ProductPlanBL.UpdateButhcerDetailFinish(selectedItem.DetailID);
|
|
|
// BindGridProductPlan();
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
private void DeleteButton_Click_2(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
if (MessageBox.Show("确认删除吗?", "温馨提示:", MessageBoxButton.OKCancel,MessageBoxImage.Information) == MessageBoxResult.Cancel) {
|
|
|
return;
|
|
|
}
|
|
|
var detail = (sender as Button).Tag as WeightInfo;
|
|
|
|
|
|
ButcherDetailData result = null;
|
|
|
decimal? finishNum = null;
|
|
|
using (var she = new SqlHelperEx()) {
|
|
|
she.CreateTransaction();
|
|
|
WeightInfoBL.DeleteByID(detail.ID,she);
|
|
|
//var weight = WeightInfoBL.GetButcDetailIDWeight(detail.ButcDetailID,she);
|
|
|
var items = gridProductPlan.ItemsSource as List<ButcherDetailData>;
|
|
|
var results = items.Where(x => x.DetailID == detail.ButcDetailID);
|
|
|
if (results != null && results.Count() > 0) {
|
|
|
result = results.First();
|
|
|
finishNum = result.FinishNum - detail.Weight;
|
|
|
ProductPlanBL.UpdateButhcerDetailFinishNum(result,finishNum, result.DetailID,result.Goods_ID,she);
|
|
|
}
|
|
|
she.Commit();
|
|
|
}
|
|
|
//待事务提交后再更新UI的值
|
|
|
if (result != null) {
|
|
|
result.FinishNum = finishNum;
|
|
|
result.SurplusNum = result.PlanNumber - result.DeliveryNumber;
|
|
|
}
|
|
|
var details = gridWeightInfo.ItemsSource as List<WeightInfo>;
|
|
|
details.Remove(detail);
|
|
|
var list = new List<WeightInfo>();
|
|
|
int i = 1;
|
|
|
foreach (var item in details) {
|
|
|
item.Number = i;
|
|
|
list.Add(item);
|
|
|
i++;
|
|
|
}
|
|
|
gridWeightInfo.ItemsSource = null;
|
|
|
gridWeightInfo.ItemsSource = list;
|
|
|
}
|
|
|
|
|
|
private void RemoveBindGridWeightInfo(WeightInfo weightInfo)
|
|
|
{
|
|
|
var details = gridWeightInfo.ItemsSource as List<WeightInfo>;
|
|
|
details.Remove(weightInfo);
|
|
|
}
|
|
|
|
|
|
private void btnProductSet_Click_1(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
if (new SelectedProductWindow().ShowDialog() == true) {
|
|
|
BindProductCatalogs();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void gridProductPlan_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
if (gridProductPlan.SelectedIndex != -1) {
|
|
|
mButcherDetailData = gridProductPlan.SelectedItem as ButcherDetailData;
|
|
|
if (CatalogDetails.Children != null && CatalogDetails.Children.Count > 0) {
|
|
|
foreach (var item in CatalogDetails.Children) {
|
|
|
var bor = item as Border;
|
|
|
if (bor != null) {
|
|
|
var block = bor.Child as TextBlock;
|
|
|
var goods = block.Tag as ProCataGoods;
|
|
|
if (goods.Goods_ID == mButcherDetailData.Goods_ID) {
|
|
|
block.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#3598fe"));
|
|
|
block.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff"));
|
|
|
|
|
|
} else {
|
|
|
block.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff"));
|
|
|
block.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#000"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
BindGridWeightInfo(mButcherDetailData.DetailID);
|
|
|
gridProductPlan.SelectedIndex = -1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void txtProductDate_PreviewMouseDown_1(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
var calendar = new CalendarSelecterWindow();
|
|
|
if (calendar.ShowDialog() == true) {
|
|
|
mProduceDate = calendar.Result;
|
|
|
if (mProduceStartDate > mProduceDate)
|
|
|
throw new ApplicationException("结束日期不能小于开始日期");
|
|
|
txtProductDate.Text = calendar.Result.ToString("yyyy-MM-dd");
|
|
|
BindCombProductBatch();
|
|
|
//BindGridProductPlan();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void txtProduceStartDate_PreviewMouseDown_1(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
var calendar = new CalendarSelecterWindow();
|
|
|
if (calendar.ShowDialog() == true) {
|
|
|
mProduceStartDate = calendar.Result;
|
|
|
if (mProduceStartDate > mProduceDate)
|
|
|
throw new ApplicationException("开始日期不能大于结束日期");
|
|
|
txtProduceStartDate.Text = calendar.Result.ToString("yyyy-MM-dd");
|
|
|
BindCombProductBatch();
|
|
|
//BindGridProductPlan();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void btnTare_Click_1(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
var keypadWindow = new Keypad(this);
|
|
|
if (keypadWindow.ShowDialog() == true && !string.IsNullOrEmpty(keypadWindow.Result)) {
|
|
|
tare = decimal.Parse(keypadWindow.Result);
|
|
|
btnTare.Content = keypadWindow.Result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void btnClear_Click_1(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
tare = null;
|
|
|
btnTare.Content = "去皮";
|
|
|
}
|
|
|
|
|
|
private void gridWeightInfo_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
if (gridWeightInfo.SelectedIndex != -1) {
|
|
|
var data = gridWeightInfo.SelectedItem as WeightInfo;
|
|
|
data.IsSelected = data.IsSelected ? false : true;
|
|
|
gridWeightInfo.SelectedIndex = -1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void scrList2_ContextMenuOpening_1(object sender, ContextMenuEventArgs e)
|
|
|
{
|
|
|
e.Handled = true;
|
|
|
}
|
|
|
|
|
|
private void scrList_ContextMenuOpening_1(object sender, ContextMenuEventArgs e)
|
|
|
{
|
|
|
e.Handled = true;
|
|
|
}
|
|
|
|
|
|
private void btnYesOrNo_Click_1(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
if (MessageBox.Show("确定更改吗?确定后入库仓库会变更", "提示:", MessageBoxButton.OKCancel) == MessageBoxResult.OK) {
|
|
|
var btn = sender as Button;
|
|
|
btn.Content = btn.Content.ToString() == "是" ? "否" : "是";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void Remark_Click_1(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
var btn = sender as Button;
|
|
|
MessageBox.Show(btn.Content.ToString(), "提示:", MessageBoxButton.OK);
|
|
|
}
|
|
|
}
|
|
|
}
|