<%@ WebService class = "ReturnOrders" Language="C#" Debug = "true"%>
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Data.SqlClient;
using System.Web.Services;
public class Order
{
private string _name = string.Empty;
private string _surname = string.Empty;
private string _zone = string.Empty;
private string _client = string.Empty;
private string _control = string.Empty;
public Order() {}
public string Name
{
get { return _name; }
set { _name = value; }
}
public string Zone
{
get { return _zone; }
set { _zone = value; }
}
public string Surname
{
get { return _surname; }
set { _surname = value; }
}
public string Client
{
get { return _client; }
set { _client = value; }
}
public string Control
{
get { return _control; }
set { _control = value; }
}
}
public class ReturnOrders : WebService
{
const string connStr = "server=192.168.61.28;uid=sa;pwd=wy;database=Pan";
[WebMethod(Description = "Method to obtain All User Info")]
public Order[] ReturnArray()
{
SqlConnection dbConn = new SqlConnection(connStr);
dbConn.Open();
string sqlSelect = " SELECT TOP (100) dbo.PersoanaFizica.Nume as Name , dbo.PersoanaFizica.Prenume as Surname, dbo.Zona.Denumire AS Zone, dbo.Persoana.Denumire AS Client , dbo.[Document].Control " +
" FROM dbo.[Document] INNER JOIN " +
" dbo.PersoanaFizica ON dbo.[Document].Utilizator_ID = dbo.PersoanaFizica.PersoanaFizica_ID INNER JOIN " +
" dbo.Persoana ON dbo.[Document].Persoana_ID = dbo.Persoana.PersoanaID INNER JOIN " +
" dbo.Comanda ON dbo.[Document].DocumentID = dbo.Comanda.Comanda_ID INNER JOIN " +
" dbo.Utilizator ON dbo.[Document].Utilizator_ID = dbo.Utilizator.UtilizatorID INNER JOIN " +
" dbo.Zona ON dbo.Utilizator.ZonaID = dbo.Zona.Id " +
" WHERE (dbo.Zona.Denumire LIKE '%RESITA%') " +
" ORDER BY Control DESC ";
SqlDataAdapter da = new SqlDataAdapter(sqlSelect, dbConn);
DataTable dt = new DataTable();
SqlCommand dbCommand = new SqlCommand(sqlSelect, dbConn);
da.Fill(dt);
dbConn.Close();
List
foreach(DataRow row in dt.Rows) {
// Person target = Activator.CreateInstance
Order target = new Order();
target.Name = row["Name"].ToString();
target.Surname = row["Surname"].ToString();
target.Zone = row["Zone"].ToString();
target.Client = row["Client"].ToString();
target.Control = row["Control"].ToString();
list.Add(target);
}
return list.ToArray();
}
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
No comments:
Post a Comment