using System;
using System.Collections;
using System.Collections.Specialized;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Drawing;

public partial class Admin_AdvanceSearch : System.Web.UI.Page
{
    string usertype;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["AdminEMAILID"] == null)
            {
                Response.Redirect("AdminLogin.aspx");
            }
            if (!IsPostBack)
            {
                if (Request.QueryString.AllKeys.Contains("var"))
                {
                    // The query string parameter "parameterName" exists.
                    string value = Request.QueryString["var"];
                    // Further processing with 'value'
                    if (value.ToLower() == "advance search")
                    {
                        ddlUserInfo.SelectedIndex = 5;
                    }
                }
                //NameValueCollection queryString = stringhelpers.DecryptQueryString(Request.QueryString.ToString());
                //if (queryString != null)
                //{
                //    if (queryString["var"].Equals("Advance Search"))
                //    {
                //        ddlUserInfo.SelectedIndex = 5;
                //    }
                //}
                div_gridview.Visible = false;
                btnForWebSD.Visible = false;
                btnForSmsDS.Visible = false;
                btnForWebMDS.Visible = false;
                btnForSmsMDS.Visible = false;
                btnForWebWL.Visible = false;
                btnForSmsWL.Visible = false;
            }
        }
        catch (Exception ex)
        {
            throw (ex);
        }    
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            if (txt_UserID.Text != "")
            {
                ViewState["user"] = txt_UserID.Text;
                getusertype(txt_UserID.Text);
            }
            else if (txt_EMail_ID.Text != "")
            {
                ViewState["user"] = txt_EMail_ID.Text;
                getusertype(txt_EMail_ID.Text);
            }
            else if (txt_Authorized_Mobile_No.Text != "")
            {
                ViewState["user"] = txt_Authorized_Mobile_No.Text;
                getusertype(txt_Authorized_Mobile_No.Text);
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('Please fill one field');"), true);
            }
        }
        catch (Exception ex)
        {
            throw (ex);
        }    
    }

    public void getusertype(string username)
    {
        SqlParameter[] usertype = new SqlParameter[]
        {
            new SqlParameter("@Userid",username),
        };
        DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "udp_getUsertypeAGDSMDSWL", usertype);
        if (ds.Tables[0].Rows.Count > 0)
        {
            ViewState["usertype"] = ds.Tables[0].Rows[0]["usertype"].ToString();
            getdata(ViewState["user"].ToString());
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('You have entered invalid details');"), true);
        }
    }

    public void getdata(string abc)
    {
        if (ViewState["usertype"].Equals("Agent"))
        {
            getdetailsAG(abc);
        }
        else if (ViewState["usertype"].Equals("Distributor"))
        {
            getdetailsDS(abc);
        }
        else if (ViewState["usertype"].Equals("Master Distributor"))
        {
            getdetailsMDS(abc);
        }
        else if (ViewState["usertype"].Equals("Master Admin"))
        {
            getdetailsWL(abc);
        }
        else
        {
            GridViewAgent.Visible = false;
            GridViewWL.Visible = false;
            GridViewMDS.Visible = false;
            GridViewDS.Visible = false;
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('This User dose Not exist');"), true);
        }
    }    

    private void getdetailsAG( string userid)
    {
        try
        {
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@UserType","AG"),
                new SqlParameter("@UserName",userid)
            };
            DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "udp_getregisteredAGDSMDSWL", param);
            if (ds.Tables[0].Rows.Count > 0)
            {
                div_gridview.Visible = true;
                GridViewAgent.Visible = true;
                GridViewAgent.DataSource = ds;
                GridViewAgent.DataBind();
                GridViewWL.Visible = false;
                GridViewMDS.Visible = false;
                GridViewDS.Visible = false;
                btnForWeb.Visible = true;
                btnForSms.Visible = true;
                btnForWebSD.Visible = false;
                btnForSmsDS.Visible = false;
                btnForWebMDS.Visible = false;
                btnForSmsMDS.Visible = false;
                btnForWebWL.Visible = false;
                btnForSmsWL.Visible = false;
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('No Data Availabel');"), true);
            }
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There is some technical problem. Please try again');"), true);
            throw (ex);
        }
    }

    private void getdetailsDS(string userid)
    {
        try
        {
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@UserType","DS"),
                new SqlParameter("@UserName",userid)
            };
            DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "udp_getregisteredAGDSMDSWL", param);
            if (ds.Tables[0].Rows.Count > 0)
            {
                div_gridview.Visible = true;
                GridViewDS.Visible = true;
                GridViewDS.DataSource = ds;
                GridViewDS.DataBind();
                GridViewWL.Visible = false;
                GridViewMDS.Visible = false;
                GridViewAgent.Visible = false;
                btnForWebSD.Visible = true;
                btnForSmsDS.Visible = true;
                btnForWeb.Visible = false;
                btnForSms.Visible = false;
                btnForWebMDS.Visible = false;
                btnForSmsMDS.Visible = false;
                btnForWebWL.Visible = false;
                btnForSmsWL.Visible = false;
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('No Data Availabel');"), true);
            }
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There is some technical problem. Please try again');"), true);
            throw (ex);
        }
    }

    private void getdetailsMDS(string userid)
    {
        try
        {
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@UserType","MDS"),
                new SqlParameter("@UserName",userid)
            };
            DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "udp_getregisteredAGDSMDSWL", param);
            if (ds.Tables[0].Rows.Count > 0)
            {
                div_gridview.Visible = true;
                GridViewMDS.Visible = true;
                GridViewMDS.DataSource = ds;
                GridViewMDS.DataBind();
                GridViewWL.Visible = false;
                GridViewDS.Visible = false;
                GridViewAgent.Visible = false;
                btnForWebSD.Visible = false;
                btnForSmsDS.Visible = false;
                btnForWeb.Visible = false;
                btnForSms.Visible = false;
                btnForWebMDS.Visible = true;
                btnForSmsMDS.Visible = true;
                btnForWebWL.Visible = false;
                btnForSmsWL.Visible = false;
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('No Data Availabel');"), true);
            }
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There is some technical problem. Please try again');"), true);
            throw (ex);
        }
    }

    private void getdetailsWL(string userid)
    {
        try
        {
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@UserType","WL"),
                new SqlParameter("@UserName",userid)
            };
            DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "udp_getregisteredAGDSMDSWL", param);
            if (ds.Tables[0].Rows.Count > 0)
            {
                div_gridview.Visible = true;
                GridViewWL.Visible = true;
                GridViewWL.DataSource = ds;
                GridViewWL.DataBind();
                GridViewMDS.Visible = false;
                GridViewDS.Visible = false;
                GridViewAgent.Visible = false;
                btnForWebSD.Visible = false;
                btnForSmsDS.Visible = false;
                btnForWeb.Visible = false;
                btnForSms.Visible = false;
                btnForWebMDS.Visible = false;
                btnForSmsMDS.Visible = false;
                btnForWebWL.Visible = true;
                btnForSmsWL.Visible = true;
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('No Data Availabel');"), true);
            }
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There is some technical problem. Please try again');"), true);
            throw (ex);
        }
    }

    protected void btnForWeb_Click(object sender, EventArgs e)
    {
        try
        {
            foreach (GridViewRow gvdr in this.GridViewAgent.Rows)
            {
                if (((CheckBox)gvdr.FindControl("chk1")).Checked == true)
                {
                    Label lbl_loginid = (Label)gvdr.FindControl("lbl_loginid");
                    SqlParameter[] paramChangeLoginStatus = new SqlParameter[]
                    {
                        new SqlParameter("@Portal","Web"),
                        new SqlParameter("@loginid",lbl_loginid.Text)
                    };
                    SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "UDP_CHANGEUSERWORKINGSTATUS", paramChangeLoginStatus);
                    div_gridview.Visible = true;
                    GridViewAgent.Visible = true;
                    GridViewWL.Visible = false;
                    GridViewMDS.Visible = false;
                    GridViewDS.Visible = false;
                    btnForWeb.Visible = true;
                    btnForSms.Visible = true;
                    btnForWebSD.Visible = false;
                    btnForSmsDS.Visible = false;
                    btnForWebMDS.Visible = false;
                    btnForSmsMDS.Visible = false;
                    btnForWebWL.Visible = false;
                    btnForSmsWL.Visible = false;
                    getdata(ViewState["user"].ToString());
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('Working Status Changed For Web Application');"), true);
                }
                else
                {
                    div_gridview.Visible = true;
                    GridViewAgent.Visible = true;
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('Please Select check box.');"), true);
                }
            }
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There is some technical problem. Please try again');"), true);
            throw (ex);
        }
    }

    protected void btnForSms_Click(object sender, EventArgs e)
    {
        try
        {
            foreach (GridViewRow gvdr in this.GridViewAgent.Rows)
            {
                if (((CheckBox)gvdr.FindControl("chk1")).Checked == true)
                {
                    Label lbl_loginid = (Label)gvdr.FindControl("lbl_loginid");
                    SqlParameter[] paramChangeLoginStatus = new SqlParameter[]
                    {
                        new SqlParameter("@Portal","Sms"),
                        new SqlParameter("@loginid",lbl_loginid.Text)
                    };
                    SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "UDP_CHANGEUSERWORKINGSTATUS", paramChangeLoginStatus);                    
                    div_gridview.Visible = true;
                    GridViewAgent.Visible = true;
                    GridViewWL.Visible = false;
                    GridViewMDS.Visible = false;
                    GridViewDS.Visible = false;
                    btnForWeb.Visible = true;
                    btnForSms.Visible = true;
                    btnForWebSD.Visible = false;
                    btnForSmsDS.Visible = false;
                    btnForWebMDS.Visible = false;
                    btnForSmsMDS.Visible = false;
                    btnForWebWL.Visible = false;
                    btnForSmsWL.Visible = false;
                    getdata(ViewState["user"].ToString());
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('Working Status Changed For SMS Application');"), true);
                }
                else
                {
                    div_gridview.Visible = true;
                    GridViewAgent.Visible = true;
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('Please Select check box.');"), true);
                }
            }
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There is some technical problem. Please try again');"), true);
            throw (ex);
        }
    }

    protected void btnForWebDS_Click(object sender, EventArgs e)
    {
        try
        {
            foreach (GridViewRow gvdr in this.GridViewDS.Rows)
            {
                if (((CheckBox)gvdr.FindControl("chk2")).Checked == true)
                {
                    Label lbl_loginid = (Label)gvdr.FindControl("lbl_loginid");
                    SqlParameter[] paramChangeLoginStatus = new SqlParameter[]
                    {
                        new SqlParameter("@Portal","Web"),
                        new SqlParameter("@loginid",lbl_loginid.Text)
                    };
                    SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "UDP_CHANGEUSERWORKINGSTATUS", paramChangeLoginStatus);                    
                    div_gridview.Visible = true;
                    GridViewAgent.Visible = false;
                    GridViewWL.Visible = false;
                    GridViewMDS.Visible = false;
                    GridViewDS.Visible = true;
                    btnForWeb.Visible = false;
                    btnForSms.Visible = false;
                    btnForWebSD.Visible = true;
                    btnForSmsDS.Visible = true;
                    btnForWebMDS.Visible = false;
                    btnForSmsMDS.Visible = false;
                    btnForWebWL.Visible = false;
                    btnForSmsWL.Visible = false;
                    getdata(ViewState["user"].ToString());
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('Working Status Changed For Web Application');"), true);
                }
                else
                {
                    div_gridview.Visible = true;
                    GridViewDS.Visible = true;
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "anc", string.Format("alert('Please select one check box.');"), true);
                }
            }            
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There is some technical problem. Please try again');"), true);
            throw (ex);
        }
    }

    protected void btnForSmsDS_Click(object sender, EventArgs e)
    {
        try
        {
            foreach (GridViewRow gvdr in this.GridViewDS.Rows)
            {
                if (((CheckBox)gvdr.FindControl("chk2")).Checked == true)
                {
                    Label lbl_loginid = (Label)gvdr.FindControl("lbl_loginid");

                    SqlParameter[] paramChangeLoginStatus = new SqlParameter[]
                    {
                        new SqlParameter("@Portal","Sms"),
                        new SqlParameter("@loginid",lbl_loginid.Text)
                    };
                    SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "UDP_CHANGEUSERWORKINGSTATUS", paramChangeLoginStatus);                   
                    div_gridview.Visible = true;
                    GridViewAgent.Visible = false;
                    GridViewWL.Visible = false;
                    GridViewMDS.Visible = false;
                    GridViewDS.Visible = true;
                    btnForWeb.Visible = false;
                    btnForSms.Visible = false;
                    btnForWebSD.Visible = true;
                    btnForSmsDS.Visible = true;
                    btnForWebMDS.Visible = false;
                    btnForSmsMDS.Visible = false;
                    btnForWebWL.Visible = false;
                    btnForSmsWL.Visible = false;
                    getdata(ViewState["user"].ToString());
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('Working Status Changed For SMS Application');"), true);
                }
                else
                {
                    div_gridview.Visible = true;
                    GridViewDS.Visible = true;
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "abc", string.Format("alert('Please select check box.');"),true);
                }
            }
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There is some technical problem. Please try again');"), true);
            throw (ex);
        }
    }

    protected void btnForWebMDS_Click(object sender, EventArgs e)
    {
        try
        {
            foreach (GridViewRow gvdr in this.GridViewMDS.Rows)
            {
                if (((CheckBox)gvdr.FindControl("chk3")).Checked == true)
                {
                    Label lbl_loginid = (Label)gvdr.FindControl("lbl_loginid");

                    SqlParameter[] paramChangeLoginStatus = new SqlParameter[]
                    {
                        new SqlParameter("@Portal","Web"),
                        new SqlParameter("@loginid",lbl_loginid.Text)
                    };
                    SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "UDP_CHANGEUSERWORKINGSTATUS", paramChangeLoginStatus);
                    div_gridview.Visible = true;
                    GridViewAgent.Visible = false;
                    GridViewWL.Visible = false;
                    GridViewMDS.Visible = true;
                    GridViewDS.Visible = false;
                    btnForWeb.Visible = false;
                    btnForSms.Visible = false;
                    btnForWebSD.Visible = false;
                    btnForSmsDS.Visible = false;
                    btnForWebMDS.Visible = true;
                    btnForSmsMDS.Visible = true;
                    btnForWebWL.Visible = false;
                    btnForSmsWL.Visible = false;
                    getdata(ViewState["user"].ToString());
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('Working Status Changed For Web Application');"), true);
                }
                else
                {
                    div_gridview.Visible = true;
                    GridViewMDS.Visible = true;
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "abc", string.Format("alert('please select check box.');"), true);
                }
            }
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There is some technical problem. Please try again');"), true);
            throw (ex);
        }
    }

    protected void btnForSmsMDS_Click(object sender, EventArgs e)
    {
        try
        {
            foreach (GridViewRow gvdr in this.GridViewMDS.Rows)
            {
                if (((CheckBox)gvdr.FindControl("chk3")).Checked == true)
                {
                    Label lbl_loginid = (Label)gvdr.FindControl("lbl_loginid");

                    SqlParameter[] paramChangeLoginStatus = new SqlParameter[]
                    {
                        new SqlParameter("@Portal","Sms"),
                        new SqlParameter("@loginid",lbl_loginid.Text)
                    };
                    SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "UDP_CHANGEUSERWORKINGSTATUS", paramChangeLoginStatus);
                    div_gridview.Visible = true;
                    GridViewAgent.Visible = false;
                    GridViewWL.Visible = false;
                    GridViewMDS.Visible = true;
                    GridViewDS.Visible = false;
                    btnForWeb.Visible = false;
                    btnForSms.Visible = false;
                    btnForWebSD.Visible = false;
                    btnForSmsDS.Visible = false;
                    btnForWebMDS.Visible = true;
                    btnForSmsMDS.Visible = true;
                    btnForWebWL.Visible = false;
                    btnForSmsWL.Visible = false;
                    getdata(ViewState["user"].ToString());
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('Working Status Changed For SMS Application');"), true);
                }
                else
                {
                    div_gridview.Visible = true;
                    GridViewMDS.Visible = true;
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "abc", string.Format("alert('Please select check box');"), true);
                }
            }
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There is some technical problem. Please try again');"), true);
            throw (ex);
        }
    }

    protected void btnForWebWL_Click(object sender, EventArgs e)
    {
        try
        {
            foreach (GridViewRow gvdr in this.GridViewWL.Rows)
            {
                if (((CheckBox)gvdr.FindControl("chk1")).Checked == true)
                {
                    Label lbl_loginid = (Label)gvdr.FindControl("lbl_loginid");

                    SqlParameter[] paramChangeLoginStatus = new SqlParameter[]
                    {
                        new SqlParameter("@Portal","Web"),
                        new SqlParameter("@loginid",lbl_loginid.Text)
                    };
                    SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "UDP_CHANGEUSERWORKINGSTATUS", paramChangeLoginStatus);                    
                    div_gridview.Visible = true;
                    GridViewAgent.Visible = false;
                    GridViewWL.Visible = true;
                    GridViewMDS.Visible = false;
                    GridViewDS.Visible = false;
                    btnForWeb.Visible = false;
                    btnForSms.Visible = false;
                    btnForWebSD.Visible = false;
                    btnForSmsDS.Visible = false;
                    btnForWebMDS.Visible = false;
                    btnForSmsMDS.Visible = false;
                    btnForWebWL.Visible = true;
                    btnForSmsWL.Visible = true;
                    getdata(ViewState["user"].ToString());
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('Working Status Changed For Web Application');"), true);
                }
                else
                {
                    div_gridview.Visible = true;
                    GridViewWL.Visible = true;
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "abc", string.Format("alert('Please select check box');"), true);
                }
            }
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There is some technical problem. Please try again');"), true);
            throw(ex);
        }
    }

    protected void btnForSmsWL_Click(object sender, EventArgs e)
    {
        try
        {
            foreach (GridViewRow gvdr in this.GridViewWL.Rows)
            {
                if (((CheckBox)gvdr.FindControl("chk1")).Checked == true)
                {
                    Label lbl_loginid = (Label)gvdr.FindControl("lbl_loginid");

                    SqlParameter[] paramChangeLoginStatus = new SqlParameter[]
                    {
                        new SqlParameter("@Portal","Sms"),
                        new SqlParameter("@loginid",lbl_loginid.Text)
                    };
                    SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "UDP_CHANGEUSERWORKINGSTATUS", paramChangeLoginStatus);                    
                    div_gridview.Visible = true;
                    GridViewAgent.Visible = false;
                    GridViewWL.Visible = true;
                    GridViewMDS.Visible = false;
                    GridViewDS.Visible = false;
                    btnForWeb.Visible = false;
                    btnForSms.Visible = false;
                    btnForWebSD.Visible = false;
                    btnForSmsDS.Visible = false;
                    btnForWebMDS.Visible = false;
                    btnForSmsMDS.Visible = false;
                    btnForWebWL.Visible = true;
                    btnForSmsWL.Visible = true;
                    getdata(ViewState["user"].ToString());
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('Working Status Changed For SMS Application');"), true);
                }
                else
                {
                    div_gridview.Visible = true;
                    GridViewWL.Visible = true;
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "abc", string.Format("alert('Please select check box');"), true);
                }
            }
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OhCrap", String.Format("alert('There is some technical problem. Please try again');"), true);
            throw(ex);
        }
    }

    protected void ddlUserInfo_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlUserInfo.SelectedItem.Text.Equals("White Label"))
        {
            Response.Redirect("RegisteredWL.aspx?var=White Label");
        }
        else if (ddlUserInfo.SelectedItem.Text.Equals("Master Distributor"))
        {
            Response.Redirect("RegisteredMDS.aspx?var=Master Distributor");
        }
        else if (ddlUserInfo.SelectedItem.Text.Equals("Distributor"))
        {
            Response.Redirect("registereddistributor.aspx?var=Distributor");
        }
        else if (ddlUserInfo.SelectedItem.Text.Equals("Agent"))
        {
            Response.Redirect("ViewAgents.aspx?var=Agent") ;
        }
        else if (ddlUserInfo.SelectedItem.Text.Equals("Advance Search"))
        {
            Response.Redirect("AdvanceSearch.aspx?var=Advance Search");
        }
    }
}
