增加修改删除页面,增加COM口的配置等
This commit is contained in:
1 parent
f3110791a7
commit
e96e2d3651
89 files changed
+10692
-727
No files matched your search
@@ -9,12 +9,13 @@ using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using WindowsFormsApp1.db;
|
||||
using WindowsFormsApp1.mod;
|
||||
using static SQLite.SQLite3;
|
||||
|
||||
namespace WindowsFormsApp1.form
|
||||
{
|
||||
public partial class FLOW_Manage : Form
|
||||
public partial class Flow_Manage : Form
|
||||
{
|
||||
public FLOW_Manage()
|
||||
public Flow_Manage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -54,47 +55,108 @@ namespace WindowsFormsApp1.form
|
||||
private void FLOW_Mange_Load(object sender, EventArgs e)
|
||||
{
|
||||
dataGridView1.AutoGenerateColumns = false;
|
||||
// 添加修改按钮列
|
||||
DataGridViewButtonColumn modifyColumn = new DataGridViewButtonColumn();
|
||||
modifyColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
modifyColumn.Name = "ModifyColumn";
|
||||
modifyColumn.HeaderText = "修改";
|
||||
modifyColumn.Text = "修改";
|
||||
modifyColumn.UseColumnTextForButtonValue = true;
|
||||
dataGridView1.Columns.Add(modifyColumn);
|
||||
|
||||
SQLiteHelper<t_interface> sQLiteHelper1 = new db.SQLiteHelper<t_interface>();
|
||||
var result1 = sQLiteHelper1.QueryAll();
|
||||
if (!result1.Success)
|
||||
{
|
||||
MessageBox.Show("查询失败");
|
||||
return;
|
||||
}
|
||||
result1.Data.Insert(0, new t_interface { id = 0, name = "" });
|
||||
|
||||
var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridView1.Columns[3];
|
||||
// 绑定数据源到 ComboBox
|
||||
comboBoxColumn.DataSource = result1.Data;
|
||||
comboBoxColumn.DisplayMember = "name";
|
||||
comboBoxColumn.ValueMember = "id";
|
||||
|
||||
// 设置默认值为 Product 的 CategoryId
|
||||
comboBoxColumn.DataPropertyName = "hopeinterfaceid"; // 绑定数据源中的 CategoryId 字段
|
||||
|
||||
var comboBoxColumn1 = (DataGridViewComboBoxColumn)dataGridView1.Columns[5];
|
||||
// 绑定数据源到 ComboBox
|
||||
comboBoxColumn1.DataSource = result1.Data;
|
||||
comboBoxColumn1.DisplayMember = "name";
|
||||
comboBoxColumn1.ValueMember = "id";
|
||||
|
||||
// 设置默认值为 Product 的 CategoryId
|
||||
comboBoxColumn1.DataPropertyName = "errinterfaceid"; // 绑定数据源中的 CategoryId 字段
|
||||
// 添加删除按钮列
|
||||
DataGridViewButtonColumn deleteColumn = new DataGridViewButtonColumn();
|
||||
deleteColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
deleteColumn.Name = "DeleteColumn";
|
||||
deleteColumn.HeaderText = "删除";
|
||||
deleteColumn.Text = "删除";
|
||||
deleteColumn.UseColumnTextForButtonValue = true;
|
||||
dataGridView1.Columns.Add(deleteColumn);
|
||||
|
||||
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 == 15)
|
||||
{
|
||||
FLow_Insert fLOW_Insert = new FLow_Insert();
|
||||
fLOW_Insert.dataid = selectid;
|
||||
fLOW_Insert.Operation = OperationType.Edit;
|
||||
fLOW_Insert.ShowDialog();
|
||||
GetInfo();
|
||||
|
||||
}
|
||||
else if (e.ColumnIndex == 16)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
|
||||
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
SQLiteHelper<t_flow> sQLiteHelper = new db.SQLiteHelper<t_flow>();
|
||||
var delresult = sQLiteHelper.Delete(selectid);
|
||||
if (delresult.Success)
|
||||
{
|
||||
MessageBox.Show("删除成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("删除失败");
|
||||
}
|
||||
GetInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void GetInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
SQLiteHelper<t_flow> sQLiteHelper = new db.SQLiteHelper<t_flow>();
|
||||
var result = sQLiteHelper.Query(a => a.flowid == Init.t_Line.flowid);
|
||||
if (result.Success)
|
||||
SQLiteHelper<t_interface> sQLiteHelper1 = new db.SQLiteHelper<t_interface>();
|
||||
var result_inf = sQLiteHelper1.QueryAll();
|
||||
var result_flow = sQLiteHelper.Query(a => a.flowid == Init.t_Line.flowid);
|
||||
if (!result_flow.Success || !result_inf.Success)
|
||||
{
|
||||
MessageBox.Show("查询失败!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
List<object> list = new List<object>();
|
||||
foreach (var flow in result_flow.Data)
|
||||
{
|
||||
var errinterface = result_inf.Data.FirstOrDefault(a => a.id == flow.errinterfaceid);
|
||||
var hopeinterface = result_inf.Data.FirstOrDefault(a => a.id == flow.hopeinterfaceid);
|
||||
list.Add(new
|
||||
{
|
||||
id = flow.id,
|
||||
flowname = flow.flowname,
|
||||
flowid = flow.flowid,
|
||||
setp = flow.setp,
|
||||
hopeinterfaceid = hopeinterface?.name,
|
||||
errinterfaceid = errinterface?.name,
|
||||
hopestatus = flow.hopestatus,
|
||||
errstatus = flow.errstatus,
|
||||
scan = flow.scan,
|
||||
fileupload = flow.fileupload,
|
||||
finaltorquevalue = flow.finaltorquevalue,
|
||||
finalanglevaluue = flow.finalanglevaluue,
|
||||
finaltorquecurve = flow.finaltorquecurve,
|
||||
finalpressurecurve = flow.finalpressurecurve,
|
||||
airtight = flow.airtight,
|
||||
|
||||
});
|
||||
}
|
||||
dataGridView1.DataSource = null;
|
||||
dataGridView1.DataSource = result.Data;
|
||||
dataGridView1.DataSource = list;
|
||||
dataGridView1.Refresh();
|
||||
}
|
||||
|
||||
@@ -103,5 +165,12 @@ namespace WindowsFormsApp1.form
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
FLow_Insert fLOW_Insert = new FLow_Insert();
|
||||
fLOW_Insert.ShowDialog();
|
||||
GetInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user