c编写web程序设计课程设计报告_第1页
c编写web程序设计课程设计报告_第2页
c编写web程序设计课程设计报告_第3页
c编写web程序设计课程设计报告_第4页
c编写web程序设计课程设计报告_第5页
已阅读5页,还剩18页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、WEB程序设计课程设计报告一、程序总体功能描述首页登陆注册密码修改任务统计设备分类管理我的维护任务我们通过设计首页来让员工注册自己的个人信息才能登陆进我们的管理系统。登陆系统后,就可以方便维修人员对自己的工作的安排,首先是自己的工作任务,还可以在设备分类里面添加我们的设备,对用户送来修理的设备进行录入,最后每天都可以查看自己的工作的统计。我们进行了一个详细的分类总结。二、添加分类需求程序详细设计(一)设备分类管理功能详细设计(梅浩)1、功能描述2、实现描述在sort_add代码中添加分类需求这个字段,然后在后台代码中添加能够判断数据库读写的字段,在SortDataAccess.cs代码中添加写

2、入数据的代码,并且在添加、修改、删除的数据段中都必须添加此字段,否则会运行报错3、主要功能函数解析sort_add.aspx代码<% Page Language="C#" MasterPageFile="/master/MasterPage.master" AutoEventWireup="true" CodeFile="sort_add.aspx.cs" Inherits="sort_sort_add" %><asp:Content ID="Content1&quo

3、t; ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <div> <asp:Button ID="Button2" runat="server" Text="返回" PostBackUrl="/sort/sort_list.aspx" /><br /> <br /> <table width="100%" class="

4、;default"> <tr class="title"> <td colspan="2" style="height: 20px"> 添加新的维修设备 </td> </tr> <tr> <td class="item" width="40%"> 设备分类名称 </td> <td> <asp:TextBox ID="TextBoxSortName" runat

5、="server" MaxLength="100"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBoxSortName" ErrorMessage="*必须输入分类名称" ValidationGroup="v1"></asp:RequiredFie

6、ldValidator> </td> </tr> <tr> <td class="item" width="40%"> 分类简介 </td> <td> <asp:TextBox ID="TextBoxIntro" runat="server" TextMode="MultiLine" Width="300"></asp:TextBox> </td> </tr

7、> <tr> <td> 用户需求</td> <td> &nbsp;<asp:TextBox ID="TextBoxSortRemark" runat="server" MaxLength="100" align="right"></asp:TextBox></td> </tr> </table> <asp:Button ID="Button1" runat="

8、server" Text="确定" ValidationGroup="v1" OnClick="Button1_Click" /><br /> <asp:Label ID="resLabel" runat="server"></asp:Label> </div></asp:Content>这个是sort_add.aspx界面,在界面上添加文字。使用后台的aspx.cs后台代码来实现他的有关功能sort_add.aspx.

9、cs界面using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;publ

