 |
|
พี่ๆคะช่วยดู code ให้หน่อยนะคะ มันฟ้องว่าคอลัมน์ teacher_id มันคลุมเครือ หรือว่าไม่เจอเนี่ยแหละค่ะ เด๊วแปะโค้ดให้พี่ดูสองส่วนแล้วกันนะคะ คือ database กะ code การ insert ที่เขียนใน aspx.vb ค่ะ
ส่วนนี้เป็นส่วน select มาจาก database ค่ะ ดึงขึ้นมาเำื่พื่อเช็คเงื่อนไขในการจองการนัดพบอาจารย์ วันที่และเวลาค่ะ
Code (VB.NET)
Function checkTime(ByVal teacherID As String, ByVal bookDate As String, ByVal bookTime As String) As DataSet
Dim ds As New DataSet
Dim sql As String = "select teacher_id,convert(varchar(10),appointment_date,120) as Date,appointment_time from Appointment,teacher where teacher_id ='" & teacherID & "' and convert(varchar(10),appointment_date,120) ='" & bookDate & "' and appointment_time ='" & bookTime & "'"
Dim da As New SqlDataAdapter(sql, cnn)
da.Fill(ds, "checkTime")
Return ds
End Function
ส่วนนี้เป็นส่วนการ insert นะคะ มาจาก aspx.vb
Code (VB.NET)
Protected Sub cmdSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Dim ds As New DataSet
Dim check As String
check = Right(Str(Val(Format(CalendarPopup1.SelectedDate, "yyyy")) - 543), 2) & Format(CalendarPopup1.SelectedDate, "-MM-dd")
ds = selectData.checkTime(ddlTeachername.SelectedValue, check, TimePicker1.PostedTime.ToString)
Dim runID As Integer
runID = insertData.runID("Appointment", "Appointment_ID")
hidApp_ID.Value = runID
If ds.Tables(0).Rows.Count = 0 Then
hidApp_ID.Value = runID
insertData.insertAppointment(lblStudent_ID.Text, lblStudent_Name.Text, ddlTeachername.SelectedValue, hidApp_ID.Value, txtTitle.Text, CalendarPopup1.SelectedDate, TimePicker1.PostedTime.ToString, txtContent.Text)
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('" + "บันทึกข้อมูลเรียบร้อยแล้ว" + "');", True)
Response.Redirect("showAppointment2.aspx")
txtTitle.Text = ""
txtContent.Text = ""
Else
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('" + "กรุณาจองเวลาการนัดพบใหม่" + "');", True)
End If
End Sub
Tag : .NET, Ms SQL Server 2005, Web (ASP.NET), VB.NET
|
|
 |
 |
 |
 |
Date :
2011-02-19 01:42:10 |
By :
deathshadow |
View :
1271 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |