Login.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace DataManager
  11. {
  12. public partial class Login : Form
  13. {
  14. public Login()
  15. {
  16. InitializeComponent();
  17. }
  18. private void btnLogin_Click(object sender, EventArgs e)
  19. {
  20. string account = txtAccount.Text.Trim();
  21. if (account != null && account.Length == 11)
  22. {
  23. DataTable dt = DataAccess.Get_cm_user_by_cellphone(account);
  24. if (dt != null && dt.Rows.Count > 0)
  25. {
  26. UIConstants.user.UserId = int.Parse(dt.Rows[0]["userid"].ToString());
  27. UIConstants.user.UserName = dt.Rows[0]["username"].ToString();
  28. UIConstants.user.OrgId = int.Parse(dt.Rows[0]["org_id"].ToString());
  29. this.DialogResult = DialogResult.OK;
  30. }
  31. else
  32. {
  33. MessageBox.Show("登录名不正确,请重新输入", "建议信息", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  34. this.txtAccount.Focus();
  35. }
  36. }
  37. }
  38. }
  39. }