📄 cpbjlx.frm
字号:
Height = 375
Left = 2820
TabIndex = 22
Top = 180
Width = 4515
End
End
Attribute VB_Name = "cpbjlx"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'为保证数据库结构的完整性,如下级有信息录入,则上级不能删除
'表1产品填制日期决定本产品的数据是否在统计区间,是否统计决定本产品是否统计数据(Y计入/N不计入)
'单位更改时,只选择单位编号,单位名称在保存时自动更改
Option Explicit
Dim tempcpbh As String, tempcpmc As String, tempdate1 As String
Private Sub Form_Load()
Me.Width = 12000
Me.Height = 8000
dogridfirst
dogridfill1
dogridfill2
dogridfind '产品表内容
txtcode1.Visible = False
txtcode2.Visible = False
cmdadd1.Enabled = False
cmdsave1.Enabled = False
cmddelete1.Enabled = False
End Sub
Private Sub Grid1_Click()
i = Grid1.ActiveCell.Row
If i >= 1 And i <= Grid1.Rows - 1 Then
txtcpbh.Text = Grid1.Cell(i, 1).Text
Frame3.Caption = Grid1.Cell(i, 2).Text
Set rsTempB = oDb.Execute("select max(code) as maxcode from abjlx where cpbh= '" & txtcpbh.Text & "'") 'code2号初始
If IsNull(rsTempB!maxcode) Then
txtcode2.Text = 1
Else
txtcode2.Text = rsTempB!maxcode + 1
End If
'在部件表里显示此产品的部件信息
dogridfill2
Set rsTempB = oDb.Execute("select * from abjlx where cpbh='" & txtcpbh.Text & "' order by bjbh")
Do While Not rsTempB.EOF
griditem = rsTempB!bjbh & Chr(9) & rsTempB!bjmc & Chr(9) & rsTempB!bjth & Chr(9) & rsTempB!cpbh & Chr(9) & rsTempB!cpmc & Chr(9) & rsTempB!code
Grid2.AddItem griditem
rsTempB.MoveNext
Loop
End If
End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdadd2_Click()
If Frame3.Caption = "" Then
MsgBox "请先点击选择需增加部件的产品", vbOKOnly, "点击产品行"
Exit Sub
End If
Grid2.Rows = Grid2.Rows + 1
Grid2.Cell(Grid2.Rows - 1, 4).Text = txtcpbh.Text '产品编号及名称
Grid2.Cell(Grid2.Rows - 1, 5).Text = Frame3.Caption
Grid2.Cell(Grid2.Rows - 1, 1).Text = txtcpbh.Text & Format$(txtcode2.Text, "0000") '部件编号=产品编号+code4位
Grid2.Cell(Grid2.Rows - 1, 6).Text = txtcode2.Text
txtcode2.Text = txtcode2.Text + 1
End Sub
Private Sub cmdsave2_Click()
'检测部件编号、名称、数量内容是否齐全,再保存
For i = 1 To Grid2.Rows - 1
If Grid2.Cell(i, 2).Text = "" Then
MsgBox "请检查输入部件名称 ", vbOKOnly, "名称、数量"
Exit Sub
End If
Next i
For i = 1 To Grid2.Rows - 1
griditem = Grid2.Cell(i, 1).Text
Set rsTempA = oDb.Execute("select * from abjlx where bjbh='" & griditem & "'")
If rsTempA.RecordCount < 1 Then '增加保存
griditem = "'" & Grid2.Cell(i, 1).Text & "','" & Grid2.Cell(i, 2).Text & "'"
If Grid2.Cell(i, 3).Text <> "" Then griditem = griditem & ",'" & Grid2.Cell(i, 3).Text & "'" Else griditem = griditem & ",''"
If Grid2.Cell(i, 4).Text <> "" Then griditem = griditem & ",'" & Grid2.Cell(i, 4).Text & "'" Else griditem = griditem & ",''"
If Grid2.Cell(i, 5).Text <> "" Then griditem = griditem & ",'" & Grid2.Cell(i, 5).Text & "'" Else griditem = griditem & ",''"
If Grid2.Cell(i, 6).Text <> "" Then griditem = griditem & "," & Grid2.Cell(i, 6).Text & "" Else griditem = griditem & ",0"
szSql = "insert abjlx (bjbh,bjmc,bjth,cpbh,cpmc,code) values (" & griditem & ")"
oDb.Execute szSql
Else
szSql = "UPDATE abjlx SET bjmc='" & Grid2.Cell(i, 2).Text & "',bjth='" & Grid2.Cell(i, 3).Text & "' where bjbh='" & Grid2.Cell(i, 1).Text & "'"
oDb.Execute szSql
End If
Next i
MsgBox "产品信息成功保存", vbOKOnly, "保存"
End Sub
Private Sub dogridfirst()
'表格1-产品信息表
Grid1.AutoRedraw = False
Grid1.DisplayFocusRect = False
Grid1.Cols = 3
Grid1.Rows = 1
Grid1.FixedRows = 1
Grid1.Column(0).Width = 5
Grid1.Column(1).Width = 110
Grid1.Column(2).Width = 330
Grid1.AutoRedraw = True
Grid1.Refresh
'表格2-部件信息
Grid2.AutoRedraw = False
Grid2.AllowUserResizing = True
Grid2.DisplayFocusRect = False
Grid2.Cols = 7
Grid2.Rows = 1
Grid2.FixedRows = 1
Grid2.Column(0).Width = 18
Grid2.Column(1).Width = 120
Grid2.Column(2).Width = 240
Grid2.Column(3).Width = 1
Grid2.Column(4).Width = 1
Grid2.Column(5).Width = 1
Grid2.Column(6).Width = 1
Grid2.AutoRedraw = True
Grid2.Refresh
Grid2.Column(1).Locked = True
Grid2.Column(4).Locked = True
Grid2.Column(5).Locked = True
Grid2.Column(6).Locked = True
End Sub
Private Sub dogridfill1()
Grid1.Cell(0, 1).Text = "产品编号"
Grid1.Cell(0, 2).Text = "产品名称"
Grid1.Rows = 1
End Sub
'以下为表格2的操作
Private Sub dogridfill2()
Grid2.Cell(0, 1).Text = "部件编号"
Grid2.Cell(0, 2).Text = "部件名称"
Grid2.Cell(0, 3).Text = "图号"
Grid2.Cell(0, 4).Text = "产品编号"
Grid2.Cell(0, 5).Text = "产品名称"
Grid2.Cell(0, 6).Text = "code"
Grid2.Rows = 1
End Sub
Private Sub dogridfind()
Set rsTempA = oDb.Execute("select * from acplx order by cpbh")
Do While Not rsTempA.EOF
Grid1.AddItem (rsTempA!cpbh & Chr(9) & rsTempA!cpmc) '& Chr(9) & rsTempA!cpxh & Chr(9) & rsTempA!dhbh & Chr(9) & rsTempA!dhmc) & Chr(9) & rsTempA!dhrq & Chr(9) & rsTempA!cpyn
rsTempA.MoveNext
Loop
End Sub
'Private Sub cmdsave1_Click()
' '数据检
' For i = 1 To Grid1.Rows - 1
' If (Grid1.Cell(i, 2).Text = "") Or (Grid1.Cell(i, 4).Text = "") Or (Grid1.Cell(i, 6).Text) = "" Then
' MsgBox "请检查输入产品名称、单位编号及日期", vbOKOnly, "名称、编号、日期"
' Exit Sub
' End If
' Next i
'
' For i = 1 To Grid1.Rows - 1
' '单位名称更新
' Set rsTempB = oDb.Execute("select * from adh where dhbh=" & Grid1.Cell(i, 4).Text & "")
' Grid1.Cell(i, 5).Text = rsTempB!dhmc
'
' griditem = Grid1.Cell(i, 1).Text
' Set rsTempA = oDb.Execute("select cpbh from acp where cpbh='" & griditem & "'")
' If rsTempA.RecordCount < 1 Then '增加保存
' griditem = "'" & Grid1.Cell(i, 1).Text & "'" & ",'" & Grid1.Cell(i, 2).Text & "'"
' If Grid1.Cell(i, 3).Text <> "" Then griditem = griditem & ",'" & Grid1.Cell(i, 3).Text & "'" Else griditem = griditem & ",''"
' If Grid1.Cell(i, 4).Text <> "" Then griditem = griditem & ",'" & Grid1.Cell(i, 4).Text & "'" Else griditem = griditem & ",''" '单位编号
' If Grid1.Cell(i, 5).Text <> "" Then griditem = griditem & ",'" & Grid1.Cell(i, 5).Text & "'" Else griditem = griditem & ",''" '单位名称
' 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 & "'" ' code
'
' szSql = "insert acp (cpbh,cpmc,cpxh,dhbh,dhmc,dhrq,cpyn,code) values (" & griditem & ")"
' oDb.Execute szSql
'
' '在部表新增部件--其它部件 编号:产品号+9999 作为不明确部件的工序录入用
' 'szSql = "insert abj (cpbh,cpmc,code,bjbh,bjmc,bjth,bjsl,bjzl,bjdate1,bjdate2) values ("" '" & Grid1.Cell(i, 1).Text & "','" & Grid1.Cell(i, 2).Text & "',9999,'" & (Grid1.Cell(i, 1).Text & "9999") & "','其它部件','',1,0,'" & Grid1.Cell(i, 6).Text & "','" & NOWDate & "'" & ")"""
' tempcpbh = Grid1.Cell(i, 1).Text
' tempcpmc = Grid1.Cell(i, 2).Text
' tempdate1 = Grid1.Cell(i, 6).Text
' griditem = "'" & tempcpbh & "','" & tempcpmc & "',0,'" & tempcpbh & "9999" & "','其它部件','',1,0,'" & tempdate1 & "','" & NOWDate & "'"
' szSql = "insert abj (cpbh,cpmc,code,bjbh,bjmc,bjth,bjsl,bjzl,bjdate1,bjdate2) values ( " & griditem & ")"
' oDb.Execute szSql
' Else '只修改产品名称、型号、填制日期、是否统计
' szSql = "UPDATE acp SET cpmc='" & Grid1.Cell(i, 2).Text & "',cpxh='" & Grid1.Cell(i, 3).Text & "',dhbh=" & Grid1.Cell(i, 4).Text & ",dhmc='" & Grid1.Cell(i, 5).Text & "',dhrq='" & Grid1.Cell(i, 6).Text & "',cpyn='" & Grid1.Cell(i, 7).Text & "' where cpbh='" & Grid1.Cell(i, 1).Text & "'"
' oDb.Execute szSql
' End If
' Next i
' MsgBox "产品信息成功保存", vbOKOnly, "保存"
' txtcode1.Text = txtcode1.Text + 1
'End Sub
'Private Sub cmddelete1_Click()
' i = Grid1.ActiveCell.Row
' griditem = Grid1.Cell(i, 1).Text
' answer = MsgBox("删除此行?" & griditem, vbYesNo, "删除")
' If answer = 6 Then
' '检测部件表中是否有引起此产品编号的数据,如有则不能删除
' Set rsTempA = oDb.Execute("select * from abj where cpbh='" & griditem & "'")
' If rsTempA.RecordCount > 0 Then
' MsgBox "本产品已有部件录入,为保证数据完整性,不能删除!", vbOKOnly, "部件"
' Exit Sub
' Else
' szSql = "delete from acp where cpbh='" & griditem & "'"
' oDb.Execute szSql
' Grid1.Selection.DeleteByRow
' Grid1.Rows = 1
' dogridfill1
' End If
' End If
'End Sub
'Private Sub cmdadd1_Click()
' '增加行数及取得code号
'
' txtcpbh.Text = Left(mskdate1.Text, 4) & Mid(mskdate1.Text, 6, 2) & Mid(mskdate1.Text, 9, 2) & Format$(txtcode1.Text, "00") '产品编号为日期+code ,用户不能编辑
' If txtcpmc.Text = "" Then
' MsgBox "请输入产品名称", vbOKOnly, "产品名称"
' Exit Sub
' End If
' griditem = txtcpbh.Text & Chr(9) & txtcpmc.Text
' If txtcpxh.Text <> "" Then griditem = griditem & Chr(9) & txtcpxh.Text Else griditem = griditem & Chr(9) & ""
' i = InStr(cmbdh.Text, ",")
' If i > 1 Then
' griditem = griditem & Chr(9) & Left(cmbdh.Text, i - 1) & Chr(9) & Mid(cmbdh.Text, i + 1) & Chr(9) & mskdate1.Text & Chr(9) & "Y" & Chr(9) & txtcode1.Text
' Else
' MsgBox "请选择订货单位", vbOKOnly, "订货单位"
' Exit Sub
' End If
' Grid1.AddItem griditem
' txtcode1.Text = txtcode1.Text + 1
' txtcpmc.Text = ""
' txtcpxh.Text = ""
' Grid1.Column(1).Locked = True
'End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -