25111702 调整登陆界面允许添加超级管理员新密码

This commit is contained in:
moxiliang
2025-11-17 16:52:59 +08:00
parent 6958075f22
commit 220a794a5b
27 changed files with 350 additions and 340 deletions

View File

@@ -1,4 +1,5 @@
using System;
using Sunny.UI;
using System;
using System.Windows.Forms;
namespace SLC1_N
@@ -17,53 +18,66 @@ namespace SLC1_N
Timer_timeShow.Interval = 1000;
Timer_timeShow.Start();
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")
{
Timer_timeShow.Stop();
Form1.f1.lb_User.Text = "厂商";
Form1.f1.User = "厂商";
this.Close();
}
else
{
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.lb_User.Text = "工程师";
Form1.f1.User = "工程师";
Timer_timeShow.Stop();
this.Close();
bPassword = true;
}
else if (Password.Text== userpassword2)
else if (tb_Password.Text == password_管理员)
{
Form1.f1.lb_User.Text = "管理员";
Form1.f1.User = "管理员";
Timer_timeShow.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 = "超级管理员";
Timer_timeShow.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();
}
}
}
@@ -73,11 +87,12 @@ namespace SLC1_N
}
}
// 密码回车
private void Password_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == System.Windows.Forms.Keys.Enter)
{
Log.PerformClick(); //执行单击button的动作
Log.PerformClick();
}
}
@@ -89,20 +104,45 @@ namespace SLC1_N
//}
}
// 显示时间
private void Timer1_Tick(object sender, EventArgs e)
{
Logtime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
private void Account_KeyDown(object sender, KeyEventArgs e)
// 添加密码
private void bt_PasswordAdd_Click(object sender, EventArgs e)
{
e.Handled = true;
}
if (Form1.f1.User == "厂商" || Form1.f1.User == "超级管理员")
{
var jsconfig = new JsonConfig("config.json");
string userPassword = jsconfig.GetValue<string>("userPassword", "8888");
private void timer2_Tick(object sender, EventArgs e)
{
Form1.f1.lb_User.Text = "操作员";
Form1.f1.User = "操作员";
if (!tb_Password.Text.Trim().IsNullOrEmpty())
{
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("非法用户!");
}
}
}
}