Web程序开发技术实训报告

Web程序开发技术实训报告

题 目 宿舍管理系统 班 级 网络技术0932 学 号 200930907239 姓 名 张天佑 实训地点 实训日期 2011.12.19 - 2011.12.23

Web程序开发技术实训报告

目录

1.1 系统需求分析 .................................................................................................................... 4

1.2 系统的体系结构设计 ........................................................................................................ 4

1.3 系统功能模块设计 ............................................................................................................ 4

1.4 数据库设计 ........................................................................................................................ 5

2 系统的实现 ................................................................................................................................... 7

3 实训总结..................................................................................................................................... 14

1 系统的总体设计

1.1 系统需求分析

所作系统名:宿舍管理系统

宿舍管理系统主要是帮助宿舍管理员更好的对宿舍进行管理,实现对宿舍的添加,修改,删除,宿舍损坏管理,文明宿舍的管理,在完成管理功能的同时增加了留言板模块和宿舍公告栏模块已便于宿舍管理员和学生交流和管理。

1.2 系统的体系结构设计

Web程序开发技术实训报告

1.3 系统功能模块设计

登录:实现系统在两种账户下登录系统。

管理员账户下的模块:

宿舍楼添加:实现添加宿舍的功能。

宿舍楼修改/删除:实现宿舍的修改和删除宿舍的功能。

文明宿舍管理:实现宿舍的分数的修改和文明宿舍的评比。

宿舍损坏管理:实现损坏内容的上报记录。

宿舍公告栏管理:实现重大事情的通知。

添加管理员:实现宿舍管理员的添加功能。

管理员密码修改:实现管理员账户密码的修改功能。 寝室楼查询:实现各个宿舍情况的查询功能。

回复/删除留言:实现留言板的回复和删除信息的功能。 宿舍长账户下的模块:

查询宿舍信息:实现本宿舍信息的查询功能。

1.4 数据库设计

Users表:用于存放系统用户的信息。

Xx表:用于存放学生的住宿信息。

Tongzhi表:用于存放通知信息。

Guestbook表:用于存放用户信息。

Home表:用于存放宿舍信息。

Homebad表:用于存放宿舍损坏物品信息。

Homedetail表:用于存放宿舍类别。

表1.1 users表

Web程序开发技术实训报告

表1.2 xx表

Web程序开发技术实训报告

表1.3 tongzhi表

Web程序开发技术实训报告

表1.4 guestbook表

表1.5 home表

Web程序开发技术实训报告

表1.6 homebad表

Web程序开发技术实训报告

表1.7 homedetail表

Web程序开发技术实训报告

Web程序开发技术实训报告

2 系统的实现

图2.1 adminmain.aspx页

Web程序开发技术实训报告

页面代码:

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

if (Session["adminname"] == null)

{

Response.Redirect("entry.aspx");

}

else

{

lbServerName.Text = "http://" + HttpContext.Current.Request.Url.Host +

HttpContext.Current.Request.ApplicationPath;

lbIp.Text = Request.ServerVariables["LOCAl_ADDR"];

lbDomain.Text = Request.ServerVariables["SERVER_NAME"].ToString();

lbPort.Text = Request.ServerVariables["Server_Port"].ToString();

lbIISVer.Text = Request.ServerVariables["Server_SoftWare"].ToString(); lbPhPath.Text = Request.PhysicalApplicationPath;

lbOperat.Text = Environment.OSVersion.ToString();

lbSystemPath.Text = Environment.SystemDirectory.ToString();

lbTimeOut.Text = (Server.ScriptTimeout / 1000).ToString() + "秒";

lbLan.Text = CultureInfo.InstalledUICulture.EnglishName;

lbAspnetVer.Text = string.Concat(new object[] { Environment.Version.Major, ".",

Environment.Version.Minor, Environment.Version.Build, ".", Environment.Version.Revision }); lbCurrentTime.Text = DateTime.Now.ToString();

RegistryKey key =

Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Version Vector"); lbIEVer.Text = key.GetValue("IE", "未检测到").ToString();

lbServerLastStartToNow.Text = ((Environment.TickCount / 0x3e8) / 60).ToString() + "分钟";

string[] achDrives = Directory.GetLogicalDrives();

for (int i = 0; i < Directory.GetLogicalDrives().Length - 1; i++)

{

lbLogicDriver.Text = lbLogicDriver.Text + achDrives[i].ToString(); }

lbCpuNum.Text =

Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS").ToString();

lbCpuType.Text =

Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER").ToString();

lbMemory.Text = (Environment.WorkingSet / 1024).ToString() + "M";

lbMemoryPro.Text = ((Double)GC.GetTotalMemory(false) / 1048576).ToString("N2") + "M";

lbMemoryNet.Text = ((Double)Process.GetCurrentProcess().WorkingSet64 / 1048576).ToString("N2") + "M";

lbCpuNet.Text =

((TimeSpan)Process.GetCurrentProcess().TotalProcessorTime).TotalSeconds.ToString("N0"); }

}

}

