1. SqlCommand sqladmin = new SqlCommand("select ROW_NUMBER() over(order by a.exid) as 'S.No.',a.exid,company_name as 'Company Name',boothnumber as 'Stand Number', b.username as 'Username' from tblExReginfo a join tblexhibitor b on a.eventId=b.eventid and a.exId=b.exid where a.eventid='" + Session["eventid"].ToString() + "' and confirm_status='Yes' and company_name<>''", Conn);
private void BindDetailGrid()
{
SqlCommand sqladmin = new SqlCommand("select ROW_NUMBER() over(order by a.exid) as 'S.No.',a.exid,company_name as 'Company Name',boothnumber as 'Stand Number', b.username as 'Username' from tblExReginfo a join tblexhibitor b on a.eventId=b.eventid and a.exId=b.exid where a.eventid='" + Session["eventid"].ToString() + "' and confirm_status='Yes' and company_name<>''", Conn);
SqlDataAdapter adp = new SqlDataAdapter(sqladmin);
adp.Fill(dtExhiDetails);
foreach (DataRow dr in dtForms.Rows)
dtExhiDetails.Columns.Add(Convert.ToString(dr["formid"]), typeof(string));
SqlCommand sqladmin1 = new SqlCommand("select first1.*, CASE c.status WHEN '0' THEN 'S' WHEN '1' THEN 'D'WHEN '2' THEN 'N' ELSE 'N' END as status from (select b.formid, a.exId, a.eventid from tblExRegInfo a full join tbl_Manual_Administrator_Panel b on b.eventId=a.eventid where a.eventid='" + Session["eventid"].ToString() + "') first1 left join tbl_Manual_FormsDetails c on first1.eventId=c.eventid and first1.exId=c.exhibitorid and first1.FormId=c.FormId where first1.eventid='" + Session["eventid"].ToString() + "' order by first1.exId, first1.FormId", Conn);
SqlDataAdapter adp1 = new SqlDataAdapter(sqladmin1);
adp1.Fill(dtFormStatus);
ViewState["viewdtExhiDetails"] = dtExhiDetails;
ViewState["viewdtFormStatus"] = dtFormStatus;
}
2. Dynamic SQL queries in cs page for searching option
string queri = string.Empty, queri1 = string.Empty, queri2 = string.Empty, queri3 = string.Empty, queri4 = string.Empty, queri5 = string.Empty;
if (!string.IsNullOrEmpty(txtfirstname.Text.Trim()))
queri1 = " and FName like '%" + txtfirstname.Text.Replace("'", "''") + "%'";
if (!string.IsNullOrEmpty(txtlastname.Text.Trim()))
queri2 = " and LName like '%" + txtlastname.Text.Replace("'", "''") + "%'";
if (!string.IsNullOrEmpty(txtcompanyname.Text.Trim()))
queri3 = " and Company_Name like '%" + txtcompanyname.Text.Replace("'", "''") + "%'";
if (ddlCountry.SelectedItem.Text.ToString().Trim() != "--Please Choose--")
queri4 = " and country='" + ddlCountry.SelectedItem.Text.ToString().Replace("'", "''") + "'";
if (!string.IsNullOrEmpty(txtstate.Text.Trim()))
queri5 = " and State like '%" + txtstate.Text.Replace("'", "''") + "%'";
queri = "select fname,lname, Company_Name, Logo,Add_Line1+' '+ State+', '+PostCode as Address from TblMember_Registration where Membership_Type='Individual' and Delete_Status='No' and confirm_status='Approved' " + queri1 + queri2 + queri3 + queri4 + queri4 + " order by" + rdlorderby.SelectedItem.Text.Trim() + "";
queri = "select nickname,company_name,REPLACE(BannerName,'The Preparation Group','Preparation Group') as BannerName,boothnumber,country,exid from tblexreginfo where eventid='event252' and exid not in ('exhireg1','exhireg2') " + queri1 + queri2 + queri3 + queri4 + " and boothnumber!='TBC' and confirm_status='Yes' order by company_name";
2. Dynamic SQL queries in cs page for searching option
string queri = string.Empty, queri1 = string.Empty, queri2 = string.Empty, queri3 = string.Empty, queri4 = string.Empty, queri5 = string.Empty;
if (!string.IsNullOrEmpty(txtfirstname.Text.Trim()))
queri1 = " and FName like '%" + txtfirstname.Text.Replace("'", "''") + "%'";
if (!string.IsNullOrEmpty(txtlastname.Text.Trim()))
queri2 = " and LName like '%" + txtlastname.Text.Replace("'", "''") + "%'";
if (!string.IsNullOrEmpty(txtcompanyname.Text.Trim()))
queri3 = " and Company_Name like '%" + txtcompanyname.Text.Replace("'", "''") + "%'";
if (ddlCountry.SelectedItem.Text.ToString().Trim() != "--Please Choose--")
queri4 = " and country='" + ddlCountry.SelectedItem.Text.ToString().Replace("'", "''") + "'";
if (!string.IsNullOrEmpty(txtstate.Text.Trim()))
queri5 = " and State like '%" + txtstate.Text.Replace("'", "''") + "%'";
queri = "select fname,lname, Company_Name, Logo,Add_Line1+' '+ State+', '+PostCode as Address from TblMember_Registration where Membership_Type='Individual' and Delete_Status='No' and confirm_status='Approved' " + queri1 + queri2 + queri3 + queri4 + queri4 + " order by" + rdlorderby.SelectedItem.Text.Trim() + "";
queri = "select nickname,company_name,REPLACE(BannerName,'The Preparation Group','Preparation Group') as BannerName,boothnumber,country,exid from tblexreginfo where eventid='event252' and exid not in ('exhireg1','exhireg2') " + queri1 + queri2 + queri3 + queri4 + " and boothnumber!='TBC' and confirm_status='Yes' order by company_name";
No comments:
Post a Comment