25111701 参数设置添加批量通道配置功能;登陆界面添加超级管理员密码添加功能。

This commit is contained in:
moxiliang
2025-11-17 17:04:39 +08:00
parent 2e5ea8848d
commit de7adcb3ae
42 changed files with 837 additions and 512 deletions

View File

@@ -46,141 +46,67 @@ namespace SLC1_N
//{
// MessageBox.Show(ex.Message);
//}
Password.Focus();
tb_Password.Focus();
}
private void Log_Click(object sender, EventArgs e)
{
try
{
if (Password.Text == "linglong29529959" || Password.Text == "29529959" || Password.Text == "qwe")
if (tb_Password.Text == "linglong29529959" || tb_Password.Text == "29529959" || tb_Password.Text == "qwe")
{
Timer1.Stop();
//Form1.f1.网络设置ToolStripMenuItem.Enabled = true;
//Form1.f1.pLC控制ToolStripMenuItem.Enabled = true;
//Form1.f1.串口配置ToolStripMenuItem.Enabled = true;
//Form1.f1.测试参数ToolStripMenuItem.Enabled = true;
//Form1.f1.基本设置ToolStripMenuItem.Enabled = true;
//Form1.f1.存储设置ToolStripMenuItem.Enabled = true;
//Form1.f1.用户管理ToolStripMenuItem.Enabled = true;
//Form1.f1.
//ToolStripMenuItem.Enabled = true;
Form1.f1.lb_User.Text = "厂商";
Form1.f1.User = "厂商";
//Form1.f1.DayTime.Start();
this.Close();
//Form1.f1.Show();
}
else
{
//string filepath = System.Environment.CurrentDirectory + "\\Config\\Users\\UsersInfo.mdb";
//if (File.Exists(filepath) == false)//判断所选路径是否有文件
//{
// MessageBox.Show("请先新建用户!");
//}
//else if (String.IsNullOrEmpty(Account.Text))
//{
// MessageBox.Show("请先选择用户!");
//}
//else
//{
//string constr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + System.Environment.CurrentDirectory + "\\Config\\Users\\UsersInfo.mdb;";
//OleDbConnection con = new OleDbConnection(constr);
//con.Open();
//string sql = "SELECT * FROM UserInfo WHERE 账户='" + Account.Text + "'";
//OleDbCommand cmd2 = new OleDbCommand(sql, con);
//OleDbDataReader userinformation = cmd2.ExecuteReader();
//string userpassword = null;
//string usercharacter = null;
//while (userinformation.Read())
//{
// userpassword = Convert.ToString(userinformation["密码"]);
// usercharacter = Convert.ToString(userinformation["权限"]);
//}
//userinformation.Close();
//con.Close();
string userpassword2 = DateTime.Now.ToString("yyMMHH");
string userpassword = DateTime.Now.ToString("ddHHmm");
string userpassword3 = "ghkj.2021";
if (Password.Text == userpassword)
bool bPassword = false;
string password_管理员 = DateTime.Now.ToString("yyMMHH");
string password_工程师 = DateTime.Now.ToString("ddHHmm");
string password_超级管理员 = "ghkj.2021";
if (tb_Password.Text == password_工程师)
{
//Form1.f1.Admin.Text = Account.Text;
Form1.f1.lb_User.Text = "工程师";
Form1.f1.User = "工程师";
Timer1.Stop();
//if (usercharacter == "操作员")
//{
// Form1.f1.网络设置ToolStripMenuItem.Enabled = false;
// Form1.f1.pLC控制ToolStripMenuItem.Enabled = false;
// Form1.f1.串口配置ToolStripMenuItem.Enabled = false;
// Form1.f1.测试参数ToolStripMenuItem.Enabled = false;
// Form1.f1.基本设置ToolStripMenuItem.Enabled = false;
// Form1.f1.存储设置ToolStripMenuItem.Enabled = false;
// Form1.f1.用户管理ToolStripMenuItem.Enabled = false;
// Form1.f1.复位ToolStripMenuItem.Enabled = false;
//}
//else
//{
// Form1.f1.网络设置ToolStripMenuItem.Enabled = true;
// Form1.f1.pLC控制ToolStripMenuItem.Enabled = true;
// Form1.f1.串口配置ToolStripMenuItem.Enabled = true;
// Form1.f1.测试参数ToolStripMenuItem.Enabled = true;
// Form1.f1.基本设置ToolStripMenuItem.Enabled = true;
// Form1.f1.存储设置ToolStripMenuItem.Enabled = true;
// Form1.f1.用户管理ToolStripMenuItem.Enabled = true;
// Form1.f1.复位ToolStripMenuItem.Enabled = true;
//}
//Form1.f1.DayTime.Start();
//string logintime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
////写入登录记录
//record_con.Open();
//string sql2 = " INSERT INTO Login(账户, 登录时间) VALUES('" + Account.Text + "', '" + logintime + "')";
//OleDbCommand record_cmd = new OleDbCommand(sql2, record_con);
//record_cmd.ExecuteNonQuery();
//record_con.Close();
//Form1.f1.Show();
//Machine mac = new Machine(usercharacter);
//mac.ShowDialog();
this.Close();
bPassword = true;
}
else if (Password.Text== userpassword2)
else if (tb_Password.Text == password_管理员)
{
Form1.f1.lb_User.Text = "管理员";
Form1.f1.User = "管理员";
Timer1.Stop();
this.Close();
bPassword = true;
}
else if (Password.Text == userpassword3 || Password.Text == "123456" || Password.Text == "8888")
else if (tb_Password.Text == password_超级管理员 || tb_Password.Text == "123456")
{
Form1.f1.lb_User.Text = "超级管理员";
Form1.f1.User = "超级管理员";
Timer1.Stop();
bPassword = true;
}
var jsconfig = new JsonConfig("config.json");
string[] userPasswordArray = jsconfig.GetValue<string>("userPassword", "8888").Split('&');
for (int i = 0; i < userPasswordArray.Length; i++)
{
if (tb_Password.Text == userPasswordArray[i])
{
Form1.f1.lb_User.Text = "超级管理员";
Form1.f1.User = "超级管理员";
bPassword = true;
}
}
// 如果有登陆成功
if (bPassword)
{
this.Close();
}
else
{
MessageBox.Show("密码错误!");
Password.ResetText();
Password.Focus();
tb_Password.ResetText();
tb_Password.Focus();
}
//}
}
}
catch (Exception ex)
@@ -210,15 +136,44 @@ namespace SLC1_N
Logtime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
private void Account_KeyDown(object sender, KeyEventArgs e)
{
e.Handled = true;
}
private void timer2_Tick(object sender, EventArgs e)
{
Form1.f1.lb_User.Text = "操作员";
Form1.f1.User = "操作员";
}
private void bt_PasswordAdd_Click(object sender, EventArgs e)
{
if (Form1.f1.User == "厂商" || Form1.f1.User == "超级管理员")
{
var jsconfig = new JsonConfig("config.json");
string userPassword = jsconfig.GetValue<string>("userPassword", "8888");
if (!string.IsNullOrEmpty(tb_Password.Text.Trim()))
{
string[] userPasswordArray = userPassword.Split('&');
for (int i = 0; i < userPasswordArray.Length; i++)
{
if (tb_Password.Text == userPasswordArray[i])
{
MessageBox.Show("密码已存在!");
return;
}
}
userPassword += $"&{tb_Password.Text}";
jsconfig.SetValue("userPassword", userPassword);
MessageBox.Show("添加成功!");
}
else
{
MessageBox.Show("密码不可为空!");
}
}
else
{
MessageBox.Show("非法用户!");
}
}
}
}