public static SqlDataReader readPlanilha(string data1, string data2) { string _sqlcommand = "Select * from tbDadosPlan where Data between @Data1 and @Data2 order by Data"; SqlDataReader dr = BDConnection.ReadDatabase(_sqlcommand, new SqlParameter("@Data1", data1), new SqlParameter("@Data2", data2)); return(dr); //MessageBox.Show("nivel DAO" + dr.HasRows.ToString()); Teste para saber se o datareader chegou }
//HELPERS private void exibeDatagrid() { #region converte data e salva data1 = datainicio ; data2 = dataFim //converte dd/mm/aaaa para aaaa-mm-dd string data1 = dataInicio.Value.Year.ToString() + "-" + dataInicio.Value.Month.ToString() + "-" + dataInicio.Value.Day.ToString(); string data2 = dataFim.Value.Year.ToString() + "-" + dataFim.Value.Month.ToString() + "-" + dataFim.Value.Day.ToString(); #endregion #region EXIBE DATAGRID dataT.Rows.Clear(); //limpo o objeto dataT.Load(PlanilhaDAO.readPlanilha(data1, data2)); //carrega dataread dgPlanilha.DataSource = dataT; //joga DataTable(backend) no Datagrid(UI) dgPlanilha.Columns[0].Visible = false; dgPlanilha.Columns[6].Visible = false; //Escondendo colunas BDConnection.fecharConexao(); //Posso fechar a conexão, o dataread foi descarreado //MessageBox.Show(dataT.Rows.Count.ToString()); Teste verificar dataTable #endregion }
public static void Insert(Planilha planilha) { string _sqlcommand = "INSERT INTO tbDadosPlan (Data, Filial, Ano, Caixa, Cte) values (@Data, @Filial, @Ano, @Caixa, @Cte)"; BDConnection.ExecuteQueries(_sqlcommand, new SqlParameter("@Data", planilha.Data), new SqlParameter("@Filial", planilha.Filial), new SqlParameter("@Ano", planilha.Ano), new SqlParameter("@Caixa", planilha.Caixa), new SqlParameter("@Cte", planilha.Protocolo)); }