01.
using
System.Data.SqlClient;
02.
using
System.Web.Configuration;
03.
using
System.Text;
04.
05.
public
partial
class
Upload_TestAutoPostBack : System.Web.UI.Page
06.
{
07.
protected
void
Page_Load(
object
sender, EventArgs e)
08.
{
09.
10.
}
11.
protected
void
TextBox1_TextChanged(
object
sender, EventArgs e)
12.
{
13.
if
(System.Convert.ToInt32(Check(System.Convert.ToInt32(TextBox1.Text))) == 0)
14.
{
15.
Label1.Text =
"NO"
;
16.
}
17.
else
18.
{
19.
Label1.Text =
"OK"
;
20.
}
21.
}
22.
protected
Object Check(
int
emp)
23.
{
24.
string
strCon = WebConfigurationManager.ConnectionStrings[
"OfficeConnect"
].ConnectionString;
25.
SqlConnection con =
new
SqlConnection();
26.
con.ConnectionString = strCon;
27.
con.Open();
28.
29.
StringBuilder str =
new
StringBuilder();
30.
str.Append(
"SELECT COUNT(EMP_ID) AS ANS"
);
31.
str.Append(
" FROM TB_HR_Emp"
);
32.
str.Append(
" WHERE EMP_ID ="
+emp);
33.
SqlCommand com =
new
SqlCommand(str.ToString(), con);
34.
Object myCount = com.ExecuteScalar();
35.
36.
con.Close();
37.
return
myCount;
38.
39.
40.
}
41.
}