using System;
using System.Web;
using System.Web.Services;
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Data;
/// <summary>
/// Summary description for AutoCompleteExtender
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class AutoCompleteExtender : System.Web.Services.WebService
{
    Database DBCon = DatabaseFactory.CreateDatabase("DBConnection");
    LeaveEventData objLeave = new LeaveEventData();
    public AutoCompleteExtender()
    {
        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }
    [WebMethod]
    public string HelloWorld()
    {
        return "Hello World";
    }
    [WebMethod(EnableSession = true)]
    public string[] GetCardNo(string prefixText, int count)
    {
        string Empautoid = string.Empty;
        string ParentLevelId = "0";
        ParentLevelId = Convert.ToString(HttpContext.Current.Session["parentLevelId"]);
        Empautoid = HttpContext.Current.Session["EmpAutoID"].ToString();
        DataSet ds = new DataSet();
        ds = objLeave.SelectAutoCompleteExtender(prefixText, "CardNo", Empautoid, ParentLevelId);
        string[] strCollection = new string[ds.Tables[0].Rows.Count];
        int i = 0;
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            strCollection.SetValue("'" + dr["swipecardno"].ToString() + "'", i);
            i++;
        }
        return strCollection;
    }
    [WebMethod(EnableSession = true)]
    public string[] GetCardNoForReports(string prefixText, int count)
    {
        string Empautoid = string.Empty;
        string ParentLevelId = "0";
        ParentLevelId = Convert.ToString(HttpContext.Current.Session["parentLevelId"]);
        Empautoid = HttpContext.Current.Session["EmpAutoID"].ToString();
        DataSet ds = new DataSet();
        ds = objLeave.SelectAutoCompleteExtenderForReports(prefixText, "CardNo", Empautoid, ParentLevelId);
        string[] strCollection = new string[ds.Tables[0].Rows.Count];
        int i = 0;
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            strCollection.SetValue("'" + dr["swipecardno"].ToString() + "'", i);
            i++;
        }
        return strCollection;
    }
    [WebMethod(EnableSession = true)]
    public string[] GetEmployeeName(string prefixText, int count)
    {
        string Empautoid = string.Empty;
        Empautoid = HttpContext.Current.Session["EmpAutoID"].ToString();
        string ParentLevelId = "0";
        ParentLevelId = Convert.ToString(HttpContext.Current.Session["parentLevelId"]);
        DataSet ds = new DataSet();
        ds = objLeave.SelectAutoCompleteExtender(prefixText, "EmployeeName", Empautoid, ParentLevelId);
        string[] strCollection = new string[ds.Tables[0].Rows.Count];
        int i = 0;
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            strCollection.SetValue("'" + dr["Employee_firstName"].ToString() + "'", i);
            i++;
        }
        return strCollection;
    }
    [WebMethod(EnableSession = true)]
    public string[] GetEmployeeNameForReports(string prefixText, int count)
    {
        string Empautoid = string.Empty;
        Empautoid = HttpContext.Current.Session["EmpAutoID"].ToString();
        string ParentLevelId = "0";
        ParentLevelId = Convert.ToString(HttpContext.Current.Session["parentLevelId"]);
        DataSet ds = new DataSet();
        ds = objLeave.SelectAutoCompleteExtenderForReports(prefixText, "EmployeeName", Empautoid, ParentLevelId);
        string[] strCollection = new string[ds.Tables[0].Rows.Count];
        int i = 0;
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            strCollection.SetValue("'" + dr["Employee_firstName"].ToString() + "'", i);
            i++;
        }
        return strCollection;
    }
    [WebMethod(EnableSession = true)]
    public string[] GetEmployeeId(string prefixText, int count)
    {
        string Empautoid = string.Empty;
        Empautoid = HttpContext.Current.Session["EmpAutoID"].ToString();
        string ParentLevelId = "0";
        ParentLevelId = Convert.ToString(HttpContext.Current.Session["parentLevelId"]);
        DataSet ds = new DataSet();
        ds = objLeave.SelectAutoCompleteExtender(prefixText, "EmployeeId", Empautoid, ParentLevelId);
        string[] strCollection = new string[ds.Tables[0].Rows.Count];
        int i = 0;
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            strCollection.SetValue("'" + dr["Employee_Code_Id"].ToString() + "'", i);
            i++;
        }
        return strCollection;
    }
    [WebMethod(EnableSession = true)]
    public string[] GetEmployeeIdForReports(string prefixText, int count)
    {
        string Empautoid = string.Empty;
        Empautoid = HttpContext.Current.Session["EmpAutoID"].ToString();
        string ParentLevelId = "0";
        ParentLevelId = Convert.ToString(HttpContext.Current.Session["parentLevelId"]);
        DataSet ds = new DataSet();
        ds = objLeave.SelectAutoCompleteExtenderForReports(prefixText, "EmployeeId", Empautoid, ParentLevelId);
        string[] strCollection = new string[ds.Tables[0].Rows.Count];
        int i = 0;
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            strCollection.SetValue("'" + dr["Employee_Code_Id"].ToString() + "'", i);
            i++;
        }
        return strCollection;
    }
}
