学生管理系统web程序设计代码.doc
上传人:sy****28 上传时间:2024-09-12 格式:DOC 页数:20 大小:165KB 金币:16 举报 版权申诉
预览加载中,请您耐心等待几秒...

学生管理系统web程序设计代码.doc

学生管理系统web程序设计代码.doc

预览

免费试读已结束,剩余 10 页请下载文档后查看

16 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

房屋销售管理系统一、HouseManagerDAL数据访问层中设计三个类:CustomerService.cs和DBhelper.cs和houseserver.cs(1)在CustomerService.cs中usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Data;usingSystem.Data.SqlClient;usingHouseManager.Models;namespaceHouseManager.DAL{publicstaticclassCustomerService{///根据提供的登录账号查询用户信息publicstaticCustomerGetCustomerByLoginName(stringname){stringsql=string.Format("select*fromCustomerswhereLoginName='{0}'",name);returnGetCustomerBySQL(sql);}///根据用户ID查询用户信息publicstaticCustomerGetCustomerById(intid){stringsql=string.Format("select*fromCustomerswhereCustomerId={0}",id);returnGetCustomerBySQL(sql);}///私有方法,提供公共方法查询用户信息使用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"].ToString();}}catch(Exceptionex){Console.WriteLine(ex.Message);}finally{conn.Close();}returnc;}}}}(2)在DBHelper中usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceHouseManager.DAL{publicstaticclassDBHelper{publicstaticreadonlystringconnectString="server=.;database=HouseDB;uid=sa;pwd=123456";}}(3)在HouseService中usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Data;usingSystem.Data.SqlClient;usingHouseManager.Models;namespaceHouseManager.DAL{publicstaticclassHouseService{///获取所有发布的房屋信息publicstaticIList<House>GetAllHouse(){List<House>houses=newList<House>();using(SqlConnectionconn=newSqlConnection(DBHelper.connectString)){try{conn.Open();SqlCommandcmd=newSqlCommand("select*fromHouses",conn);SqlDataReadersdr=cmd.ExecuteReader();while(sdr.Read()){Househ=newHouse();h.Id=(int)sdr["HouseId"];h.TypeName=sdr["HouseTypeName"].ToString();h.Area=(int)sdr["Area"];h.Price=