public void fillgrid()
{
bool Mbook = false;
string[] filld = new string[2];
string[] oper = new string[2];
string[] val = new string[2];
int k = 0;
bool Mcommon = false;
string str = "select * from View_avlflat where FLATNO!='999' and BOOK='" + Mbook + "' and common='" + Mcommon + "' and ";
if (ddlprojectsite.SelectedIndex != 0)
{
filld[k] = "PROJECTCODE";
oper[k] = "="; ;
val[k] = "'" + ddlprojectsite.SelectedValue + "'";
k++;
}
if (ddlFlateType.SelectedIndex != 0)
{
filld[k] = "flattypeId";
oper[k] = "="; ;
val[k] = "'" + ddlFlateType.SelectedValue + "'";
k++;
}
for (int i = 0; i < k; i++)
{
str = str + filld[i] + oper[i] + val[i] + " and ";
}
//if (str.Substring(str.Length - 4, 4) == "and ")
//{
str = str.Substring(0, str.Length - 4);
//}
con.Open();
SqlDataAdapter da = new SqlDataAdapter(str, con);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
gvflateavalable.DataSource = ds;
gvflateavalable.DataBind();
if (gvflateavalable.Rows.Count > 0)
{
Button3.Visible = true;
Button4.Visible = true;
}
ReportViewer1.LocalReport.DataSources.Clear();
ReportDataSource reportDSHeader = new ReportDataSource("AvailableFlat_View_avlflat", ds.Tables[0]);
ReportViewer1.LocalReport.DataSources.Add(reportDSHeader);
ReportViewer1.LocalReport.Refresh();
}
{
bool Mbook = false;
string[] filld = new string[2];
string[] oper = new string[2];
string[] val = new string[2];
int k = 0;
bool Mcommon = false;
string str = "select * from View_avlflat where FLATNO!='999' and BOOK='" + Mbook + "' and common='" + Mcommon + "' and ";
if (ddlprojectsite.SelectedIndex != 0)
{
filld[k] = "PROJECTCODE";
oper[k] = "="; ;
val[k] = "'" + ddlprojectsite.SelectedValue + "'";
k++;
}
if (ddlFlateType.SelectedIndex != 0)
{
filld[k] = "flattypeId";
oper[k] = "="; ;
val[k] = "'" + ddlFlateType.SelectedValue + "'";
k++;
}
for (int i = 0; i < k; i++)
{
str = str + filld[i] + oper[i] + val[i] + " and ";
}
//if (str.Substring(str.Length - 4, 4) == "and ")
//{
str = str.Substring(0, str.Length - 4);
//}
con.Open();
SqlDataAdapter da = new SqlDataAdapter(str, con);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
gvflateavalable.DataSource = ds;
gvflateavalable.DataBind();
if (gvflateavalable.Rows.Count > 0)
{
Button3.Visible = true;
Button4.Visible = true;
}
ReportViewer1.LocalReport.DataSources.Clear();
ReportDataSource reportDSHeader = new ReportDataSource("AvailableFlat_View_avlflat", ds.Tables[0]);
ReportViewer1.LocalReport.DataSources.Add(reportDSHeader);
ReportViewer1.LocalReport.Refresh();
}
No comments:
Post a Comment