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

@@ -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();
}
}
}