Web課程設(shè)計(jì)-酒店管理系統(tǒng)(共27頁)_第1頁
Web課程設(shè)計(jì)-酒店管理系統(tǒng)(共27頁)_第2頁
Web課程設(shè)計(jì)-酒店管理系統(tǒng)(共27頁)_第3頁
Web課程設(shè)計(jì)-酒店管理系統(tǒng)(共27頁)_第4頁
Web課程設(shè)計(jì)-酒店管理系統(tǒng)(共27頁)_第5頁
已閱讀5頁,還剩22頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、洛 陽 理 工 學(xué) 院課 程 設(shè) 計(jì) 報(bào) 告 課程名稱 Web程序設(shè)計(jì)課程設(shè)計(jì) 設(shè)計(jì)題目 酒店管理系統(tǒng) 專 業(yè) 計(jì)算機(jī)科學(xué)與技術(shù) 班 級 學(xué) 號 姓 名 完成日期 課 程 設(shè) 計(jì) 任 務(wù) 書設(shè)計(jì)題目: 酒店管理系統(tǒng) _設(shè)計(jì)內(nèi)容與要求:(1)數(shù)據(jù)庫設(shè)計(jì)要符合范式要求。(2)能對客戶入住資料進(jìn)行添加、刪除、修改操作。(3)提供訂單查詢功能,輸入訂單號,能查找出訂單的相關(guān)信息。能對訂單進(jìn)行添加、刪除、修改操作。(4)用戶權(quán)限控制,服務(wù)員能對訂單和客戶資料進(jìn)行修改,管理員用戶修改登錄密碼。 指導(dǎo)教師: 年月 日課 程 設(shè) 計(jì) 評 語 成績: 指導(dǎo)教師: 年 月 日洛 陽 理 工 學(xué) 院 課 程 設(shè) 計(jì)

2、 報(bào) 告目錄第1章 需求分析11.1 需求分析11.2 可行性分析11.2.1經(jīng)濟(jì)可行性分析11.2.1技術(shù)可行性分析1第2章 數(shù)據(jù)庫設(shè)計(jì)22.1 數(shù)據(jù)庫概念結(jié)構(gòu)設(shè)計(jì)22.1.1 實(shí)體關(guān)系圖22.1.2 系統(tǒng)總體E-R圖32.2 數(shù)據(jù)表設(shè)計(jì)42.2.1 數(shù)據(jù)庫表設(shè)計(jì)4第3章 概要設(shè)計(jì)63.1 系統(tǒng)架構(gòu)設(shè)計(jì)63.2 系統(tǒng)功能設(shè)計(jì)63.2.1 系統(tǒng)功能模塊63.2.2 系統(tǒng)處理流程7第4章 詳細(xì)設(shè)計(jì)與實(shí)現(xiàn)84.1 系統(tǒng)首頁84.2 酒店日常管理界面104.3 預(yù)訂房間界面104.4 訂單查詢界面124.5 大堂入住界面164.6 結(jié)賬退房界面174.7 系統(tǒng)管理員登陸界面22第5章 總結(jié)2424

3、第1章 需求分析1.1 需求分析酒店管理系統(tǒng)是我們常說的MIS(Management Information System管理信息系統(tǒng))的一種,在強(qiáng)調(diào)管理,強(qiáng)調(diào)信息的現(xiàn)代社會中它越來越得到普及,酒店管理系統(tǒng)的主要目標(biāo)是實(shí)現(xiàn)對酒店內(nèi)部各種管理的電子化合自動化,提高酒店的辦公效率,為高質(zhì)量的酒店管理提供服務(wù),提供保證。在酒店業(yè)競爭越來越激烈的今天,努力在市場競爭中脫穎而出,已經(jīng)成為每位酒店經(jīng)營者所追求的的目標(biāo)。酒店如何才能提高服務(wù)質(zhì)量,其管理力顯得越來越重要。由于使用了先進(jìn)的數(shù)據(jù)管理技術(shù),酒店管理系統(tǒng)對提高酒店的管理能力將會起到比較重大的作用。整個系統(tǒng)的基本設(shè)計(jì)目標(biāo)是實(shí)現(xiàn)系統(tǒng)界面友好美觀、簡單易用

