วันอาทิตย์ที่ ๑๕ เมษายน พ.ศ. ๒๕๕๐

กรมสรรพากร Web Services ตรวจสอบเลขที่บัตรประชาชน

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Security.Cryptography.X509Certificates;
using System.Net;
using System.Net.Security;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(TrustAllCertificateCallback);
}
}

public string checkpin(string citizen_id)
{
th.go.rd.rdws.CheckTINPINService p = new th.go.rd.rdws.CheckTINPINService();

DataSet result = new DataSet();


// p.ClientCertificates.Add(x509);
// p.ServicePINAsync(
p.Timeout = 600*1000;
result = p.ServicePIN("anonymous","anonymous",citizen_id);
string r=string.Empty;


foreach (DataRow pRow in result.Tables[0].Rows) {
r= pRow[1].ToString();
}

if (result.Tables.Count >1)
{
foreach (DataRow sRow in result.Tables[1].Rows) {
r += sRow[0].ToString();
r += sRow[1].ToString();
}
}
if (r=="") {
return "No "+r;
}
else
{ return "OK "+r;}


}

protected void Button1_Click(object sender, EventArgs e)
{
// Load the client certificate from a file.
// X509Certificate x509 = X509Certificate.CreateFromCertFile(@"d:\My Project\Demo\AJAXTodoList\iisx509.cer");

th.go.rd.rdws.CheckTINPINService p = new th.go.rd.rdws.CheckTINPINService();

DataSet result = new DataSet();


// p.ClientCertificates.Add(x509);
// p.ServicePINAsync(
p.Timeout = 600*1000;
result = p.ServicePIN("anonymous","anonymous","citizen id xxxx");


foreach (DataRow pRow in result.Tables[0].Rows) {
CitizenLabel.Text = pRow[0].ToString();
DigitOkLabel.Text = pRow[1].ToString();
IsExistLabel.Text = pRow[2].ToString();
}

foreach (DataRow sRow in result.Tables[1].Rows) {
CodeLabel.Text = sRow[0].ToString();
DescriptionLabel.Text = sRow[1].ToString();
}

}

public static bool TrustAllCertificateCallback(Object sender,X509Certificate cert,X509Chain chain,SslPolicyErrors errors)
{
return true;
}
}

0 ความคิดเห็น: