代码上传
This commit is contained in:
1 parent
4150cd1c02
commit
c324c71fe9
42 files changed
+3534
No files matched your search
@@ -0,0 +1,86 @@
|
||||
using edu.huvtc.utils;
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace FileProcessClient
|
||||
{
|
||||
public partial class LoginForm : Form
|
||||
{
|
||||
public LoginForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private async void btnLogin_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
string username = txtName.Text;
|
||||
if (username.Length == 0)
|
||||
{
|
||||
MessageBox.Show("请输入账号!");
|
||||
return;
|
||||
}
|
||||
string password = txtPassword.Text;
|
||||
if (password.Length == 0)
|
||||
{
|
||||
MessageBox.Show("请输入密码!");
|
||||
return;
|
||||
}
|
||||
|
||||
//Trace.WriteLine(password);
|
||||
|
||||
Trace.WriteLine(username);
|
||||
|
||||
bool flag = await HttpUtils.validateLogin(username, password);
|
||||
if (!flag)
|
||||
{
|
||||
MessageBox.Show("用户名或密码错误,请重试");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (chkSavePassword.Checked)
|
||||
{
|
||||
CommonUtils.writeToIni("userData", "userName", Convert.ToBase64String(CommonUtils.EncryptString(username)));
|
||||
CommonUtils.writeToIni("userData", "password", Convert.ToBase64String(CommonUtils.EncryptString(password)));
|
||||
}
|
||||
|
||||
await HttpUtils.getUserInfo();
|
||||
|
||||
loadMainForm();
|
||||
}
|
||||
private void loadMainForm()
|
||||
{
|
||||
mainForm mainForm = new mainForm();
|
||||
mainForm.Show();
|
||||
this.Hide();
|
||||
}
|
||||
private async void LoginForm_Activated(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
bool valid = await HttpUtils.getUserInfo();
|
||||
if (!valid)
|
||||
{
|
||||
string name = CommonUtils.readFromFile("userData", "username");
|
||||
//Trace.WriteLine(name);
|
||||
if (name != null && name != "")
|
||||
{
|
||||
txtName.Text = CommonUtils.DecryptToString(Convert.FromBase64String(name));
|
||||
}
|
||||
|
||||
string password = CommonUtils.readFromFile("userData", "password");
|
||||
//Trace.WriteLine(name);
|
||||
if (password != null && password != "")
|
||||
{
|
||||
txtPassword.Text = CommonUtils.DecryptToString(Convert.FromBase64String(password));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loadMainForm();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user