Login.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Data;
  3. using System.Windows.Forms;
  4. using UAS_AutoPass.ToolClass;
  5. namespace UAS_AutoPass
  6. {
  7. public partial class Login : Form
  8. {
  9. DataHelper dh = new DataHelper();
  10. public Login()
  11. {
  12. StartPosition = FormStartPosition.CenterScreen;
  13. InitializeComponent();
  14. }
  15. private void CheckLogin_Click(object sender, EventArgs e)
  16. {
  17. string ErrMessage = "";
  18. if (LogicHandler.CheckUserLogin(UserName.Text, PassWord.Text, out ErrMessage))
  19. {
  20. if (LogicHandler.CheckUserAndResourcePassed(UserName.Text, Source.Text, out ErrMessage))
  21. {
  22. BaseUtil.SetCacheData("UserName", UserName.Text);
  23. BaseUtil.SetCacheData("Source", Source.Text);
  24. AutoAnalysisXml xml = new AutoAnalysisXml(UserName.Text, Source.Text);
  25. Hide();
  26. xml.ShowDialog();
  27. Close();
  28. }
  29. else MessageBox.Show(ErrMessage);
  30. }
  31. else MessageBox.Show(ErrMessage);
  32. }
  33. private void Login_Load(object sender, EventArgs e)
  34. {
  35. DataTable DB = (DataTable)dh.ExecuteSql("select ms_pwd,ma_user,ma_address,ma_inneraddress from master where ma_user='MES'", "select");
  36. Master.DataSource = DB;
  37. Master.DisplayMember = "ma_user";
  38. Master.ValueMember = "ma_user";
  39. UserName.Text = BaseUtil.GetCacheData("UserName").ToString();
  40. Source.Text = BaseUtil.GetCacheData("Source").ToString();
  41. if (UserName.Text != "")
  42. {
  43. PassWord.Focus();
  44. }
  45. }
  46. }
  47. }