![學生管理系統(tǒng)web程序設計代碼_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/14/515971e4-8d09-41d5-ba0d-cc612e983b34/515971e4-8d09-41d5-ba0d-cc612e983b341.gif)
![學生管理系統(tǒng)web程序設計代碼_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/14/515971e4-8d09-41d5-ba0d-cc612e983b34/515971e4-8d09-41d5-ba0d-cc612e983b342.gif)
![學生管理系統(tǒng)web程序設計代碼_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/14/515971e4-8d09-41d5-ba0d-cc612e983b34/515971e4-8d09-41d5-ba0d-cc612e983b343.gif)
版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、房屋銷售管理系統(tǒng)一、HouseManagerDAL數(shù)據(jù)訪問層中設計三個類:CustomerService.cs和DBhelper.cs和houseserver.cs(1)在CustomerService.cs中usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Data;usingSystem.Data.SqlClient;usingHouseManager.Models;namespaceHouseManager.DALpublic/staticclassCustomerService根據(jù)提供的登錄
2、賬號查詢用戶信息publicstaticCustomerGetCustomerByLoginName(stringname)stringsql=string.Format("select*fromCustomerswhereLoginName='0'"returnGetCustomerBySQL(sql);/根據(jù)用戶ID查詢用戶信息publicstaticCustomerGetCustomerById(intid)stringsql=string.Format("select*fromCustomerswhereCustomerId=0"
3、returnGetCustomerBySQL(sql);/私有方法,提供公共方法查詢用戶信息使用privatestaticCustomerGetCustomerBySQL(stringsql)using(SqlConnectionconn=newSqlConnection(DBHelper.connectString)Customerc=null;,name);,id);tryconn.Open();SqlCommandcmd=newSqlCommand(sql,conn);SqlDataReadersdr=cmd.ExecuteReader();if(sdr.Read()c=c.Id=(c.
4、LoginName=sdrc.Password=sdrnewCustomer();int)sdr"CustomerId""LoginName".ToString();"Password".ToString();catch(Exceptionex)Console.WriteLine(ex.Message);finally(conn.Close();returnc;在DBHelper中usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceHouseMan
5、ager.DAL(publicstaticclassDBHelper(publicstaticreadonlystringconnectString="server=.;database=HouseDB;uid=sa;pwd=123456”;在HouseService中usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Data;usingSystem.Data.SqlClient;usingHouseManager.Models;namespaceHouseManager.DAL(publ
6、icstaticclassHouseService(/獲取所有發(fā)布的房屋信息publicstaticIList<House>GetAllHouse()(List<House>houses=newList<House>();using(SqlConnectionconn=newSqlConnection(DBHelper.connectString)(try(conn.Open();SqlCommandcmd=newSqlComman(d"select*fromHouses",conn);SqlDataReadersdr=cmd.Execu
7、teReader();Househ=h.Id=(h.TypeName=sdrh.Area=(while(sdr.Read()newHouse();int)sdr"HouseId""HouseTypeName'.ToString();int)sdr"Area"h.Price=Convert.ToDouble(sdr"Price");h.Address=sdr"Address".ToString();外鍵對象的處理h.Customer=CustomerService.GetCustomerById(i
8、nt)sdr"CustomerId");houses.Add(h);catch(Exceptionex)Console.WriteLine(ex.Message);finallyconn.Close();returnhouses;/根據(jù)房屋信息主鍵ID刪除發(fā)布的房屋信息/<returns>受影響的行數(shù)/returnspublicstaticintDeleteHouseById(inthouserId)intcount=0;using(SqlConnectionconn=newSqlConnection(DBHelper.connectString)trystri
9、ngsql=string.Format("deletefromHouseswhereHouseId=0",houserld);conn.Open();SqlCommandcmd=newSqlCommandsql,conn);count=cmd.ExecuteNonQuery();catch(Exceptionex)Console.WriteLine(ex.Message);finallyconn.Close();returncount;/增加發(fā)布的房屋信息/<returns>受影響的行數(shù)</returns>publicstaticintAddHous
10、e(Househouse)(stringsql=string.Format("insertintodbo.Houses"+"(HouseTypeName,Area,Price,Address,CustomerId)”+"values('0',1,2,'3',4)”,house.TypeName,house.Area,house.Price,house.Address,house.Customer.Id);intcount=0;using(SqlConnectionconn=newSqlConnection(DBHelper
11、.connectString)tryconn.Open();SqlCommandcmd=newSqlCommand(sql,conn);count=cmd.ExecuteNonQuery();catch(Exceptionex)Console.WriteLine(ex.Message);return0;finallyconn.Close();return1;二、在HouseManagerModels模型層中設計兩個類:Customer.cs和house.cs(1)在Customer.cs中usingSystem;usingSystem.Collections.Generic;usingSyst
12、em.Text;namespace(SerializablepublicclassCustomer(privateintid;publicintId(get(returnid;set(id=value;privatestringloginName;/登錄賬號publicstringLoginName(get(returnloginName;set(loginName=value;privatestringpassword;/登錄密碼publicstringPassword(get(returnpassword;set(password=value;(2)在house.cs中usingSyste
13、m;usingSystem.Collections.Generic;usingSystem.Text;namespaceHouseManager.Models(SerializablepublicclassHouse(privateintid;publicintId(get(returnid;set(id=value;privatestringtypeName;/房屋類型名稱publicstringTypeName(get(returntypeName;set(typeName=value;privateintarea;/面積publicintArea(get(returnarea;set(a
14、rea=value;privatedoubleprice;/價格publicdoublePrice(get(returnprice;set(price=value;privatestringaddress;/地址publicstringAddress(get(returnaddress;set(address=value;privateCustomercustomer;/發(fā)布人publicCustomerCustomer(get(returncustomer;set(customer=value;(1) 三、在HouseManagerBL邏輯業(yè)務層中設計兩個類:HouseManager.cs和
15、LoginManager.cs在HouseManager.cs中:usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingHouseManager.Models;usingHouseManager.DAL;namespaceHouseManager.BLL(publicstaticclassHouseManager(/查詢所有發(fā)布的房屋信息publicstaticIList<House>GetAllHouse()(returnHouseService.GetAllHouse();/刪除已發(fā)布的房屋信息/&l
16、t;returns>刪除是否成功</returns>publicstaticboolDeleteHouse(inthouseId)(returnHouseService.DeleteHouseById(houseId)!=0;/發(fā)布房屋信息/<returns>添加是否成功</returns>publicstaticboolAddHouse(Househouse)(returnHouseService.AddHouse(house)!=0;在LoginManager.cs中usingSystem;usingSystem.Collections.Gener
17、ic;usingSystem.Text;usingHouseManager.Models;usingHouseManager.DAL;namespaceHouseManager.BLL(publicstaticclassLoginManager(/用戶登錄判斷/returns是否登錄成功/returnspublicstaticboolLogin(stringname,stringpassword,outCustomercustomer)(customer=null;Customerc=CustomerService.GetCustomerByLoginName(name);if(c=null)
18、(returnfalse;if(c.Password.Equals(password)customer=c;returntrue;returnfalse;(1) 和LoginPage.aspx和四、在表示層中建立一個空網(wǎng)站:其中包括四個網(wǎng)頁窗體:about.aspx和default.aspxReleaseHouseInformationPage.aspx在LoginPage.aspx中1登家窗口登錄名密碼B嗟錄代碼如下:usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSyst
19、em.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingHouseManager.Models;usingHouseManager.BLL;publicpartialclassLoginPage:System.Web.UI.Page(protectedvoidPage_Load(objectsender,EventArgse)(if(!
20、this.IsPostBack)(/已登錄直接跳轉(zhuǎn)到查看頁面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)(/跳轉(zhuǎn)到查看頁面Session&q
21、uot;User"=cus;this.Response.Redirect("/default.aspx");else(Warnning/提不'錯誤信息this.ClientScript.RegisterStartupScript(this.GetType(),"<script>alert('用戶信息不正確!)</script>");(2) 在ReleaseHouseInformationPage.aspx中:房型史堂一廳,面積B平方米幻LI1價格ibfer已1地址Un1E.錯誤消息瓦錯誤消息2.代碼如下:
22、usingSystem;usingSystem.Data;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.Models;usingHouseManager.BLL;publicparti
23、alclassReleaseHouseInformationPage:System.Web.UI.Page(protectedvoidPage_Load(objectsender,EventArgse)(if(!this.IsPostBack)(/沒有登錄的話,跳轉(zhuǎn)到登錄頁面if(Session"User"=null)(this.Response.Redirect("/LoginPage.aspx");protectedvoidbtnSubmit_Click(objectsender,EventArgse)(/從界面獲取用戶輸入的信息Househouse
24、=newHouse();house.TypeName=house.Area=house.Price=house.Address=this.ddlType.SelectedValue;int.Parse(this.txtArea.Text);double.Parse(this.txtPrice.Text);this.txtAddress.Text;Customercustomer=Session"User"asCustomer;house.Customer=customer;/判斷保存信息是否成功if(HouseManager.BLL.HouseManager.AddHous
25、e(house)(/提示成功信息并跳轉(zhuǎn)到查看頁面"Alert"this.ClientScript.RegisterStartupScript(this.GetType(),"<script>alert('房屋信息增加成功!);window.location.href='default.aspx'</script>");else(/提不'錯誤信息"Alert"this.ClientScript.RegisterStartupScript(this.GetType(),"&
26、lt;script>alert('房屋信息增加失敗!);</script>");(3) 在default.aspx中:房屋類型面積價格地址數(shù)據(jù)綁定數(shù)據(jù)綁定數(shù)據(jù)綁定數(shù)據(jù)綁定刪除數(shù)據(jù)綁定數(shù)據(jù)綁定數(shù)據(jù)綁定數(shù)據(jù)綁定刪除數(shù)據(jù)綁定數(shù)據(jù)綁定數(shù)據(jù)綁定數(shù)據(jù)綁定刪除數(shù)據(jù)綁定數(shù)據(jù)綁定數(shù)據(jù)綁定數(shù)據(jù)綁定刪除數(shù)據(jù)綁定選據(jù)綁定數(shù)據(jù)墅數(shù)據(jù)綁定刪除6bjcCtDat&So'tarce-odsHousft5具體就是:設置GridView,設置數(shù)據(jù)源等操作。(4) 在about.aspx中:自動帶的。學生管理系統(tǒng)一、StudentDAL數(shù)據(jù)訪問層中設計三個類:AdminDAL.c
27、s和DBHelper.cs和studentDAL.cs(1)在AdminDAL.cs中usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingStudentModel;usingSystem.Data;usingSystem.Data.SqlClient;namespaceStudentDALpublicclassAdminDALpublicstaticAdminGetAdminByLoginName(stringname)stringsql=string.Format("s
28、elect*fromadminwhereUserId='0'",name);returnGetAdminBySQL(sql);privatestaticAdminGetAdminBySQL(stringsql)using(SqlConnectionconn=newSqlConnection(DBHelper.connectString)Adminc=null;tryconn.Open();SqlCommandcmd=newSqlCommand(sql,conn);SqlDataReadersdr=cmd.ExecuteReader();if(sdr.Read()c=n
29、ewAdmin();c.UserId=sdr"UserId".ToString().Trim();c.UserPwd=sdr"UserPwd".ToString().Trim();catch(Exceptionex)(Console.WriteLine(ex.Message);finally(conn.Close();returnc;在DBHelper中usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceStudentDAL(publicstaticclassDBHe
30、lper(publicstaticreadonlystringconnectString="DataSource=PC-201012101127SQLEXPRESS;InitialCatalog=StudDB;IntegratedSecurity=True”;在studentDAL.cs中usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Data;usingSystem.Data.SqlClient;usingStudentModel;namespaceS
31、tudentDAL(publicstaticclassstudentDAL(publicstaticIList<student>GetAllstudent()(List<student>students=newList<student>();using(SqlConnectionconn=newSqlConnection(DBHelper.connectString)(try(conn.Open();SqlCommandcmd=newSqlCommand("select*fromstudent",conn);SqlDataReadersd
32、r=cmd.ExecuteReader();while(sdr.Read()(students=newstudent();s.sno=sdr"sno".ToString();s.sname=sdr"sname".ToString();s.ssex=sdr"ssex".ToString();s.snation=sdr"snation".ToString();s.sclass=sdr"sclass".ToString();s.spass=sdr"spass".ToString()
33、;students.Add(s);catch(Exceptionex)(Console.WriteLine(ex.Message);finally(conn.Close();returnstudents;publicstaticintAddStudent(studentstudent)(stringsql=string.Format("insertintostudent"+"(sno,sname,ssex,snation,sclass,spass)”+"values('0','1','2','3
34、39;,'4','5')”,student.sno,student.sname,student.ssex,student.snation,student.sclass,student.spass);intcount=0;using(SqlConnectionconn=newSqlConnection(DBHelper.connectString)tryconn.Open();SqlCommandcmd=newSqlCommand(sql,conn);count=cmd.ExecuteNonQuery();catch(Exceptionex)(Console.Wr
35、iteLine(ex.Message);return0;finally(conn.Close();return1;publicstaticintDeleteStudent(stringstudentsno)(intcount=0;using(SqlConnectionconn=newSqlConnection(DBHelper.connectString)(try(stringsql=string.Format("deletefromstudentwheresno='0'",studentsno);conn.Open();SqlCommandcmd=newS
36、qlCommand(sql,conn);count=cmd.ExecuteNonQuery();catch(Exceptionex)Console.WriteLine(ex.Message);finallyconn.Close();returncount;二、在StudentModel模型層中設計兩個類:Admin.cs和student.cs(1)在Admin.cs中usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Data;namespaceStudentMode
37、l(publicclassAdmin(privatestringuserid;publicstringUserId(get(returnuserid;set(userid=value;privatestringuserpwd;publicstringUserPwd(get(returnuserpwd;set(userpwd=value;(2)在student.cs中usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Data;namespaceStudentModel
38、(publicclassstudent(privatestringS_sno;publicstringsno(get(returnS_sno;set(S_sno=value;privatestringS_sname;publicstringsname(get(returnS_sname;set(S_sname=value;privatestringS_ssex;publicstringssexget(returnS_ssex;set(S_ssex=value;privatestringS_snation;publicstringsnation(get(returnS_snation;set(S
39、_snation=value;privatestringS_sclass;publicstringsclass(get(returnS_sclass;set(S_sclass=value;privatestringS_spass;publicstringspass(get(returnS_spass;set(S_spass=value;(1) 三、在StudentBLL邏輯業(yè)務層中設計兩個類:AdminBLL.cs和studentBLL.cs在AdminBLL.cs中:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;us
40、ingSystem.Text;usingStudentDAL;usingStudentModel;namespaceStudentBLL(publicclassAdminBLL(publicstaticboolLogin(stringname,stringpassword,outAdminadmin)(admin=null;Adminc=AdminDAL.GetAdminByLoginName(name);if(c=null)(returnfalse;if(c.UserPwd.Equals(password)(admin=c;returntrue;returnfalse;在studentBLL
41、.cs中usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingStudentDAL;usingStudentModel;namespaceStudentBLL(publicstaticclassstudentBLL(publicstaticIList<student>GetAllStudent()(returnstudentDAL.GetAllstudent();publicstaticboolAddStudent(studentstudent)(returnstuden
42、tDAL.AddStudent(student)!=0;publicstaticboolDeleteStudent(stringsno)(returnstudentDAL.DeleteStudent(sno)!=0;about.aspx和AddStudent.aspx和Login.aspx和四、在表示層中建立一個空網(wǎng)站:其中包括五個網(wǎng)頁窗體:Default.aspx和ShowStudent.aspx在AddStudent.aspx中學號匕I姓凱性別;I陽f蓿備I代碼如下:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;u
43、singSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingStudentModel;usingStudentBLL;publicpartialclassAddStudent:System.Web.UI.PageprotectedvoidPage_Load(objectsender,EventArgse)protectedvoidButton1_Click(objectsender,EventArgse)studentstu=newstudent();stu.sno=this.TextBox1.Text.ToString().Trim();stu.sname=this.TextBox2.Text.ToString().Trim();stu.ssex=this.TextBox3.Text.ToString().Trim();stu.sclass=this.TextBox4.Text.ToString().Trim();stu.snation=this.TextBox5.Text.ToString()
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年福州貨運資格證模擬考試題庫
- 2024-2025學年九年級科學上冊第4章代謝與平衡第1節(jié)食物與營養(yǎng)作業(yè)設計新版浙教版
- 2024-2025學年七年級數(shù)學上冊第二章有理數(shù)及其運算2.12用計算器進行運算教案新版北師大版
- 《橋梁監(jiān)測方案》
- 個人簡歷表格模板14篇
- 教師個人年度工作成效總結
- 秋季學期六年級語文組工作總結
- 湘教版地理八年級上冊《第一節(jié) 中國的地形》聽課評課記錄3
- 青年干部培訓計劃
- 部編人教版道德與法治九年級上冊3.2《參與民主生活》聽課評課記錄
- 2021屆高考英語887核心詞(打印、詞頻、出處、例句、背誦)
- 天津市鄉(xiāng)鎮(zhèn)衛(wèi)生院街道社區(qū)衛(wèi)生服務中心地址醫(yī)療機構名單
- 公司機關管理類責任矩陣
- 山東省青島市各縣區(qū)鄉(xiāng)鎮(zhèn)行政村村莊村名居民村民委員會明細及行政區(qū)劃代碼
- 《鉆井液用磺甲基酚醛樹脂技術要求》
- 數(shù)學-九宮數(shù)獨100題(附答案)
- 中國農(nóng)業(yè)發(fā)展銀行XX支行 關于綜合評價自評情況的報告
- 2010年宣武區(qū)第六屆中小學生地理知識競賽題庫
- QC課題提高檢查井周邊壓實
- 應征公民體格檢查表(征兵)
- ACL磁致伸縮液位計說明書
評論
0/150
提交評論