增加修改删除页面,增加COM口的配置等

This commit is contained in:
bnala committed 2025-02-23 20:06:16 +08:00
1 parent f3110791a7
commit e96e2d3651
89 files changed
+10692 -727

No files matched your search

+64 -83
View File
@@ -13,9 +13,9 @@ using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace WindowsFormsApp1.form
{
public partial class LINE_Manage : Form
public partial class Line_Manage : Form
{
public LINE_Manage()
public Line_Manage()
{
InitializeComponent();
}
@@ -25,39 +25,6 @@ namespace WindowsFormsApp1.form
GetInfo();
}
private void 保存_Click(object sender, EventArgs e)
{
try
{
SQLiteHelper<t_line> sQLiteHelper = new db.SQLiteHelper<t_line>();
var result = sQLiteHelper.UpdateAll((List<t_line>)dataGridView1.DataSource);
if (result.Success)
{
MessageBox.Show("更新成功");
SQLiteHelper<t_line> sQLiteHelper1 = new db.SQLiteHelper<t_line>();
var result_combox = sQLiteHelper1.QuerySingle(a => a.id == Init.t_Line.id);
if (!result_combox.Success)
{
MessageBox.Show("更新产线配置失败!");
return;
}
else
{
Init.t_Line = result_combox.Data;
GetInfo();
}
}
else
{
MessageBox.Show("更新失败");
}
}
catch (Exception ex)
{
MessageBox.Show($"更新失败,错误原因{ex.Message}");
}
}
private void 关闭_Click(object sender, EventArgs e)
{
this.Close();
@@ -67,64 +34,71 @@ namespace WindowsFormsApp1.form
{
dataGridView1.AutoGenerateColumns = false;
SQLiteHelper<t_flow> sQLiteHelper1 = new db.SQLiteHelper<t_flow>();
var result = sQLiteHelper1.QueryAll();
if (!result.Success)
{
MessageBox.Show("查询失败!");
return;
}
var result1 = result.Data.GroupBy(a => a.flowid).ToList();
SQLiteHelper<t_plc> sQLiteHelper2 = new db.SQLiteHelper<t_plc>();
var result2 = sQLiteHelper2.QueryAll();
if (!result2.Success)
{
MessageBox.Show("查询失败!");
return;
}
result2.Data.Insert(0, new t_plc { id = 0, plcip = "" });
var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridView1.Columns[5];
// 绑定数据源到 ComboBox
comboBoxColumn.DataSource = result2.Data;
comboBoxColumn.DisplayMember = "plcip";
comboBoxColumn.ValueMember = "id";
//// 设置默认值为 Product 的 CategoryId
comboBoxColumn.DataPropertyName = "plcid1"; // 绑定数据源中的 CategoryId 字段
var comboBoxColumn1 = (DataGridViewComboBoxColumn)dataGridView1.Columns[6];
// 绑定数据源到 ComboBox
comboBoxColumn1.DataSource = result2.Data;
comboBoxColumn1.DisplayMember = "plcip";
comboBoxColumn1.ValueMember = "id";
// 设置默认值为 Product 的 CategoryId
comboBoxColumn1.DataPropertyName = "plcid2"; // 绑定数据源中的 CategoryId 字段
var comboBoxColumn2 = (DataGridViewComboBoxColumn)dataGridView1.Columns[7];
// 绑定数据源到 ComboBox
comboBoxColumn2.DataSource = result1;
comboBoxColumn2.DisplayMember = "key";
comboBoxColumn2.ValueMember = "key";
// 设置默认值为 Product 的 CategoryId
comboBoxColumn2.DataPropertyName = "flowid"; // 绑定数据源中的 CategoryId 字段
// 添加修改按钮列
DataGridViewButtonColumn modifyColumn = new DataGridViewButtonColumn();
modifyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
modifyColumn.Name = "ModifyColumn";
modifyColumn.HeaderText = "修改";
modifyColumn.Text = "修改";
modifyColumn.UseColumnTextForButtonValue = true;
dataGridView1.Columns.Add(modifyColumn);
dataGridView1.CellContentClick += DataGridView1_CellContentClick;
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 == 6)
{
Line_Insert fLOW_Insert = new Line_Insert();
fLOW_Insert.dataid = selectid;
fLOW_Insert.Operation = OperationType.Edit;
fLOW_Insert.ShowDialog();
GetInfo();
}
}
}
public void GetInfo()
{
try
{
SQLiteHelper<t_line> sQLiteHelper = new db.SQLiteHelper<t_line>();
var result = sQLiteHelper.Query(a=>a.id == Init.t_Line.id);
if (result.Success)
SQLiteHelper<t_flow> sQLiteHelper1 = new db.SQLiteHelper<t_flow>();
var result_flow = sQLiteHelper1.QueryAll();
var result_line = sQLiteHelper.Query(a=>a.id == Init.t_Line.id);
if (!result_line.Success || !result_flow.Success)
{
MessageBox.Show("查询失败!");
return;
}
else
{
List<object> list = new List<object>();
foreach (var line in result_line.Data)
{
var flowname = result_flow.Data.FirstOrDefault(a=>a.flowid == line.flowid);
list.Add( new
{
id = line.id,
flowid = line.flowid,
linename = line.linename,
linecode = line.linecode,
linetype = line.linetype,
linemode = line.linemode,
flowname = flowname.flowname,
});
}
dataGridView1.DataSource = null;
dataGridView1.DataSource = result.Data;
dataGridView1.DataSource = list;
dataGridView1.Refresh();
}
}
@@ -132,5 +106,12 @@ namespace WindowsFormsApp1.form
{
}
}
private void 新增_Click(object sender, EventArgs e)
{
Line_Insert fLOW_Insert = new Line_Insert();
fLOW_Insert.ShowDialog();
GetInfo();
}
}
}