com口配置

master
zhaojian 2 years ago
parent 20f79fc0a1
commit 9350679d8f

Binary file not shown.

@ -15,9 +15,9 @@
<add key="ClientMode" value="4" />
<add key="SerialPort" value="COM5" />
<add key="weigh" value="COM12" />
<add key="DryingHouseList" value="H13,H14,H15" />
<!--线体编码-->
<add key="LineCode" value="101" />
<!--获取设备状态间隔时间 单位秒-->

@ -94,31 +94,31 @@
</Grid.RowDefinitions>
<Label Content="1号称重设备" FontSize="14" Grid.Row="1" Margin="15,10,1078,53" Grid.RowSpan="2"></Label>
<Border BorderThickness="1" CornerRadius="4" BorderBrush="#404040" Width="70" Grid.Row="1" HorizontalAlignment="Left" Margin="132,14,0,6">
<TextBlock Text="未连接" Name="lianjiezhuangtai" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
<TextBlock Text="未连接" Name="lianjiezhuangtai" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
</Border>
<Label Content="检验物料:" FontSize="14" Grid.Row="2" Margin="15,0,1082,0" ></Label>
<Border Grid.Row="2" Margin="132,6,711,6" BorderBrush="#404040" BorderThickness="1" CornerRadius="4">
<TextBox Name="jianyanwuliao" BorderThickness="0" Margin="1,1,0,1" HorizontalAlignment="Left" Width="360" ></TextBox>
<TextBox Name="jianyanwuliao" BorderThickness="0" FontSize="18" Margin="1,1,0,1" HorizontalAlignment="Left" Width="360" ></TextBox>
</Border>
<Label Content="检验节点:" FontSize="14" Grid.Row="2" Margin="649,10,455,0" ></Label>
<Border Grid.Row="2" Margin="755,6,84,6" BorderBrush="#404040" BorderThickness="1" CornerRadius="4">
<TextBox Name="jianyanjiedian" BorderThickness="0" Margin="1,1,1,1" Width="360"></TextBox>
<TextBox Name="jianyanjiedian" BorderThickness="0" FontSize="18" Margin="1,1,1,1" Width="360"></TextBox>
</Border>
<Label Content="任务编号:" FontSize="14" Grid.Row="3" Margin="15,6,1082,0" ></Label>
<Border Grid.Row="3" Margin="132,6,711,6" BorderBrush="#404040" BorderThickness="1" CornerRadius="4">
<TextBox Name="renwubianhao" BorderThickness="0" Margin="1,1,1,1" Width="360" ></TextBox>
<TextBox Name="renwubianhao" BorderThickness="0" FontSize="18" Margin="1,1,1,1" Width="360" ></TextBox>
</Border>
<!--<Label Content="规则属性:" FontSize="14" Grid.Row="3" Margin="649,10,455,0" ></Label>
<Border Grid.Row="3" Margin="755,6,84,6" BorderBrush="#404040" BorderThickness="1" CornerRadius="4">
<TextBox Name="guizeshuxing" BorderThickness="0" Margin="1,1,1,1" Width="360"></TextBox>
</Border>-->
<Label Content="规则名称:" FontSize="14" Grid.Row="3" Margin="649,10,455,0" ></Label>
<Border Grid.Row="3" Margin="755,6,84,6" BorderBrush="#404040" BorderThickness="1" CornerRadius="4">
<TextBox Name="guizemingcheng" BorderThickness="0" Margin="1,1,1,1" Width="360"></TextBox>
<Border Grid.Row="3" Margin="755,6,84,6" BorderBrush="#404040" BorderThickness="1" CornerRadius="4">
<TextBox Name="guizemingcheng" FontSize="18" BorderThickness="0" Margin="1,1,1,1" Width="360"></TextBox>
</Border>
<Label Content="重 量(g):" FontSize="14" Grid.Row="4" Margin="15,6,1082,0" ></Label>
<Border Grid.Row="4" Margin="132,6,711,6" BorderBrush="#404040" BorderThickness="1" CornerRadius="4">
<TextBox Name="zhongliang" BorderThickness="0" Margin="1,1,1,1" Width="360"></TextBox>
<TextBox Name="zhongliang" FontSize="18" BorderThickness="0" Margin="1,1,1,1" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Width="360"></TextBox>
</Border>
<Border BorderThickness="1" CornerRadius="3" BorderBrush="#404040" Background="#2F82E7" Grid.Row="5" Height="32" Margin="88,0,304,8" Width="80">
<Button Content="称 重" BorderThickness="0" FontSize="16" Foreground="White" Background="#2F82E7" Click="Button_Click_1"/>
@ -173,7 +173,7 @@
<Label Content="任务编号:" FontSize="14" Grid.Row="0" Margin="10,22,1750,56" ></Label>
<Border Grid.Row="0" Margin="112,19,1471,55" BorderBrush="#404040" BorderThickness="1" CornerRadius="4">
<TextBox Name="renwubianhao1" BorderThickness="0" Margin="1,1,1,1" ></TextBox>
<TextBox Name="renwubianhao1" FontSize="16" BorderThickness="0" Margin="1,1,1,1" ></TextBox>
</Border>
<Label Content="检验日期:" FontSize="14" Grid.Row="0" Margin="400,22,1357,56" ></Label>
<!--<Border Grid.Row="0" Margin="505,20,1066,56" BorderBrush="#404040" BorderThickness="1" CornerRadius="4">-->
@ -185,11 +185,11 @@
<Label Content="检验节点:" FontSize="14" Grid.Row="0" Margin="10,68,1750,10" ></Label>
<Border Grid.Row="0" Margin="112,64,1471,10" BorderBrush="#404040" BorderThickness="1" CornerRadius="4">
<TextBox Name="jianyanjiedian1" BorderThickness="0" Margin="1,1,1,1" ></TextBox>
<TextBox Name="jianyanjiedian1" BorderThickness="0" FontSize="18" Margin="1,1,1,1" ></TextBox>
</Border>
<Label Content="检验物料:" FontSize="14" Grid.Row="0" Margin="400,68,1357,0" Height="36" VerticalAlignment="Top" ></Label>
<Border Grid.Row="0" Margin="505,64,1066,10" BorderBrush="#404040" BorderThickness="1" CornerRadius="4">
<TextBox Name="jianyanwuliao1" BorderThickness="0" Margin="1,1,1,1" ></TextBox>
<TextBox Name="jianyanwuliao1" BorderThickness="0" Margin="1,1,1,1" FontSize="18"></TextBox>
</Border>
<Border BorderThickness="1" CornerRadius="4" BorderBrush="#404040" Background="#2F82E7" Grid.Row="0" Height="32" Margin="867,23,910,59" Width="80">
<Button Content="查询" BorderThickness="0" FontSize="16" Foreground="White" Background="#2F82E7" Click="Button_Click_2"/>

