416 添加OEE报警相关

This commit is contained in:
gf zhou committed 2025-04-17 09:20:19 +08:00
1 parent 233737bc31
commit 9c5ef7bb31
12 files changed
+1164 -171

No files matched your search

+198
View File
@@ -0,0 +1,198 @@
namespace WindowsFormsApp1.form
{
partial class OEEaddress_Manage
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.id = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.plcid = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.code = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.type = new System.Windows.Forms.DataGridViewComboBoxColumn();
this.dbaddress = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.addresstype = new System.Windows.Forms.DataGridViewComboBoxColumn();
this.addresstypelegth = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.addressoffset = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.addressdecimal = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.button1 = new System.Windows.Forms.Button();
this.查询 = new System.Windows.Forms.Button();
this.保存 = new System.Windows.Forms.Button();
this.关闭 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// dataGridView1
//
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.id,
this.plcid,
this.code,
this.type,
this.dbaddress,
this.addresstype,
this.addresstypelegth,
this.addressoffset,
this.addressdecimal});
this.dataGridView1.Location = new System.Drawing.Point(12, 41);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(1044, 397);
this.dataGridView1.TabIndex = 0;
//
// id
//
this.id.DataPropertyName = "id";
this.id.HeaderText = "id";
this.id.Name = "id";
//
// plcid
//
this.plcid.DataPropertyName = "plcid";
this.plcid.HeaderText = "plcid";
this.plcid.Name = "plcid";
//
// code
//
this.code.DataPropertyName = "code";
this.code.HeaderText = "code";
this.code.Name = "code";
//
// type
//
this.type.DataPropertyName = "type";
this.type.HeaderText = "类型";
this.type.Name = "type";
//
// dbaddress
//
this.dbaddress.DataPropertyName = "dbaddress";
this.dbaddress.HeaderText = "地址";
this.dbaddress.Name = "dbaddress";
//
// addresstype
//
this.addresstype.DataPropertyName = "addresstype";
this.addresstype.HeaderText = "地址类型";
this.addresstype.Name = "addresstype";
//
// addresstypelegth
//
this.addresstypelegth.DataPropertyName = "addresstypelegth";
this.addresstypelegth.HeaderText = "地址长度";
this.addresstypelegth.Name = "addresstypelegth";
//
// addressoffset
//
this.addressoffset.DataPropertyName = "addressoffset";
this.addressoffset.HeaderText = "地址偏移";
this.addressoffset.Name = "addressoffset";
//
// addressdecimal
//
this.addressdecimal.DataPropertyName = "addressdecimal";
this.addressdecimal.HeaderText = "位地址";
this.addressdecimal.Name = "addressdecimal";
//
// button1
//
this.button1.Location = new System.Drawing.Point(12, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "新增";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// 查询
//
this.查询.Location = new System.Drawing.Point(93, 12);
this.查询.Name = "查询";
this.查询.Size = new System.Drawing.Size(75, 23);
this.查询.TabIndex = 2;
this.查询.Text = "查询";
this.查询.UseVisualStyleBackColor = true;
this.查询.Click += new System.EventHandler(this.查询_Click);
//
// 保存
//
this.保存.Location = new System.Drawing.Point(174, 12);
this.保存.Name = "保存";
this.保存.Size = new System.Drawing.Size(75, 23);
this.保存.TabIndex = 3;
this.保存.Text = "保存";
this.保存.UseVisualStyleBackColor = true;
this.保存.Click += new System.EventHandler(this.保存_Click);
//
// 关闭
//
this.关闭.Location = new System.Drawing.Point(255, 12);
this.关闭.Name = "关闭";
this.关闭.Size = new System.Drawing.Size(75, 23);
this.关闭.TabIndex = 4;
this.关闭.Text = "关闭";
this.关闭.UseVisualStyleBackColor = true;
this.关闭.Click += new System.EventHandler(this.关闭_Click);
//
// OEEaddress_Manage
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1068, 450);
this.Controls.Add(this.关闭);
this.Controls.Add(this.保存);
this.Controls.Add(this.查询);
this.Controls.Add(this.button1);
this.Controls.Add(this.dataGridView1);
this.Name = "OEEaddress_Manage";
this.Text = "OEE地址管理";
this.Load += new System.EventHandler(this.OEEaddress_Manage_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button 查询;
private System.Windows.Forms.Button 保存;
private System.Windows.Forms.Button 关闭;
private System.Windows.Forms.DataGridViewTextBoxColumn id;
private System.Windows.Forms.DataGridViewTextBoxColumn plcid;
private System.Windows.Forms.DataGridViewTextBoxColumn code;
private System.Windows.Forms.DataGridViewComboBoxColumn type;
private System.Windows.Forms.DataGridViewTextBoxColumn dbaddress;
private System.Windows.Forms.DataGridViewTextBoxColumn plcname;
private System.Windows.Forms.DataGridViewComboBoxColumn addresstype;
private System.Windows.Forms.DataGridViewTextBoxColumn addresstypelegth;
private System.Windows.Forms.DataGridViewTextBoxColumn addressoffset;
private System.Windows.Forms.DataGridViewTextBoxColumn addressdecimal;
}
}
+204
View File
@@ -0,0 +1,204 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WindowsFormsApp1.db;
using WindowsFormsApp1.mod;
namespace WindowsFormsApp1.form
{
public partial class OEEaddress_Manage : Form
{
public OEEaddress_Manage()
{
InitializeComponent();
}
private void 查询_Click(object sender, EventArgs e)
{
GetInfo();
}
private void 保存_Click(object sender, EventArgs e)
{
try
{
SQLiteHelper<t_oeeaddress> sQLiteHelper = new db.SQLiteHelper<t_oeeaddress>();
var result = sQLiteHelper.UpdateAll((List<t_oeeaddress>)dataGridView1.DataSource);
if (result.Success)
{
MessageBox.Show("更新成功");
GetInfo();
}
else
{
MessageBox.Show("更新失败");
}
}
catch (Exception ex)
{
MessageBox.Show($"更新失败,错误原因{ex.Message}");
}
}
private void 关闭_Click(object sender, EventArgs e)
{
this.Close();
}
private void OEEaddress_Manage_Load(object sender, EventArgs e)
{
dataGridView1.AutoGenerateColumns = false;
SQLiteHelper<t_plc> sQLiteHelper1 = new db.SQLiteHelper<t_plc>();
var result_combox = sQLiteHelper1.QueryAll();
if (!result_combox.Success)
{
MessageBox.Show("查询失败");
return;
}
var result1 = new List<object>
{
new {name = "read",value = "read"},
new {name = "write",value = "write"}
};
var result2 = new List<object>
{
new {name = "real",value = "real"},
new {name = "string",value = "string"},
new {name = "uint",value = "uint"},
new {name = "bool",value = "bool"},
new {name = "int",value = "int"},
new {name = "dint",value = "dint"},
new {name = "byte",value = "byte"},
};
var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridView1.Columns[3];
// 绑定数据源到 ComboBox
comboBoxColumn.DataSource = result1;
comboBoxColumn.DisplayMember = "name";
comboBoxColumn.ValueMember = "value";
comboBoxColumn.DataPropertyName = "type";
var comboBoxColumn1 = (DataGridViewComboBoxColumn)dataGridView1.Columns[5];
// 绑定数据源到 ComboBox
comboBoxColumn1.DataSource = result2;
comboBoxColumn1.DisplayMember = "name";
comboBoxColumn1.ValueMember = "value";
comboBoxColumn1.DataPropertyName = "addresstype";
DataGridViewButtonColumn modifyColumn = new DataGridViewButtonColumn();
modifyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
modifyColumn.Name = "ModifyColumn";
modifyColumn.HeaderText = "修改";
modifyColumn.Text = "修改";
modifyColumn.UseColumnTextForButtonValue = true;
dataGridView1.Columns.Add(modifyColumn);
// 添加删除按钮列
DataGridViewButtonColumn deleteColumn = new DataGridViewButtonColumn();
deleteColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
deleteColumn.Name = "DeleteColumn";
deleteColumn.HeaderText = "删除";
deleteColumn.Text = "删除";
deleteColumn.UseColumnTextForButtonValue = true;
dataGridView1.CellContentClick += DataGridView1_CellContentClick;
dataGridView1.Columns.Add(deleteColumn);
GetInfo();
}
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
// 检查点击的是否为按钮列
if (e.RowIndex >= 0)
{
DataGridView dataGridView = (DataGridView)sender;
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
int selectid = int.Parse(row.Cells[0].Value.ToString());
if (e.ColumnIndex == 9)
{
OEEaddress_Insert oeeInsert = new OEEaddress_Insert();
oeeInsert.dataid = selectid;
oeeInsert.Operation = OperationType.Edit;
oeeInsert.ShowDialog();
GetInfo();
}
else if (e.ColumnIndex == 10)
{
DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (result == DialogResult.OK)
{
SQLiteHelper<t_oeeaddress> sQLiteHelper = new db.SQLiteHelper<t_oeeaddress>();
var delresult = sQLiteHelper.Delete(selectid);
if (delresult.Success)
{
MessageBox.Show("删除成功");
}
else
{
MessageBox.Show("删除失败");
}
GetInfo();
}
}
}
}
public void GetInfo()
{
try
{
dataGridView1.DataSource = null;
SQLiteHelper<t_oeeaddress> sQLiteHelper = new db.SQLiteHelper<t_oeeaddress>();
var result = sQLiteHelper.QueryAll();
if (result.Success)
{
List<object> list = new List<object>();
foreach (var plcaddress in result.Data)
{
list.Add(new
{
id = plcaddress.id,
plcid = plcaddress.plcid,
code = plcaddress.code,
type = plcaddress.type,
dbaddress = plcaddress.dbaddress,
addresstype = plcaddress.addresstype,
addresstypelegth = plcaddress.addresstypelegth,
addressoffset = plcaddress.addressoffset,
remark = plcaddress.remark,
value = plcaddress.value,
addressdecimal = plcaddress.addressdecimal
});
}
dataGridView1.DataSource = list;
dataGridView1.Refresh();
}
}
catch (Exception ex)
{
MessageBox.Show($"查询失败,错误原因:{ex.Message}");
}
}
private void button1_Click(object sender, EventArgs e)
{
OEEaddress_Insert oeeInsert = new OEEaddress_Insert();
oeeInsert.ShowDialog();
GetInfo();
}
}
}
@@ -0,0 +1,276 @@
namespace WindowsFormsApp1.form
{
partial class OEEaddress_Insert
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.comboBox2 = new System.Windows.Forms.ComboBox();
this.label4 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.comboBox3 = new System.Windows.Forms.ComboBox();
this.label6 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.textBox4 = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.textBox5 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.label9 = new System.Windows.Forms.Label();
this.textBox6 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 15);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(29, 12);
this.label1.TabIndex = 0;
this.label1.Text = "PLC:";
//
// comboBox1
//
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(47, 12);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 20);
this.comboBox1.TabIndex = 1;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 41);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(35, 12);
this.label2.TabIndex = 2;
this.label2.Text = "编码:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(47, 38);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(121, 21);
this.textBox1.TabIndex = 3;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 68);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(35, 12);
this.label3.TabIndex = 4;
this.label3.Text = "类型:";
//
// comboBox2
//
this.comboBox2.FormattingEnabled = true;
this.comboBox2.Location = new System.Drawing.Point(47, 65);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(121, 20);
this.comboBox2.TabIndex = 5;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 95);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(35, 12);
this.label4.TabIndex = 6;
this.label4.Text = "地址:";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(47, 92);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(121, 21);
this.textBox2.TabIndex = 7;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(12, 122);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(59, 12);
this.label5.TabIndex = 8;
this.label5.Text = "地址类型:";
//
// comboBox3
//
this.comboBox3.FormattingEnabled = true;
this.comboBox3.Location = new System.Drawing.Point(77, 119);
this.comboBox3.Name = "comboBox3";
this.comboBox3.Size = new System.Drawing.Size(91, 20);
this.comboBox3.TabIndex = 9;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(12, 149);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(59, 12);
this.label6.TabIndex = 10;
this.label6.Text = "地址长度:";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(77, 146);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(91, 21);
this.textBox3.TabIndex = 11;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(12, 176);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(59, 12);
this.label7.TabIndex = 12;
this.label7.Text = "地址偏移:";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(77, 173);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(91, 21);
this.textBox4.TabIndex = 13;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(12, 206);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(59, 12);
this.label8.TabIndex = 14;
this.label8.Text = "位地址值:";
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(77, 203);
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(91, 21);
this.textBox6.TabIndex = 15;
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(12, 236);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(59, 12);
this.label9.TabIndex = 16;
this.label9.Text = "备注:";
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(77, 233);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(91, 21);
this.textBox5.TabIndex = 17;
//
// button1
//
this.button1.Location = new System.Drawing.Point(14, 264);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 18;
this.button1.Text = "确定";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(95, 264);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 19;
this.button2.Text = "取消";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// OEEaddress_Insert
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(184, 299);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox6);
this.Controls.Add(this.label9);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.label8);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.label7);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.label6);
this.Controls.Add(this.comboBox3);
this.Controls.Add(this.label5);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label4);
this.Controls.Add(this.comboBox2);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label1);
this.Name = "OEEaddress_Insert";
this.Text = "OEE地址编辑";
this.Load += new System.EventHandler(this.OEEaddress_Insert_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox comboBox2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.ComboBox comboBox3;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox textBox6;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
}
}
@@ -0,0 +1,130 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WindowsFormsApp1.db;
using WindowsFormsApp1.mod;
namespace WindowsFormsApp1.form
{
public partial class OEEaddress_Insert : Form
{
public int dataid { get; set; }
public OperationType Operation { get; set; } = OperationType.Add;
public OEEaddress_Insert()
{
InitializeComponent();
}
private void OEEaddress_Insert_Load(object sender, EventArgs e)
{
SQLiteHelper<t_plc> sQLiteHelper = new db.SQLiteHelper<t_plc>();
var result = sQLiteHelper.QueryAll();
if (result.Success)
{
comboBox1.DataSource = result.Data;
comboBox1.DisplayMember = "plcname";
comboBox1.ValueMember = "id";
comboBox1.SelectedValue = Init.t_Line.plcid;
}
comboBox2.Items.Add("read");
comboBox2.Items.Add("write");
comboBox2.SelectedIndex = 0;
comboBox3.Items.Add("bool");
comboBox3.Items.Add("real");
comboBox3.Items.Add("string");
comboBox3.Items.Add("uint");
comboBox3.Items.Add("int");
comboBox3.Items.Add("dint");
comboBox3.Items.Add("byte");
comboBox3.SelectedIndex = 0;
if (Operation == OperationType.Edit)
{
SQLiteHelper<t_oeeaddress> sQLiteHelper1 = new db.SQLiteHelper<t_oeeaddress>();
var result1 = sQLiteHelper1.QuerySingle(x => x.id == dataid);
if (result1.Success)
{
comboBox1.SelectedValue = result1.Data.plcid;
textBox1.Text = result1.Data.code;
comboBox2.Text = result1.Data.type;
textBox2.Text = result1.Data.dbaddress;
comboBox3.Text = result1.Data.addresstype;
textBox3.Text = result1.Data.addresstypelegth.ToString();
textBox4.Text = result1.Data.addressoffset.ToString();
textBox6.Text = result1.Data.addressdecimal.ToString();
textBox5.Text = result1.Data.remark;
}
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
t_oeeaddress t_Oeeaddress = new t_oeeaddress();
t_Oeeaddress.plcid = (int)comboBox1.SelectedValue;
t_Oeeaddress.code = textBox1.Text;
t_Oeeaddress.type = comboBox2.Text;
t_Oeeaddress.dbaddress = textBox2.Text;
t_Oeeaddress.addresstype = comboBox3.Text;
t_Oeeaddress.addresstypelegth = int.Parse(textBox3.Text);
t_Oeeaddress.addressoffset = int.Parse(textBox4.Text);
t_Oeeaddress.remark = textBox5.Text;
// 处理位地址
if (!string.IsNullOrEmpty(textBox6.Text) && int.TryParse(textBox6.Text, out int bitOffset))
{
t_Oeeaddress.addressdecimal = bitOffset;
}
SQLiteHelper<t_oeeaddress> sQLiteHelper = new db.SQLiteHelper<t_oeeaddress>();
if (Operation == OperationType.Add)
{
var result = sQLiteHelper.Insert(t_Oeeaddress);
if (result.Success)
{
MessageBox.Show("添加成功");
this.Close();
}
else
{
MessageBox.Show("添加失败");
}
}
else
{
t_Oeeaddress.id = dataid;
var result = sQLiteHelper.Update(t_Oeeaddress);
if (result.Success)
{
MessageBox.Show("修改成功");
this.Close();
}
else
{
MessageBox.Show("修改失败");
}
}
}
catch (Exception ex)
{
MessageBox.Show($"操作失败,错误原因:{ex.Message}");
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
}
}