4、、功能全面并有較高的安全性。本系統(tǒng)需要實(shí)現(xiàn)酒店常用的房間預(yù)訂、入住記錄查詢、房間管理等功能,并幫助酒店建立客戶數(shù)據(jù)庫和入住記錄數(shù)據(jù)庫,能夠方便的進(jìn)行查詢,并在系統(tǒng)的易用性和安全性兩方面進(jìn)行相應(yīng)的完善。該系統(tǒng)有以下特點(diǎn):功能強(qiáng)大:該軟件以中小型酒店為應(yīng)用對象,結(jié)合中小型酒店客房當(dāng)前和未來發(fā)展的管理需求提供實(shí)用先進(jìn)的客房管理模式,提高酒店客房管理的效益。用戶界面操作簡潔:系統(tǒng)的每個功能充分考慮到使用人員計(jì)算機(jī)知識較少的特點(diǎn),軟件系統(tǒng)由各種具體的功能模塊組成,全部使用業(yè)務(wù)人員最熟悉的業(yè)務(wù)流程、提示用語和操作方式,即使不熟悉此軟件的人也能熟練使用本軟件完成業(yè)務(wù)處理。系統(tǒng)性能穩(wěn)定:嚴(yán)格按照規(guī)范的軟件工程

5、管理,充分利用面向?qū)ο蠹夹g(shù),采用sql為后臺數(shù)據(jù)庫。從技術(shù)上和應(yīng)用廣泛性上保證了系統(tǒng)的穩(wěn)定性、廣泛性和先進(jìn)性。1.2 可行性分析1.2.1經(jīng)濟(jì)可行性分析模擬酒店管理系統(tǒng)的開發(fā)從長遠(yuǎn)的角度來看,投資可以完全收回,并可以節(jié)省管理費(fèi)用,避免了人工填單操作所帶來的一系列不必要的麻煩,節(jié)省了用戶和相關(guān)工作人員的時間,能夠很好地提高工作效率,改進(jìn)決策質(zhì)量。同時也對酒店的靈活管理有了很大的提升,有利于提高酒店的運(yùn)營和服務(wù)效率,其開發(fā)前景良好并能產(chǎn)生很好的經(jīng)濟(jì)和社會效益。1.2.1技術(shù)可行性分析本系統(tǒng)采用ASP.NET開發(fā)技術(shù)及SQL SERVER 2008開發(fā)平臺,該系統(tǒng)是數(shù)據(jù)庫應(yīng)用程序,數(shù)據(jù)項(xiàng)之間的關(guān)系雖

6、然很復(fù)雜,但是都可以很清楚的用關(guān)系數(shù)據(jù)庫模式表示出來,采用數(shù)據(jù)庫的操作沒有難度。就規(guī)模來說,酒店管理系統(tǒng)應(yīng)屬于小型數(shù)據(jù)庫應(yīng)用程序,在課程設(shè)計(jì)期間可以完成從系統(tǒng)需求分析到系統(tǒng)測試的所有工作,不存在開發(fā)時間限制的問題。由于酒店管理系統(tǒng)不屬于大的數(shù)據(jù)庫系統(tǒng)并且沒有嚴(yán)格的實(shí)時性要求,只要普通系統(tǒng)配置就可運(yùn)行。對于酒店管理系統(tǒng)的開發(fā)就沒有特殊的要求。第2章 數(shù)據(jù)庫設(shè)計(jì)2.1 數(shù)據(jù)庫概念結(jié)構(gòu)設(shè)計(jì)2.1.1 實(shí)體關(guān)系圖通過需求分析可以得出數(shù)據(jù)庫之間的實(shí)體關(guān)系圖如下:圖 2-1 客戶實(shí)體關(guān)系圖圖 2-2 訂單實(shí)體關(guān)系圖圖 2-3 入住記錄實(shí)體關(guān)系圖圖 2-4 管理員實(shí)體關(guān)系圖圖 2-5 服務(wù)員實(shí)體關(guān)系圖2.1

