Example #1
0
        public CadastroMoeda listarHistoricoMoeda(int id, DateTime A)
        {
            conn1 = classeConexão.obterConexao();
            if (conn1.State == ConnectionState.Open)
            {
                SqlCommand cmd = new SqlCommand("select * from HistoricoMoeda where idMoeda = @id and DataRegistro = @a", conn1);
                cmd.Parameters.AddWithValue("@id", id);
                cmd.Parameters.AddWithValue("@a", A);

                try
                {
                    CadastroMoeda a      = new CadastroMoeda();
                    SqlDataReader reader = cmd.ExecuteReader();

                    if (reader.Read())
                    {
                        a.setId(id);

                        a.setIdHistorico(int.Parse(reader[0].ToString()));
                        a.setAttt(DateTime.Parse(reader[1].ToString()));
                        a.setValor(Double.Parse(reader[2].ToString()));
                        a.setId(int.Parse(reader[3].ToString()));
                        return(a);
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Erro: " + error);

                    return(null);
                }
                finally
                {
                    classeConexão.fecharConexao();
                }
            }
            else
            {
                MessageBox.Show("Erro: " + conn1.State.ToString());
                return(null);
            }
        }
Example #2
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            CadastroMoeda a = new CadastroMoeda();

            a.setId(int.Parse(txtId.Text));
            a.setNome(txtNome.Text);
            a.setValor(Double.Parse(txtValor.Text));
            a.setAttt(DateTime.Parse(txtAtt.Text));

            consultaDao.atualizarMoeda(a);

            listarTable();

            txtId.Clear();
            txtNome.Clear();
            txtAtt.Clear();
            txtValor.Clear();
        }