(读者可打开【光盘】|【源文件】|【实例 96 】|【 96.1.txt 】文件,直接复制) 程序说明: 该 “ Page_Load ”过程是在第一次载入页面时,为单选按钮列表“ RoomRadio ”添加列表项,添加列表项的标签值等于“ RoomData ”数据集下的字段“ RoomType ”,而选取值等于字段“ RoomID ”。 提示:也许有人会问为什么不直接用单选按钮列表的数据绑定呢?这由于通过 Dreamweaver 进行数据绑定,在程序中经常会出现无法获取单选按钮列表选取值的错误。 ( 7 )定义“ MyCalendar1_SelectionChanged ”过程,用于响应日历控件“ MyCalendar1 ”的“ SelectionChanged ”事件,该过程的代码如下所述。 Protected Sub MyCalendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)Handles MyCalendar1.SelectionChanged starttime.text = MyCalendar1.SelectedDate.ToShortDateString End Sub |
(读者可打开【光盘】|【源文件】|【实例 96 】|【 96.2.txt 】文件,直接复制) ( 8 )定义“ MyCalendar2_SelectionChanged ”过程,用于响应日历控件“ MyCalendar2 ”的“ SelectionChanged ”事件,该过程的代码如下所述。 Protected Sub MyCalendar2_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)Handles MyCalendar2.SelectionChanged lasttime.text= MyCalendar2.SelectedDate.ToShortDateString End Sub |
(读者可打开【光盘】|【源文件】|【实例 96 】|【 96.3.txt 】文件,直接复制) 步骤三 实现客户预订业务 ( 1 )实现客户预订业务的程序流程如图 96-11 所示。 ( 2 )为页面添加 4 个全局变量,如图 96-12 中圆角方框所示。 ( 3 )定义“ Usercheck ”函数。该函数用于检测用户是否登录正确,登录不正确时是否注册成功,如果用户登录正确或者注册成功,则该函数返回“ True ”,否则将返回“ False ”,该函数的代码如下所述。 以下是引用片段: Function Usercheck() As Boolean Dim Hotelada1, Hotelada2 As OleDbDataAdapter Dim HotelDataSet1, HotelDataSet2 As System.Data.DataSet Dim Hoteldt1, Hoteldt2 As DataTable Dim tbRow As DataRow Dim yy As OleDbCommandBuilder Hotelstring = "Select * From tbUser Where UserId=’" & UserID1.Text & "’ And UserPass=’" & UserPass1.Text & "’" Hotelada1 = New OleDbDataAdapter(Hotelstring, conn) HotelDataSet1 = New System.Data.DataSet Hotelada1.Fill(HotelDataSet1, "tbUser") Hoteldt1 = HotelDataSet1.Tables("tbUser") If Hoteldt1.Rows.Count > 0 Then strName = Hoteldt1.Rows(0)("UserId") Else If (Trim(UserID.Text) <> Nothing) And (Trim(UserPass.Text) <> Nothing) _ And (Trim(UserName.Text) <> Nothing) And (Trim(UserEmail.Text) <> Nothing) _ And (Trim(UserTel.Text) <> Nothing) Then Hotelstring = "Select * from tbUser" Hotelada2 = New OleDbDataAdapter(Hotelstring, conn) yy = New OleDbCommandBuilder(Hotelada2) HotelDataSet2 = New System.Data.DataSet Hotelada2.Fill(HotelDataSet2, "tbUser") Hoteldt2 = HotelDataSet2.Tables("tbUser") tbRow = Hoteldt2.NewRow tbRow("UserId") = UserID.Text tbRow("UserPass") = UserPass.Text tbRow("UserName") = UserName.Text tbRow("UserEmail") = UserEmail.Text tbRow("UserTel") = UserTel.Text Hoteldt2.Rows.Add(tbRow) Hotelada2.Update(HotelDataSet2, "tbUser") strName = UserID.Text Else Usercheck = False Exit Function End If End If Usercheck = True End Function | |