0
我有一個GridView
,其中包含.net checkbox
控件的行。用戶將檢查行和在點擊該按鈕,將在表insert
的checked
行GeneratedInvoiceBatches
DB中的重複插入
VB代碼:
Protected Sub btnGenerate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
Dim grItem As DataGridItem
Dim i As Integer = 0
For Each grItem In grdTransactions.Items
If grItem.ItemType = ListItemType.AlternatingItem Or grItem.ItemType = ListItemType.Item Then
If CType(grItem.Cells(0).FindControl("chkSelect"), CheckBox).Checked = True Then
Utilities.InsertUnsettledBatchesForInvoice(grItem.Cells(5).Text.Trim, grItem.Cells(7).Text.Trim, grItem.Cells(11).Text.Trim)
i = i + 1
End If
End If
Next
If i = 0 Then
Response.Write("<script> alert('No selected record(s) to process!');</script>")
Else
Response.Write("<script> alert('Operation Successful!');</script>")
BindDataGrid()
End If
End Sub
存儲過程:
Create proc [dbo].[spInsertUnsettledBatchesForInvoice]
@TerminalID varchar(8),
@BatchNumber int,
@SettledAmount money
as
insert into GeneratedInvoiceBatches (GenerationDate,TerminalID,BatchNumber,SettledAmount,isPayment,isHSBCFile,paymentdate)
values
(GetDate(),@TerminalID,@BatchNumber,@SettledAmount,1,1,getdate())
問題是有時它插入重複行在三個月內說一次。有人可以確定這個問題嗎?這與複選框控件有關嗎?我怎樣才能避免這種重複?
哪個值確定記錄是重複的? –
如果不是在任何點擊重複..比通過點擊意外兩次..在dgv相同的行,你可以檢查是否存在分貝警告.. – CristiC777
是似乎我必須使用NOT EXISTS用子查詢來檢查是否有重複 – Nuke