|
|
|
|
@ -5,27 +5,16 @@ using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.IO.Ports;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using System.Windows.Markup;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
using System.Windows.Media.Media3D;
|
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
using System.Windows.Threading;
|
|
|
|
|
using XGL.Dats.DBServiceFinishProd;
|
|
|
|
|
using XGL.Models;
|
|
|
|
|
using XGL.Models.Model.OrderPrepare;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
using CommonFunc;
|
|
|
|
|
|
|
|
|
|
namespace XGLFinishPro.Views
|
|
|
|
|
{
|
|
|
|
|
@ -34,7 +23,7 @@ namespace XGLFinishPro.Views
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class weighWindows : UserControl
|
|
|
|
|
{
|
|
|
|
|
Dispatcher dispatcher;
|
|
|
|
|
Dispatcher dispatcher ;
|
|
|
|
|
FinishProdDBService userDbWareHouse = new FinishProdDBService();
|
|
|
|
|
static SerialPort serialPort;
|
|
|
|
|
public CheckTaskModel checkTaskModel = new CheckTaskModel();//当前选择的任务
|
|
|
|
|
@ -49,6 +38,8 @@ namespace XGLFinishPro.Views
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var dataTable = userDbWareHouse.WeighingTask("");
|
|
|
|
|
|
|
|
|
|
@ -63,6 +54,11 @@ namespace XGLFinishPro.Views
|
|
|
|
|
WeighingTaskDateTable.ItemsSource = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.instance.log.Error("初始化发生异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 重置
|
|
|
|
|
/// </summary>
|
|
|
|
|
@ -85,7 +81,6 @@ namespace XGLFinishPro.Views
|
|
|
|
|
}
|
|
|
|
|
Button_Click_2(null, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 称重
|
|
|
|
|
/// </summary>
|
|
|
|
|
@ -94,6 +89,8 @@ namespace XGLFinishPro.Views
|
|
|
|
|
private void Button_Click_1(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (jianyanwuliao.Text.IsNullOrEmpty() || jianyanjiedian.Text.IsNullOrEmpty() || renwubianhao.Text.IsNullOrEmpty() || guizemingcheng.Text.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("数据不完整,无法称重!!");
|
|
|
|
|
@ -169,8 +166,6 @@ namespace XGLFinishPro.Views
|
|
|
|
|
zhongliang.Text = data;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ClosePort()
|
|
|
|
|
{
|
|
|
|
|
if (serialPort != null && serialPort.IsOpen)
|
|
|
|
|
@ -184,14 +179,24 @@ namespace XGLFinishPro.Views
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
LogHelper.instance.log.Error("称重发生异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 称重更新数据库
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Date"></param>
|
|
|
|
|
public void upDateDate(string Date)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// 将数据保存
|
|
|
|
|
CheckTaskModel newItem = new CheckTaskModel() { material_name = Date };
|
|
|
|
|
// 获取当前应用程序的Dispatcher
|
|
|
|
|
dispatcher = Application.Current.Dispatcher;
|
|
|
|
|
Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
zhongDate.Items.Add(newItem);
|
|
|
|
|
@ -211,6 +216,11 @@ namespace XGLFinishPro.Views
|
|
|
|
|
userDbWareHouse.InsertCheckTaskDetail(checkTaskModel.actual_value, checkTaskModel.record_id);//保存称重数据
|
|
|
|
|
Button_Click_2(null, null);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.instance.log.Error("称重更新数据库发生异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
@ -219,6 +229,10 @@ namespace XGLFinishPro.Views
|
|
|
|
|
private void Button_Click_2(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string wher = "";
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// 获取当前应用程序的Dispatcher
|
|
|
|
|
dispatcher = Application.Current.Dispatcher;
|
|
|
|
|
// 使用Dispatcher.Invoke确保在UI线程上执行更新操作
|
|
|
|
|
dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
@ -252,8 +266,11 @@ namespace XGLFinishPro.Views
|
|
|
|
|
WeighingTaskDateTable.ItemsSource = null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.instance.log.Error("查询数据发生异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 表格双击事件
|
|
|
|
|
@ -261,6 +278,8 @@ namespace XGLFinishPro.Views
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// 获取选中行的索引
|
|
|
|
|
int selectedIndex = WeighingTaskDateTable.SelectedIndex;
|
|
|
|
|
@ -303,8 +322,12 @@ namespace XGLFinishPro.Views
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LogHelper.instance.log.Error("表格双击事件发生异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 表格删除按钮
|
|
|
|
|
@ -312,6 +335,8 @@ namespace XGLFinishPro.Views
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var button = sender as Button;
|
|
|
|
|
var dataContext = button?.DataContext;
|
|
|
|
|
@ -322,7 +347,7 @@ namespace XGLFinishPro.Views
|
|
|
|
|
// 从 DataGrid 的 ItemsSource 中移除该项
|
|
|
|
|
zhongDate.Items.Remove(item); // 从 actual_value 中移除 materialName
|
|
|
|
|
checkTaskModel.actual_value = RemoveMaterialNameFromActualValue(checkTaskModel.actual_value, materialName);
|
|
|
|
|
if (checkTaskModel.actual_value=="[]")
|
|
|
|
|
if (checkTaskModel.actual_value == "[]")
|
|
|
|
|
{
|
|
|
|
|
checkTaskModel.actual_value = null;
|
|
|
|
|
}
|
|
|
|
|
@ -331,6 +356,11 @@ namespace XGLFinishPro.Views
|
|
|
|
|
// 从数据源中移除该项
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.instance.log.Error(" 表格删除按钮发生异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private string RemoveMaterialNameFromActualValue(string actualValue, string materialName)
|
|
|
|
|
{
|
|
|
|
|
// 解析 actualValue,移除 materialName,并返回更新后的值
|
|
|
|
|
@ -341,7 +371,6 @@ namespace XGLFinishPro.Views
|
|
|
|
|
|
|
|
|
|
private void pickerstart_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class motre
|
|
|
|
|
|