Private Sub cmdRentSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdRentSave.Click
If MessageBox.Show("คุณต้องการที่จะบันทึกการยืมหรือไม่", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Information) = Windows.Forms.DialogResult.Yes Then
Dim o As New Rent()
o.CustomerID = txtCustomerID.Text.Trim()
o.RentDate = CDate(DateTimePicker_InComeDate.Text)
Dim i As Integer
Dim od As RentsDetail
For i = 0 To ListViewRent.Items.Count - 1
od = New RentsDetail()
od.BookID = ListViewRent.Items(i).SubItems(0).Text
od.RentPrice = CDec(ListViewRent.Items(i).SubItems(2).Text)
od.Status = ListViewRent.Items(i).SubItems(3).Text
od.Status = "002"
o.RentsDetails.Add(od)
Next
Using ts As New TransactionScope()
db.Rents.InsertOnSubmit(o)
db.SubmitChanges()
ts.Complete()
End Using
MessageBox.Show("บันทึกรายการยืมเรียบร้อยแล้ว", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
ListViewRent.Clear()
ClearBookData()
ClearCustomerData()
lblNet.Text = "0"
txtCustomerID.Focus()
End If
End Sub
Tag : .NET, Win (Windows App), LINQ, VB.NET, VS 2010 (.NET 4.x)