This commit is contained in:
wxt
2026-01-24 16:55:48 +08:00
parent 3a9868cbb9
commit 8533734111
5 changed files with 239 additions and 70 deletions

View File

@@ -63,27 +63,22 @@ namespace 材料热传导系数
/// <summary>
/// 压力
/// </summary>
public double diffpressure { get; set; }
public float diffpressure { get; set; }
/// <summary>
/// 出口温度
/// </summary>
public double exit_temperature { get; set; }
public float exit_temperature { get; set; }
/// <summary>
/// 温度
/// </summary>
public double temperature { get; set; }
public float temperature { get; set; }
/// <summary>
/// 保压时间
/// </summary>
public double dwelltime { get; set; }
public float dwelltime { get; set; }
public DateTime CreateTime { get; set; }
@@ -99,7 +94,7 @@ namespace 材料热传导系数
public class ConductivityRepository
{
private readonly string _connectionString;
public readonly string _connectionString;
public ConductivityRepository()
{

View File

@@ -127,6 +127,7 @@ namespace 全自动水压检测仪
this.uiPanel13 = new Sunny.UI.UIPanel();
this.uiTableLayoutPanel9 = new Sunny.UI.UITableLayoutPanel();
this.uiPanel14 = new Sunny.UI.UIPanel();
this.uiButton8 = new Sunny.UI.UIButton();
this.uiButton5 = new Sunny.UI.UIButton();
this.uiLabel48 = new Sunny.UI.UILabel();
this.uiTextBox9 = new Sunny.UI.UITextBox();
@@ -160,7 +161,6 @@ namespace 全自动水压检测仪
this.uiPanel2 = new Sunny.UI.UIPanel();
this.uiLabel1 = new Sunny.UI.UILabel();
this.uiLight1 = new Sunny.UI.UILight();
this.uiButton8 = new Sunny.UI.UIButton();
this.uiTableLayoutPanel1.SuspendLayout();
this.uiTableLayoutPanel2.SuspendLayout();
this.panel1.SuspendLayout();
@@ -1696,6 +1696,19 @@ namespace 全自动水压检测仪
this.uiPanel14.Text = null;
this.uiPanel14.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
//
// uiButton8
//
this.uiButton8.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiButton8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiButton8.Location = new System.Drawing.Point(426, 126);
this.uiButton8.MinimumSize = new System.Drawing.Size(1, 1);
this.uiButton8.Name = "uiButton8";
this.uiButton8.Size = new System.Drawing.Size(58, 33);
this.uiButton8.TabIndex = 16;
this.uiButton8.Text = "写入";
this.uiButton8.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiButton8.Click += new System.EventHandler(this.uiButton8_Click);
//
// uiButton5
//
this.uiButton5.Cursor = System.Windows.Forms.Cursors.Hand;
@@ -2194,18 +2207,6 @@ namespace 全自动水压检测仪
this.uiLight1.TabIndex = 1;
this.uiLight1.Text = "uiLight1";
//
// uiButton8
//
this.uiButton8.Cursor = System.Windows.Forms.Cursors.Hand;
this.uiButton8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiButton8.Location = new System.Drawing.Point(426, 126);
this.uiButton8.MinimumSize = new System.Drawing.Size(1, 1);
this.uiButton8.Name = "uiButton8";
this.uiButton8.Size = new System.Drawing.Size(58, 33);
this.uiButton8.TabIndex = 16;
this.uiButton8.Text = "写入";
this.uiButton8.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
//
// NormalTemperatureMode
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;

View File

@@ -1,5 +1,8 @@
using Microsoft.Win32;
using Dapper;
using Microsoft.Win32;
using Modbus.Device;
using MySql.Data.MySqlClient;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using Sunny.UI;
using System;
using System.Collections.Generic;
@@ -624,8 +627,8 @@ namespace 全自动水压检测仪
private void NormalTemperatureMode_Load(object sender, EventArgs e)
{
// string plcIp = "192.168.1.10";
string plcIp = "127.0.0.1";
string plcIp = "192.168.1.10";
//string plcIp = "127.0.0.1";
bool initSuccess = Data.ModbusResourceManager.Instance.Init(plcIp, 502);
if (!initSuccess)
{
@@ -699,8 +702,8 @@ namespace 全自动水压检测仪
{
try
{
//string plcIp = "192.168.1.10";
string plcIp = "127.0.0.1";
string plcIp = "192.168.1.10";
//string plcIp = "127.0.0.1";
bool initSuccess = Data.ModbusResourceManager.Instance.Init(plcIp, 502);
if (initSuccess)
{
@@ -901,5 +904,110 @@ namespace 全自动水压检测仪
{
SwitchWindow(ref _scanImport, () => new ScanImport());
}
private void uiButton8_Click(object sender, EventArgs e)
{
try
{
// 1. 获取条码输入
string barcode = uiTextBox2.Text.Trim();
if (string.IsNullOrEmpty(barcode))
{
MessageBox.Show("请输入条码!");
return;
}
// 2. 从数据库查询数据
ScanData scanData = GetScanDataByBarcode(barcode);
if (scanData == null)
{
MessageBox.Show($"未找到条码为 {barcode} 的记录!");
return;
}
// 3. 连接到PLC并写入数据
WriteScanDataToPLC(scanData);
}
catch (Exception ex)
{
MessageBox.Show($"操作失败:{ex.Message}");
}
}
private ScanData GetScanDataByBarcode(string barcode)
{
using (var connection = new MySqlConnection(_repository._connectionString))
{
connection.Open();
var sql = @"SELECT * FROM scandata
WHERE barcode = @barcode
ORDER BY CreateTime DESC
LIMIT 1";
return connection.QueryFirstOrDefault<ScanData>(sql, new { barcode });
}
}
private void WriteScanDataToPLC(ScanData data)
{
// 写入压力到PLC地址2400浮点型
//ma?.WriteToPLCForNew(data.diffpressure.ToString(), 2400, Function.DataType.浮点型);
//// 写入测试保压时间到PLC地址2404整形
//ma?.WriteToPLCForNew(data.dwelltime.ToString("F0"), 2404, Function.DataType.整形);
//// 写入温度到PLC地址2402浮点型
//ma?.WriteToPLCForNew(data.temperature.ToString(), 2402, Function.DataType.浮点型);
//// 写入出口温度到PLC地址2412浮点型
//ma?.WriteToPLCForNew(data.exit_temperature.ToString(), 2412, Function.DataType.浮点型);
// 1. 写入压力到PLC地址2400浮点型
float pressure = data.diffpressure;
ushort[] pressureRegisters = ConvertFloatToRegisters(pressure);
_modbusMaster.WriteMultipleRegisters(1, 2400, pressureRegisters);
// 2. 写入测试保压时间到PLC地址2404整形
int dwellTime = (int)data.dwelltime;
ushort[] dwellTimeRegisters = ConvertIntToRegisters(dwellTime);
_modbusMaster.WriteMultipleRegisters(1, 2404, dwellTimeRegisters);
// 3. 写入温度到PLC地址2402浮点型
float temperature = data.temperature;
ushort[] temperatureRegisters = ConvertFloatToRegisters(temperature);
_modbusMaster.WriteMultipleRegisters(1, 2402, temperatureRegisters);
// 4. 写入出口温度到PLC地址2412浮点型
float exitTemperature = data.exit_temperature;
ushort[] exitTempRegisters = ConvertFloatToRegisters(exitTemperature);
_modbusMaster.WriteMultipleRegisters(1, 2412, exitTempRegisters);
}
// 将浮点数转换为寄存器数组2个寄存器
private ushort[] ConvertFloatToRegisters(float value)
{
byte[] bytes = BitConverter.GetBytes(value);
ushort[] registers = new ushort[2];
registers[0] = BitConverter.ToUInt16(bytes, 0); // 第一个寄存器(低位)
registers[1] = BitConverter.ToUInt16(bytes, 2); // 第二个寄存器(高位)
return registers;
}
// 将整数转换为寄存器数组2个寄存器
private ushort[] ConvertIntToRegisters(int value)
{
byte[] bytes = BitConverter.GetBytes(value);
ushort[] registers = new ushort[2];
registers[0] = BitConverter.ToUInt16(bytes, 0); // 第一个寄存器(低位)
registers[1] = BitConverter.ToUInt16(bytes, 2); // 第二个寄存器(高位)
return registers;
}
}
}

View File

@@ -28,11 +28,11 @@
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle21 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle22 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle23 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle24 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle25 = new System.Windows.Forms.DataGridViewCellStyle();
this.save = new Sunny.UI.UIButton();
this.uiDataGridView1 = new Sunny.UI.UIDataGridView();
this.uiTextBox2 = new Sunny.UI.UITextBox();
@@ -52,6 +52,8 @@
this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.uiTextBox3 = new Sunny.UI.UITextBox();
this.uiLabel2 = new Sunny.UI.UILabel();
((System.ComponentModel.ISupportInitialize)(this.uiDataGridView1)).BeginInit();
this.SuspendLayout();
//
@@ -70,18 +72,18 @@
//
// uiDataGridView1
//
dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
this.uiDataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
dataGridViewCellStyle21.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
this.uiDataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle21;
this.uiDataGridView1.BackgroundColor = System.Drawing.Color.White;
this.uiDataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle2.ForeColor = System.Drawing.Color.White;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.uiDataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
dataGridViewCellStyle22.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle22.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
dataGridViewCellStyle22.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle22.ForeColor = System.Drawing.Color.White;
dataGridViewCellStyle22.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle22.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle22.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.uiDataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle22;
this.uiDataGridView1.ColumnHeadersHeight = 32;
this.uiDataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
this.uiDataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
@@ -92,31 +94,31 @@
this.Column7,
this.Column5,
this.Column6});
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.uiDataGridView1.DefaultCellStyle = dataGridViewCellStyle3;
dataGridViewCellStyle23.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle23.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle23.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle23.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
dataGridViewCellStyle23.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle23.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle23.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.uiDataGridView1.DefaultCellStyle = dataGridViewCellStyle23;
this.uiDataGridView1.EnableHeadersVisualStyles = false;
this.uiDataGridView1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiDataGridView1.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
this.uiDataGridView1.Location = new System.Drawing.Point(12, 137);
this.uiDataGridView1.Name = "uiDataGridView1";
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.White;
dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.uiDataGridView1.RowHeadersDefaultCellStyle = dataGridViewCellStyle4;
dataGridViewCellStyle24.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle24.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
dataGridViewCellStyle24.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle24.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
dataGridViewCellStyle24.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
dataGridViewCellStyle24.SelectionForeColor = System.Drawing.Color.White;
dataGridViewCellStyle24.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.uiDataGridView1.RowHeadersDefaultCellStyle = dataGridViewCellStyle24;
this.uiDataGridView1.RowHeadersWidth = 51;
dataGridViewCellStyle5.BackColor = System.Drawing.Color.White;
dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiDataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle5;
dataGridViewCellStyle25.BackColor = System.Drawing.Color.White;
dataGridViewCellStyle25.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiDataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle25;
this.uiDataGridView1.RowTemplate.Height = 27;
this.uiDataGridView1.SelectedIndex = -1;
this.uiDataGridView1.Size = new System.Drawing.Size(958, 537);
@@ -127,7 +129,7 @@
//
this.uiTextBox2.Cursor = System.Windows.Forms.Cursors.IBeam;
this.uiTextBox2.Font = new System.Drawing.Font("微软雅黑", 10.5F);
this.uiTextBox2.Location = new System.Drawing.Point(13, 60);
this.uiTextBox2.Location = new System.Drawing.Point(13, 44);
this.uiTextBox2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiTextBox2.MinimumSize = new System.Drawing.Size(1, 16);
this.uiTextBox2.Name = "uiTextBox2";
@@ -233,8 +235,9 @@
this.uiButton1.Name = "uiButton1";
this.uiButton1.Size = new System.Drawing.Size(100, 35);
this.uiButton1.TabIndex = 31;
this.uiButton1.Text = "返回";
this.uiButton1.Text = "测试";
this.uiButton1.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiButton1.Click += new System.EventHandler(this.uiButton1_Click);
//
// uiLabel1
//
@@ -320,10 +323,40 @@
this.Column6.Name = "Column6";
this.Column6.Width = 125;
//
// uiTextBox3
//
this.uiTextBox3.Cursor = System.Windows.Forms.Cursors.IBeam;
this.uiTextBox3.Font = new System.Drawing.Font("微软雅黑", 10.5F);
this.uiTextBox3.Location = new System.Drawing.Point(118, 81);
this.uiTextBox3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.uiTextBox3.MinimumSize = new System.Drawing.Size(1, 16);
this.uiTextBox3.Name = "uiTextBox3";
this.uiTextBox3.Padding = new System.Windows.Forms.Padding(5);
this.uiTextBox3.Radius = 3;
this.uiTextBox3.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
this.uiTextBox3.ShowText = false;
this.uiTextBox3.Size = new System.Drawing.Size(91, 28);
this.uiTextBox3.TabIndex = 36;
this.uiTextBox3.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.uiTextBox3.Watermark = "";
//
// uiLabel2
//
this.uiLabel2.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiLabel2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.uiLabel2.Location = new System.Drawing.Point(49, 79);
this.uiLabel2.Name = "uiLabel2";
this.uiLabel2.Size = new System.Drawing.Size(110, 30);
this.uiLabel2.TabIndex = 37;
this.uiLabel2.Text = "序号:";
this.uiLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// ScanImport
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(982, 693);
this.Controls.Add(this.uiTextBox3);
this.Controls.Add(this.uiLabel2);
this.Controls.Add(this.uiLabel1);
this.Controls.Add(this.uiTextBox1);
this.Controls.Add(this.uiButton1);
@@ -366,5 +399,7 @@
private System.Windows.Forms.DataGridViewTextBoxColumn Column7;
private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
private System.Windows.Forms.DataGridViewTextBoxColumn Column6;
private Sunny.UI.UITextBox uiTextBox3;
private Sunny.UI.UILabel uiLabel2;
}
}

View File

@@ -14,6 +14,8 @@ namespace 全自动水压检测仪
{
public partial class ScanImport : UIForm
{
private NormalTemperatureMode _normalTemperatureMode;
private ConductivityRepository _repository;
public ScanImport()
{
@@ -24,14 +26,14 @@ namespace 全自动水压检测仪
private void save_Click(object sender, EventArgs e)
{
double diffpressure = 0, exit_temperature = 0, dwelltime = 0, temperature = 0;
double.TryParse(uiTextBox4.Text, out diffpressure);
double.TryParse(uiTextBox9.Text, out exit_temperature);
double.TryParse(uiTextBox5.Text, out dwelltime);
double.TryParse(uiTextBox1.Text, out temperature);
float diffpressure = 0,exit_temperature = 0, dwelltime = 0, temperature = 0;
float.TryParse(uiTextBox4.Text, out diffpressure);
float.TryParse(uiTextBox9.Text, out exit_temperature);
float.TryParse(uiTextBox5.Text, out dwelltime);
float.TryParse(uiTextBox1.Text, out temperature);
_repository.InsertScanItems(new ScanData
{
barcode = uiTextBox4.Text,
barcode = uiTextBox2.Text,
diffpressure = diffpressure,
exit_temperature = exit_temperature,
dwelltime = dwelltime,
@@ -54,5 +56,33 @@ namespace 全自动水压检测仪
uiDataGridView1.Refresh();
}
private void SwitchWindow<T>(ref T windowInstance, Func<T> createFunc) where T : UIForm
{
if (windowInstance == null || windowInstance.IsDisposed)
{
windowInstance = createFunc();
windowInstance.FormClosed += (s, e) =>
{
this.Invoke(new Action(() =>
{
this.Show();
this.Activate();
}));
};
}
else
{
windowInstance.Activate();
return;
}
this.Hide();
windowInstance.Show();
}
private void uiButton1_Click(object sender, EventArgs e)
{
SwitchWindow(ref _normalTemperatureMode, () => new NormalTemperatureMode());
}
}
}