10、ic partial class sort_sort_add : System.Web.UI.Page private CommDataAccess cda = new CommDataAccess(); private SortDataAccess sda = new SortDataAccess(); private TaskDataAccess tda = new TaskDataAccess(); protected void Page_Load(object sender, EventArgs e) if (!IsPostBack) cda.changeHeadBg("h2

11、", Master); protected void Button1_Click(object sender, EventArgs e) int res = 0; try res = sda.addSort(TextBoxSortName.Text, TextBoxIntro.Text,TextBoxSortRemark.Text);/这个是最主要的字段,将TextBox中的SortRemark文本框中的字段添加到数据库中 if (res > 0) resLabel.Text = "操作成功" else resLabel.Text = "操作失败&

12、quot; /使用判断语句判断是否操作成功,但是我们还要在数据库中添加备注这个字段,所以就要修改数据库的代码。 catch (Exception ex) resLabel.Text = "操作失败!原因是:" + ex.ToString(); SortDataAccess.cs代码分析我们是在sort_add代码中添加的模块所以在数据库中我们就要在sortdataaccess.cs中添加我们所需要的数据信息,下面我们着重介绍添加的数据流程我们在获取任务分类,删除任务分类,修改任务分类,增加任务分类中都用到了sort_remark这个字段,所以在数据库添加的文件中也必须要修改

13、这几个字段,在这几个代码中添加这个字段的名称即可using System;using System.Data;using System.Configuration;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using Sys

14、tem.Data.SqlClient;using System.Collections.Generic;/ <summary>/ Summary description for SortDataAccess/ </summary>public class SortDataAccess public SortDataAccess() /获取Web.Config中设置的连接字符串 connectionString = "server='.'database='task'uid='sa'pwd='307'

15、;" /connectionString = "Data Source=.SQLEXPRESS;Initial Catalog=task;Integrated Security=True" private string connectionString; / <summary> / 获取任务分类信息 / </summary> / public DataSet SortList() using (SqlConnection conn = new SqlConnection(connectionString) string sqlstr = &

16、quot;SELECT sortid,sortname,intro,sortremark FROM task.dbo.sort ORDER BY sortid DESC" SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = sqlstr; DataSet ds = new DataSet(); SqlDataAdapter sda = new SqlDataAdapter(cmd); /将数据填充到DataSet中 sda.Fill(ds); return ds; / <summ

17、ary> / 删除任务分类 / </summary> / public int delSort(string sortid) using (SqlConnection conn = new SqlConnection(connectionString) string sqlstr = "delete from task.dbo.sort where sortid = sortid" SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = sqlstr; cmd.

18、Parameters.Add("sortid", SqlDbType.VarChar); cmd.Parameters"sortid".Value = sortid; conn.Open(); int res = cmd.ExecuteNonQuery(); return res; / <summary> / 修改任务分类 / </summary> / public int updateSort(string sortid, string sortname, string intro, string sortremark) usi

19、ng (SqlConnection conn = new SqlConnection(connectionString) string sqlstr = "update task.dbo.sort set sortname=sortname,intro=intro ,sortremark=sortremark where sortid = sortid" SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = sqlstr; cmd.Parameters.Add("so

20、rtid", SqlDbType.VarChar); cmd.Parameters"sortid".Value = sortid; cmd.Parameters.Add("sortname", SqlDbType.VarChar); cmd.Parameters"sortname".Value = sortname; cmd.Parameters.Add("intro", SqlDbType.VarChar); cmd.Parameters"intro".Value = intro;

21、cmd.Parameters.Add("sortremark", SqlDbType.VarChar); cmd.Parameters"sortremark".Value = sortremark; conn.Open(); int res = cmd.ExecuteNonQuery(); return res; / <summary> / 增加任务分类 / </summary> / public int addSort(string sortname, string intro,string sortremark) using

22、(SqlConnection conn = new SqlConnection(connectionString) string sqlstr = "insert into task.dbo.sort(sortname,intro,sortremark) values (sortname,intro,sortremark)" SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = sqlstr; cmd.Parameters.Add("sortname", S

23、qlDbType.VarChar); cmd.Parameters"sortname".Value = sortname; cmd.Parameters.Add("intro", SqlDbType.VarChar); cmd.Parameters"intro".Value = intro; cmd.Parameters.Add("sortremark", SqlDbType.VarChar); cmd.Parameters"sortremark".Value = sortremark; con

24、n.Open(); int res = cmd.ExecuteNonQuery(); return res; / <summary> / 获取分类中任务的数量 / </summary> / public int getSortNum(string sortid) using (SqlConnection conn = new SqlConnection(connectionString) string sqlstr = "select count(*) from task.dbo.task where sortid = sortid" SqlComm

25、and cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = sqlstr; cmd.Parameters.Add("sortid", SqlDbType.VarChar); cmd.Parameters"sortid".Value = sortid; conn.Open(); int res = Convert.ToInt32(cmd.ExecuteScalar(); return res; / <summary> / 根据任务sortid获取任务信息 / <

26、/summary> / public Dictionary<string, string> selectInfoBySortid(string sortid) using (SqlConnection conn = new SqlConnection(connectionString) conn.Open(); string sqlstr = "select * from task.dbo.sort where sortid=" + sortid; SqlCommand cmd = new SqlCommand(); cmd.Connection = co

27、nn; cmd.CommandText = sqlstr; SqlDataReader reader = cmd.ExecuteReader(); Dictionary<string, string> sortInfo = new Dictionary<string, string>(); while (reader.Read() sortInfo.Add("sortid", reader0.ToString(); sortInfo.Add("sortname", reader1.ToString(); sortInfo.Add(

28、"intro", reader2.ToString(); sortInfo.Add("sortremark", reader3.ToString(); return sortInfo; / <summary> / 统计任务分类 / </summary> / public DataSet getStatistic() using (SqlConnection conn = new SqlConnection(connectionString) string sqlstr = "SELECT sortid, sortname

29、, (SELECT count(*) FROM task WHERE sortid = S.sortid) as Total, (SELECT count(*) FROM task WHERE sortid = S.sortid and taskstatus='未完成') as TotalIncomplete, (SELECT count(*) FROM task WHERE sortid = S.sortid and taskstatus='完成') as TotalComplete FROM sort S" SqlCommand cmd = new

30、 SqlCommand(); cmd.Connection = conn; cmd.CommandText = sqlstr; conn.Open(); DataSet ds = new DataSet(); SqlDataAdapter sda = new SqlDataAdapter(cmd); /将数据填充到DataSet中 sda.Fill(ds); return ds; public int addSort(string p, string p_2, TextBox TextBoxSortRemark) throw new Exception("The method or

31、operation is not implemented."); (二)注册功能详细设计(朱佳宇、马海涛、孙轩凯)1、功能描述添加工作人员注册模块,为我们的上班人员注册自己的账户2、实现描述在以前现有的模版上添加了注册的模块,我们只需要截取userid以及username加入数据库中user的表中就可以添加一行数据项,但是还要在数据库的表中添加userdataaccess.cs文件3、主要功能函数解析register.aspx代码<% Page Language="C#" AutoEventWireup="true" CodeFile=&

32、quot;register.aspx.cs" Inherits="register" %><!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml" ><head runat="server"&g

33、t; <title>用户注册</title></head><body> <form id="form1" runat="server"> <div id="LoginPage" style="padding-top: 150px;" align="center"> <table style="width: 680px; height: 347px;"> </table> <t

34、able style="width: 680px; height: 347px; border-collapse: collapse; text-align: center;"> <tr> <td colspan="3"> <asp:Image ID="Image3" runat="server" ImageUrl="/images/company.jpg" Width="680px" BorderStyle="None"

35、; Height="646px" /></td> </tr> <tr bgcolor="#065b92" > <td style="font-size: larger; text-decoration: blink;" height="30px" colspan="3"><strong>用户注册</strong></td> </tr> <tr bgcolor="#065b92&q

36、uot;> <td height="30px"><asp:Label ID="Label3" runat="server" Text="用户名:" Font-Size="Large" ></asp:Label></td> <td height="30px"><asp:TextBox ID="txtUserName" runat="server" Font-Size=

37、"Large" ></asp:TextBox></td> <td height="30px" style="width: 191px"> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="必须填写" ControlToValidate="txtUserName"></asp:R

38、equiredFieldValidator></td> </tr> <tr bgcolor="#065b92"> <td height="30px" > <asp:Label ID="Label2" runat="server" Text="密码:" Font-Size="Large" Height="33px"></asp:Label></td> <td he

39、ight="30px"> <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Font-Size="Large" ></asp:TextBox> </td> <td height="30px" style="width: 191px"><asp:RequiredFieldValidator ID="Requir

40、edFieldValidator2" runat="server" ErrorMessage="密 码不能为空" ControlToValidate="txtPassword" ></asp:RequiredFieldValidator></td> </tr> <tr bgcolor="#065b92" > <td height="30px"><asp:Label ID="Label1" run

41、at="server" Text="确认密码:" Font-Size="Large" ></asp:Label></td> <td height="30px"><asp:TextBox ID="txtPasswordQR" runat="server" TextMode="Password" Font-Size="Large" ></asp:TextBox></td

42、> <td height="30px" style="width: 191px"> <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="两次密码不一样" ControlToCompare="txtPassword" ControlToValidate="txtPasswordQR"></asp:CompareValidator

43、></td> </tr> <tr bgcolor="#065b92"> <td height="30px"><asp:Label ID="Label4" runat="server" Text="性别:" Font-Size="Large" ></asp:Label></td> <td height="30px"> <asp:RadioButton

44、ID="RadioButton1" runat="server" Text="男" GroupName="Choose" />&nbsp&nbsp&nbsp&nbsp&nbsp <asp:RadioButton ID="RadioButton2" runat="server" Text="女" GroupName="Choose" /> </td> <td he

45、ight="30px" style="width: 191px"></td> </tr> <tr bgcolor="#065b92"> <td height="30px"><asp:Label ID="Label5" runat="server" Text="真实姓名:" Font-Size="Large" ></asp:Label></td> &

46、lt;td height="30px"><asp:TextBox ID="TextBox1" runat="server" Font-Size="Large" ></asp:TextBox></td> <td height="30px" style="width: 191px"></td> </tr> <tr bgcolor="#065b92"> <td hei

47、ght="30px"><asp:Label ID="Label6" runat="server" Text="电话:" Font-Size="Large" ></asp:Label></td> <td height="30px"><asp:TextBox ID="TextBox2" runat="server" Font-Size="Large" >&

48、lt;/asp:TextBox></td> <td height="30px" style="width: 191px" ></td> </tr> <tr bgcolor="#065b92" > <td height="30px"><asp:Label ID="Label7" runat="server" Text="电子邮件:" Font-Size="Large

49、" ></asp:Label></td> <td height="30px"><asp:TextBox ID="TextBox3" runat="server" Font-Size="Large" ></asp:TextBox></td> <td height="30px" style="width: 191px"> <asp:RequiredFieldValidator

50、 ID="RequiredFieldValidator3" runat="server" ErrorMessage="必须填写" ControlToValidate="TextBox3"></asp:RequiredFieldValidator> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="格式不正确

51、" ControlToValidate="TextBox3" ValidationExpression="w+(-+.'w+)*w+(-.w+)*.w+(-.w+)*"></asp:RegularExpressionValidator> </td> </tr> <tr bgcolor="#065b92"> <td height="30px"></td> <td height="30px">

52、 <asp:Button ID="Button1" runat="server" Text="注册" style="text-align: left; font-size: large;" Onclick="Button1_Click"/> &nbsp&nbsp&nbsp&nbsp&nbsp <asp:Button ID="Button2" runat="server" Text="取消&

53、quot; Onclick="Button2_Click" style="font-size: large" CausesValidation="False"/> </td> <td height="30px" style="width: 191px"></td> </tr> <tr bgcolor="#065b92"> <td height="30px"></td>

54、 <td height="30px"> <asp:Label ID="resLabel" runat="server"></asp:Label></td> <td height="30px" style="width: 191px"></td> </tr> </table> </div> </form></body></html>register.asp

55、x.cs代码主要涉及到的代码:将文件中的txtUserName.Text, txtPassword.Text字段添加到数据库中using System;using System.Data;using System.Configuration;using System.Collections;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.U

56、I.HtmlControls;public partial class register : System.Web.UI.Page private CommDataAccess cda = new CommDataAccess(); private SortDataAccess sda = new SortDataAccess(); private UsersDataAccess uda = new UsersDataAccess(); protected void Page_Load(object sender, EventArgs e) protected void Button1_Click(object sender, EventArgs e) int res = 0; try res = uda.addUsers(txtUserName.Text, txtPassword.Text); if (res > 0) resLabel.Text = "操作成功" Response.Redire

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论