Exemple #1
0
        private void CarregaDados()
        {
            try
            {
                {
                    // Instancio a Classe StrCon Onde esta a String de Conexão:
                    StrCon obj = new StrCon();
                    // Cria um Novo objeto SqlConnection object usando a string de conexão
                    SqlConnection conn = new SqlConnection(obj.sql);
                    // abre Conexão
                    conn.Open();
                    SqlCommand     cmd = new SqlCommand("SELECT tblNome.IdNome as Código ,tblNome.Nome, tblNome.Imagem, tblEntradaApto.IdEntr_Apto as ID, tblEntradaApto.Entrada_Apto as Entrada FROM tblNome  INNER JOIN tblEntradaApto   ON tblNome.IdEntr_Apto = tblEntradaApto.IdEntr_Apto", conn);
                    SqlDataAdapter da  = new SqlDataAdapter(cmd);
                    DataTable      dt  = new DataTable();
                    da.Fill(dt);
                    dgvDados.DataContext = dt.DefaultView;

                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: Detalhe -->> " + ex);
            }
        }
Exemple #2
0
        private void Novo_Morador()
        {
            try
            {
                {
                    StrCon        obj  = new StrCon();
                    SqlConnection conn = new SqlConnection(obj.sql);
                    conn.Open();
                    string        Query         = "SELECT * FROM tblEntradaApto WHERE Entrada_Apto= '" + ListUnidades.Text + "' ";
                    SqlCommand    createCommand = new SqlCommand(Query, conn);
                    SqlDataReader dr            = createCommand.ExecuteReader();
                    while (dr.Read())
                    {
                        string IdEntr_Apto  = dr.GetInt32(0).ToString();
                        string Entrada_Apto = dr.GetString(1);

                        txtCod_EntradaApto.Text       = IdEntr_Apto;
                        txtEntrada_Apto.Text          = Entrada_Apto;
                        txtCod_EntradaApto.IsReadOnly = true;
                        txtEntrada_Apto.IsReadOnly    = true;
                    }
                    conn.Close();
                }
            }
            catch (Exception)
            {
                //
            }
        }
Exemple #3
0
 private void Senha(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();
             FrmCadCond frmcadCond = new FrmCadCond();
             frmcadCond.Show();
             Close(); // Fecha o Form da Senha.
         }
         else
         {
             MessageBox.Show("Dados não Conferem, Login e/ou Senha incorretos...", "ERRO!!!", MessageBoxButton.OK, MessageBoxImage.Error);
             txtLogin.IsReadOnly = true;
             txtSenha.IsEnabled  = false;
         }
         try
         {
             dr.Close();
             conn.Close();
         }
         catch (Exception)
         {
             //
         }
         txtLogin.Text             = string.Empty;
         txtSenha.Password         = string.Empty;
         txtLogin.IsReadOnly       = false;
         txtSenha.IsEnabled        = true;
         chkBoxMudaSenha.IsChecked = false;
         txtLogin.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);
     }
 }
Exemple #4
0
 private void InseriDados()
 {
     try
     {
         {
             StrCon         obj  = new StrCon();
             SqlConnection  conn = new SqlConnection(obj.sql);
             SqlCommand     cmd  = new SqlCommand("insert into tblNome (Nome, IdEntr_Apto,Imagem) Values  ('" + txtNome.Text + "','" + txtCod_EntradaApto.Text + "','" + Textnome.Text + "')  Select  Nome FROM tblNome", conn);
             SqlDataAdapter da   = new SqlDataAdapter(cmd);
             DataTable      dt   = new DataTable();
             da.Fill(dt);
             dgvDados.DataContext = dt.DefaultView;
             conn.Close();
         }
     }
     catch (Exception)
     {
         //
     }
 }
Exemple #5
0
 private void ListBoxCondominos()
 {
     try
     {
         {
             StrCon        obj  = new StrCon();
             SqlConnection conn = new SqlConnection(obj.sql);
             conn.Open();
             SqlCommand     cmd = new SqlCommand("SELECT tblNome.IdNome as Código ,tblNome.Nome, tblNome.Imagem, tblEntradaApto.IdEntr_Apto as ID, tblEntradaApto.Entrada_Apto as Entrada FROM tblNome  INNER JOIN tblEntradaApto  ON tblNome.IdEntr_Apto = tblEntradaApto.IdEntr_Apto WHERE tblNome.IdEntr_Apto = " + ListUnidades.SelectedValue, conn);
             SqlDataAdapter da  = new SqlDataAdapter(cmd);
             DataTable      dt  = new DataTable();
             da.Fill(dt);
             dgvDados.DataContext = dt.DefaultView;
             conn.Close();
         }
     }
     catch (Exception)
     {
         //
     }
 }
