if (con.State == ConnectionState.Closed)
con.Open();
string komutisteme = "select * from Tablo_KHesap ";
switch (p3_kosul1_CBox.SelectedIndex)
{
case 1:
komutisteme = komutisteme + "where lokasyon=@lokasyon";
break;
case 2:
komutisteme = komutisteme + "where Kguc=@tbox";
break ;
case 3:
komutisteme = komutisteme + "where Gverim=@tinyinttbox";
break;
case 4:
komutisteme = komutisteme + "where tkmw=@decimaltbox";
break;
case 5:
komutisteme = komutisteme + "where tkgi=@decimaltbox";
break;
case 6:
komutisteme = komutisteme + "where hbasla=@hbasla and hbitis=@hbitis";
break;
case 7:
komutisteme = komutisteme + "where ksb=@tbox";
break;
case 8:
komutisteme = komutisteme + "where fsb=@tbox";
break;
case 9:
komutisteme = komutisteme + "where msb=@tbox";
break;
}
com.Connection = con;
com.CommandText = komutisteme;
com.Parameters.Add("@lokasyon", SqlDbType.TinyInt).Value = p3_lokasyon_Cbox.SelectedIndex;
com.Parameters.Add("@hbasla", SqlDbType.Date).Value = p3_kosul1Hbasla_DTP.Value.ToString("dd/MM/yyyy");
com.Parameters.Add("@hbitis", SqlDbType.Date).Value = p3_kosul1Hbitis_DTP.Value.ToString("dd/MM/yyyy");
com.Parameters.Add("@tinyinttbox", SqlDbType.TinyInt).Value = p3_kosul1arama_Tbox.Text.Trim();
com.Parameters.Add("@decimaltbox", SqlDbType.Decimal).Value = p3_kosul1arama_Tbox.Text.Trim();
com.Parameters.Add("@tbox", SqlDbType.TinyInt).Value = p3_kosul1arama_Tbox.Text.Trim();
SqlDataAdapter da = new SqlDataAdapter(com);
DataTable dt = new DataTable();
da.Fill(dt);
p3_Kayitlar_DGW.DataSource = dt;
con.Close();