后置代码中在页面第一次加载时将对记录用户档案号的Session进行判断,为空(null)则提示用户重新登录否则取出当前用户的相关资料显示。
“上一步”按钮的事件为客户端JavaScript脚本返回找回密码第一步(getPwd1.aspx),“下一步”按钮则根据用户输入的“密码答案”调用Users类中的初始化对象程序以判断记录的档案号和提供的密码是否存在于数据库中,存在则进入getPwd3.aspx否则返回getPwd2.aspx重新输入密码答案。
getPwd3.aspx包含姓名、性别、年龄、档案编号、查询密码五个Label控件用于显示用户资料;包
含“登录”和“关闭”两个按钮。
后置代码中在页面第一次加载时将对记录用户档案号的Session进行判断,为空(null)则提示用户重新登录否则取出当前用户的相关资料显示;“登录按钮”的点击事件(ImgBtnOK_Click)则直接将页面跳转到登录窗体(UserLogin.aspx);“关闭”按钮用客户端脚本JavaScript对窗体进行关闭。
(4)、查询主窗体(Default.aspx):
包含用户姓名、档案编号、体检次数三个文本框(TextBox),并且姓名和档案号两个TextBox的Enabled属性为false,只有体检次数才提供给用户交互式输入;包含“查询”、“退出”、“修改密码”三个按钮。
后置代码中在页面第一次加载时将对记录用户档案号的Session进行判断,为空(null)则提示用户重新登录否则将记录档案号和用户姓名的Session内容分别赋值给档案号和姓名两个文本框。
“查询”按钮以客户端JavaScript脚本传递用户输入的体检次数给体检结果显示窗体;“退出”按钮以客户端JavaScript脚本将界面转至用户登录窗体;“修改密码”按钮以客户端JavaScript脚本将界面转到“用户资料修改”界面。
(5)、体检结果显示窗体(ShowInfo.aspx):
包含由于包含的控件太多就不一一介绍;
后置代码在页面第一次加载时将对记录用户档案号的Session进行判断,为空(null)则提示用户重新登录否则根据传入的体检次数参数和记录的档案号Session读取数据库中的用户记录和xml_data目录中的XML文档,并调用MakeTable类的MakeTableByXml子程序生成体检结果详细显示界面。
3.6程序源代码
程序实现的部分代码如下:
1、 公共类源码:
(1)、数据库连接、操作类(DataAdapter.cs):
using System; using System.Data; using System.Data.Common; 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.Reflection; using System.Web.Configuration; namespace Zhigu.ZgData
{
///
public class DataAdapter : IDisposable {
protected bool isTran;
protected ConnectionStringSettings connStr; protected DbConnection conn; protected DbTransaction tran; protected bool paraAllowName; public DataAdapter() {
this.isTran = false; this.connStr =
WebConfigurationManager.ConnectionStrings[WebConfigurationManager.AppSettings[\tionString\]];
this.Init(); }
protected void Init() {
this.InitConn(); if (this.isTran) {
this.tran = this.conn.BeginTransaction(); }
this.paraAllowName = this.connStr.ProviderName == \; }
protected void InitConn() {
Assembly assembly1 = typeof(DbConnection).Assembly; Type[] typeArray1 = assembly1.GetTypes(); foreach (Type type1 in typeArray1) {
if ((type1.BaseType == typeof(DbConnection)) && (type1.Namespace == this.connStr.ProviderName)) {
this.conn = assembly1.CreateInstance(type1.FullName) as DbConnection; this.conn.ConnectionString = this.connStr.ConnectionString; this.conn.Open(); return; } } }
protected DbDataAdapter CreatAdapter() {
Assembly assembly1 = typeof(DbConnection).Assembly; Type[] typeArray1 = assembly1.GetTypes(); foreach (Type type1 in typeArray1) {
if ((type1.BaseType == typeof(DbDataAdapter)) && (type1.Namespace == this.connStr.ProviderName)) {
return (assembly1.CreateInstance(type1.FullName) as DbDataAdapter); } }
return null; }
protected DbCommand CreatCommand(string commandText, object[] paraValue) {
DbCommand command1 = this.conn.CreateCommand(); if (this.tran != null) {
command1.Transaction = this.tran; }
object[] objArray1 = paraValue; int num1 = 0;
while (num1 < objArray1.Length) {
DbParameter parameter1 = command1.CreateParameter(); parameter1.Value = objArray1[num1]; if (this.paraAllowName) {
parameter1.ParameterName = \ + num1; }
command1.Parameters.Add(parameter1); num1++; }
num1 = 0;
if (this.paraAllowName) {
while (commandText.IndexOf(\) != -1) {
commandText = string.Concat(new object[] { commandText.Substring(0, commandText.IndexOf(\)), \, num1, commandText.Substring(commandText.IndexOf(\) + 1) });
num1++; }
}
command1.CommandText = commandText; return command1; }
protected DbCommand CreatCommand(string commandText, string[] paraValue) {
DbCommand command1 = this.conn.CreateCommand(); if (this.tran != null) {
command1.Transaction = this.tran; }
string[] textArray1 = paraValue; int num1 = 0;
while (num1 < textArray1.Length) {
DbParameter parameter1 = command1.CreateParameter(); parameter1.Value = textArray1[num1]; if (this.paraAllowName) {
parameter1.ParameterName = \ + num1; }
command1.Parameters.Add(parameter1); num1++; }
num1 = 0;
if (this.paraAllowName) {
while (commandText.IndexOf(\) != -1) {
commandText = string.Concat(new object[] { commandText.Substring(0, commandText.IndexOf(\)), \, num1, commandText.Substring(commandText.IndexOf(\) + 1) });
num1++; } }
command1.CommandText = commandText; return command1; }
public void Dispose() {
if (this.tran != null) {
this.tran.Dispose(); }
if (this.conn != null) {
if (this.conn.State != ConnectionState.Closed) {
this.conn.Close(); }
this.conn.Dispose(); }
GC.SuppressFinalize(this); }
public DataTable ExecuteDataTable(string commandText) {
DataTable table1 = new DataTable();
DbDataAdapter adapter1 = this.CreatAdapter(); DbCommand command1 = this.conn.CreateCommand(); command1.CommandText = commandText; adapter1.SelectCommand = command1; try {
adapter1.Fill(table1); } finally {
adapter1.Dispose(); }
return table1; }
public DataTable ExecuteDataTable(string commandText, object[] paraValue) {
DataTable table1 = new DataTable();
DbDataAdapter adapter1 = this.CreatAdapter();
adapter1.SelectCommand = this.CreatCommand(commandText, paraValue); try {
adapter1.Fill(table1); } finally {
adapter1.Dispose(); }
return table1; }
public DataTable ExecuteDataTable(string commandText, string[] paraValue) {