137 lines
4.6 KiB
C#
137 lines
4.6 KiB
C#
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;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
|
namespace WindowsFormsApp1.form
|
|
{
|
|
public partial class LINE_Manage : Form
|
|
{
|
|
public LINE_Manage()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void 查询_Click(object sender, EventArgs e)
|
|
{
|
|
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();
|
|
}
|
|
|
|
private void LINE_Manage_Load(object sender, EventArgs e)
|
|
{
|
|
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 字段
|
|
|
|
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)
|
|
{
|
|
dataGridView1.DataSource = null;
|
|
dataGridView1.DataSource = result.Data;
|
|
dataGridView1.Refresh();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|