Enter.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace MOTINOVA_Motor_Factory_Set
  10. {
  11. public partial class Enter : Form
  12. {
  13. public Enter()
  14. {
  15. InitializeComponent();
  16. }
  17. private void button1_Click(object sender, EventArgs e)
  18. {
  19. this.Close();
  20. }
  21. public Dictionary<string, string> UserAccount = new Dictionary<string, string>();
  22. private void Enter_Load(object sender, EventArgs e)
  23. {
  24. UserAccount.Clear();
  25. //读取账户信息
  26. try
  27. {
  28. //加载配置文件
  29. StreamReader objReader = new StreamReader("UserAccount");
  30. string sLine = "";
  31. List<string> userInfo = new List<string>();
  32. while (sLine != null)
  33. {
  34. sLine = objReader.ReadLine();
  35. userInfo.Add(sLine);
  36. }
  37. objReader.Close();
  38. foreach(string info in userInfo)
  39. {
  40. if (info != null)
  41. {
  42. UserAccount.Add(info.Split(',')[0].Split('=')[1], info.Split(',')[1].Split('=')[1]);
  43. }
  44. }
  45. }
  46. catch (System.Exception)
  47. {
  48. MessageBox.Show("无账户信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  49. UserAccount.Add("未知用户", "");
  50. }
  51. //账户名下拉列表更新
  52. comboBox_User.Items.Clear();
  53. foreach (string key in UserAccount.Keys)
  54. {
  55. comboBox_User.Items.Add(key);
  56. }
  57. //密码框清空
  58. textBox_Passwd.Text = "";
  59. }
  60. private void button_keyboard_Click(object sender, EventArgs e)
  61. {
  62. System.Diagnostics.Process.Start("osk.exe");
  63. }
  64. private void textBox_Passwd_KeyUp(object sender, KeyEventArgs e)
  65. {
  66. if (e.KeyCode == Keys.Enter)
  67. this.Close();
  68. }
  69. }
  70. }