protected int DisplayNameOnLabel()
        {
            string searchColumn = "";
            string searchValue  = "";

            searchColumn = "Name";
            searchValue  = txtSearchElderInput.Text;

            Volunteers objVolunteer = new Volunteers();

            objVolunteer.EmailAddr = Session["LoginID"].ToString();
            objVolunteer.getPass();
            objVolunteer.getId();
            string VolID = objVolunteer.getId();

            string strConn = ConfigurationManager.ConnectionStrings
                             ["P2ConnectionString"].ToString();

            SqlConnection conn = new SqlConnection(strConn);

            SqlCommand cmd = new SqlCommand("SELECT * FROM Elder WHERE " + searchColumn + " =@value AND VolunteerID = @VolunteerID", conn);

            cmd.Parameters.AddWithValue("@value", txtSearchElderInput.Text);

            try
            {
                conn.Open();
                conn.Close();

                return(1);
            }
            catch
            {
                return(0);
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataSet    result       = new DataSet();
            Elderlies  objElder     = new Elderlies();
            Volunteers objVolunteer = new Volunteers();

            objVolunteer.EmailAddr = Session["LoginID"].ToString();
            objVolunteer.getPass();
            objVolunteer.getId();

            int errorCode = objVolunteer.getPrepare(ref result);

            if (errorCode == 0)
            {
                gvElderPrepare.DataSource = result.Tables["ElderDetails"];
                gvElderPrepare.DataBind();
            }
        }
        protected int searchElders()
        {
            string searchColumn = "";
            string searchValue  = "";
            string sqlCommand   = "";

            Volunteers objVolunteer = new Volunteers();

            objVolunteer.EmailAddr = Session["LoginID"].ToString();
            objVolunteer.getPass();
            objVolunteer.getId();
            string VolID = objVolunteer.getId();


            if (rdoSerial.Checked)
            {
                searchColumn = "SerialNo";
                searchValue  = txtSearchElderInput.Text + "%";
                DisplayNameOnLabel();
                sqlCommand = " LIKE";
                if (searchValue == "%%")
                {
                    return(0);
                }
            }

            else
            {
                searchColumn = "Name";
                searchValue  = txtSearchElderInput.Text + "%";
                sqlCommand   = " LIKE";

                if (searchValue == "%%")
                {
                    return(0);
                }
            }

            string strConn = ConfigurationManager.ConnectionStrings
                             ["P2ConnectionString"].ToString();

            SqlConnection conn = new SqlConnection(strConn);

            SqlCommand cmd = new SqlCommand("SELECT * FROM Elder WHERE " + searchColumn + sqlCommand + " @value AND VolunteerID = @VolunteerID", conn);

            cmd.Parameters.AddWithValue("@value", searchValue);
            cmd.Parameters.AddWithValue("@VolunteerID", VolID);

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            DataSet result = new DataSet();

            try
            {
                conn.Open();
                da.Fill(result, "ElderDetails");
                conn.Close();

                gvElderN.DataSource = result.Tables["ElderDetails"];
                gvElderN.DataBind();

                if (result.Tables["ElderDetails"].Rows.Count == 0)
                {
                    return(0);
                }
                else
                {
                    return(1);
                }
            }
            catch
            {
                return(0);
            }
        }