Public Enum chkdoSave
insert = 0
update = 1
End Enum
Protected Function doSaveData(ByVal projectName As String, ByVal projectDatePath As String) As Boolean
Dim db As New DataClassesProjectDataContext
Dim result
Dim chk As chkdoSave
Try
result = (From p In db.projects Where p.projectID =
idProject Select
p).Single()
chk = chkdoSave.update
Catch ex As Exception
result = Nothing
result = New project
chk = chkdoSave.insert
End Try
result.projectID = idProject
result.proStatus = status
result.proConfirmReceiveDate =
Now.ToString("s")
result.proComment = proComment
Using tc As New TransactionScope
If chk = chkdoSave.insert Then
db.projects.InsertOnSubmit(result)
End If
db.SubmitChanges()
tc.Complete()
End Using
result = Nothing
db.Dispose()
Return True
End Function
ไม่มีความคิดเห็น:
แสดงความคิดเห็น