@ -25,6 +25,8 @@ using XGL.Dats.DBServiceFinishProd;
using XGL.Models;
using XGL.Models.Model.OrderPrepare;
using System.Text.RegularExpressions;
using System.Configuration;
namespace XGLFinishPro.Views
{
/// <summary>
@ -102,9 +104,13 @@ namespace XGLFinishPro.Views
dispatcher = Application.Current.Dispatcher;
// 创建一个新的SerialPort实例
serialPort = new SerialPort();
string portName = ConfigurationManager.AppSettings["weigh"];
if (!string.IsNullOrEmpty(portName))
{
serialPort.PortName = portName;
}
// 设置串口号和波特率
serialPort.PortName = "COM12"; // 串口号根据实际情况设置
//serialPort.PortName = "COM12"; // 串口号根据实际情况设置
serialPort.BaudRate = 9600; // 波特率根据实际情况设置
// 设置其他串口参数,如数据位、校验位等
@ -140,7 +146,7 @@ namespace XGLFinishPro.Views
Match match1 = Regex.Match(data, @"(\d+\.\d+)");
string bb = match1.Groups[1].Value;
upDateDate(bb);
UpdateUI(data);
UpdateUI(bb);
break; // 读到数据后跳出循环
}
}
@ -213,34 +219,40 @@ namespace XGLFinishPro.Views
private void Button_Click_2(object sender, RoutedEventArgs e)
{
string wher = "";
if (!renwubianhao1.Text.IsNullOrEmpty())
// 使用Dispatcher.Invoke确保在UI线程上执行更新操作
dispatcher.Invoke(() =>
{
wher += " and qct.check_no LIKE '%" + renwubianhao1.Text + "%'";
}
if (!jianyanjiedian1.Text.IsNullOrEmpty())
{
wher += " and qt.check_name LIKE '%" + jianyanjiedian1.Text + "%'";
}
if (!jianyanwuliao1.Text.IsNullOrEmpty())
{
wher += " and qct.material_name LIKE '%" + jianyanwuliao1.Text + "%'";
}
if (!dateStart.Text.IsNullOrEmpty())
{
wher += " and qct.income_time='" + dateStart.Text+"'";
}
var dataTable = userDbWareHouse.WeighingTask(wher);
if (dataTable != null && dataTable.Rows.Count > 0)
{
// 绑定 DataTable 到 DataGrid
WeighingTaskDateTable.ItemsSource = null;
WeighingTaskDateTable.ItemsSource = dataTable.DefaultView;
}
else
{
// 清空 DataGrid
WeighingTaskDateTable.ItemsSource = null;
}
// 更新UI控件
if (!renwubianhao1.Text.IsNullOrEmpty())
{
wher += " and qct.check_no LIKE '%" + renwubianhao1.Text + "%'";
}
if (!jianyanjiedian1.Text.IsNullOrEmpty())
{
wher += " and qt.check_name LIKE '%" + jianyanjiedian1.Text + "%'";
}
if (!jianyanwuliao1.Text.IsNullOrEmpty())
{
wher += " and qct.material_name LIKE '%" + jianyanwuliao1.Text + "%'";
}
if (!dateStart.Text.IsNullOrEmpty())
{
wher += " and qct.income_time='" + dateStart.Text + "'";
}
var dataTable = userDbWareHouse.WeighingTask(wher);
if (dataTable != null && dataTable.Rows.Count > 0)
{
// 绑定 DataTable 到 DataGrid
WeighingTaskDateTable.ItemsSource = null;
WeighingTaskDateTable.ItemsSource = dataTable.DefaultView;
}
else
{
// 清空 DataGrid
WeighingTaskDateTable.ItemsSource = null;
}
});
}
/// <summary>
@ -315,6 +327,7 @@ namespace XGLFinishPro.Views
checkTaskModel.actual_value = null;
}
userDbWareHouse.InsertCheckTaskDetail(checkTaskModel.actual_value, checkTaskModel.record_id);
Button_Click_2(null, null);
// 从数据源中移除该项
}
}

Loading…
Cancel
Save