📄 frmm_del.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "Mscomctl.ocx"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form FrmM_Del
BorderStyle = 3 'Fixed Dialog
Caption = "删除数据"
ClientHeight = 4935
ClientLeft = 45
ClientTop = 330
ClientWidth = 5520
Icon = "FrmM_Del.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4935
ScaleWidth = 5520
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.OptionButton Option1
Caption = "按批号删除"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Index = 1
Left = 150
TabIndex = 7
Top = 4350
Width = 1500
End
Begin VB.OptionButton Option1
Caption = "按单号删除"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Index = 0
Left = 150
TabIndex = 6
Top = 3855
Width = 1500
End
Begin VB.CommandButton Command1
Caption = "删除选定数据"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 915
Index = 0
Left = 1755
Picture = "FrmM_Del.frx":030A
Style = 1 'Graphical
TabIndex = 1
Top = 3780
Width = 1665
End
Begin VB.CommandButton Command1
Caption = "退出窗口(&X)"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 915
Index = 1
Left = 3675
Picture = "FrmM_Del.frx":0614
Style = 1 'Graphical
TabIndex = 2
Top = 3780
Width = 1665
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 4320
Top = 975
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.Frame Frame1
Caption = "请输入单号:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 3375
Index = 0
Left = 75
TabIndex = 3
Top = 165
Width = 5250
Begin MSComctlLib.ListView ListView1
Height = 2895
Left = 2625
TabIndex = 5
Top = 345
Width = 2520
_ExtentX = 4445
_ExtentY = 5106
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = -1 'True
Checkboxes = -1 'True
FullRowSelect = -1 'True
GridLines = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
NumItems = 0
End
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2910
Left = 135
Style = 1 'Simple Combo
TabIndex = 0
Text = "Combo1"
Top = 345
Width = 1950
End
Begin VB.PictureBox Picture1
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 480
Left = 2145
Picture = "FrmM_Del.frx":0A5E
ScaleHeight = 480
ScaleWidth = 480
TabIndex = 4
Top = 1545
Width = 480
End
End
End
Attribute VB_Name = "FrmM_Del"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim Rec As New ADODB.Recordset
Dim Cn As New ADODB.Connection
Dim i As Integer
Private Sub Combo1_Change()
ListView1.ListItems.Clear
ListView1.ColumnHeaders.Clear
ListView1.ColumnHeaders.Add , "h1", "批号列表", 1900
Set Rec = Cn.Execute("select ph from maindb where orderid='" & _
Combo1.Text & "' order by orderid")
If Not Rec.EOF And Not Rec.BOF Then
Do While Not Rec.EOF
For i = 1 To ListView1.ListItems.Count
If ListView1.ListItems(i).Text = Rec.Fields("ph") Then Exit For
Next i
If i > ListView1.ListItems.Count Or ListView1.ListItems.Count = 0 Then ListView1.ListItems.Add , , Rec.Fields("ph")
Rec.MoveNext
Loop
End If
Rec.Close: Set Rec = Nothing
End Sub
Private Sub Combo1_Click()
ListView1.ListItems.Clear
ListView1.ColumnHeaders.Clear
ListView1.ColumnHeaders.Add , "h1", "批号列表", 1900
Set Rec = Cn.Execute("select ph from maindb where orderid='" & _
Combo1.Text & "' order by orderid")
If Not Rec.EOF And Not Rec.BOF Then
Do While Not Rec.EOF
For i = 1 To ListView1.ListItems.Count
If ListView1.ListItems(i).Text = Rec.Fields("ph") Then Exit For
Next i
If i > ListView1.ListItems.Count Or ListView1.ListItems.Count = 0 Then ListView1.ListItems.Add , , Rec.Fields("ph")
Rec.MoveNext
Loop
End If
Rec.Close: Set Rec = Nothing
End Sub
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0
On Error Resume Next
If Option1(1).Value = True Then
If ListView1.ListItems.Count = 0 Then
MsgBox "没有选择《批号》。", vbOKOnly + vbExclamation, "删除出错"
ListView1.SetFocus
Exit Sub
End If
For i = 1 To ListView1.ListItems.Count
If ListView1.ListItems(i).Checked = True Then Exit For
Next i
If i > ListView1.ListItems.Count Then
MsgBox "没有选择《批号》。", vbOKOnly + vbExclamation, "删除出错"
ListView1.SetFocus
Exit Sub
End If
End If
If Trim(Combo1.Text) = "" Then
MsgBox "没有选取单号!", vbOKOnly + vbExclamation, "选择单号出错..."
Combo1.SetFocus
Exit Sub
End If
If MsgBox("你真的要删除选定的数据吗?", vbOKCancel + vbQuestion, "删除确认...") = vbCancel Then Exit Sub
If Option1(1).Value = True Then
For i = 1 To ListView1.ListItems.Count
If ListView1.ListItems(i).Checked = True Then
Cn.Execute "delete from maindb where ph='" & ListView1.ListItems(i).Text & _
"' and orderid='" & Combo1.Text & "'"
End If
Next i
Else
Cn.Execute "delete from maindb where orderid='" & Combo1.Text & "'"
End If
Cn.Close: Set Cn = Nothing
DoEvents
Cn.Open DbConnectSql
Combo1.Clear
Set Rec = Cn.Execute("select distinct(orderid) from maindb order by orderid")
If Not Rec.EOF And Not Rec.BOF Then
Do While Not Rec.EOF
Combo1.AddItem Rec.Fields("orderid")
Rec.MoveNext
Loop
End If
Rec.Close: Set Rec = Nothing
Case 1
Unload Me
End Select
End Sub
Private Sub Form_Load()
Option1(0).Value = True
Cn.Open DbConnectSql
Combo1.Clear
Set Rec = Cn.Execute("select distinct(orderid) from maindb order by orderid")
If Not Rec.EOF And Not Rec.BOF Then
Do While Not Rec.EOF
Combo1.AddItem Rec.Fields("orderid")
Rec.MoveNext
Loop
End If
Rec.Close: Set Rec = Nothing
Combo1.Text = ""
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
Rec.Close: Set Rec = Nothing
Cn.Close: Set Cn = Nothing
End Sub
Private Sub Option1_Click(Index As Integer)
If Option1(0).Value = True Then
ListView1.Enabled = False
Else
ListView1.Enabled = True
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -