📄 cpljbj.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{4F29B06F-16D9-4A0C-9C8A-2F0C02F625FE}#1.0#0"; "FlexCell.ocx"
Begin VB.Form cpljbj
Caption = "零件表"
ClientHeight = 8415
ClientLeft = 60
ClientTop = 345
ClientWidth = 11910
LinkTopic = "Form2"
MDIChild = -1 'True
ScaleHeight = 8415
ScaleWidth = 11910
Begin FlexCell.Grid Grid1
Height = 6135
Left = 5400
TabIndex = 15
Top = 1590
Width = 6465
_ExtentX = 11404
_ExtentY = 10821
Cols = 5
Rows = 30
End
Begin VB.TextBox txtcpbh
Height = 285
Left = 8340
TabIndex = 12
Top = 60
Width = 1875
End
Begin VB.TextBox txtcode
Height = 285
Left = 10500
TabIndex = 11
Top = 60
Width = 615
End
Begin VB.Frame Frame1
Height = 675
Left = 6600
TabIndex = 7
Top = 7680
Width = 4995
Begin VB.CommandButton cmddel
Caption = "删除"
Height = 315
Left = 1500
TabIndex = 13
Top = 240
Width = 855
End
Begin VB.CommandButton cmdadd
Caption = "增加"
Height = 315
Left = 180
TabIndex = 10
Top = 240
Width = 915
End
Begin VB.CommandButton cmdsave
Caption = "保存"
Height = 315
Left = 2760
TabIndex = 9
Top = 240
Width = 915
End
Begin VB.CommandButton Cmdexit
Caption = "返回"
Height = 315
Left = 3960
TabIndex = 8
Top = 240
Width = 855
End
End
Begin VB.TextBox txtbjth
Height = 285
Left = 6180
TabIndex = 6
Top = 1260
Width = 2355
End
Begin VB.TextBox txtbjmc
Height = 315
Left = 9360
TabIndex = 2
Top = 840
Width = 2355
End
Begin VB.TextBox txtbjbh
Height = 285
Left = 6180
TabIndex = 1
Top = 840
Width = 2355
End
Begin MSComctlLib.TreeView TvwDB
Height = 7515
Left = 0
TabIndex = 0
Top = 780
Width = 5295
_ExtentX = 9340
_ExtentY = 13256
_Version = 393217
LineStyle = 1
Style = 7
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Label Label1
Caption = " 零 件 信 息 登 记 表"
BeginProperty Font
Name = "MS Sans Serif"
Size = 18
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 435
Index = 3
Left = 3960
TabIndex = 14
Top = 60
Width = 3675
End
Begin VB.Label Label1
Caption = "部件型号"
Height = 195
Index = 2
Left = 5400
TabIndex = 5
Top = 1260
Width = 735
End
Begin VB.Label Label1
Caption = "部件名称"
Height = 195
Index = 1
Left = 8580
TabIndex = 4
Top = 900
Width = 735
End
Begin VB.Label Label1
Caption = "部件编号"
Height = 195
Index = 0
Left = 5400
TabIndex = 3
Top = 900
Width = 735
End
End
Attribute VB_Name = "cpljbj"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private TempNode As Node ', mnode As Node
Dim txtkey As String, intIndex As Integer
Dim txtnode As String
Private Sub Form_Load()
Me.Width = 12000: Me.Height = 9000
Set rsTempA = oDb.Execute("select * from acp where cpyn='Y' order by cpbh")
Do Until rsTempA.EOF
Set TempNode = TvwDB.Nodes.Add()
TempNode.Text = rsTempA!cpbh & "," & rsTempA!cpmc & "," & rsTempA!cpxh
TempNode.Key = "'" & rsTempA!cpbh & "'"
intIndex = TempNode.Index
txtkey = TempNode.Key
Set rsTempB = oDb.Execute("select * from abj where cpbh=" & txtkey & " order by bjbh")
Do Until rsTempB.EOF
Set TempNode = TvwDB.Nodes.Add(intIndex, tvwChild)
TempNode.Text = rsTempB!bjbh & "," & rsTempB!bjmc & "." & rsTempB!bjth
rsTempB.MoveNext
Loop
rsTempA.MoveNext
Loop
TvwDB.Nodes(1).Expanded = True
Grid1.AutoRedraw = False
Grid1.DisplayFocusRect = False
Grid1.Cols = 9
Grid1.Rows = 1
Grid1.FixedRows = 1
Grid1.FixedCols = 3
Grid1.Column(0).Width = 5
Grid1.Column(1).Width = 25
Grid1.Column(2).Width = 120
Grid1.Column(3).Width = 120
Grid1.Column(4).Width = 120
Grid1.Column(5).Width = 40
Grid1.Column(6).Width = 80
Grid1.Column(7).Width = 80
Grid1.Column(8).Width = 2
Grid1.AutoRedraw = True
Grid1.Refresh
Grid1.Column(1).Locked = True
Grid1.Column(2).Locked = True '零件编号不能修改
Grid1.Column(8).Locked = True 'code不能修改
Grid1.Column(5).Mask = CellValue
Grid1.Column(6).CellType = cellComboBox
dogridfill
txtcpbh.Visible = False
txtcode.Visible = False
End Sub
Private Sub tvwdb_NodeClick(ByVal Node As Node)
txtnode = Node.Text
txtcpbh.Text = Node.Key
If txtcpbh.Text = "" Then
'部件级分支,在表格刷新对应零件,txtcode号初始
i = InStr(Node.Text, ",")
j = InStr(Node.Text, ".")
txtbjbh.Text = Left(txtnode, i - 1)
txtbjmc.Text = Mid(txtnode, i + 1, j - i - 1)
txtbjth.Text = Mid(txtnode, j + 1)
dogridfill
'txtcode
Set rsTempC = oDb.Execute("select max(code) as maxcode from alj where bjbh='" & txtbjbh.Text & "'") 'code号初始
If IsNull(rsTempC!maxcode) Then
txtcode.Text = 1
Else
txtcode.Text = rsTempC!maxcode + 1
End If
'零件表格内容填列
Set rsTempB = oDb.Execute("select * from alj where bjbh='" & txtbjbh.Text & "' order by ljbh")
Do Until rsTempB.EOF
'griditem = rsTempB!code & Chr(9) & rsTempB!ljbh & Chr(9) & rsTempB!ljmc & Chr(9) & rsTempB!ljth & Chr(9) & rsTempB!ljsl & Chr(9) & rsTempB!ljqx & Chr(9) & rsTempB!ljbz & Chr(9) & rsTempB!code
griditem = (rsTempB!code - 1) & Chr(9) & rsTempB!ljbh & Chr(9) & rsTempB!ljmc & Chr(9) & rsTempB!ljth & Chr(9) & rsTempB!ljsl & Chr(9) & rsTempB!ljqx & Chr(9) & rsTempB!ljbz & Chr(9) & rsTempB!code
Grid1.AddItem griditem
rsTempB.MoveNext
Loop
Else
txtbjbh.Text = ""
txtbjmc.Text = ""
txtbjth.Text = ""
End If
End Sub
Private Sub cmdadd_Click()
If txtcpbh.Text <> "" Then
MsgBox "请先点击选择需增加零件的产品部件", vbOKOnly, "点击产品部件"
Exit Sub
End If
Grid1.Rows = Grid1.Rows + 1
'Grid1.Cell(Grid1.Rows - 1, 1).Text =txtcode.Text
Grid1.Cell(Grid1.Rows - 1, 1).Text = (txtcode.Text - 1)
Grid1.Cell(Grid1.Rows - 1, 2).Text = txtbjbh.Text & Format$(txtcode.Text, "0000")
Grid1.Cell(Grid1.Rows - 1, 8).Text = txtcode.Text
Grid1.ComboBox(6).Clear
Set rsTempC = oDb.Execute("select * from aljqx order by qxbh")
Do Until rsTempC.EOF
Grid1.ComboBox(6).AddItem rsTempC!qxmc
rsTempC.MoveNext
Loop
txtcode.Text = txtcode.Text + 1
End Sub
Private Sub cmddel_Click()
'删除时检测进度表中有否保存,若有则不能删除
i = Grid1.ActiveCell.Row
griditem = Grid1.Cell(i, 2).Text
answer = MsgBox("删除此行?" & griditem, vbYesNo, "删除")
If answer = 6 Then
Set rsTempA = oDb.Execute("select ljbh from ajdlj where ljbh='" & griditem & "'")
If rsTempA.RecordCount > 0 Then
MsgBox "本零件已编入生产计划,为保证数据完整性,不能删除!", vbOKOnly, "零件"
Exit Sub
Else
szSql = "delete from alj where ljbh='" & griditem & "'"
oDb.Execute szSql
Grid1.Selection.DeleteByRow
dogridfill
End If
End If
End Sub
Private Sub cmdsave_Click()
'检测零件编号、名称是否齐全,再保存
For i = 1 To Grid1.Rows - 1
If (Grid1.Cell(i, 3).Text = "") Or (Val(Grid1.Cell(i, 5).Text) <= 0) Then
MsgBox "请检查输入零件名称及数量", vbOKOnly, "名称、数量"
Exit Sub
End If
Next i
For i = 1 To Grid1.Rows - 1
griditem = Grid1.Cell(i, 2).Text
Set rsTempA = oDb.Execute("select ljbh from alj where ljbh='" & griditem & "'")
If rsTempA.RecordCount < 1 Then '增加保存 '部件编号、部件名称、零件编号、零件名称
griditem = "'" & txtbjbh.Text & "','" & txtbjmc.Text & "','" & Grid1.Cell(i, 2).Text & "','" & Grid1.Cell(i, 3).Text & "'"
If Grid1.Cell(i, 4).Text <> "" Then griditem = griditem & ",'" & Grid1.Cell(i, 4).Text & "'" Else griditem = griditem & ",''"
griditem = griditem & "," & Grid1.Cell(i, 5).Text & ""
If Grid1.Cell(i, 6).Text <> "" Then griditem = griditem & ",'" & Grid1.Cell(i, 6).Text & "'" Else griditem = griditem & ",''"
If Grid1.Cell(i, 7).Text <> "" Then griditem = griditem & ",'" & Grid1.Cell(i, 7).Text & "'" Else griditem = griditem & ",''"
griditem = griditem & "," & Grid1.Cell(i, 8).Text & ""
szSql = "insert alj (bjbh,bjmc,ljbh,ljmc,ljth,ljsl,ljqx,ljbz,code) values (" & griditem & ")"
oDb.Execute szSql
Else
szSql = "UPDATE alj SET ljmc='" & Grid1.Cell(i, 3).Text & "',ljth='" & Grid1.Cell(i, 4).Text & "',ljsl=" & Grid1.Cell(i, 5).Text & ",ljbz='" & Grid1.Cell(i, 7).Text & "' where ljbh='" & Grid1.Cell(i, 2).Text & "'"
oDb.Execute szSql
End If
Next i
MsgBox "产品信息成功保存", vbOKOnly, "保存"
End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub dogridfill()
Grid1.Cell(0, 1).Text = "序号"
Grid1.Cell(0, 2).Text = "零件编号"
Grid1.Cell(0, 3).Text = "零件名称"
Grid1.Cell(0, 4).Text = "图号"
Grid1.Cell(0, 5).Text = "数量"
Grid1.Cell(0, 6).Text = "零件去向"
Grid1.Cell(0, 7).Text = "备注"
Grid1.Cell(0, 8).Text = "code"
Grid1.Rows = 1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -