📄 makedatabase.aspx.vb
字号:
Me.deleteCar.Add(Convert.ToString(checkBox.CssClass))
Session("deleteCar") = deleteCar
Else
checkBox = CType(sender, CheckBox)
If checkBox.Checked = True Then
deleteCar = CType(Session("deleteCar"), ArrayList)
deleteCar.Add(Convert.ToString(checkBox.CssClass))
'Session("deleteCar") = deleteCar
Else
deleteCar = CType(Session("deleteCar"), ArrayList)
deleteCar.Remove(Convert.ToString(checkBox.CssClass))
If deleteCar.Count = 0 Then
Session.Remove("deleteCar")
Else
Session("deleteCar") = deleteCar
End If
End If
End If
Me.allSession()
End Sub
'<-----------------------------点击删除数据库中打勾的行------------------------------->
Private Sub btnRemove_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.ServerClick, btnRemoveAll.ServerClick
Dim input As HtmlInputButton = CType(sender, HtmlInputButton)
If input.ID = "btnRemove" Then
If Not Session("deleteCar") Is Nothing Then
deleteCar = CType(Session("deleteCar"), ArrayList)
Else
deleteCar = Nothing
End If
Else
If Not Session("deleteBase") Is Nothing Then
deleteCar = CType(Session("deleteBase"), ArrayList)
Else
deleteCar = Nothing
End If
End If
If Not deleteCar Is Nothing Then
Dim MyConnection As SqlConnection = Global.GetConnection("equipment")
Dim DeleteCmd As String = "DELETE FROM card WHERE card_id='"
Dim i As Integer
For i = 0 To deleteCar.Count - 1
If i <> deleteCar.Count - 1 Then
DeleteCmd &= Convert.ToString(deleteCar(i)) & "'OR card_id='"
Else
DeleteCmd &= Convert.ToString(deleteCar(i)) & "'"
End If
Next
Dim MyCommand As SqlCommand = New SqlCommand(DeleteCmd, MyConnection)
MyCommand.Connection.Open()
Try '删除数据的提示
MyCommand.ExecuteNonQuery()
info.Text = "所选记录已经成功删除"
info.Style.Add("color", "green")
MyConnection.Close()
Session.Remove("deleteCar")
If input.ID = "btnRemoveAll" Then
Session.Remove("deleteBase")
End If
Catch Exc As SqlException
info.Text = "ERROR: Could not delete record"
info.Style.Add("color", "red")
Finally
MyCommand.Connection.Close()
End Try
SQLstr = Me.getQueryString(Me.competence)
mydatagrid.DataSource = Global.CreateDataView(SQLstr)
mydatagrid.DataBind()
Else
info.Text = "无记录可删除"
info.Style.Add("color", "red")
End If
End Sub
Sub reMark()
If Not Session("deleteCar") Is Nothing Then
Dim check_card As System.Web.UI.WebControls.CheckBox
Dim oDataGridItem As DataGridItem
deleteCar = CType(Session("deleteCar"), ArrayList)
'deleteCar = CType(deleteCar.Clone(), ArrayList)
Dim i As Integer
For i = 0 To Me.mydatagrid.Items.Count - 1
oDataGridItem = mydatagrid.Items(i)
check_card = oDataGridItem.FindControl("check_card")
For Each arr As String In deleteCar
If Convert.ToString(check_card.CssClass) = arr Then
check_card.Checked = True
'deleteCar.Remove(arr)
Exit For
End If
Next
If deleteCar.Count = 0 Then
Exit For
End If
Next
End If
End Sub
Sub compareDeleteSession(ByVal str As String)
If Session("deleteBase") Is Nothing Then
If Not Session("deleteCar") Is Nothing Then
deleteCar = CType(Session("deleteCar"), ArrayList)
Dim t As New ArrayList
For Each s As String In deleteCar
t.Add(s)
Next
Session("deleteBase") = t
deleteCar = New ArrayList
Dim conn As SqlConnection = Global.GetConnection("equipment")
Dim comm As SqlCommand = New SqlCommand(str, conn)
Dim reader As SqlDataReader
Dim temp As New ArrayList
deleteCar = CType(Session("deleteCar"), ArrayList)
'deleteCar = CType(deleteCar.Clone(), ArrayList)
conn.Open()
reader = comm.ExecuteReader()
If reader.Read() Then
For Each stri As String In deleteCar
If stri = Convert.ToString(reader.Item("card_id")) Then
'deleteCar.Remove(stri)
temp.Add(stri)
Exit For
End If
Next
End If
reader.Close()
conn.Close()
If temp.Count <> 0 Then
Session("deleteCar") = temp
End If
End If
Else
If Not Session("deleteCar") Is Nothing Then
Dim tempCar As ArrayList = CType(Session("deleteCar"), ArrayList)
'tempCar = CType(tempCar.Clone(), ArrayList)
Dim tempBase As ArrayList = CType(Session("deleteBase"), ArrayList)
Dim temp As New ArrayList
For Each tc As String In tempCar
temp.Add(tc)
Next
For Each tb As String In tempBase
Dim t As Integer = 0
For Each tc As String In tempCar
If tc = tb Then
Exit For
End If
t = t + 1
Next
If t = tempCar.Count Then
temp.Add(tb)
Else
'tempCar.Remove(tb)
End If
Next
If temp.Count <> 0 Then
Session("deleteBase") = temp
End If
temp = New ArrayList
Dim conn As SqlConnection = Global.GetConnection("equipment")
Dim comm As SqlCommand = New SqlCommand(str, conn)
Dim reader As SqlDataReader
deleteCar = CType(Session("deleteBase"), ArrayList)
'deleteCar = CType(deleteCar.Clone(), ArrayList)
conn.Open()
reader = comm.ExecuteReader()
If reader.Read() Then
For Each stri As String In deleteCar
If stri = Convert.ToString(reader.Item("card_id")) Then
'deleteCar.Remove(stri)
temp.Add(stri)
Exit For
End If
Next
End If
reader.Close()
conn.Close()
If temp.Count <> 0 Then
Session("deleteCar") = temp
End If
Else
Dim temp As New ArrayList
Dim conn As SqlConnection = Global.GetConnection("equipment")
Dim comm As SqlCommand = New SqlCommand(str, conn)
Dim reader As SqlDataReader
deleteCar = CType(Session("deleteBase"), ArrayList)
'deleteCar = CType(deleteCar.Clone(), ArrayList)
conn.Open()
reader = comm.ExecuteReader()
If reader.Read() Then
For Each stri As String In deleteCar
If stri = Convert.ToString(reader.Item("card_id")) Then
'deleteCar.Remove(stri)
temp.Add(stri)
Exit For
End If
Next
End If
reader.Close()
conn.Close()
If temp.Count <> 0 Then
Session("deleteCar") = temp
End If
End If
End If
End Sub
Sub allSession()
If Not Session("deleteBase") Is Nothing Then
If Not Session("deleteCar") Is Nothing Then
Dim tempCar As ArrayList = CType(Session("deleteCar"), ArrayList)
'tempCar = CType(tempCar.Clone(), ArrayList)
Dim tempBase As ArrayList = CType(Session("deleteBase"), ArrayList)
Dim temp As New ArrayList
For Each tc As String In tempCar
temp.Add(tc)
Next
For Each tb As String In tempBase
Dim t As Integer = 0
For Each tc As String In tempCar
If tc = tb Then
Exit For
End If
t = t + 1
Next
If t = tempCar.Count Then
temp.Add(tb)
Else
'tempCar.Remove(tb)
End If
Next
If temp.Count <> 0 Then
Session("deleteBase") = temp
End If
End If
Else
If Not Session("deleteCar") Is Nothing Then
Dim deleteCar As New ArrayList
deleteCar = Session("deleteCard")
'deleteCar = CType(deleteCar.Clone(), ArrayList)
Session("deleteBase") = deleteCar
End If
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -