static ConnectionExeption() { _lineNotSelected = null; }
private bool HandleLoginError(Exception e) { bool bHandled = false; if (e is ConnectionExeption) { bHandled = true; ConnectionExeption ex = (ConnectionExeption)e; MessageBox.Show(ex.Message); switch (ex.ExeptionType) { case ConnectionExeptionType.LineNotSelected: { cmbLine.Focus(); break; } } } else if (e is AccountException) { bHandled = true; AccountException ex = (AccountException)e; MessageBox.Show(ex.Message); switch (ex.ExeptionType) { case AccountExeptionType.UserNameNotExists: { cmbUserName.Focus(); cmbUserName.SelectAll(); txtPassword.Text = string.Empty; break; } case AccountExeptionType.PasswordNotMatch: case AccountExeptionType.AccountInvalid: case AccountExeptionType.PasswordInvalid: { txtPassword.Focus(); txtPassword.SelectAll(); break; } case AccountExeptionType.NeedChangePassword: { frmEmployeePassword frmEmployeePassword = new frmEmployeePassword(); frmEmployeePassword.ShowDialog(); txtPassword.Focus(); txtPassword.SelectAll(); break; } case AccountExeptionType.PasswordRepeatNotMatch: break; } } else if (e is WebException) { bHandled = true; WebException ex = (WebException)e; StringBuilder sb = new StringBuilder(); sb.AppendLine(@"连接不上服务器!"); sb.Append(HintString.PleaseConnectAdmin); MessageBox.Show(sb.ToString()); } else if (e is SqlException) { SqlException ex = (SqlException)e; StringBuilder sb = new StringBuilder(); switch (ex.Number) { case SqlExceptionType.ConnectFailed: { bHandled = true; sb.AppendLine(@"连接不上服务器!"); sb.AppendLine(@"请先检查本机网络连接是否正常,若问题依然存在"); sb.Append(HintString.PleaseConnectAdmin); MessageBox.Show(sb.ToString()); break; } } } else { Show(); } return(bHandled); }