图2.2 homeadd.aspx页

Web程序开发技术实训报告

页面代码:

protected void Page_Load(object sender, EventArgs e)

{

if (!this.IsPostBack)

{

if (Session["adminname"] == null)

{

Response.Redirect("entry.aspx");

}

else

{

databind();

}

}

}

public void databind()

{

string sql = "select * from homedetail ";

GridView1.DataSource = DB.getdata(sql,"homedetail");

GridView1.DataBind();

}

protected void Button1_Click(object sender, EventArgs e)

{

string sql = "insert into homedetail(home,homesex)values('" + TextBox1.Text + "','" + DropDownList1.SelectedValue + "')";

string sql1 = "select * from homedetail where home='"+TextBox1.Text.ToString()+"'"; if (DB.SQLsel(sql1))

{

Response.Write("<script>alert('要添加的宿舍楼已经存在了!')</script>");

}

else

{

if (DB.execSQL(sql))

{

databind();

Response.Write("<script>alert('添加成功')</script>");

}

else

{

Response.Write("<script>alert('添加失败')</script>");

}

}

}

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {

e.Row.Attributes.Add("onMouseOver",

"Color=this.style.backgroundColor;this.style.backgroundColor='lightBlue'");

e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;"); }

图2.3 admindel.aspx页

Web程序开发技术实训报告

页面代码:

protected void Page_Load(object sender, EventArgs e)

{

if (!this.IsPostBack)

{

if (Session["adminname"] == null)

{

Response.Redirect("entry.aspx");

}

else

{

databind();

}

}

}

public void databind()

{

string sql = "select * from homedetail";

GridView1.DataSource = DB.getdata(sql, "homedetail");

GridView1.DataKeyNames = new string[] { "id"};

GridView1.DataBind();

}

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {

e.Row.Attributes.Add("onMouseOver",

"Color=this.style.backgroundColor;this.style.backgroundColor='lightBlue'");

e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;"); }

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) {

int id =Convert.ToInt32( GridView1.DataKeys[e.RowIndex].Value);

string sql = "delete from homedetail where id=" + id + "";

if (DB.execSQL(sql))

{

Response.Write("<script>alert('删除成功!')</script>");

}

else

{

Response.Write("<script>alert('删除失败!')</script>");

}

databind();

}

图2.4 admingoodhome.aspx页

Web程序开发技术实训报告

页面代码:

protected void Page_Load(object sender, EventArgs e)

{

if (!this.IsPostBack)

{

if (Session["adminname"] == null)

{

Response.Redirect("entry.aspx");

}

else

{

databind();

}

}

}

private void databind()

{

string sql = "select * from home";

GridView1.DataSource = DB.getdata(sql, "home");

GridView1.DataKeyNames = new string[] { "homeid" };

GridView1.DataBind();

}

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {

e.Row.Attributes.Add("onMouseOver",

"Color=this.style.backgroundColor;this.style.backgroundColor='lightBlue'");

e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;"); }

图2.5 adminhomebad.aspx页

Web程序开发技术实训报告

页面代码:

protected void Page_Load(object sender, EventArgs e)

{

if (!this.IsPostBack)

{

if (Session["adminname"] == null)

{

Response.Redirect("entry.aspx");

}

else

{

databind();

}

}

}

public void databind()

{

string sql = "select * from homebad";

GridView1.DataSource = DB.getdata(sql, "homebad");

GridView1.DataKeyNames = new string[] { "id" };

GridView1.DataBind();

}

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)

{

int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);

string sql = "delete from homebad where id=" + id + "";

if (DB.execSQL(sql))

{

Response.Write("<script>alert('删除成功!')</script>");

}

else

{

Response.Write("<script>alert('删除失败!')</script>");

}

databind();

}

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

{

e.Row.Attributes.Add("onMouseOver",

"Color=this.style.backgroundColor;this.style.backgroundColor='lightBlue'");

e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;");

}

protected void Button1_Click(object sender, EventArgs e)

{

Response.Write("<script

language=javascript>window.open('adminhomebadadd.aspx','','width=300,height=400')</script>") }

3 实训总结

这次实训,让我对asp.net有了更深一层的理解,能简单的使用asp.net的多项控件,并能访问和绑定数据。对asp.net的网站架构也有了自己的一些浅见,最终能够用asp.net软件对网站进行简单的编辑操作。

ASP.NET实训过程中,让我明白理论与实践的关系,只有理论联系实际、举一反三才能逐步形成分析和解决实际问题的能力,这种能力,我相信能够让我在以后的道路上受益匪浅。

这次的实训,我感觉收获最大的并不是我明白了以前asp.net不懂的地方,而是我感觉到在解决别人和各自问题的同时,间接的形成我对学习耐心、细心和一丝不苟的习惯。

相关推荐