123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Welling_Motor_Debug_Tool
- {
- public partial class Login : Form
- {
- LocalInfo localInfo = new LocalInfo();
- public Login()
- {
- InitializeComponent();
- }
- public Dictionary<string, string> UserAccount = new Dictionary<string, string>();
- private void Login_Load(object sender, EventArgs e)
- {
- UserAccount.Clear();
- //读取账户信息
- try
- {
- //检查配置文件
- if (!Directory.Exists(localInfo.LocalPath))
- Directory.CreateDirectory(localInfo.LocalPath);
- if (!File.Exists(localInfo.LocalPath+localInfo.UsrFileName))
- {
- FileStream fs = File.Create(localInfo.LocalPath + localInfo.UsrFileName);
- fs.Close();
- StreamWriter file = new StreamWriter(localInfo.LocalPath + localInfo.UsrFileName);
- file.WriteLine("USER=中置量产写入,PASSWD=1");
- file.WriteLine("USER=中置量产检验,PASSWD=2");
- file.WriteLine("USER=轮毂量产写入,PASSWD=3");
- file.WriteLine("USER=轮毂量产检验,PASSWD=4");
- file.WriteLine("USER=中置样机测试,PASSWD=5");
- file.WriteLine("USER=轮毂样机测试,PASSWD=6");
- file.WriteLine("USER=FCT治具测试,PASSWD=7");
- file.WriteLine("USER=工程参数配置,PASSWD=123456");
- file.WriteLine("USER=研发调试,PASSWD=123456");
- file.WriteLine("USER=管理员,PASSWD=ttium.123");
- file.Close();
- }
- //读取配置文件
- StreamReader objReader = new StreamReader(localInfo.LocalPath + localInfo.UsrFileName);
- string sLine = "";
- List<string> userInfo = new List<string>();
- while (sLine != null)
- {
- sLine = objReader.ReadLine();
- userInfo.Add(sLine);
- }
- objReader.Close();
- foreach (string info in userInfo)
- {
- if (info != null)
- {
- UserAccount.Add(info.Split(',')[0].Split('=')[1], info.Split(',')[1].Split('=')[1]);
- }
- }
- }
- catch (System.Exception)
- {
- MessageBox.Show("无账户信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- UserAccount.Add("未知用户", "");
- }
- //账户名下拉列表更新
- comboBox_User.Items.Clear();
- foreach (string key in UserAccount.Keys)
- {
- comboBox_User.Items.Add(key);
- }
- //密码框清空
- textBox_Passwd.Text = "";
- }
- private void button_Login_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void button_keyboard_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Process.Start("osk.exe");
- }
- private void textBox_Passwd_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- this.Close();
- }
- private void comboBox_User_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- private void label1_Click(object sender, EventArgs e)
- {
- }
- }
- }
|