private void button1_Click(object sender, EventArgs e)
{
try
{
OdbcConnection conn;
string edvResultado = txtEDV.Text;
string date_inicial = dtaInicial.Value.ToString("DD/MM/YYYY HH24:MI:SS");
string date_final = dtaFinal.Value.ToString("DD/MM/YYYY HH24:MI:SS");
Planta planta = (Planta)comboBanco.SelectedItem;
conn = new OdbcConnection(planta.Banco);
MessageBox.Show(conn.State.ToString());
conn.Open();
MessageBox.Show(conn.State.ToString());
DataSet ds = new DataSet();
DataTable dt = new DataTable();
OdbcDataAdapter ada = new OdbcDataAdapter();
OdbcCommand cmd = new OdbcCommand();
//cmd.Parameters.Add("@edvResultado", OdbcType.NVarChar).Value = "%" + edvResultado + "%";
//cmd.Parameters.Add("@data_inicial", OdbcType.DateTime).Value = dtaInicial;
//cmd.Parameters.Add("@data_final", OdbcType.DateTime).Value = dtaFinal;
string sql = String.Format("SELECT * from emp where SSNO like '%{0}%' and LASTCHANGED between TO_DATE('{1} 00:00:00', 'DD/MM/YYYY HH24:MI:SS') and TO_DATE('{2} 23:59:59', 'DD/MM/YYYY HH24:MI:SS')", edvResultado,dtaInicial,dtaFinal);
cmd.CommandText = sql;
cmd.Connection = conn;
ada = new OdbcDataAdapter(cmd);
ada.Fill(dt);
MessageBox.Show(dt.Rows.Count.ToString());
FrmGrid c = new FrmGrid();
c.lblLocal.Text = ((Planta)comboBanco.SelectedItem).Local;
c.lblConexao.Text = groupBox1.Controls.OfType<RadioButton>().SingleOrDefault(rad => rad.Checked == true).Text;
c.grdRelatorio.DataSource = dt;
c.grdRelatorio.Refresh();
c.ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}