Login.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Windows.Forms;
  3. namespace UAS_XmlAnalysor
  4. {
  5. public partial class Login : Form
  6. {
  7. public Login()
  8. {
  9. StartPosition = FormStartPosition.CenterScreen;
  10. InitializeComponent();
  11. }
  12. private void CheckLogin_Click(object sender, EventArgs e)
  13. {
  14. string ErrMessage = "";
  15. if (LogicHandler.CheckUserLogin(UserName.Text, PassWord.Text, out ErrMessage))
  16. {
  17. if (LogicHandler.CheckUserAndResourcePassed(UserName.Text, Source.Text, out ErrMessage))
  18. {
  19. BaseUtil.SetCacheData("UserName", UserName.Text);
  20. BaseUtil.SetCacheData("Source", Source.Text);
  21. if (onlinebutton.Checked)
  22. {
  23. BaseUtil.SetCacheData("Status", "online");
  24. }
  25. else
  26. BaseUtil.SetCacheData("Status", "offline");
  27. BaseUtil.SetCacheData("Mode", Equipment.Text);
  28. Form1 xml = new Form1(UserName.Text, Source.Text);
  29. Hide();
  30. xml.ShowDialog();
  31. Close();
  32. }
  33. else MessageBox.Show(ErrMessage);
  34. }
  35. else MessageBox.Show(ErrMessage);
  36. }
  37. private void Login_Load(object sender, EventArgs e)
  38. {
  39. UserName.Text = BaseUtil.GetCacheData("UserName").ToString();
  40. Source.Text = BaseUtil.GetCacheData("Source").ToString();
  41. Equipment.Text = BaseUtil.GetCacheData("Mode").ToString();
  42. if (BaseUtil.GetCacheData("Status").ToString() == "offline")
  43. {
  44. onlinebutton.Checked = false;
  45. }
  46. if (UserName.Text != "")
  47. {
  48. PassWord.Focus();
  49. }
  50. }
  51. }
  52. }