private void MudaSenha(String Nome, String Senha) { try { SqlDataReader dr = null; StrCon obj = new StrCon(); SqlConnection conn = new SqlConnection(obj.sql); conn.Open(); SqlCommand cmd = new SqlCommand("select * from tblSenhaChefe where Nome = '" + Nome + "' and senha = '" + Senha + "'", conn); dr = cmd.ExecuteReader(CommandBehavior.SingleRow); if (dr.HasRows) { dr.Read(); FrmMudaSenha2 muda = new FrmMudaSenha2(); muda.ShowDialog(); Close(); } else { MessageBox.Show("Dados não Conferem, Login e/ou Senha incorretos...", "ERRO!!!", MessageBoxButton.OK, MessageBoxImage.Error); PTextLogin.IsEnabled = false; PtextSenha.IsEnabled = false; } try { dr.Close(); conn.Close(); } catch (Exception) { // } PTextLogin.Password = string.Empty; PtextSenha.Password = string.Empty; PTextLogin.IsEnabled = true; PtextSenha.IsEnabled = true; PTextLogin.Focus(); return; } catch (Exception ex) { MessageBox.Show("ERRO Detalhe: " + ex.Message + "Tente o Acesso assim que o Servidor e/ou a Reade forem restabelecidos.... O SISTEMA SERÁ ENCERRADO!!!", "ERRO", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void FrmMudaSenha1_Loaded(object sender, RoutedEventArgs e) { PTextLogin.Focus(); // 3º Passo para Desabilitar o (X) de Fechar o Form em WPF. var hwnd = new WindowInteropHelper(this).Handle; SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU); }