7、.2 系統(tǒng)總體E-R圖圖 2-6 系統(tǒng)總體E-R圖2.2 數(shù)據(jù)表設(shè)計(jì)2.2.1 數(shù)據(jù)庫表設(shè)計(jì)表2-1 客戶表序號列名數(shù)據(jù)類型長度備注說明1客戶標(biāo)識nchar10主鍵2姓名nchar20NOT NULL3性別nchar2NOT NULL4證件nchar20NOT NULL表2-2 房間表序號列名數(shù)據(jù)類型長度備注說明1房間號nchar10主鍵2房間類別nchar10NOT NULL3房間位置nchar504房間描述nchar100 5備注nchar50表2-3 入住記錄表表序號列名數(shù)據(jù)類型長度備注說明1入主流水號nchar10主鍵2房間號nchar10NOT NULL3客戶標(biāo)識nchar10外鍵4

8、入住人姓名nchar20NOT NULL5入住人證件nchar20NOT NULL6入住時間DatetimeNOT NULL7退房時間Datetime8消費(fèi)nchar109押金nchar10表2-4 管理員表序號列名數(shù)據(jù)類型長度備注說明1姓名Char 9主鍵2性別Varchar10NOT NULL3工號Varchar16NOT NULL4密碼Varchar100表2-5 服務(wù)員表序號列名數(shù)據(jù)類型長度備注說明1姓名Char 9主鍵2性別Varchar10NOT NULL3工號Varchar16NOT NULL4密碼Varchar100第3章 概要設(shè)計(jì)3.1 系統(tǒng)架構(gòu)設(shè)計(jì)B/S模式(Browse/

9、Server瀏覽器/服務(wù)器)模式是在C/S模式發(fā)展到一定階段的產(chǎn)物,它以Web技術(shù)為基礎(chǔ),將傳統(tǒng)C/S模式中的服務(wù)器部分細(xì)分為數(shù)據(jù)庫服務(wù)器和Web服務(wù)器,從而變成3層結(jié)構(gòu)。B/S架構(gòu)是Intranet上的一個典型的分布式信息系統(tǒng)。B/S模式的優(yōu)點(diǎn)主要是:(1)用戶的操作使用簡單,B/S模式的客戶端只須安裝一個提供友好界面的通用瀏覽器,如Internet Explorer等,不需要對客戶進(jìn)行額外培訓(xùn);(2) B/S結(jié)構(gòu)具有可伸縮性,在網(wǎng)絡(luò)環(huán)境允許的條件下,可以盡可能多地增加瀏覽器和服務(wù)器,不受原有網(wǎng)絡(luò)資源的影響;(3)易于開發(fā)、安裝和維護(hù),B/S結(jié)構(gòu)只需對服務(wù)器端的應(yīng)用平臺進(jìn)行開發(fā)和集成,減少了

10、開發(fā)、安裝和維護(hù)費(fèi)用。以目前的技術(shù)看,局域網(wǎng)建立B/S結(jié)構(gòu)的網(wǎng)絡(luò)應(yīng)用,并通過工Internet/Intranet模式下數(shù)據(jù)庫應(yīng)用,相對易于把握,成本也是較低的。它是一次性到位的開發(fā),能實(shí)現(xiàn)不同的人員,從不同的地點(diǎn),以不同的接入方式(比如LAN, WAN,Internet/Intranet等)訪問和操作共同的數(shù)據(jù)庫;它能有效地保護(hù)數(shù)據(jù)平臺和管理訪問權(quán)限,服務(wù)器數(shù)據(jù)庫也很安全。本系統(tǒng)采用ASP. NET構(gòu)造程序框架,數(shù)據(jù)庫采用SQL Server2008為數(shù)據(jù)庫3.2 系統(tǒng)功能設(shè)計(jì)3.2.1 系統(tǒng)功能模塊本系統(tǒng)包括系統(tǒng)管理和酒店管理兩個部分,其功能如下:(1)系統(tǒng)管理:修改管理員登錄密碼,修改管理

