Пример #1
0
        private void CarregaGridView()
        {
            ConexaoBD    bd       = new ConexaoBD();
            List <Conta> lstDados = new List <Conta>();

            lstDados = bd.Consultar();
            dataGridView1.DataSource = lstDados;
        }
Пример #2
0
        private void tsbExcluir_Click(object sender, EventArgs e)
        {
            ConexaoBD bd = new ConexaoBD();

            bd.Deletar(Conta.id);

            /*if (MessageBox.Show("Deseja realmente Excluir essa Conta?", "Cuidado", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
             * {
             *  MessageBox.Show("Operação Cancelada!!!");
             *
             * }
             * else
             * {
             *  strSql = "delete from Contas where Id=@Id";
             *  SqlCon = new SqlConnection(strConexao);
             *  SqlCommand comando = new SqlCommand(strSql, SqlCon);
             *
             *  comando.Parameters.Add("@Id", Conta.id);
             *  try
             *  {
             *      SqlCon.Open();
             *      comando.ExecuteNonQuery();
             *      MessageBox.Show("Conta Deletada com Sucesso!!!");
             *  }
             *  catch (Exception ex)
             *  {
             *      MessageBox.Show(ex.Message);
             *
             *  }
             *  finally {
             *
             *      SqlCon.Close();
             *  }
             * }
             */

            tsbNovo.Enabled     = true;
            tsbAlterar.Enabled  = true;
            tsbCancelar.Enabled = true;
            tsbExcluir.Enabled  = true;
            tsbBuscar.Enabled   = true;
            tsbSalvar.Enabled   = true;
            mtbNumero.Text      = "";
            mtbAgencia.Text     = "";
            txtSaldo.Text       = " ";
        }
Пример #3
0
        private void tsbAlterar_Click(object sender, EventArgs e)
        {
            string Numero  = Convert.ToString(mtbNumero);
            string Agencia = Convert.ToString(mtbAgencia);
            string Tipo;

            if (rbtCorrente.Checked)
            {
                Tipo = rbtCorrente.Text;
            }
            else
            {
                Tipo = rbtPoupanca.Text;
            }
            decimal Saldo = Convert.ToDecimal(txtSaldo.Text);

            ConexaoBD bd = new ConexaoBD();

            bd.Alterar(Conta.id, Numero, Agencia, Tipo, Saldo);

            /*
             *
             * strSql = "update Contas set Numero=@Numero, Agencia=@Agencia, Tipo=@Tipo, Saldo=@Saldo where Id=@Id";
             * SqlCon = new SqlConnection(strConexao);
             * SqlCommand comando = new SqlCommand(strSql, SqlCon);
             *
             * comando.Parameters.Add("@Id", Conta.id);
             * comando.Parameters.Add("@Numero", Conta.Numero);
             * comando.Parameters.Add("@Agencia", Conta.Agencia);
             * if (rbtCorrente.Checked)
             * {
             *  comando.Parameters.Add("@Tipo", SqlDbType.NChar).Value = rbtCorrente.Text;
             * }
             * else
             * {
             *  comando.Parameters.Add("@Tipo", SqlDbType.NChar).Value = rbtPoupanca.Text;
             * }
             *
             * comando.Parameters.Add("@Saldo", SqlDbType.NChar).Value = txtSaldo.Text;
             *
             *
             * try
             * {
             *  SqlCon.Open();
             *  comando.ExecuteNonQuery();
             *  MessageBox.Show("Alteração Concluida!!!");
             * }
             * catch (Exception ex)
             * {
             *  MessageBox.Show(ex.Message);
             * }
             * finally
             * {
             *  SqlCon.Close();
             * }
             *
             */
            tsbNovo.Enabled     = true;
            tsbAlterar.Enabled  = true;
            tsbCancelar.Enabled = true;
            tsbExcluir.Enabled  = true;
            tsbBuscar.Enabled   = true;
            tsbSalvar.Enabled   = false;
            mtbNumero.Text      = "";
            mtbAgencia.Text     = "";
            txtSaldo.Text       = " ";
        }
Пример #4
0
        private void tsbSalvar_Click(object sender, EventArgs e)
        {
            /*strSql = "insert into Contas (Numero, Agencia, Tipo, Saldo) values (@Numero, @Agencia, @Tipo, @Saldo)";
             * SqlCon = new SqlConnection(strConexao);
             * SqlCommand comando = new SqlCommand(strSql, SqlCon);
             *
             * comando.Parameters.Add("@Numero", SqlDbType.NChar).Value = mtbNumero.Text;
             * comando.Parameters.Add("@Agencia", SqlDbType.NChar).Value = mtbAgencia.Text;
             * if (rbtCorrente.Checked)
             * {
             *  comando.Parameters.Add("@Tipo", SqlDbType.NChar).Value = rbtCorrente.Text;
             * }
             * else
             * {
             *  comando.Parameters.Add("@Tipo", SqlDbType.NChar).Value = rbtPoupanca.Text;
             * }
             *
             * comando.Parameters.Add("@Saldo", SqlDbType.NChar).Value = txtSaldo.Text;
             *
             * try
             *  {
             *      SqlCon.Open();
             *      comando.ExecuteNonQuery();
             *      MessageBox.Show("Cadastro Concluido!!!");
             *  }
             * catch (Exception ex)
             *  {
             *      MessageBox.Show(ex.Message);
             *  }
             * finally
             *  {
             *      SqlCon.Close();
             *
             * }
             *
             */
            string Numero  = Convert.ToString(mtbNumero);
            string Agencia = Convert.ToString(mtbAgencia);
            string Tipo;

            if (rbtCorrente.Checked)
            {
                Tipo = rbtCorrente.Text;
            }
            else
            {
                Tipo = rbtPoupanca.Text;
            }
            decimal Saldo = Convert.ToDecimal(txtSaldo.Text);

            ConexaoBD bd = new ConexaoBD();

            bd.Inserir(Numero, Agencia, Tipo, Saldo);

            tsbNovo.Enabled     = true;
            tsbAlterar.Enabled  = true;
            tsbCancelar.Enabled = true;
            tsbExcluir.Enabled  = true;
            tsbBuscar.Enabled   = true;
            tsbSalvar.Enabled   = true;
            mtbNumero.Text      = "";
            mtbAgencia.Text     = "";
            txtSaldo.Text       = " ";
        }