Example #1
0
 public static Cliente fb_ProcuraDados(int id)
 {
     using (FbConnection conexaoFireBird = AcessoFB.getInstancia().getConexao())
     {
         try
         {
             conexaoFireBird.Open();
             string       mSQL    = "Select * from Clientes Where id = " + id;
             FbCommand    cmd     = new FbCommand(mSQL, conexaoFireBird);
             FbDataReader dr      = cmd.ExecuteReader();
             Cliente      cliente = new Cliente();
             while (dr.Read())
             {
                 cliente.ID   = Convert.ToInt32(dr[0]);
                 cliente.Nome = dr[1].ToString();
             }
             return(cliente);
         }
         catch (FbException fbex)
         {
             throw fbex;
         }
         finally
         {
             conexaoFireBird.Close();
         }
     }
 }
Example #2
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            Cliente cliente = new Cliente();

            cliente.ID   = Convert.ToInt32(txtCodigo.Text);
            cliente.Nome = txtNome.Text;

            try
            {
                AcessoFB.fb_InserirDados(cliente);
                MessageBox.Show("Cliente inserido com sucesso !", "Inserir", MessageBoxButtons.OK);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK);
            }
        }
Example #3
0
 public static void fb_ExcluirDados(int id)
 {
     using (FbConnection conexaoFireBird = AcessoFB.getInstancia().getConexao())
     {
         try
         {
             conexaoFireBird.Open();
             string    mSQL = "DELETE from Clientes Where id= " + id;
             FbCommand cmd  = new FbCommand(mSQL, conexaoFireBird);
             cmd.ExecuteNonQuery();
         }
         catch (FbException fbex)
         {
             throw fbex;
         }
         finally
         {
             conexaoFireBird.Close();
         }
     }
 }
Example #4
0
 public static void fb_AlterarDados(Cliente cliente)
 {
     using (FbConnection conexaoFireBird = AcessoFB.getInstancia().getConexao())
     {
         try
         {
             conexaoFireBird.Open();
             string    mSQL = "Update Clientes set nome= '" + cliente.Nome + "'" + " Where id= " + cliente.ID;
             FbCommand cmd  = new FbCommand(mSQL, conexaoFireBird);
             cmd.ExecuteNonQuery();
         }
         catch (FbException fbex)
         {
             throw fbex;
         }
         finally
         {
             conexaoFireBird.Close();
         }
     }
 }
Example #5
0
    public static void fb_InserirDados(Cliente cliente)
    {
        using (FbConnection conexaoFireBird = AcessoFB.getInstancia().getConexao())
        {
            try
            {
                conexaoFireBird.Open();
                string mSQL = "INSERT into " + '\u0022' + "clientes" + '\u0022' + " Values (" + cliente.ID + ",'" + cliente.Nome + "')";

                FbCommand cmd = new FbCommand(mSQL, conexaoFireBird);
                cmd.ExecuteNonQuery();
            }
            catch (FbException fbex)
            {
                throw fbex;
            }
            finally
            {
                conexaoFireBird.Close();
            }
        }
    }
Example #6
0
 public static DataTable fb_GetDados()
 {
     using (FbConnection conexaoFireBird = AcessoFB.getInstancia().getConexao())
     {
         try
         {
             conexaoFireBird.Open();
             string        mSQL = "Select * from Clientes";
             FbCommand     cmd  = new FbCommand(mSQL, conexaoFireBird);
             FbDataAdapter da   = new FbDataAdapter(cmd);
             DataTable     dt   = new DataTable();
             da.Fill(dt);
             return(dt);
         }
         catch (FbException fbex)
         {
             throw fbex;
         }
         finally
         {
             conexaoFireBird.Close();
         }
     }
 }