11、密碼;(2)酒店管理:預(yù)訂房間,訂單查詢,大堂入住,退房。如圖3-1所示:圖 3-1 系統(tǒng)功能結(jié)構(gòu)圖3.2.2 系統(tǒng)處理流程用戶使用本系統(tǒng)時,根據(jù)不同的身份使用不同的功能,客戶使用時無需登錄,可直接進(jìn)行房間預(yù)訂和訂單查詢,管理人員須登錄后才能使用各項(xiàng)管理功能。系統(tǒng)處理流程如圖3-2所示。圖 3-2 系統(tǒng)流程圖第4章 詳細(xì)設(shè)計(jì)與實(shí)現(xiàn)4.1 系統(tǒng)首頁系統(tǒng)首頁設(shè)置為登陸頁,用戶權(quán)限不同,操作數(shù)據(jù)庫的權(quán)限也不同,管理員登陸成功后能進(jìn)入到sysadmin.aspx界面進(jìn)行修改密碼權(quán)限,服務(wù)員登陸后能進(jìn)入到service.aspx界面,進(jìn)行酒店的日常管理。如圖4-1所示:圖 4-1 系統(tǒng)流程圖 關(guān)鍵后臺代

12、碼:protected void Button1_Click(object sender, EventArgs e)string sf = DropDownList1.SelectedValue.ToString();string strcon, strsql, msg;strcon = ConfigurationManager.ConnectionStringsHotelConnectionString.ConnectionString;if (sf = 管理員)strsql = select * from 管理員 where 工號 = + txtName.Text.Trim() + and

13、 密碼 = + txtPwd.Text.Trim() + ;elsestrsql = select * from 服務(wù)員 where 工號 = + txtName.Text.Trim() + and 密碼 = + txtPwd.Text.Trim() + ;SqlConnection con = new SqlConnection(strcon);DataTable dt = new DataTable();/創(chuàng)建一個數(shù)據(jù)表dtSqlDataAdapter Cmd = new SqlDataAdapter(strsql, con);msg = yes;tryCmd.Fill(dt);/執(zhí)行命令

14、catch (Exception ex) /如果try出錯,則捕獲錯誤msg = no +ex.Message.ToString().Trim();finallycon.Close();if (msg = yes)if (dt.Rows.Count 0)if (sf = 管理員)Sessionadmin = txtName.Text.Trim();/將用戶名記入sessionSessionpwd = txtPwd.Text.Trim();Response.Redirect(sysadmin.aspx);elseSessionservice = txtName.Text.Trim();Sessi

15、onpwd = txtPwd.Text.Trim();Response.Redirect(service.aspx);elseScriptManager.RegisterStartupScript(this, this.GetType(), click, alert(用戶名或密碼錯誤!);, false);elseScriptManager.RegisterStartupScript(this, this.GetType(), click, alert(數(shù)據(jù)庫連接或訪問失?。?;, false);4.2 酒店日常管理界面在服務(wù)員登陸后進(jìn)入到service.aspx頁面,這個頁面放了4個Link

16、button連接4個界面分別對應(yīng)酒店日常管理的四個基本功能:預(yù)訂房間、訂單查詢、大堂入住、結(jié)賬退房。界面如圖4-2所示圖 4-2 系統(tǒng)流程圖4.3 預(yù)訂房間界面在service.aspx界面點(diǎn)擊預(yù)訂房間進(jìn)入房間預(yù)訂界面,這個界面使用Command對象實(shí)現(xiàn)對數(shù)據(jù)庫表dbo.訂單的插入操作。預(yù)定界面如圖4-3所示圖 4-3 系統(tǒng)流程圖關(guān)鍵后臺代碼:protected void Page_Load(object sender, EventArgs e)Label1.Text = Sessionservice.ToString();protected void Buttonok1_Click(obje

17、ct sender, EventArgs e)string msg;string sqlconnstr = ConfigurationManager.ConnectionStringsHotelConnectionString.ConnectionString;SqlConnection sqlconn = new SqlConnection(sqlconnstr);/建立Command對象SqlCommand sqlcommand = new SqlCommand();sqlcommand.Connection = sqlconn;/把SQL語句賦給Command對象sqlcommand.C

18、ommandText = insert into 訂單(訂單號,預(yù)定時間,入住時間,房間類型,房間數(shù),房間號,入住人,聯(lián)系人,聯(lián)系電話) values (訂單號,預(yù)定時間,入住時間,房間類型,房間數(shù),房間號,入住人,聯(lián)系人,聯(lián)系電話);sqlcommand.Parameters.AddWithValue(訂單號,TextBox1.Text);sqlcommand.Parameters.AddWithValue(預(yù)定時間,TextBox2.Text);sqlcommand.Parameters.AddWithValue(入住時間,TextBox3.Text);sqlcommand.Paramet

19、ers.AddWithValue(房間類型,TextBox4.Text);sqlcommand.Parameters.AddWithValue(房間數(shù),TextBox5.Text);sqlcommand.Parameters.AddWithValue(房間號,TextBox6.Text);sqlcommand.Parameters.AddWithValue(入住人,TextBox7.Text);sqlcommand.Parameters.AddWithValue(聯(lián)系人,TextBox8.Text);sqlcommand.Parameters.AddWithValue(聯(lián)系電話,TextBox

20、9.Text);trysqlconn.Open();/打開連接sqlcommand.ExecuteNonQuery();/執(zhí)行命令msg = 添加成功;catch (Exception ex) /如果try出錯,則捕獲錯誤msg = 添加失敗+ex.Message.ToString().Trim();finallysqlconn.Close();ScriptManager.RegisterStartupScript(this, this.GetType(), click, alert( + msg + );, false);protected void Buttoncancel_Click(o

21、bject sender, EventArgs e)TextBox1.Text = ;TextBox2.Text = ;TextBox3.Text = ;TextBox4.Text = ;TextBox5.Text = ;TextBox6.Text = ;TextBox7.Text = ;4.4 訂單查詢界面訂單查詢界面使用了一個GridView控件使用數(shù)據(jù)綁定的方式實(shí)現(xiàn)輸入訂單號來查詢訂單,并在使用設(shè)置控件的CommandField類型來實(shí)現(xiàn)服務(wù)員對訂單的修改和刪除操作。訂單查詢界面如圖4-4所示:圖4-4 訂單查詢界面 關(guān)鍵后臺代碼:protected void Page_Load(obj

22、ect sender, EventArgs e)if (!Page.IsPostBack) bindgrid();Label1.Text = Sessionservice.ToString();void bindgrid()/刷新gridview的數(shù)據(jù)string strcon, strsql, msg;DataTable dt = new DataTable();strcon = ConfigurationManager.ConnectionStringsHotelConnectionString.ConnectionString;strsql = select * from 訂單 orde

23、r by 訂單號 ;SqlConnection con = new SqlConnection(strcon);/定義新的數(shù)據(jù)連接控件并初始化SqlDataAdapter cmd = new SqlDataAdapter(strsql, con);msg = 成功;trycon.Open();/打開連接cmd.Fill(dt);/填充數(shù)據(jù)集catch (Exception ex) /如果try出錯,則捕獲錯誤msg = 數(shù)據(jù)訪問出錯;/ +ex.Message.ToString().Trim();finallycon.Close();if (msg = 成功)GridView1.DataSou

24、rce = dt;GridView1.DataBind();elseScriptManager.RegisterStartupScript(this, this.GetType(), click, alert( + msg + );, false);protected void TextBox1_TextChanged(object sender, EventArgs e)protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)GridView1.PageIndex = e.NewPag

