学生管理系统web程序设计代码文档格式.docx

上传人:b****5 文档编号:21486518 上传时间:2023-01-30 格式:DOCX 页数:28 大小:50.36KB
下载 相关 举报
学生管理系统web程序设计代码文档格式.docx_第1页
第1页 / 共28页
学生管理系统web程序设计代码文档格式.docx_第2页
第2页 / 共28页
学生管理系统web程序设计代码文档格式.docx_第3页
第3页 / 共28页
学生管理系统web程序设计代码文档格式.docx_第4页
第4页 / 共28页
学生管理系统web程序设计代码文档格式.docx_第5页
第5页 / 共28页
点击查看更多>>
下载资源
资源描述

学生管理系统web程序设计代码文档格式.docx

《学生管理系统web程序设计代码文档格式.docx》由会员分享,可在线阅读,更多相关《学生管理系统web程序设计代码文档格式.docx(28页珍藏版)》请在冰豆网上搜索。

学生管理系统web程序设计代码文档格式.docx

privatestaticCustomerGetCustomerBySQL(stringsql)

using(SqlConnectionconn=newSqlConnection(DBHelper.connectString))

Customerc=null;

try

conn.Open();

SqlCommandcmd=newSqlCommand(sql,conn);

SqlDataReadersdr=cmd.ExecuteReader();

if(sdr.Read())

c=newCustomer();

c.Id=(int)sdr["

CustomerId"

];

c.LoginName=sdr["

LoginName"

].ToString();

c.Password=sdr["

Password"

catch(Exceptionex)

Console.WriteLine(ex.Message);

finally

conn.Close();

returnc;

}

(2)在DBHelper中

