📄 cpjdtz.frm
字号:
End If
Next
For i = currow + 1 To currow2 - 1
gszp = gszp + Val(Grid1.Cell(i, CURcol).Text)
gsxx = gsxx + Val(Grid1.Cell(i, CURcol + 1).Text)
Next i
Grid1.Cell(currow2, CURcol).Text = gszp
Grid1.Cell(currow2, CURcol + 1).Text = gsxx
Grid1.Cell(currow2, CURcol + 2).Text = gszp + gsxx
Grid1.Cell(Grid1.Rows - 2, CURcol).Text = Gsdn + gszp
Grid1.Cell(Grid1.Rows - 2, CURcol + 1).Text = gswx + gsxx
Grid1.Cell(Grid1.Rows - 2, CURcol + 2).Text = Gsdn + gszp + gswx + gsxx
Grid1.Cell(0, CURcol).Text = txtym.Text '当前月
Else '表gpdnh,gpdnb,gpzph,gpzpb 中汇总本工序当前年月的发生额
lblstar.Caption = txtym.Text
'按车间、工序编号排列填列全部统计工序及工时定额
Set rsTempA = oDb.Execute("select * from acj order by cjorder") 'where cjbh<>1003
Do While Not rsTempA.EOF
subtotgs = 0
Set rsTempB = oDb.Execute("select * from agx where gxtj='Y' and gxcjbh ='" & rsTempA!cjbh & "'order by gxcjbh,gxbh")
Do Until rsTempB.EOF
Set rsTempC = oDb.Execute("select gxgs from ajdbj where bjbh='" & lblbj(0).Caption & "' and gxbh='" & rsTempB!gxbh & "'")
If rsTempC.RecordCount > 0 Then
Grid1.AddItem (Grid1.Rows - 1) & Chr(9) & rsTempB!gxcj & Chr(9) & rsTempB!gxmc & Chr(9) & rsTempC!gxgs
subtotgs = subtotgs + rsTempC!gxgs
Else
Grid1.AddItem (Grid1.Rows - 1) & Chr(9) & rsTempB!gxcj & Chr(9) & rsTempB!gxmc & Chr(9) & ""
End If
rsTempB.MoveNext
Loop
Grid1.AddItem (Grid1.Rows - 1) & Chr(9) & rsTempA!cjbh & Chr(9) & "工时小计" & Chr(9) & subtotgs '车间编号
rsTempA.MoveNext
Loop
'从abj表取得工时合计与重量
Set rsTempA = oDb.Execute("select * from abj where bjbh='" & lblbj(0).Caption & "'")
Grid1.AddItem (Grid1.Rows - 1) & Chr(9) & "" & Chr(9) & "工时合计" & Chr(9) & rsTempA!bjtotgs
Grid1.Cell(Grid1.Rows - 1, 4).Alignment = cellLeftCenter
Grid1.AddItem (Grid1.Rows - 1) & Chr(9) & "" & Chr(9) & "重量合计" & Chr(9) & rsTempA!bjzl
'工序工时数
For i = 2 To Grid1.Rows - 3
curgxmc = Grid1.Cell(i, 3).Text
'定额工时
szSql = "select sum(gpdnb.gpgs) as sumgs from gpdnh,gpdnb where (gpdnh.gpbh=gpdnb.gpbh) and gpdnh.gprq>='" & curdate1 & "' and gpdnh.gprq<='" & curdate2 & "'" _
& " and gpdnb.gpbjbh='" & lblbj(0).Caption & "' and gpdnb.gpgxmc='" & curgxmc & "'"
Set rsTempB = oDb.Execute(szSql)
If Not IsNull(rsTempB!sumgs) Then Gsdn = rsTempB!sumgs Else Gsdn = 0
'增拨工时 不需要统计进去 2006.10.8改
' szSql = "select sum(gpzpb.gpgs) as sumgs from gpzph,gpzpb where (gpzph.gpbh=gpzpb.gpbh) and gpzph.gprq>='" & curdate1 & "' and gpzph.gprq<='" & curdate2 & "'" _
' & " and gpzpb.gpbjbh='" & lblbj(0).Caption & "' and gpzpb.gpgxmc='" & curgxmc & "'"
' Set rsTempB = oDb.Execute(szSql)
' If Not IsNull(rsTempB!sumgs) Then gszp = rsTempB!sumgs Else gszp = 0
gszp = 0
'外协工时
szSql = "select sum(gpwxb.gpgs) as sumgs from gpwxh,gpwxb where (gpwxh.gpbh=gpwxb.gpbh) and gpwxh.gprq>='" & curdate1 & "' and gpwxh.gprq<='" & curdate2 & "'" _
& " and gpwxb.gpbjbh='" & lblbj(0).Caption & "' and gpwxb.gpgxmc='" & curgxmc & "'"
Set rsTempB = oDb.Execute(szSql)
If Not IsNull(rsTempB!sumgs) Then gswx = rsTempB!sumgs Else gswx = 0
If (Gsdn + gszp) > 0 Then Grid1.Cell(i, 5).Text = Round((Gsdn + gszp) / 60, 1)
If gswx > 0 Then Grid1.Cell(i, 6).Text = Round(gswx / 60, 1)
If (Gsdn + gszp + gswx) > 0 Then Grid1.Cell(i, 7).Text = Round((Gsdn + gszp + gswx) / 60, 1)
Next i
'列小计
Gsdn = 0 '小计车间一
gszp = 0 '小计车间二
gswx = 0
gsxx = 0
For i = 2 To Grid1.Rows - 3
If Val(Grid1.Cell(i, 2).Text) > 0 Then
currow = i
Exit For
End If
Next
For i = 2 To currow - 1
Gsdn = Gsdn + Val(Grid1.Cell(i, 5).Text)
gswx = gswx + Val(Grid1.Cell(i, 6).Text)
Next i
Grid1.Cell(currow, 5).Text = Gsdn '车间小计数
Grid1.Cell(currow, 6).Text = gswx '车间外协小计
Grid1.Cell(currow, 7).Text = Gsdn + gswx '车间累计
For i = currow + 1 To Grid1.Rows - 3
If Val(Grid1.Cell(i, 2).Text) > 0 Then
currow2 = i
Exit For
End If
Next
For i = currow + 1 To currow2 - 1
gszp = gszp + Val(Grid1.Cell(i, 5).Text)
gsxx = gsxx + Val(Grid1.Cell(i, 6).Text)
Next i
Grid1.Cell(currow2, 5).Text = gszp
Grid1.Cell(currow2, 6).Text = gsxx
Grid1.Cell(currow2, 7).Text = gszp + gsxx
Grid1.Cell(Grid1.Rows - 2, 5).Text = Gsdn + gszp
Grid1.Cell(Grid1.Rows - 2, 6).Text = gswx + gsxx
Grid1.Cell(Grid1.Rows - 2, 7).Text = Gsdn + gszp + gswx + gsxx
Grid1.Cell(0, 5).Text = txtym.Text '当前月
End If
End Sub
Private Sub cmdsave_Click()
answer = MsgBox("当月工票都已录入了吗?保存后原月份工时数据不能更改。", vbYesNo, "保存")
If answer <> 6 Then
Exit Sub
End If
'表头信息保存
Set rsTempA = oDb.Execute("select * from ajdtzh where bjbh='" & lblbj(0).Caption & "'")
If rsTempA.RecordCount > 0 Then
szSql = "update ajdtzh set ymcur='" & txtym.Text & "' where bjbh='" & lblbj(0).Caption & "'"
oDb.Execute szSql
Else
szSql = "insert ajdtzh(bjbh,ymstar,ymcur) values (" & "'" & lblbj(0).Caption & "','" & lblstar.Caption & "','" & txtym.Text & "')"
oDb.Execute szSql
End If
'表体先删原有的,再添加
szSql = "delete from ajdtz where bjbh='" & lblbj(0).Caption & "'"
oDb.Execute (szSql)
For i = 2 To Grid1.Rows - 1
'部件编号 +车间+工序 +工时定额
griditem = "'" & lblbj(0).Caption & "'," & Grid1.Cell(i, 1).Text & ",'" & Grid1.Cell(i, 2).Text & "','" & Grid1.Cell(i, 3).Text & "'"
If Val(Grid1.Cell(i, 4).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 4).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 5).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 5).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 6).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 6).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 7).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 7).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 8).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 8).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 9).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 9).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 10).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 10).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 11).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 11).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 12).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 12).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 13).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 13).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 14).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 14).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 15).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 15).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 16).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 16).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 17).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 17).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 18).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 18).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 19).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 19).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 20).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 20).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 21).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 21).Text Else griditem = griditem & Chr(9) & ",0"
If Val(Grid1.Cell(i, 22).Text) > 0 Then griditem = griditem & "," & Grid1.Cell(i, 22).Text Else griditem = griditem & Chr(9) & ",0"
szSql = "insert ajdtz(bjbh,code,cjmc,gxmc,gxgs,ymsub1,ymwx1,ymtot1,ymsub2,ymwx2,ymtot2,ymsub3,ymwx3,ymtot3,ymsub4,ymwx4,ymtot4,ymsub5,ymwx5,ymtot5,ymsub6,ymwx6,ymtot6) values (" & griditem & ")"
oDb.Execute szSql
Next i
MsgBox txtym.Text & "数据已保存!", vbOKOnly, "保存"
Grid1.Cell(0, 1).Text = "序号"
Grid1.Cell(0, 2).Text = "车间"
Grid1.Cell(0, 3).Text = "工序名称"
Grid1.Cell(0, 4).Text = "工时定额"
Grid1.Cell(1, 5).Text = "本月"
Grid1.Cell(1, 6).Text = "外协"
Grid1.Cell(1, 7).Text = "累计"
End Sub
Private Sub tvwdb_NodeClick(ByVal Node As Node)
txtnode = Node.Text
txtcpbh.Text = Node.Key
If txtcpbh.Text = "" Then
'部件级分支,在表格刷新对应零件
'填列表上面的基本信息
i = InStr(Node.Text, ",")
j = InStr(Node.Text, ".")
lblcp(0).Caption = Left(txtnode, i - 5)
Set rsTempA = oDb.Execute("select * from acp where cpbh='" & lblcp(0).Caption & "'")
lblcp(1).Caption = rsTempA!cpmc
If Not IsNull(rsTempA!cpxh) Then lblcp(2).Caption = rsTempA!cpxh
lbldh(0).Caption = rsTempA!dhbh
lbldh(1).Caption = rsTempA!dhmc
lblbj(0).Caption = Left(txtnode, i - 1)
lblbj(1).Caption = Mid(txtnode, i + 1, j - i - 1)
lblbj(2).Caption = Mid(txtnode, j + 1)
Set rsTempA = oDb.Execute("select * from abj where bjbh='" & Left(txtnode, i - 1) & "'")
lblsl.Caption = rsTempA!bjsl
lblzl.Caption = rsTempA!bjzl
lbldate.Caption = rsTempA!bjdate1
End If
End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub dogridfirst()
Grid1.AutoRedraw = False
Grid1.DisplayFocusRect = False
Grid1.Cols = 23
Grid1.Rows = 2
Grid1.FixedRows = 2
Grid1.FixedCols = 5
Grid1.Column(0).Width = 5
Grid1.Column(1).Width = 15
Grid1.Column(2).Width = 50
Grid1.Column(3).Width = 50
Grid1.Column(4).Width = 50
For i = 5 To 22
Grid1.Column(i).Width = 40
Grid1.Column(i).Mask = CellValue
Grid1.Column(i).FormatString = "#####.0"
Grid1.Column(i).Alignment = cellRightCenter
Grid1.Column(i).DecimalLength = 1
Next i
Grid1.AutoRedraw = True
Grid1.Refresh
Grid1.Range(0, 2, 1, 2).Merge
Grid1.Range(0, 3, 1, 3).Merge
Grid1.Range(0, 4, 1, 4).Merge
Grid1.Range(0, 5, 0, 7).Merge
Grid1.Range(0, 8, 0, 10).Merge
Grid1.Range(0, 11, 0, 13).Merge
Grid1.Range(0, 14, 0, 16).Merge
Grid1.Range(0, 17, 0, 19).Merge
Grid1.Range(0, 20, 0, 22).Merge
Grid1.Cell(0, 1).Text = "序号"
Grid1.Cell(0, 2).Text = "车间"
Grid1.Cell(0, 3).Text = "工序名称"
Grid1.Cell(0, 4).Text = "工时定额"
Grid1.Cell(1, 5).Text = "本月"
Grid1.Cell(1, 6).Text = "外协"
Grid1.Cell(1, 7).Text = "累计"
Grid1.Cell(1, 8).Text = "本月"
Grid1.Cell(1, 9).Text = "外协"
Grid1.Cell(1, 10).Text = "累计"
Grid1.Cell(1, 11).Text = "本月"
Grid1.Cell(1, 12).Text = "外协"
Grid1.Cell(1, 13).Text = "累计"
Grid1.Cell(1, 14).Text = "本月"
Grid1.Cell(1, 15).Text = "外协"
Grid1.Cell(1, 16).Text = "累计"
Grid1.Cell(1, 17).Text = "本月"
Grid1.Cell(1, 18).Text = "外协"
Grid1.Cell(1, 19).Text = "累计"
Grid1.Cell(1, 20).Text = "本月"
Grid1.Cell(1, 21).Text = "外协"
Grid1.Cell(1, 22).Text = "累计"
Grid1.Column(4).Locked = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -