欢迎来到天天文库
浏览记录
ID:17749624
大小:165.00 KB
页数:20页
时间:2018-09-05
《学生管理系统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{publicstaticclassCustomerSe
2、rvice{///根据提供的登录账号查询用户信息publicstaticCustomerGetCustomerByLoginName(stringname){stringsql=string.Format("select*fromCustomerswhereLoginName='{0}'",name);returnGetCustomerBySQL(sql);}///根据用户ID查询用户信息publicstaticCustomerGetCustomerById(intid){stringsql=string.Format("select*fromCustomerswher
3、eCustomerId={0}",id);returnGetCustomerBySQL(sql);}///私有方法,提供公共方法查询用户信息使用privatestaticCustomerGetCustomerBySQL(stringsql){using(SqlConnectionconn=newSqlConnection(DBHelper.connectString)){Customerc=null;try{conn.Open();SqlCommandcmd=newSqlCommand(sql,conn);SqlDataReadersdr=cmd.ExecuteRead
4、er();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;usi
5、ngSystem.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;usingHouseMa
6、nager.Models;namespaceHouseManager.DAL{publicstaticclassHouseService{///获取所有发布的房屋信息publicstaticIListGetAllHouse(){Listhouses=newList();using(SqlConnectionconn=newSqlConnection(DBHelper.connectString)){try{conn.Open();SqlCommandcmd=newSqlCommand("select*fromHouses",co
7、nn);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=Convert.ToDouble(sdr["Price"]);h.Address=sdr["Address"].ToString();//外键对象的处理h.Customer=Customer
此文档下载收益归作者所有