|
|
|
ช่วยดูโค้ดระบบคืนหนังสือห้องสมุดให้ด้วยค่ะ พอกดEnter ข้อมูลก้อมาแสดงนะคะแต่อยากดึงข้อมูลของสมาชิก1 คนที่่มีสถานะการยืมหนังสือให้มาแสดงใน Datagridview ทั้งหมดน่ะคะ |
|
|
|
|
|
|
|
Code (VB.NET)
Private Sub txtbksearch_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtbksearch.KeyDown
Dim bFlag As Boolean = True
If e.KeyCode = Keys.Enter Then
sql = "SELECT t1.Borrow_ID, t2.Bookseries, t3.BookCode, t4.Bookname, t1.Mem_ID, t1.Mem_name, t5.Class, t5.Classroom, t6.Membertype_name, t5.RegistDateEnd, " & _
"t1.Mem_surename, t1.Bowdate, t1.Duedate, t6.book_fines, t2.Borrowstatus, t44.Booktype_Name ,t3.borrowpenalty, t2.ReturnDate " & _
"FROM tb_Borrow AS t1 INNER JOIN " & _
"tb_detailborrow AS t2 ON t1.Borrow_ID = t2.Borrow_ID INNER JOIN " & _
"tb_detailbook AS t3 ON t2.Bookseries = t3.Bookseries INNER JOIN " & _
"tb_book AS t4 ON t3.BookCode = t4.BookCode INNER JOIN " & _
"tb_booktype AS t44 ON t4.Booktype_ID = t44.Booktype_ID INNER JOIN " & _
"tb_member AS t5 ON t1.Mem_ID = t5.Mem_ID INNER JOIN " & _
"tb_Membertype AS t6 ON t5.Membertype_ID = t6.Membertype_ID " & _
"WHERE (t2.Borrowstatus='ยืม') AND (t2.Bookseries = '" + txtbksearch.Text + "');"
Dim dr As SqlDataReader
com = New SqlCommand
com.Connection = conn
com.CommandText = sql
dr = com.ExecuteReader
If dr.HasRows Then
dr.Read()
txtbkid.Text = dr("Bookseries")
txtbkname.Text = dr("Bookname")
txtbktybook.Text = dr("Booktype_Name")
txtborrowpenalty.Text = dr("borrowpenalty")
txtduedate.Text = dr("ReturnDate")
txtbrsearch.Text = dr("Mem_ID")
txtmemname.Text = dr("Mem_name") + " " + dr("Mem_surename")
txtmemtype.Text = dr("Membertype_name")
txtmemclass.Text = dr("Class")
txtmemclassroom.Text = dr("Classroom")
txtRegisEndDate.Text = dr("RegistDateEnd")
Dim drx As DataRow = databorrow.NewRow()
drx(0) = dr("BookCode")
drx(1) = dr("Bookseries")
drx(2) = dr("Bookname")
drx(3) = CDate(dr("ReturnDate")).ToString("dd/MM/yyyy")
databorrow.Rows.Add(drx)
DataGridView1.AutoGenerateColumns = False
DataGridView1.DataSource = databorrow
'lblborrowid.Text = dr("Borrow_ID")
'txtmemid.Text = dr("Mem_ID")
'txtmemname.Text = dr("Mem_name")
'txtmemsur.Text = dr("Mem_surename")
'txtbkid.Text = dr("BookCode")
'txtbkname.Text = dr("Bookname")
'txtbowdate.Text = dr("Bowdate")
'txtduedate.Text = dr("Duedate")
'txtnet.Text = dr("book_fines")
'Dim iday As Integer
'If CDate(txtreturn.Text) > CDate(txtduedate.Text) Then
' iday = DateDiff(DateInterval.Day, CDate(txtreturn.Text), CDate(txtduedate.Text))
'Else
' iday = 0
'End If
Dim iDay As Integer
If Today > CDate(txtduedate.Text) Then
iDay = DateDiff(DateInterval.Day, Today, CDate(txtduedate.Text)) * -1
TextBox1.Text = "ส่งคืนเกินกำหนด " + iDay.ToString() + " วัน"
lbltotal.Text = Integer.Parse(lbltotal.Text) + (iDay * Integer.Parse(txtborrowpenalty.Text))
Else
iDay = 0
TextBox1.Text = ""
End If
'Dim iDayCount As Integer = DateDiff(DateInterval.Day, CDate(txtbowdate.Text), CDate(txtreturn.Text))
''If iDay < 0 Then iDay = 0
'txtdatenum.Text = iDay.ToString
'txtfine.Text = (Integer.Parse(txtnet.Text) * iDay).ToString
'If MessageBox.Show("คุณต้องการคืนหนังสือ " + txtbkname.Text + " ใช่หรือไม่ ?", "ยืนยันการคืน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
' Dim lvi As ListViewItem = New ListViewItem(New String() {btsearchmem.Text, txtbkid.Text, txtbkname.Text, txtfine.Text, "รอการบันทึกข้อมูล", lblborrowid.Text, txtbowdate.Text, txtduedate.Text, txtreturn.Text, iDayCount.ToString, txtmemid.Text})
' lsvreturn.Items.Add(lvi)
' strBorrowList.Add(btsearchmem.Text)
' dr.Close()
' Call doShowBorrow()
' Call doShowBorrowDetail()
' btsearchmem.Text = ""
' If txtTotal.Text = "" Then txtTotal.Text = "0"
' txtTotal.Text = (Integer.Parse(txtTotal.Text) + Integer.Parse(txtfine.Text)).ToString
' 'Call cleartext(False)
'Else
' dr.Close()
' 'Call cleartext()
'End If
dr.Close()
txtbksearch.Text = ""
txtbksearch.Focus()
Else
dr.Close()
MessageBox.Show("ไม่พบข้อมูลการยืมหนังสือจากเลขทะเบียนที่ระบุ", "แจ้งเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtbksearch.Text = ""
txtbkid.Text = ""
txtbktybook.Text = ""
txtbkname.Text = ""
txtborrowpenalty.Text = ""
txtduedate.Text = ""
TextBox1.Text = ""
txtbrsearch.Text = ""
txtmemname.Text = ""
txtmemtype.Text = ""
txtmemclass.Text = ""
txtmemclassroom.Text = ""
txtRegisEndDate.Text = ""
txtbksearch.Focus()
Exit Sub
End If
End If
End Sub
Tag : .NET, Ms SQL Server 2005, Ms SQL Server 2008, VS 2008 (.NET 3.x)
|
|
|
|
|
|
Date :
2011-08-20 10:44:23 |
By :
มะนาวหวาน |
View :
1390 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้าจะตรวจสอบสถานะก็ WHERE คอลัมบ์ที่เป็น Status เข้าไปครับ
|
|
|
|
|
Date :
2011-08-22 21:08:33 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|