增加修改删除页面,增加COM口的配置等
This commit is contained in:
1 parent
f3110791a7
commit
e96e2d3651
89 files changed
+10692
-727
No files matched your search
@@ -12,9 +12,9 @@ using WindowsFormsApp1.mod;
|
||||
|
||||
namespace WindowsFormsApp1.form
|
||||
{
|
||||
public partial class PLCADDRESS_Manage : Form
|
||||
public partial class PlcAddress_Manage : Form
|
||||
{
|
||||
public PLCADDRESS_Manage()
|
||||
public PlcAddress_Manage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -55,16 +55,18 @@ namespace WindowsFormsApp1.form
|
||||
{
|
||||
dataGridView1.AutoGenerateColumns = false;
|
||||
SQLiteHelper<t_plc> sQLiteHelper1 = new db.SQLiteHelper<t_plc>();
|
||||
var result_combox = sQLiteHelper1.Query(a => a.id == Init.t_Line.plcid1 || a.id == Init.t_Line.plcid2);
|
||||
var result_combox = sQLiteHelper1.QueryAll();
|
||||
if (!result_combox.Success)
|
||||
{
|
||||
MessageBox.Show("查询失败");
|
||||
return;
|
||||
}
|
||||
|
||||
var list = result_combox.Data.FindAll(a => Init.t_Lineplcs.Select(p => p.plcid).Contains(a.id));
|
||||
|
||||
// 绑定数据源到 ComboBox
|
||||
comboBox1.DataSource = result_combox.Data;
|
||||
comboBox1.DisplayMember = "name";
|
||||
comboBox1.DataSource = list;
|
||||
comboBox1.DisplayMember = "plcname";
|
||||
comboBox1.ValueMember = "id";
|
||||
|
||||
var result1 = new List<object>
|
||||
@@ -80,7 +82,7 @@ namespace WindowsFormsApp1.form
|
||||
new {name = "uint",value = "uint"},
|
||||
};
|
||||
|
||||
var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridView1.Columns[2];
|
||||
var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridView1.Columns[3];
|
||||
// 绑定数据源到 ComboBox
|
||||
comboBoxColumn.DataSource = result1;
|
||||
comboBoxColumn.DisplayMember = "name";
|
||||
@@ -88,26 +90,107 @@ namespace WindowsFormsApp1.form
|
||||
|
||||
comboBoxColumn.DataPropertyName = "type";
|
||||
|
||||
var comboBoxColumn1 = (DataGridViewComboBoxColumn)dataGridView1.Columns[5];
|
||||
var comboBoxColumn1 = (DataGridViewComboBoxColumn)dataGridView1.Columns[6];
|
||||
// 绑定数据源到 ComboBox
|
||||
comboBoxColumn1.DataSource = result2;
|
||||
comboBoxColumn1.DisplayMember = "name";
|
||||
comboBoxColumn1.ValueMember = "value";
|
||||
|
||||
comboBoxColumn1.DataPropertyName = "addresstype";
|
||||
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);
|
||||
|
||||
}
|
||||
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)
|
||||
{
|
||||
PlcAddress_Insert fLOW_Insert = new PlcAddress_Insert();
|
||||
fLOW_Insert.dataid = selectid;
|
||||
fLOW_Insert.Operation = OperationType.Edit;
|
||||
fLOW_Insert.ShowDialog();
|
||||
GetInfo((int)comboBox1.SelectedValue);
|
||||
|
||||
}
|
||||
else if (e.ColumnIndex == 10)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
|
||||
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
SQLiteHelper<t_plcaddress> sQLiteHelper = new db.SQLiteHelper<t_plcaddress>();
|
||||
var delresult = sQLiteHelper.Delete(selectid);
|
||||
if (delresult.Success)
|
||||
{
|
||||
MessageBox.Show("删除成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("删除失败");
|
||||
}
|
||||
GetInfo((int)comboBox1.SelectedValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void GetInfo(int plcid)
|
||||
{
|
||||
try
|
||||
{
|
||||
dataGridView1.DataSource = null;
|
||||
SQLiteHelper<t_plcaddress> sQLiteHelper = new db.SQLiteHelper<t_plcaddress>();
|
||||
SQLiteHelper<t_plc> sQLiteHelper1 = new db.SQLiteHelper<t_plc>();
|
||||
var result_plc = sQLiteHelper1.QueryAll();
|
||||
var result = sQLiteHelper.Query(a=>a.plcid == plcid);
|
||||
if (result.Success)
|
||||
{
|
||||
dataGridView1.DataSource = null;
|
||||
dataGridView1.DataSource = result.Data;
|
||||
List<object> list = new List<object>();
|
||||
foreach (var plcaddress in result.Data)
|
||||
{
|
||||
var plc = result_plc.Data.FirstOrDefault(a => a.id == plcaddress.plcid);
|
||||
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,
|
||||
plcname = plc.plcname,
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
dataGridView1.DataSource = list;
|
||||
dataGridView1.Refresh();
|
||||
}
|
||||
}
|
||||
@@ -115,5 +198,12 @@ namespace WindowsFormsApp1.form
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
PlcAddress_Insert fLOW_Insert = new PlcAddress_Insert();
|
||||
fLOW_Insert.ShowDialog();
|
||||
GetInfo((int)comboBox1.SelectedValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user