(读者可打开【光盘】|【源文件】|【实例 96 】|【 96.6.txt 】文件,直接复制) ( 6 )定义过程“ ErrInfo ”用于出错时调用该过程显示错误信息,该过程的代码如下所述。 Sub ErrInfo(ByVal Errmess As String) Dim strScript As String strScript = "<script language=javascript>" strScript += "alert(’" + Errmess + "’);" strScript += "<" strScript += "/" strScript += "script>" RegisterClientScriptBlock("showSaveMessage", strScript) End Sub |
(读者可打开【光盘】|【源文件】|【实例 96 】|【 96.7.txt 】文件,直接复制) ( 7 )定义【现在预订】按钮的“ OnClick ”事件响应过程为“ Orderbt_Click ”,并将该过程绑定到【现在预订】按钮的“ OnClick ”事件中。“ Orderbt_Click ”过程的源代码如下所述。 Protected Sub Orderbt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim Errstr As String HotelConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("data/hotel.mdb") conn = New OleDbConnection(HotelConn) If Usercheck() = False Then Errstr = " 请正确登录或正确输入您的注册信息! " ErrInfo(Errstr) Exit Sub End If If Roomcheck() = False Then Errstr = " 您预订客房在您预订时间段中已预订满了! " ErrInfo(Errstr) Exit Sub End If Orderinser() End Sub | |