📄 whfrmcpxx.frm
字号:
Exit Sub
Else
End If
End Sub
Private Sub Command4_Click()
On Error GoTo err
Set mrc = New ADODB.Recordset
If Trim(combo1.Text) = "" Then
combo1.SetFocus
Else
Set mrc = New ADODB.Recordset
TxtSql = "select * from Fl_物资类别表 where 类别名称 = '" & combo1.Text & "'"
mrc.Open Trim$(TxtSql), Cw_DataEnvi.DataConnect, adOpenKeyset, adLockOptimistic
If mrc.EOF = True Then
combo1.SetFocus
MsgBox "请正确填选类别名称!"
Exit Sub
End If
combo1.Tag = mrc!类别编码
mrc.Close
End If
If Trim(Text1.Text) = "" Then
MsgBox "物资名称不能为空!"
Exit Sub
End If
If Trim(Text2.Text) = "" Then Text2.Text = "UnKnow"
If Trim(Text3.Text) = "" Then Text3.Text = "NO"
Rs!物资名称 = Text1.Text
Rs!类别编码 = combo1.Tag
Rs!物资型号 = Text2.Text
Rs!计量单位 = Text3.Text
Rs!参考价格 = Text4.Text
Rs!备注信息 = RichTextBox1.Text
If AddFlg = True Then
Rs.Update
Rs.MoveNext
If Rs.EOF Then Rs.MoveLast
MsgBox "记录成功添加!"
Else
Rs.UpdateBatch adAffectAllChapters
Rs.MoveNext
If Rs.EOF Then Rs.MoveLast
MsgBox "记录成功修改!"
End If
loaddata
TxtSqlbj = "select * from Fl_物资信息表 where 类别编码 = '" & combo1.Tag & "'"
Set Rstmp = New ADODB.Recordset
Rstmp.Open TxtSqlbj, Cw_DataEnvi.DataConnect, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = Rstmp
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = False
Command5.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
'Combo1.Enabled = False
DataGrid1.Enabled = True
tv.Enabled = True
Exit Sub
err:
End Sub
Private Sub Command5_Click()
If AddFlg = True Then
Rs.CancelUpdate
Else
Rs.CancelBatch adAffectAllChapters
End If
tv.Enabled = True
Command1.Enabled = True
'Command2.Enabled = True
' Command3.Enabled = True
Command4.Enabled = False
Command5.Enabled = False
DataGrid1.Enabled = True
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
combo1.Enabled = False
End Sub
Private Sub Command6_Click()
Dim SqlSctmp As String
Dim RsSCtmp As ADODB.Recordset
Set RsSCtmp = New ADODB.Recordset
If Trim(Text6.Text) <> "" And Trim(Text7.Text) = "" Then
SqlSctmp = "select * from Fl_物资信息表 where 物资名称 LIKE '%" & Trim(Text6.Text) & "%'"
End If
If Trim(Text6.Text) = "" And Trim(Text7.Text) <> "" Then
SqlSctmp = "select * from Fl_物资信息表 where 物资型号 LIKE '%" & Trim(Text7.Text) & "%'"
End If
SqlSctmp = "select * from Fl_物资信息表 where 物资名称 LIKE '%" & Trim(Text6.Text) & "%' and 物资型号 LIKE '%" & Trim(Text7.Text) & "%'"
RsSCtmp.Open SqlSctmp, Cw_DataEnvi.DataConnect, adOpenKeyset, adLockReadOnly, adCmdText
Set DataGrid1.DataSource = RsSCtmp
End Sub
Private Sub Form_Load()
Dim topNode As Node
Dim Rsbj As ADODB.Recordset
Set Rsbj = New ADODB.Recordset
Rsbj.Open "select 类别名称,类别编码 from Fl_物资类别表 order by 类别编码", Cw_DataEnvi.DataConnect, adOpenStatic, adLockPessimistic, adCmdText
tv.Nodes.Clear
combo1.Clear
Do While Not Rsbj.EOF
Set topNode = tv.Nodes.Add(, , "A" & CStr(Rsbj!类别编码), Rsbj!类别名称, "Root")
topNode.Tag = Rsbj!类别编码
loadChild (Rsbj!类别编码)
combo1.AddItem Rsbj!类别名称
Rsbj.MoveNext
Loop
If combo1.ListCount > 0 Then
combo1.ListIndex = 0
Else
Command1.Enabled = False
End If
End Sub
Private Sub loaddata()
Dim topNode As Node
Dim Rsbj As ADODB.Recordset
Set Rsbj = New ADODB.Recordset
Rsbj.Open "select 类别名称,类别编码 from fl_物资类别表 order by 类别编码", Cw_DataEnvi.DataConnect, adOpenStatic, adLockPessimistic, adCmdText
tv.Nodes.Clear
combo1.Clear
Do While Not Rsbj.EOF
Set topNode = tv.Nodes.Add(, , "A" & CStr(Rsbj!类别编码), Rsbj!类别名称, "Root")
topNode.Tag = Rsbj!类别编码
loadChild (Rsbj!类别编码)
combo1.AddItem Rsbj!类别名称
Rsbj.MoveNext
Loop
End Sub
Private Sub loadChild(Lbj As String)
Dim child As Node
Set Rsgg = New ADODB.Recordset
Rsgg.Open "select * from Fl_物资信息表 where 类别编码 = '" & Lbj & "' ", Cw_DataEnvi.DataConnect, adOpenStatic, adLockPessimistic, adCmdText
Do While Not Rsgg.EOF
Set child = tv.Nodes.Add("A" & Lbj, tvwChild, "B" & CStr(Rsgg!物资编号), Rsgg!物资名称, "Child")
child.Tag = Rsgg!物资编号
Rsgg.MoveNext
Loop
Set Rs = New ADODB.Recordset
Rs.Open "select * from Fl_物资信息表 where 类别编码= '" & combo1.Text & "'", Cw_DataEnvi.DataConnect, adOpenStatic, adLockPessimistic, adCmdText
End Sub
Private Sub display()
If Rs.BOF And Rs.EOF Then
Lablsh.Caption = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
RichTextBox1.Text = ""
MsgBox "此类别暂时没有可用信息!"
Else
'Combo1.Text = Rs!类别编码
Text1.Text = Rs!物资名称
Text2.Text = Rs!物资型号
Text3.Text = Rs!计量单位
Text4.Text = Rs!参考价格
Lablsh.Caption = Rs!物资编号
RichTextBox1.Text = "" & Rs!备注信息
Command2.Enabled = True
Command3.Enabled = True
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
'小数点只允许输入一次
If KeyAscii = 190 Then
If InStr(Trim(Text4), ".") = 0 Then
If Len(Trim(Text4)) > 0 Then
Text4.Locked = False
Else
Text4.Locked = True
End If
Else
Text4.Locked = True
End If
Exit Sub
End If
'非数字不能输入
If KeyAscii > 57 Or KeyAscii < 48 Then
Text4.Locked = True
Else
Text4.Locked = False
End If
'允许Backspace
If KeyAscii = 8 Then
Text4.Locked = False
End If
'Delete键
If KeyAscii = 46 Then
Text4.Locked = False
End If
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
'小数点只允许输入一次
If KeyAscii = 190 Then
If InStr(Trim(Text5), ".") = 0 Then
If Len(Trim(Text5)) > 0 Then
Text5.Locked = False
Else
Text5.Locked = True
End If
Else
Text5.Locked = True
End If
Exit Sub
End If
'非数字不能输入
If KeyAscii > 57 Or KeyAscii < 48 Then
Text5.Locked = True
Else
Text5.Locked = False
End If
'允许Backspace
If KeyAscii = 8 Then
Text5.Locked = False
End If
'Delete键
If KeyAscii = 46 Then
Text5.Locked = False
End If
End Sub
Private Sub tv_NodeClick(ByVal Node As MSComctlLib.Node)
On Error Resume Next
Dim TxtSqlbj As String
If Left(Node.Key, 1) = "B" Then
CBJ = Right(Node.Parent.Key, Len(Node.Parent.Key) - 1)
Command1.Enabled = True
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
combo1.Enabled = False
combo1.Text = Node.Parent.Text
combo1.Tag = Node.Parent.Key
CJMC = Node.Parent.Tag
YGXM = Node.Tag
TxtSqlbj = "select * from Fl_物资信息表 where 类别编码= '" & CJMC & "' and 物资编号='" & YGXM & "'"
If Rs.State <> adStateClosed Then Rs.Close
Rs.Open TxtSqlbj, Cw_DataEnvi.DataConnect, adOpenStatic, adLockPessimistic, adCmdText
Set DataGrid1.DataSource = Rs
ElseIf Left(Node.Key, 1) = "A" Then
CBJ = Right(Node.Key, Len(Node.Key) - 1)
Command1.Enabled = True
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
combo1.Enabled = False
combo1.Text = Node.Text
combo1.Tag = Node.Key
CJMC = Node.Tag
TxtSqlbj = "select * from Fl_物资信息表 where 类别编码 = '" & CJMC & "'"
If Rs.State <> adStateClosed Then Rs.Close
Rs.Open TxtSqlbj, Cw_DataEnvi.DataConnect, adOpenStatic, adLockPessimistic, adCmdText
Set DataGrid1.DataSource = Rs
End If
If Rs.BOF And Rs.EOF Then
MsgBox "此类别暂时没有可用信息!"
Command2.Enabled = False
Command3.Enabled = False
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Lablsh.Caption = ""
Else
display
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -