Пример #1
0
        public PostoColecao ConsultarPorId(int IDCADPOSTO)
        {
            try
            {
                PostoColecao postoColecao = new PostoColecao();

                acessoDadosSqlServer.LimparParametros();
                acessoDadosSqlServer.AdicionarParametros("@IDCADPOSTO", IDCADPOSTO);

                DataTable dataTablePosto = acessoDadosSqlServer.ExecutarConsulta(CommandType.StoredProcedure, "uspCADPOSTOConsultarPorID");
                foreach (DataRow dataRowLinha in dataTablePosto.Rows)
                {
                    Posto posto = new Posto();

                    posto.IDCADPOSTO = Convert.ToInt32(dataRowLinha["IDCADPOSTO"]);
                    posto.CADPOSTO   = Convert.ToString(dataRowLinha["CADPOSTO"]);

                    postoColecao.Add(posto);
                }

                return(postoColecao);
            }
            catch (Exception exception)
            {
                throw new Exception("Não foi possível consultar o posto por código. Detalhes: " + exception.Message);
            }
        }
Пример #2
0
        //Criando um método atualizar grid
        private void AtualizarGrid()
        {
            PostoNegocios postoNegocios = new PostoNegocios();

            PostoColecao postoColecao = new PostoColecao();

            postoColecao = postoNegocios.ConsultarPorNome(textBoxPesquisa.Text);

            dataGridViewPrincipal.DataSource = null;
            dataGridViewPrincipal.DataSource = postoColecao;

            dataGridViewPrincipal.Update();
            dataGridViewPrincipal.Refresh();
        }