Function Coupon_INSERTCouponLog(ByVal eventID As Integer, ByVal EPCouponTable As DataTable) As String
Dim strInsertCmd As String = "INSERT INTO tbLog( couponPKID,eventID,userID,userName,gamenickname,usergender,usedcoupon,tradestatus,playdate,createdate,haverandomflag,iswinner) VALUES(@CouponPKID," + eventID.ToString() + ",@UserID,@UserName,@GameNickname,@UserGender,@UsedCoupon,1,@CreateDate,getdate(),0,0)"
Dim dbm As LuckyDBManager = New LuckyDBManager()
If Not dbm.ConnectToDB() = "SUCCESS" Then
Return Nothing
Exit Function
End If
Dim succ As String = "SUCCESS"
Dim dbTrans As OleDb.OleDbTransaction = dbm.dbCon.BeginTransaction()
Try
Dim cmdInsert As OleDb.OleDbCommand = New OleDb.OleDbCommand(strInsertCmd, dbm.dbCon, dbTrans)
cmdInsert.Parameters.Add("@CouponPKID", OleDb.OleDbType.Integer, 4, "couponPKID")
cmdInsert.Parameters.Add("@UserID", OleDb.OleDbType.Integer, 4, "userID")
cmdInsert.Parameters.Add("@UserName", OleDb.OleDbType.VarChar, 20, "username")
cmdInsert.Parameters.Add("@GameNickname", OleDb.OleDbType.VarChar, 20, "gamenickname")
cmdInsert.Parameters.Add("@UserGender", OleDb.OleDbType.VarChar, 10, "usergender")
cmdInsert.Parameters.Add("@UsedCoupon", OleDb.OleDbType.Integer, 4, "usedcoupon")
cmdInsert.Parameters.Add("@CreateDate", OleDb.OleDbType.Date, 8, "createdate")
Dim insertAdapter As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter()
insertAdapter.InsertCommand = cmdInsert
insertAdapter.Update(EPCouponTable)
'success
dbTrans.Commit()
Catch ex As Exception
succ = "ERROR"
HttpContext.Current.Response.Write(ex.Message)
dbTrans.Rollback()
Finally
dbm.ConnectionClose()
End Try
Return succ
End Function