private void btnLogin_Click(object sender, EventArgs e) { if (DateTime.Now.Hour == 23 || DateTime.Now.Hour < 7) { this.toolStripMsg.Text = "系统维护中,维护时间为23:00-07:00"; return; } string userName = cbUserName.Text.Trim(); string pwd = txtPwd.Text.Trim(); string vc = txtVc.Text.Trim(); if (userName != "" && pwd != "" && vc != "") { toolStripMsg.Text = "系统正在登陆中..."; this.btnLogin.Enabled = false; string msg = string.Empty; Thread t = new Thread(() => { bool flag = LoginHelper.Login(userName, pwd, vc, ref msg, ref StaticValues.MyCookies); if (flag) { TicketService service = new TicketService(StaticValues.MyCookies); StaticValues.UserName = service.GetUserName(); StaticValues.PassengerList = service.GetMyPassengers().data.normal_passengers; if (ckRememerUser.Checked) { UserManager.SaveUserInfo(userName, pwd); } this.DialogResult = DialogResult.OK; } else { this.BeginInvoke(new MethodInvoker(delegate() { btnLogin.Enabled = true; toolStripMsg.Text = msg; })); } }); t.IsBackground = true; t.Start(); } else { if (userName == "") { toolStripMsg.Text = "请输入登录名~"; cbUserName.Focus(); return; } if (pwd == "") { toolStripMsg.Text = "请输入密码~"; txtPwd.Focus(); return; } if (vc == "") { toolStripMsg.Text = "请输入验证码~"; txtVc.Focus(); return; } } }
public static void GetPassengers() { TicketService service = new TicketService(StaticValues.MyCookies); GetPassengerDTOsResponseInfo ri = service.GetMyPassengers(); StaticValues.PassengerList= ri.data.normal_passengers; }