添加项目文件。
This commit is contained in:
1 parent
d68cdea124
commit
faaf9136d6
51 files changed
+11674
No files matched your search
@@ -0,0 +1,119 @@
|
||||
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 PLCADDRESS_Manage : Form
|
||||
{
|
||||
public PLCADDRESS_Manage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void 查询_Click(object sender, EventArgs e)
|
||||
{
|
||||
GetInfo((int)comboBox1.SelectedValue);
|
||||
}
|
||||
|
||||
private void 保存_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
SQLiteHelper<t_plcaddress> sQLiteHelper = new db.SQLiteHelper<t_plcaddress>();
|
||||
var result = sQLiteHelper.UpdateAll((List<t_plcaddress>)dataGridView1.DataSource);
|
||||
if (result.Success)
|
||||
{
|
||||
MessageBox.Show("更新成功");
|
||||
GetInfo((int)comboBox1.SelectedValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("更新失败");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"更新失败,错误原因{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void 关闭_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void PLCADDRESS_Manage_Load(object sender, EventArgs e)
|
||||
{
|
||||
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);
|
||||
if (!result_combox.Success)
|
||||
{
|
||||
MessageBox.Show("查询失败");
|
||||
return;
|
||||
}
|
||||
|
||||
// 绑定数据源到 ComboBox
|
||||
comboBox1.DataSource = result_combox.Data;
|
||||
comboBox1.DisplayMember = "name";
|
||||
comboBox1.ValueMember = "id";
|
||||
|
||||
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"},
|
||||
};
|
||||
|
||||
var comboBoxColumn = (DataGridViewComboBoxColumn)dataGridView1.Columns[2];
|
||||
// 绑定数据源到 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";
|
||||
|
||||
}
|
||||
|
||||
public void GetInfo(int plcid)
|
||||
{
|
||||
try
|
||||
{
|
||||
SQLiteHelper<t_plcaddress> sQLiteHelper = new db.SQLiteHelper<t_plcaddress>();
|
||||
var result = sQLiteHelper.Query(a=>a.plcid == plcid);
|
||||
if (result.Success)
|
||||
{
|
||||
dataGridView1.DataSource = null;
|
||||
dataGridView1.DataSource = result.Data;
|
||||
dataGridView1.Refresh();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user