25、eIndex;bindgrid();protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)GridView1.EditIndex = -1;bindgrid();protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)string strcon, strsql, msg;strcon = ConfigurationManager.ConnectionStringsHotelCo

26、nnectionString.ConnectionString;strsql = delete from 訂單 where 訂單號= + GridView1.DataKeyse.RowIndex.Value.ToString() + ;SqlConnection con = new SqlConnection(strcon);/定義新的數(shù)據(jù)連接控件并初始化SqlCommand com = new SqlCommand(strsql, con);msg = 刪除成功;trycon.Open();/打開連接com.ExecuteNonQuery();/執(zhí)行命令catch (Exception ex

27、) /如果try出錯,則捕獲錯誤msg = 刪除失敗;/ +ex.Message.ToString().Trim();finallycon.Close();if (msg = 刪除成功)bindgrid();elseScriptManager.RegisterStartupScript(this, this.GetType(), click, alert( + msg + );, false);protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)GridView1.EditIndex = e.Ne

28、wEditIndex;/EditIndex:獲取或設(shè)置要編輯的行的索引。bindgrid();protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)string sqlconnstr = ConfigurationManager.ConnectionStringsHotelConnectionString.ConnectionString;string msg;SqlConnection sqlconn = new SqlConnection(sqlconnstr);/提交行修改trysqlc

29、onn.Open();SqlCommand Comm = new SqlCommand();Comm.Connection = sqlconn;Comm.CommandText = update 訂單 set 訂單號=訂單號,預(yù)定時間=預(yù)定時間,入住時間=入住時間,房間類型=房間類型,房間數(shù)=房間數(shù),入住人=入住人,聯(lián)系人=聯(lián)系人,聯(lián)系電話=聯(lián)系電話,備注=備注where 訂單號=訂單號;Comm.Parameters.AddWithValue(訂單號, GridView1.DataKeyse.RowIndex.Value.ToString();Comm.Parameters.AddWithV

30、alue(預(yù)定時間, (TextBox)GridView1.Rowse.RowIndex.Cells1.Controls0).Text);Comm.Parameters.AddWithValue(入住時間, (TextBox)GridView1.Rowse.RowIndex.Cells2.Controls0).Text);Comm.Parameters.AddWithValue(房間類型, (TextBox)GridView1.Rowse.RowIndex.Cells3.Controls0).Text);Comm.Parameters.AddWithValue(房間數(shù), (TextBox)Gr

31、idView1.Rowse.RowIndex.Cells4.Controls0).Text);Comm.Parameters.AddWithValue(房間號, (TextBox)GridView1.Rowse.RowIndex.Cells5.Controls0).Text);Comm.Parameters.AddWithValue(入住人, (TextBox)GridView1.Rowse.RowIndex.Cells6.Controls0).Text);Comm.Parameters.AddWithValue(聯(lián)系人, (TextBox)GridView1.Rowse.RowIndex.C

32、ells7.Controls0).Text);Comm.Parameters.AddWithValue(聯(lián)系電話, (TextBox)GridView1.Rowse.RowIndex.Cells8.Controls0).Text);Comm.Parameters.AddWithValue(備注, (TextBox)GridView1.Rowse.RowIndex.Cells9.Controls0).Text);Comm.ExecuteNonQuery();msg = 退房成功;sqlconn.Close();sqlconn = null;Comm = null;catch (Exception

33、 ex)msg=數(shù)據(jù)庫更新出錯;GridView1.EditIndex = -1;bindgrid();protected void Button1_Click(object sender, EventArgs e)string strcon, strsql, msg;DataSet ds = new DataSet();strcon = ConfigurationManager.ConnectionStringsHotelConnectionString.ConnectionString;strsql = select * from 訂單 where 訂單號 like % + TextBox

