📄 frm_del_data.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frm_del_Data
BorderStyle = 3 'Fixed Dialog
Caption = "数据清理"
ClientHeight = 2685
ClientLeft = 4005
ClientTop = 3330
ClientWidth = 6000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2685
ScaleWidth = 6000
ShowInTaskbar = 0 'False
Begin MSComctlLib.ProgressBar ProgressBar1
Height = 270
Left = 90
TabIndex = 8
Top = 1965
Width = 5800
_ExtentX = 10239
_ExtentY = 476
_Version = 393216
Appearance = 1
End
Begin VB.CommandButton Command3
Caption = "全部选中"
Height = 375
Left = 2145
TabIndex = 3
Top = 2295
Width = 1245
End
Begin VB.Frame Frame1
Caption = "请选择所要初始化的数据表"
Height = 1845
Left = 90
TabIndex = 2
Top = 75
Width = 5805
Begin VB.CheckBox Check8
Caption = "供应商信息数据表"
Height = 300
Left = 2280
TabIndex = 12
Top = 1425
Width = 2145
End
Begin VB.CheckBox Check7
Caption = "库存盘点数据表"
Height = 345
Left = 240
TabIndex = 11
Top = 1410
Width = 1725
End
Begin VB.CheckBox Check6
Caption = "货品归还数据表"
Height = 330
Left = 4095
TabIndex = 10
Top = 900
Width = 1635
End
Begin VB.CheckBox Check5
Caption = "货品借出数据表"
Height = 330
Left = 2280
TabIndex = 9
Top = 915
Width = 1710
End
Begin VB.CheckBox Check4
Caption = "操作员资料数据表"
Height = 495
Left = 240
TabIndex = 7
Top = 840
Width = 1890
End
Begin VB.CheckBox Check3
Caption = "库存资料数据表"
Height = 375
Left = 4095
TabIndex = 6
Top = 360
Width = 1600
End
Begin VB.CheckBox Check2
Caption = "出库资料数据表"
Height = 375
Left = 2280
TabIndex = 5
Top = 360
Width = 1815
End
Begin VB.CheckBox Check1
Caption = "入库资料数据表"
Height = 375
Left = 240
TabIndex = 4
Top = 360
Width = 1815
End
End
Begin VB.CommandButton Command2
Caption = "取消初始化"
Height = 375
Left = 4680
TabIndex = 1
Top = 2295
Width = 1230
End
Begin VB.CommandButton Command1
Caption = "确认初始化"
Height = 375
Left = 3405
TabIndex = 0
Top = 2295
Width = 1255
End
End
Attribute VB_Name = "frm_del_Data"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'*** “系统初始化”按钮的事件过程 ***
Private Sub Command1_Click()
rtn = SetWindowPos(Me.hwnd, -2, 0, 0, 0, 0, 3) '运用API函数SetWindowPos,来实现取消窗体置前的功能
Command1.Enabled = False '在进行初始化的过程中,使“系统初始化”按钮不可用
Dim rs1 As ADODB.Recordset '定义一个记录集对象rs1
Set rs1 = New ADODB.Recordset
Dim cnn1 As ADODB.Connection '定义一个连接对象cnn1
Set cnn1 = New ADODB.Connection
'与数据库取得连接
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_kcgl.mdb;Persist Security Info=False"
Dim connter As Integer
Dim sql, workarea(200) As String '定义一个数组,用来实现在初始化数据时控制进度条快慢的功能
ProgressBar1.Visible = True
'UBound函数和LBound函数分别用于指定数组的最大下标和最小下标,关于该函数的具体用法请参阅明日公司《Visual Basic编程词典》中的函数应用部分 网址 www.cccxy.com
ProgressBar1.Max = UBound(workarea)
ProgressBar1.Value = ProgressBar1.Min
For connter = LBound(workarea) To UBound(workarea)
workarea(connter) = "initial value" & connter
ProgressBar1.Value = connter
If Check1.Value = 1 Then '利用SQL语句删除入库信息表中的数据
sql = "delete tb_in from tb_in"
Set rs1 = cnn1.Execute(sql)
End If
If Check2.Value = 1 Then '利用SQL语句删除出库信息表中的数据
sql = "delete tb_out from tb_out"
Set rs1 = cnn1.Execute(sql)
End If
If Check3.Value = 1 Then '利用SQL语句删除库存信息表中的数据
sql = "delete tb_kcxx from tb_kcxx"
Set rs1 = cnn1.Execute(sql)
End If
If Check4.Value = 1 Then '利用SQL语句删除操作员资料信息表中的数据
sql = "delete tb_enter from tb_enter"
Set rs1 = cnn1.Execute(sql)
End If
If Check5.Value = 1 Then '利用SQL语句删除货品借出信息表中的数据
sql = "delete tb_hpout from tb_hpout"
Set rs1 = cnn1.Execute(sql)
End If
If Check6.Value = 1 Then '利用SQL语句删除货品归还信息表中的数据
sql = "delete tb_hpin from tb_hpin"
Set rs1 = cnn1.Execute(sql)
End If
If Check7.Value = 1 Then '利用SQL语句删除库存盘点信息表中的数据
sql = "delete tb_kcpd from tb_kcpd"
Set rs1 = cnn1.Execute(sql)
End If
If Check8.Value = 1 Then '利用SQL语句删除供应商信息表中的数据
sql = "delete tb_gys from tb_gys"
Set rs1 = cnn1.Execute(sql)
End If
Next connter
ProgressBar1.Value = ProgressBar1.Min
cnn1.Close '关闭数据连接
Check1.Value = 0
Check2.Value = 0
Check3.Value = 0
Check4.Value = 0
Check5.Value = 0
Check6.Value = 0
Check7.Value = 0
Check8.Value = 0
MsgBox "初始化成功完成!!", 48, "初始化信息提示"
Command1.Enabled = True '使“系统初始化”按钮变为可用
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
'*** “全部选中”按钮的事件过程 ***
Private Sub Command3_Click()
'若想使操作员具有所有的权限,应该使所有复选框中的值都为“真”
Check1.Value = 1
Check2.Value = 1
Check3.Value = 1
Check4.Value = 1
Check5.Value = 1
Check6.Value = 1
Check7.Value = 1
Check8.Value = 1
End Sub
Private Sub Form_Load()
rtn = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3) '运用API函数SetWindowPos,来实现使窗体置前的功能
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
End Sub
Private Sub Form_Unload(Cancel As Integer)
frm_main.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -