private void PreencheTela(JogoVO j)
 {
     if (j != null)
     {
         txtId.Text                 = j.Id.ToString();
         txtDescricao.Text          = j.Descricao;
         cbcategorias.SelectedValue = j.CategoriaId;
         txtData.Text               = j.Data.ToShortDateString();
         txtPreco.Text              = j.valor.ToString();
     }
 }
Beispiel #2
0
        private static SqlParameter[] CriaParametros(JogoVO j)
        {
            SqlParameter[] parametros =
            {
                //new SqlParameter("id", j.Id),
                new SqlParameter("descricao",     j.Descricao),
                new SqlParameter("valor_locacao", j.valor),
                new SqlParameter("dataCompra",    j.Data),
                new SqlParameter("categoriaId",   j.CategoriaId)
            };

            return(parametros);
        }
Beispiel #3
0
        public static void Alterar(JogoVO j)
        {
            string sql =
                @"update  jogos                     
                   set                            
                    descricao = @descricao,
                    valor_locacao = @valor_locacao, 
                    data_aquisicao =  @dataCompra
                    categoriaID =  @categoriaID
                   where id = @id";
            var parametros = CriaParametros(j);

            Metodos.ExecutaSQL(sql, parametros);
        }
Beispiel #4
0
        public static void Incluir(JogoVO j)
        {
            string sql =
                @" insert into  jogos                     
                        (descricao, valor_locacao,
                         data_aquisicao, categoriaId)       
                       values
                        (@descricao, @valor_locacao,
                         @dataCompra, @categoriaId)";

            var parametros = CriaParametros(j);

            Metodos.ExecutaSQL(sql, parametros);
        }
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            try
            {
                JogoVO j = new JogoVO();
                j.Id          = Convert.ToInt32(txtId.Text);
                j.Descricao   = txtDescricao.Text;
                j.valor       = Convert.ToDouble(txtPreco.Text);
                j.CategoriaId = Convert.ToInt32(cbcategorias.SelectedValue);
                j.Data        = Convert.ToDateTime(txtData.Text);

                JogoDAO.Alterar(j);
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
        private void btnProximo_Click(object sender, EventArgs e)
        {
            JogoVO j = JogoDAO.Proximo(Convert.ToInt32(txtId.Text));

            PreencheTela(j);
        }
        private void btnAnterior_Click(object sender, EventArgs e)
        {
            JogoVO j = JogoDAO.Anterior(Convert.ToInt32(txtId.Text));

            PreencheTela(j);
        }
        private void btnPrimeiro_Click(object sender, EventArgs e)
        {
            JogoVO j = JogoDAO.Primeiro();

            PreencheTela(j);
        }
        private void btnUltimo_Click(object sender, EventArgs e)
        {
            JogoVO j = JogoDAO.Ultimo();

            PreencheTela(j);
        }