欢迎来到天天文库
浏览记录
ID:18249208
大小:165.01 KB
页数:20页
时间:2018-09-16
《学生管理系统web程序方案设计书代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、房屋销售管理系统一、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{///
2、根据提供的登录账号查询用户信息publicstaticCustomerGetCustomerByLoginName(stringname){stringsql=string.Format("select*fromCustomerswhereLoginName='{0}'",name);returnGetCustomerBySQL(sql);}///根据用户ID查询用户信息publicstaticCustomerGetCustomerById(intid){stringsql=string.Format("select*fromCustomerswhereCustomerId={0}",i
3、d);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=newCu
4、stomer();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.
5、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{public
6、staticclassHouseService{///获取所有发布的房屋信息publicstaticIListGetAllHouse(){Listhouses=newList();using(SqlConnectionconn=newSqlConnection(DBHelper.connectString)){try{conn.Open();SqlCommandcmd=newSqlCommand("select*fromHouses",conn);SqlDataReadersdr=cmd.ExecuteReader();while(sdr.Rea
7、d()){Househ=newHouse();h.Id=(int)sdr["HouseId"];h.TypeName=sdr["HouseTypeName"].ToString();h.Area=(int)sdr["Area"];h.Price=Convert.ToDouble(sdr["Price"]);h.Address=sdr["Address"].ToString();//外键对象的处理h.Customer=Customer
此文档下载收益归作者所有