在这里,旅客输入相关信息,进行注册,其中,全部选项填写完毕后,旅客可以点击相关按钮查看自己的用户名是否被注册过,成功注册后,页面将直接跳转进下面界面:
以上显示的全是列车的基本信息,以及票的销售信息,旅客可以通过不同的条件对这些信息进行模糊查询,如果需要定票,点击“进入”:
旅客输入需要定的票数后,系统会给出提示,该旅客的订票信息已经保存入数据库,等待着管理员的审核,管理员审核通过后,该票才会通过某些方式到旅客手中。
点击“管理员请进”进入管理员操作模块:
管理员输入用户名和密码,并输入正确的权限后,可以进入相关界面进行操作,以下以总管理员(用户名为:admin 密码为:admin)登陆系统:
进入“管理员信息设置”
在这个模块,总管理员可以添加,删除,修改管理员的基本信息:
修改管理员登陆信息。
“列车基本信息设置”
在这里管理员可以添加新的列车信息,也可以查看某具体列车信息,修改某具体列车信息,删除某具体列车信息。
“列车运行时刻设置”:
在这里,管理员可以分类模糊查询自己感兴趣的数据,点击“查看”,进入该班次列车的详细信息,点击修改,可以对相关信息进行修改,点击“删除”则将该条信息进行删除。
点击“添加”进入:
“列车票价信息设置”:
进入“添加票价信息”
在这里,我们可以根据具体情况,设置车票的价格,其中“售票开始站”是指在某个区间段内的开始站,“售票结束站”是指在某个区间段内的结束站。本模块的输入尤其要重视对于时间的输入。添加完成票务信息后,我们可以查看某各具体的票务信息,可以修改该票务信息内容,也可以为该票务信息重新设置票的数量等。各种操作如下:
以上为查看。
以上为重新更新票数。
以上为站点及票价信息更新。
“审核订票信息”:
如上图,如果旅客提供了订票信息后,未审核的旅客订票信息将在该页显示,如果管理员需要对某个旅客的订票信息进行审核,点击该旅客后面的“进入”,
点击“通过审核”后,该旅客的所有订票信息,将会保存入相关数据库,其中原来存有列车票数的表中的列车票数信息也会得到更新(系统会作出判断,如果原来还剩5张车票,但是旅客定的是六张,系统会拒绝审核,并给出相应提示),“取消审核”将会把旅客提交的订票信息完全清空,但是旅客的登记信息依然保存在数据库中,旅客可以凭借登陆信息继续登陆,完成订票。
“查询已定票旅客”
实际实际上是对通过审核的旅客进行查看:
查看“详细信息”:
4.2 系统核心代码
基本类说明:
SqlData类,主要完成对数据库的操作:
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.Data.SqlClient;
///
/// SqlData 的摘要说明
///
public class SqlData
{
private SqlConnection con;
public SqlData()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
///
/// 连接数据库
///
///
public SqlConnection ExceCon()//连接并打开数据库
{
if (con == null)
{ con = new SqlConnection(ConfigurationManager.AppSettings["ConSQL"]); }//从配置文件中读入数据库连接信息
if (con.State == System.Data.ConnectionState.Closed)
con.Open();
return con;
}
#region
///
/// 绑定GridView控件
///
/// 要绑定的GridView控件
/// 要执行的SQL语句
/// 绑定的数据表名
///
public bool BindData(GridView dl, string cmdtxt,string tblName)//将数据绑定到GridView控件
{
dl.DataSource = this.ExceDS(cmdtxt,tblName);//执行SQL语句
try
{
dl.DataBind();
return true;
}
catch
{
return false;
}
finally
{
ExceCon().Close();
}
}
#endregion
#region
///
/// 返回一个DataSet数据类型的数据
///
/// 要执行的SQL语句
/// 要绑定的数据表
///
public DataSet ExceDS(string cmdtxt,string tblName)//返回一个DataSet数据类型
{
SqlConnection Con = ExceCon();
SqlCommand Com;
DataSet ds=null;
try
{
Com = new SqlCommand(cmdtxt, Con);//执行对应的SQL语句
SqlDataAdapter Da = new SqlDataAdapter();
Da.SelectCommand = Com;
ds = new DataSet(tblName);
Da.Fill(ds);//填充数据表
}
catch (Exception ex)
{
Con.Close();
}
return ds;
}
#endregion
#region
///
/// 执行SQL语句
///
/// 要执行的SQL语句
///
public bool ExceSQL(string cmdtxt)//执行相应的SQL语句
{
SqlCommand Com = new SqlCommand(cmdtxt, ExceCon());//执行对应的SQL语句
try
{
Com.ExecuteNonQuery();
sp; return true;
}
catch
{
return false;
}
finally
{
ExceCon().Close();
}
}
#endregion
///
/// 返回SqlDataReader数据类型
///
/// 要执行的SQL语句
///
public SqlDataReader ExceDr(string cmdtxt)//返回SqlDataReader数据类型
{
SqlCommand Com = new SqlCommand(cmdtxt, ExceCon());//执行SQL语句
SqlDataReader dr = Com.ExecuteReader();
return dr;
}
}
//以下为验证码生成代码
ublic class CheckCode
{
public CheckCode()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static void DrawImage()
{
CheckCode img = new CheckCode();
HttpContext.Current.Session["CheckCode"] = img.RndNum(4);
img.checkCodes(HttpContext.Current.Session["CheckCode"].ToString());
}
///
/// 生成验证图片
///
/// 验证字符
private void checkCodes(string checkCode)
{
int iwidth = (int)(checkCode.Length * 13);
System.Drawing.Bitmap image = new System.Drawing.Bitmap(iwidth, 23);
Graphics g = Graphics.FromImage(image);
g.Clear(Color.White);
//定义颜色
Color[] c = { Color.Black, Color.Red, Color.DarkBlue, Color.Green, Color.Orange, Color.Brown, Color.DarkCyan, Color.Purple };
//定义字体
string[] font = { "Verdana", "Microsoft Sans Serif", "Comic Sans MS", "Arial", "宋体" };
Random rand = new Random();
//随机输出噪点
for (int i = 0; i < 50; i++)
; {
int x = rand.Next(image.Width);
int y = rand.Next(image.Height);
g.DrawRectangle(new Pen(Color.LightGray, 0), x, y, 1, 1);
}
//输出不同字体和颜色的验证码字符
for (int i = 0; i < checkCode.Length; i++)
{
int cindex = rand.Next(7);
int findex = rand.Next(5);
Font f = new System.Drawing.Font(font[findex], 10, System.Drawing.FontStyle.Bold);
Brush b = new System.Drawing.SolidBrush(c[cindex]);
int ii = 4;
if ((i + 1) % 2 == 0)
{
ii = 2;
}
g.DrawString(checkCode.Substring(i, 1), f, b, 3 + (i * 12), ii);
}
//画一个边框
g.DrawRectangle(new Pen(Color.Black, 0), 0, 0, image.Width - 1, image.Height - 1);
//输出到浏览器
System.IO.MemoryStream ms = new System.IO.MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
HttpContext.Current.Response.ClearContent();
//Response.ClearContent();
HttpContext.Current.Response.ContentType = "image/Jpeg";
HttpContext.Current.Response.BinaryWrite(ms.ToArray());
g.Dispose();
image.Dispose();
}
///
/// 生成随机的字母
///
/// 生成字母的个数
/// string
private string RndNum(int VcodeNum)
{
string Vchar = "0,1,2,3,4,5,6,7,8,9";
string[] VcArray = Vchar.Split(',');
string VNum = ""; //由于字符串很
短,就不用StringBuilder了
int temp = -1; //记录上次随机数值,尽量避免生产几个一样的随机数
//采用一个简单的算法以保证生成随机数的不同
Random rand = new Random();
for (int i = 1; i < VcodeNum + 1; i++)
{
if (temp != -1)
{
rand = new Random(i * temp * unchecked((int)DateTime.Now.Ticks));
}
int t = rand.Next(VcArray.Length);
if (temp != -1 && temp == t)
{
return RndNum(VcodeNum);
}
temp = t;
VNum += VcArray[t];
}
return VNum;
}
}
//以下为管理员登陆模块的核心代码:
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox3.Text == Convert.ToString(Session["CheckCode"]))//判断用户输入的验证码是否正确
{
ds = sqldata.ExceDS("select * from Regedit where userName='" + TextBox1.Text + "' and passWord='" + TextBox2.Text + "' and kind='" + DropDownList1.Text + "'", "table");//数据库中查找该管理员登陆信息,看是否存在
if (ds.Tables[0].Rows.Count > 0)//有记录
{//判断不同的管理员级别,并登陆到不同界面
if (DropDownList1.Text == "总管理员")
{
Response.Redirect("adminWindows.aspx");
}
else if (DropDownList1.Text == "审核订票管理员")
{
Response.Redirect("shenheManagement/shenHeMan
agement.aspx");
}
else if (DropDownList1.Text == "列车时刻设置管理员")
Response.Redirect("schedue/trainSchedue.aspx");
else if (DropDownList1.Text == "列车票价设置管理员")
Response.Redirect("chargeofticket/chargemanagement.aspx");
TextBox1.Text = "";
&nb