📄 main_jbxx_ckinf.frm
字号:
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "仓库代码:"
ForeColor = &H000000FF&
Height = 240
Index = 0
Left = 120
TabIndex = 10
Top = 450
Width = 945
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Height = 240
Left = 135
TabIndex = 9
Top = 435
Width = 930
End
End
Begin MSDataGridLib.DataGrid DataGrid1
Bindings = "main_jbxx_ckinf.frx":5639
Height = 1245
Left = 75
TabIndex = 14
Top = 2190
Width = 8220
_ExtentX = 14499
_ExtentY = 2196
_Version = 393216
AllowUpdate = 0 'False
HeadLines = 1
RowHeight = 15
FormatLocked = -1 'True
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 4
BeginProperty Column00
DataField = "仓库代码"
Caption = "仓库代码"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = "仓库名称"
Caption = "仓库名称"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column02
DataField = "库管员"
Caption = "库管员"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column03
DataField = "仓库说明"
Caption = "仓库说明"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
ColumnWidth = 1140.095
EndProperty
BeginProperty Column01
ColumnWidth = 2459.906
EndProperty
BeginProperty Column02
ColumnWidth = 629.858
EndProperty
BeginProperty Column03
ColumnWidth = 3525.166
EndProperty
EndProperty
End
End
Attribute VB_Name = "main_jbxx_ckinf"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer '定义整型变量
Dim rs1 As New ADODB.Recordset '定义数据集对象
Public Sub view_data() '定义显示数据的函数
For i = 0 To 3
If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).Text = Adodc1.Recordset.Fields(i)
Next i
End Sub
Private Sub Form_Activate()
rs1.Open "select * from ckinf order by 仓库代码", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
For i = 0 To 3
If rs1.Fields(i) <> "" Then Text1(i).Text = rs1.Fields(i)
Text1(i).Enabled = False
Next i
End If
rs1.Close '关闭数据集对象
'查询所有仓库信息,并按"仓库代码"排序
Adodc1.RecordSource = "select * from ckinf order by 仓库代码"
Adodc1.Refresh
Me.Caption = Me.Caption & " 操作员: " & frm_main.St1.Panels(3).Text
End Sub
Private Sub Form_Unload(Cancel As Integer)
frm_main.Enabled = True
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
Enter KeyCode '回车获得焦点
End Sub
Private Sub CmdMD_Click(Index As Integer)
Select Case Index
Case Is = 0 '移到第一条记录
If Not Adodc1.Recordset.BOF Then Adodc1.Recordset.MoveFirst
Case Is = 1 '移到上一条记录
If Adodc1.Recordset.RecordCount <> 0 Then
If Adodc1.Recordset.BOF = False Then Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF = True Then Adodc1.Recordset.MoveFirst
End If
Case Is = 2 '移到下一条记录
If Adodc1.Recordset.RecordCount <> 0 Then
If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveLast
End If
Case Is = 3 '移到最后一条记录
If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveLast
End Select
Call view_data '调用函数
End Sub
Private Sub ComAdd_Click() '添加
'自动创建仓库代码
Dim dm As Integer
rs1.Open "select * from ckinf order by 仓库代码", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
If Not rs1.EOF Then rs1.MoveLast
If rs1.Fields("仓库代码") <> "" Then
dm = Right(Trim(rs1.Fields("仓库代码")), 2) + 1
Text1(0).Text = "c" & Format(dm, "00")
End If
Else
Text1(0).Text = "c01"
End If
rs1.Close '关闭数据集对象
For i = 1 To 3
Text1(i).Enabled = True
Text1(i).Text = ""
Next i
Text1(1).SetFocus
'设置控件状态
ComAdd.Enabled = False: ComDelete.Enabled = False
ComModify.Enabled = False: ComSave.Enabled = True
For i = 0 To 3
CmdMD(i).Enabled = False
Next i
End Sub
Private Sub ComModify_Click() '允许用户修改
If Adodc1.Recordset.RecordCount <> 0 Then
For i = 0 To 3
Text1(i).Enabled = True
CmdMD(i).Enabled = False
Next i
ComSave.Enabled = True: ComAdd.Enabled = False
ComModify.Enabled = False: ComDelete.Enabled = False
Else
MsgBox ("没有要修改的数据!")
End If
End Sub
Private Sub ComDelete_Click() '删除仓库信息
On Error Resume Next
Adodc1.Recordset.Delete
Adodc1.Refresh
End Sub
Private Sub ComSave_Click() '保存仓库信息
'打开"ckinf"表
rs1.Open "select * from ckinf where 仓库代码='" & Trim(Text1(0).Text) & "'order by 仓库代码", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
Dim a As String
a = MsgBox("您确实要修改这条数据吗?", vbYesNo)
If a = vbYes Then
For i = 0 To 3
If Text1(1).Text <> "" Then rs1.Fields(i) = Trim(Text1(i).Text)
Text1(i).Enabled = False
Next i
rs1.Update
Adodc1.Refresh
End If
Else
If Text1(1).Text <> "" Then
'添加仓库信息
rs1.AddNew
For i = 0 To 3
rs1.Fields(i) = Trim(Text1(i).Text)
Text1(i).Enabled = False
CmdMD(i).Enabled = True
Next i
'更新数据库
rs1.Update
Adodc1.Refresh
Else
MsgBox "请填写完整的信息"
End If
End If
rs1.Close '关闭数据集对象
'设置控件有效或无效
ComSave.Enabled = False: ComEsc.Enabled = False: ComAdd.Enabled = True
ComModify.Enabled = True: ComDelete.Enabled = True
End Sub
Private Sub ComEsc_Click() '取消操作
rs1.Open "select * from ckinf order by 仓库代码", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
For i = 0 To 3
If rs1.Fields(i) <> "" Then Text1(i).Text = rs1.Fields(i) '赋值给text1
Text1(i).Enabled = False
CmdMD(i).Enabled = True
Next i
End If
rs1.Close
'设置控件状态
ComSave.Enabled = False: ComEsc.Enabled = False: ComAdd.Enabled = True
ComModify.Enabled = True: ComDelete.Enabled = True
End Sub
Private Sub ComExit_Click()
Unload Me
frm_main.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -