using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using SteamWare;
using GMW_data;

namespace GMW.WS
{
    /// <summary>
    /// servizi per AutoCompletamento oggetti
    /// </summary>
    [WebService(Namespace = "http://www.steamware.net/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 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 AutoCompletamento : System.Web.Services.WebService
    {

        [System.Web.Services.WebMethod]
        public string[] elencoParticolari(string prefixText, int count)
        {
            // inizializzo risposta
            List<string> suggerimenti = new List<string>();
            // proseguo SOLO SE min "MinCharAutocomplete" char...
            if (count > memLayer.ML.confReadInt("MinCharAutocomplete"))
            {
                // elenco candidati
                DS_magazzino.V_ParticolariOverviewDataTable tabParticolari = MagClass.magazzino.taVParticolariOverwiew.getByLikePrefix(prefixText, memLayer.ML.confReadString("CodCS"));
                // aggiungo ogni riga...
                foreach (DS_magazzino.V_ParticolariOverviewRow riga in tabParticolari)
                {
                    suggerimenti.Add(riga.Particolare);
                }
            }
            return suggerimenti.ToArray();
        }

    }
}