{

publicstaticclassDBHelper

publicstaticreadonlystringconnectString="

server=.;

database=HouseDB;

uid=sa;

pwd=123456"

;

(3)在HouseService中

publicstaticclassHouseService

///获取所有发布的房屋信息

publicstaticIList<

House>

GetAllHouse()

List<

houses=newList<

();

SqlCommandcmd=newSqlCommand("

select*fromHouses"

conn);

while(sdr.Read())

Househ=newHouse();

h.Id=(int)sdr["

HouseId"

h.TypeName=sdr["

HouseTypeName"

h.Area=(int)sdr["

Area"

h.Price=Convert.ToDouble(sdr["

Price"

]);

h.Address=sdr["

Address"

//外键对象的处理

h.Customer=CustomerService.GetCustomerById((int)sdr["

houses.Add(h);

returnhouses;

///根据房屋信息主键ID删除发布的房屋信息

///<

returns>

受影响的行数<

/returns>

publicstaticintDeleteHouseById(inthouserId)

intcount=0;

using(SqlConnectionconn=newSqlConnection(DBHelper.connectString))

deletefromHouseswhereHouseId={0}"

houserId);

count=cmd.ExecuteNonQuery();

returncount;

///增加发布的房屋信息

publicstaticintAddHouse(Househouse)

insertintodbo.Houses"

+"

(HouseTypeName,Area,Price,Address,CustomerId)"

+"

values('

{1},{2},'

{3}'

{4})"

house.TypeName,house.Area,

house.Price,house.Address,

house.Customer.Id);

return0;

return1;

二、在HouseManagerModels模型层中设计两个类:

Customer.cs和house.cs

(1)在Customer.cs中

namespace

[Serializable]

publicclassCustomer

privateintid;

publicintId

get{returnid;

set{id=value;

privatestringloginName;

///登录账号

publicstringLoginName

get{returnloginName;

set{loginName=value;

privatestringpassword;

///登录密码

publicstringPassword

get{returnpassword;

set{password=value;

(2)在house.cs中

namespaceHouseManager.Models

publicclassHouse

privatestringtypeName;

///房屋类型名称

publicstringTypeName

get{returntypeName;

set{typeName=value;

privateintarea;

///面积

publicintArea

get{returnarea;

set{area=value;

privatedoubleprice;

///价格

publicdoublePrice

get{returnprice;

set{price=value;

privatestringaddress;

///地址

publicstringAddress

get{returnaddress;

set{address=value;

privateCustomercustomer;

///发布人

publicCustomerCustomer

get{returncustomer;

set{customer=value;

三、在HouseManagerBLL逻辑业务层中设计两个类:

HouseManager.cs和LoginManager.cs

(1)在HouseManager.cs中:

usingHouseManager.DAL;

namespaceHouseManager.BLL

publicstaticclassHouseManager

///查询所有发布的房屋信息

returnHouseService.GetAllHouse();

///删除已发布的房屋信息

删除是否成功<

publicstaticboolDeleteHouse(inthouseId)

returnHouseService.DeleteHouseById(houseId)!

=0;

///发布房屋信息

添加是否成功<

publicstaticboolAddHouse(Househouse)

returnHouseService.AddHouse(house)!

(2)在LoginManager.cs中

publicstaticclassLoginManager

///用户登录判断

是否登录成功<

publicstaticboolLogin(stringname,stringpassword,outCustomercustomer)

customer=null;

Customerc=CustomerService.GetCustomerByLoginName(name);

if(c==null)

returnfalse;

if(c.Password.Equals(password))

customer=c;

returntrue;

四、在表示层中建立一个空网站:

其中包括四个网页窗体:

about.aspx和default.aspx和LoginPage.aspx和ReleaseHouseInformationPage.aspx

(1)在LoginPage.aspx中

代码如下:

usingSystem.Configuration;

usingSystem.Collections;

usingSystem.Web;

usingSystem.Web.Security;

usingSystem.Web.UI;

usingSystem.Web.UI.WebControls;

usingSystem.Web.UI.WebControls.WebParts;

usingSystem.Web.UI.HtmlControls;

usingHouseManager.BLL;

publicpartialclassLoginPage:

System.Web.UI.Page

protectedvoidPage_Load(objectsender,EventArgse)

if(!

this.IsPostBack)

//已登录直接跳转到查看页面

if(Session["

User"

]!

=null)

this.Response.Redirect("

~/default.aspx"

);

protectedvoidbtnLogin_Click(objectsender,EventArgse)

Customercus=null;

//验证登录信息是否正确

if(LoginManager.Login(this.txtLoginName.Text.Trim(),

this.txtPassword.Text.Trim(),

outcus))

//跳转到查看页面

Session["

]=cus;

else

//提示错误信息

this.ClientScript.RegisterStartupScript(this.GetType(),"

Warnning"

"

<

script>

alert('

用户信息不正确!

'

)<

/script>

(2)在ReleaseHouseInformationPage.aspx中:

publicpartialclassReleaseHouseInformationPage:

//没有登录的话,跳转到登录页面

]==null)

~/LoginPage.aspx"

protectedvoidbtnSubmit_Click(objectsender,EventArgse)

//从界面获取用户输入的信息

Househouse=newHouse();

house.TypeName=this.ddlType.SelectedValue;

house.Area=int.Parse(this.txtArea.Text);

house.Price=double.Parse(this.txtPrice.Text);

house.Address=this.txtAddress.Text;

Customercustomer=Session["

]asCustomer;

house.Customer=customer;

//判断保存信息是否成功

if(HouseManager.BLL.HouseManager.AddHouse(house))

//提示成功信息并跳转到查看页面

Alert"

房屋信息增加成功!

window.location.href='

default.aspx'

房屋信息增加失败!

(3)在default.aspx中:

具体就是:

设置GridView,设置数据源等操作。

(4)在about.aspx中:

自动带的。

学生管理系统

一、StudentDAL数据访问层中设计三个类:

AdminDAL.cs和DBHelper.cs和studentDAL.cs

(1)在AdminDAL.cs中

usingSystem.Linq;

usingStudentModel;

namespaceStudentDAL

publicclassAdminDAL

publicstaticAdminGetAdminByLoginName(stringname)

select*fromadminwhereUserId='

returnGetAdminBySQL(sql);

privatestaticAdminGetAdminBySQL(stringsql)

Adminc=null;

c=newAdmin();

c.UserId=sdr["

UserId"

].ToString().Trim();

c.UserPwd=sdr["

UserPwd"

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 教学研究 > 教学案例设计

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1