Exemple #6
0
 private void AlteraDados()
 {
     try
     {
         {
             StrCon        obj  = new StrCon();
             SqlConnection conn = new SqlConnection(obj.sql);
             conn.Open();
             SqlCommand     cmd = new SqlCommand("UPDATE tblNome SET Nome = '" + txtNome.Text + "' WHERE IdNome = '" + txtCod_nome.Text + "'", conn);
             SqlDataAdapter da  = new SqlDataAdapter(cmd);
             DataTable      dt  = new DataTable();
             da.Fill(dt);
             dgvDados.DataContext = dt.DefaultView;
             conn.Close();
         }
     }
     catch (Exception)
     {
         //
     }
 }
Exemple #7
0
 private void DeletaDados()
 {
     try
     {
         {
             StrCon        obj  = new StrCon();
             SqlConnection conn = new SqlConnection(obj.sql);
             conn.Open();
             SqlCommand     cmd = new SqlCommand("DELETE FROM tblNome WHERE IdNome = '" + txtCod_nome.Text + "'", conn);
             SqlDataAdapter da  = new SqlDataAdapter(cmd);
             DataTable      dt  = new DataTable();
             da.Fill(dt);
             dgvDados.DataContext = dt.DefaultView;
             conn.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Erro: Detalhe -->> " + ex);
     }
 }
Exemple #8
0
        private void BuscaporNome()
        {
            try
            {
                {
                    StrCon        obj  = new StrCon();
                    SqlConnection conn = new SqlConnection(obj.sql);
                    conn.Open();
                    SqlCommand     cmd = new SqlCommand("SELECT tblNome.IdNome as Código ,tblNome.Nome, tblNome.Imagem, tblEntradaApto.IdEntr_Apto as ID,tblEntradaApto.Entrada_Apto as Entrada FROM tblNome  INNER JOIN tblEntradaApto   ON tblNome.IdEntr_Apto = tblEntradaApto.IdEntr_Apto WHERE Nome LIKE '%" + txtBuscar.Text + "%'", conn);
                    SqlDataAdapter da  = new SqlDataAdapter(cmd);
                    DataTable      dt  = new DataTable();
                    da.Fill(dt);
                    dgvDados.DataContext = dt.DefaultView;

                    conn.Close();
                }
            }
            catch (Exception)
            {
                //
            }
        }
Exemple #9
0
 private void CarregaDadosNoList()
 {
     try
     {
         {
             StrCon        obj  = new StrCon();
             SqlConnection conn = new SqlConnection(obj.sql);
             conn.Open();
             SqlCommand     cmd = new SqlCommand("SELECT * FROM tblEntradaApto ", conn);
             SqlDataAdapter da  = new SqlDataAdapter(cmd);
             DataTable      dt  = new DataTable();
             da.Fill(dt);
             ListUnidades.SelectedValuePath = "IdEntr_Apto";
             ListUnidades.DisplayMemberPath = "Entrada_Apto";
             ListUnidades.ItemsSource       = dt.DefaultView;
             conn.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Erro: Detalhe -->> " + ex);
     }
 }
Exemple #10
0
 private void SenhaNovaAltera()
 {
     try
     {
         {
             // Instancio a Classe StrCon Onde esta a String de Conexão:
             StrCon obj = new StrCon();
             // Cria um Novo objeto SqlConnection object usando a string de conexão
             SqlConnection conn = new SqlConnection(obj.sql);
             // abre Conexão
             conn.Open();
             SqlCommand     cmd = new SqlCommand("UPDATE tblSenhaChefe SET Nome = '" + PTextUsuarioNovo.Password + "' WHERE Codigo = '" + TextGuardaCampo.Text + "'" + "UPDATE tblSenhaChefe SET Senha = '" + PTexeSenhaNova.Password + "' WHERE Codigo = '" + TextGuardaCampo.Text + "'", conn);
             SqlDataAdapter da  = new SqlDataAdapter(cmd);
             DataTable      dt  = new DataTable();
             da.Fill(dt);
             tblSenhaChefeDataGrid.DataContext = (dt);
             conn.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Erro: Detalhe -->> " + ex);
     }
 }
Exemple #11
0
 private void SenhaNova()
 {
     try
     {
         {
             // Instancio a Classe StrCon Onde esta a String de Conexão:
             StrCon obj = new StrCon();
             // Cria um Novo objeto SqlConnection object usando a string de conexão
             SqlConnection conn = new SqlConnection(obj.sql);
             // abre Conexão
             conn.Open();
             SqlCommand     cmd = new SqlCommand("SELECT * FROM tblSenhaChefe", conn);
             SqlDataAdapter da  = new SqlDataAdapter(cmd);
             DataTable      dt  = new DataTable();
             da.Fill(dt);
             tblSenhaChefeDataGrid.DataContext = (dt);
             conn.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Erro: Detalhe -->> " + ex);
     }
 }