34、1.Text.Trim() + % order by 訂單號 ;SqlConnection con = new SqlConnection(strcon);/定義新的數(shù)據(jù)連接控件并初始化SqlDataAdapter cmd = new SqlDataAdapter(strsql, con);msg = 成功;trycon.Open();/打開連接cmd.Fill(ds, inorder);/填充數(shù)據(jù)集catch (Exception ex) /如果try出錯,則捕獲錯誤msg = 數(shù)據(jù)訪問出錯;finallycon.Close();if (msg = 成功)GridView1.DataSour

35、ce = ds.Tablesinorder.DefaultView;GridView1.DataBind();elseScriptManager.RegisterStartupScript(this, this.GetType(), click, alert( + msg + );, false); 4.5 大堂入住界面大堂入住界面是客戶沒有事先預(yù)定,直接到就酒店大堂辦理入住的界面,實(shí)現(xiàn)對數(shù)據(jù)庫表dbo.入住記錄的插入。界面如圖4-5所示:圖4-5 大堂入住界面關(guān)鍵后臺代碼:protected void Button1_Click(object sender, EventArgs e)stri

36、ng strcon, strsql, msg;strcon = ConfigurationManager.ConnectionStringsHotelConnectionString.ConnectionString;strsql = insert into 入住記錄(入住流水號,房間號,客戶標(biāo)識,入住人姓名,入住人證件,入住時間,押金) values ( +TextBox1.Text + , + TextBox2.Text + , + TextBox3.Text + , + TextBox4.Text + , + TextBox5.Text + , + TextBox6.Text + , +

37、 TextBox7.Text + );SqlConnection con = new SqlConnection(strcon);/定義新的數(shù)據(jù)連接控件并初始化SqlCommand com = new SqlCommand(strsql, con);msg = 添加成功;trycon.Open();/打開連接com.ExecuteNonQuery();/執(zhí)行命令catch (Exception ex) /如果try出錯,則捕獲錯誤msg = 添加失敗;finallycon.Close();ScriptManager.RegisterStartupScript(this, this.GetTyp

38、e(), click, alert( + msg + );, false);protected void Buttoncancel_Click(object sender, EventArgs e)TextBox1.Text = ;TextBox2.Text = ;TextBox3.Text = ;TextBox4.Text = ;TextBox5.Text = ;TextBox6.Text = ;TextBox7.Text = ;4.6 結(jié)賬退房界面結(jié)賬退房界面,實(shí)現(xiàn)了駛?cè)敕块g號查詢?nèi)胱∮涗洷?,在GridView控件中顯示查詢結(jié)果,點(diǎn)擊退房按鈕更新表中數(shù)據(jù)。如圖4-6所示:圖 4-6 結(jié)賬退

39、房界面關(guān)鍵后臺代碼:protected void Page_Load(object sender, EventArgs e)if (!Page.IsPostBack) bindgrid();Label1.Text = Sessionservice.ToString();void bindgrid()/刷新gridview的數(shù)據(jù)string strcon, strsql, msg;DataTable dt = new DataTable();strcon = ConfigurationManager.ConnectionStringsHotelConnectionString.Connectio

40、nString;strsql = select * from 入住記錄 order by 入住流水號 ;SqlConnection con = new SqlConnection(strcon);/定義新的數(shù)據(jù)連接控件并初始化SqlDataAdapter cmd = new SqlDataAdapter(strsql, con);msg = 成功;trycon.Open();/打開連接cmd.Fill(dt);/填充數(shù)據(jù)集catch (Exception ex) /如果try出錯,則捕獲錯誤msg = 數(shù)據(jù)訪問出錯;/ +ex.Message.ToString().Trim();finally

41、con.Close();if (msg = 成功)GridView1.DataSource = dt;GridView1.DataBind();elseScriptManager.RegisterStartupScript(this, this.GetType(), click, alert( + msg + );, false);protected void Button1_Click(object sender, EventArgs e)string strcon, strsql, msg;DataSet ds = new DataSet();strcon = ConfigurationM

