<%@ WebHandler Language="C#" Class="AutoCompleteByCardNo" %>
using System;
using System.Web;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
public class AutoCompleteByCardNo : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        string prefixText = context.Request.QueryString["q"];
        string Empautoid = context.Request.QueryString["EmpAutoid"];
        using (SqlConnection conn = new SqlConnection())
        {
            string strDecryptedConnectionString = string.Empty;
            strDecryptedConnectionString = Cryptographys.Cryptography.GetDecryptedConnectionString();
            conn.ConnectionString = strDecryptedConnectionString;
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.CommandText = "Proc_TA_AutoCompleteCommaSeparated";
                cmd.CommandType = CommandType.StoredProcedure;
                //cmd.CommandText = "select swipecardNo from TA_Tbl_Employee where " +
                //"swipecardNo like @SearchText + '%' and swipecardNo not in('18000000') and isdeleted=0";
                cmd.Parameters.AddWithValue("@RequiredInput", prefixText);
                cmd.Parameters.AddWithValue("@SearchType", "SwipeCardNo");
                // Included Empautoid by A.Amsaveni on 30/09/2013 to show employees based on the grade 
                cmd.Parameters.AddWithValue("@EmpAutoId", Empautoid);
                cmd.Connection = conn;
                StringBuilder sb = new StringBuilder();
                conn.Open();
                using (SqlDataReader sdr = cmd.ExecuteReader())
                {
                    while (sdr.Read())
                    {
                        sb.Append(sdr["swipecardNo"])
                            .Append(Environment.NewLine);
                    }
                }
                conn.Close();
                context.Response.Write(sb.ToString());
            }
        }
    }
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}