78 lines
2.6 KiB
C#
78 lines
2.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
|
|
{
|
|
public partial class LoginForm : Form
|
|
{
|
|
public LoginForm()
|
|
{
|
|
InitializeComponent();
|
|
textBox1.Text = "admin";
|
|
textBox2.Text = "admin";
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(textBox1.Text) || string.IsNullOrWhiteSpace(textBox2.Text) || comboBox1.SelectedValue == null)
|
|
{
|
|
MessageBox.Show("输入信息为空,请确认");
|
|
}
|
|
|
|
SQLiteHelper<t_user> sQLiteHelper = new db.SQLiteHelper<t_user>();
|
|
var result = sQLiteHelper.QuerySingle(a=>a.username == textBox1.Text && a.password == textBox2.Text);
|
|
|
|
SQLiteHelper<t_line> sQLiteHelper1 = new db.SQLiteHelper<t_line>();
|
|
var result_combox = sQLiteHelper1.QuerySingle(a=>a.id == (int)comboBox1.SelectedValue);
|
|
|
|
if (!result.Success || !result_combox.Success)
|
|
{
|
|
MessageBox.Show("账号/密码/产线错误!");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
SQLiteHelper<t_lineplc> sQLiteHelper_lineplc = new db.SQLiteHelper<t_lineplc>();
|
|
var lineplc_result = sQLiteHelper_lineplc.Query(a => a.lineid == result_combox.Data.id);
|
|
if (!lineplc_result.Success)
|
|
{
|
|
MessageBox.Show("无法初始化PLC-产线关联信息!");
|
|
return;
|
|
}
|
|
|
|
Init.t_Lineplcs = lineplc_result.Data;
|
|
Init.t_User = result.Data;
|
|
Init.t_Line = result_combox.Data;
|
|
DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
}
|
|
|
|
private void LoginForm_Load(object sender, EventArgs e)
|
|
{
|
|
SQLiteHelper<t_line> sQLiteHelper1 = new db.SQLiteHelper<t_line>();
|
|
var result_combox = sQLiteHelper1.QueryAll();
|
|
if (!result_combox.Success)
|
|
{
|
|
MessageBox.Show("查询失败");
|
|
return;
|
|
}
|
|
|
|
// 绑定数据源到 ComboBox
|
|
comboBox1.DataSource = result_combox.Data;
|
|
comboBox1.DisplayMember = "linename";
|
|
comboBox1.ValueMember = "id";
|
|
}
|
|
}
|
|
}
|