42、anager.ConnectionStringsHotelConnectionString.ConnectionString;strsql = select * from 入住記錄 where 房間號 like % + TextBox1.Text.Trim() + % order by 房間號 ;SqlConnection con = new SqlConnection(strcon);/定義新的數(shù)據(jù)連接控件并初始化SqlDataAdapter cmd = new SqlDataAdapter(strsql, con);msg = 成功;trycon.Open();/打開連接cmd.Fill(

43、ds,intoRecord);/填充數(shù)據(jù)集 / 注意:查詢結(jié)果若是空集,不屬于出錯情形catch (Exception ex) /如果try出錯,則捕獲錯誤msg = 數(shù)據(jù)訪問出錯;finallycon.Close();if (msg = 成功)GridView1.DataSource = ds.TablesintoRecord.DefaultView;GridView1.DataBind();elseScriptManager.RegisterStartupScript(this, this.GetType(), click, alert( + msg + );, false);protec

44、ted void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)GridView1.PageIndex = e.NewPageIndex;bindgrid();protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)GridView1.EditIndex = -1;bindgrid();protected void GridView1_RowDeleting(object sender, G

45、ridViewDeleteEventArgs e)string strcon, strsql, msg;strcon = ConfigurationManager.ConnectionStringsHotelConnectionString.ConnectionString;strsql = delete from 入住記錄 where 入住流水號= + GridView1.DataKeyse.RowIndex.Value.ToString() + ;SqlConnection con = new SqlConnection(strcon);/定義新的數(shù)據(jù)連接控件并初始化SqlCommand

46、com = new SqlCommand(strsql, con);msg = 刪除成功;trycon.Open();/打開連接com.ExecuteNonQuery();/執(zhí)行命令catch (Exception ex) /如果try出錯,則捕獲錯誤msg = 刪除失敗;/ +ex.Message.ToString().Trim();finallycon.Close();if (msg = 刪除成功)bindgrid();elseScriptManager.RegisterStartupScript(this, this.GetType(), click, alert( + msg + );

47、, false);protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)GridView1.EditIndex = e.NewEditIndex;/EditIndex:獲取或設(shè)置要編輯的行的索引。bindgrid();protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)string strcon, strsql, msg;strcon = ConfigurationManager.Connecti

48、onStringsHotelConnectionString.ConnectionString;SqlConnection con = new SqlConnection(strcon);/定義新的數(shù)據(jù)連接控件并初始化strsql = update 入住記錄 set 入住流水號= + (TextBox)GridView1.Rowse.RowIndex.Cells0.Controls0).Text + ;strsql = strsql + ,房間號= + (TextBox)GridView1.Rowse.RowIndex.Cells1.Controls0).Text + ;strsql = st

49、rsql + ,客戶標(biāo)識= + (TextBox)GridView1.Rowse.RowIndex.Cells2.Controls0).Text + ;strsql = strsql + ,入住人姓名= + (TextBox)GridView1.Rowse.RowIndex.Cells3.Controls0).Text + ;strsql = strsql + ,入住人證件= + (TextBox)GridView1.Rowse.RowIndex.Cells4.Controls0).Text + ;strsql = strsql + ,入住時間= + (TextBox)GridView1.Ro

50、wse.RowIndex.Cells5.Controls0).Text + ;strsql = strsql + ,退房時間= + (TextBox)GridView1.Rowse.RowIndex.Cells7.Controls0).Text + ;strsql = strsql + ,消費(fèi)= + (TextBox)GridView1.Rowse.RowIndex.Cells7.Controls0).Text + ;strsql = strsql + ,押金= + (TextBox)GridView1.Rowse.RowIndex.Cells6.Controls0).Text + ;strsql = strsql + where 入住流水號= + GridView1.DataKeyse.RowIndex.Value.ToString() + ;

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論