using System;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Data.Sql;
using System.Data.SqlClient;
///
/// Summary description for arvutusabiline
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
// 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 arvutusabiline : System.Web.Services.WebService {
public arvutusabiline () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
[WebMethod]
public int Korruta(int a, int b) {
return a * b;
}
[WebMethod]
public string[] Korrutused(string prefixText, int count, string contextKey)
{
try
{
int tegur = Convert.ToInt32(prefixText);
List vastused = new List();
for (int i = 1; i <= count; i++) {
vastused.Add(prefixText + "x" + i +"="+ (tegur * i));
}
return vastused.ToArray();
}
catch (Exception ex) {
}
return new string[] { "Ei saa korrutada" };
}
[WebMethod]
public string[] OtsitavadSonad(string prefixText, int count, string contextKey)
{
try
{
SqlConnection cn = new SqlConnection(
"Data Source=.\\SQLEXPRESS; Initial Catalog=jatkukursus; "+
"Integrated Security=true");
SqlCommand cm = new SqlCommand("SELECT eesnimi FROM lapsed " +
"WHERE eesnimi LIKE @algus+'%'", cn);
cn.Open();
cm.Parameters.AddWithValue("algus", prefixText);
List eesnimed = new List();
SqlDataReader lugeja = cm.ExecuteReader();
while (lugeja.Read()) {
eesnimed.Add(lugeja.GetString(0));
}
return eesnimed.ToArray();
}
catch (Exception ex)
{
}
return new string[] { "Probleem andmetega" };
}
[WebMethod]
public string[] GetCompletionList(string prefixText, int count, string contextKey)
{
//return default(string[]);
return new string[] { "Juhan", "kati", "mati", "madis" };
}
}