⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpbjlj.frm

📁 一个机械产品(产品、部件、零件)的工时、工资及进度软件
💻 FRM
📖 第 1 页 / 共 2 页
字号:
    
    Set rsTempA = oDb.Execute("select max(code) as maxcode from acp where dhrq= '" & Mskdate1.Text & "'")    'code号初始
    If IsNull(rsTempA!maxcode) Then
        txtcode1.Text = 1
        Else
        txtcode1.Text = rsTempA!maxcode + 1
    End If
    
    Set rsTempA = oDb.Execute("select * from adh ")
    Do While Not rsTempA.EOF
        cmbdh.AddItem rsTempA!dhbh & "," & rsTempA!dhmc
        rsTempA.MoveNext
    Loop
    cmbdh.ListIndex = 0

    txtcode1.Visible = False
    txtcode2.Visible = False

    MonthView1.Visible = False
    MonthView1.Value = NOWDate
    chkyn.Value = False
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 & Chr(9) & "0" Else griditem = griditem & Chr(9) & "" & Chr(9) & "0"
    i = InStr(cmbdh.Text, ",")
    If i > 1 Then
        griditem = griditem & Chr(9) & "0" & 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
Private Sub cmdsave1_Click()
    '数据检
    For i = 1 To Grid1.Rows - 1
        If (Grid1.Cell(i, 2).Text = "") Or (Grid1.Cell(i, 6).Text = "") Or (Grid1.Cell(i, 8).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, 6).Text & "")
         Grid1.Cell(i, 7).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 & ",0"
            If Grid1.Cell(i, 5).Text <> "" Then griditem = griditem & "," & Grid1.Cell(i, 5).Text & "" Else griditem = griditem & ",0"
            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 & ",''"   '单位名称
            If Grid1.Cell(i, 8).Text <> "" Then griditem = griditem & ",'" & Grid1.Cell(i, 8).Text & "'" Else griditem = griditem & ",''"    '日期
            If Grid1.Cell(i, 9).Text <> "" Then griditem = griditem & ",'" & Grid1.Cell(i, 9).Text & "'" Else griditem = griditem & ",''"    '是否统计
            griditem = griditem & ",'" & Grid1.Cell(i, 10).Text & "'"      ' code
                
            szSql = "insert acp (cpbh,cpmc,cpxh,cpsl,cpzl,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, 8).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   '只修改产品名称、型号、填制日期、是否统计
            If IsNumeric(Grid1.Cell(i, 5).Text) Then cpzltemp = Grid1.Cell(i, 5).Text Else cpzltemp = 0
            szSql = "UPDATE acp SET cpmc='" & Grid1.Cell(i, 2).Text & "',cpxh='" & Grid1.Cell(i, 3).Text & "',cpsl=" & Grid1.Cell(i, 4).Text & ",cpzl=" & cpzltemp & ",dhbh=" & Grid1.Cell(i, 6).Text & ",dhmc='" & Grid1.Cell(i, 7).Text & "',dhrq='" & Grid1.Cell(i, 8).Text & "',cpyn='" & Grid1.Cell(i, 9).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 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 abj 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 abj 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!bjsl & Chr(9) & rsTempB!bjzl
            griditem = griditem & Chr(9) & rsTempB!bjdate1 & Chr(9) & rsTempB!bjdate2 & Chr(9) & rsTempB!cpbh & Chr(9) & rsTempB!cpmc & Chr(9) & rsTempB!code
            Grid2.AddItem griditem
           rsTempB.MoveNext
        Loop
        
    End If
End Sub
Private Sub mskdate1_LostFocus()
    '是否为日期需校验
    If IsDate(Mskdate1.Text) = False Then
        MsgBox "请检查日期是否正确?", vbOKOnly, "日期校验"
        Exit Sub
    End If
    Set rsTempA = oDb.Execute("select max(code) as maxcode from acp where dhrq= '" & Mskdate1.Text & "'")    'code号初始
    If IsNull(rsTempA!maxcode) Then
        txtcode1.Text = 1
        Else
        txtcode1.Text = rsTempA!maxcode + 1
    End If
End Sub
Private Sub cmdfind_Click()
    dogridfill1
    dogridfind
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, 7).Text = NOWDate
    Grid2.Cell(Grid2.Rows - 1, 8).Text = txtcpbh.Text     '产品编号及名称
    Grid2.Cell(Grid2.Rows - 1, 9).Text = Frame3.Caption
    Grid2.Cell(Grid2.Rows - 1, 1).Text = txtcpbh.Text & Format$(txtcode2.Text, "0000") '部件编号=产品编号+code4位
    Grid2.Cell(Grid2.Rows - 1, 10).Text = txtcode2.Text
    txtcode2.Text = txtcode2.Text + 1                                                      'code2+1
End Sub
Private Sub cmdsave2_Click()
    '检测部件编号、名称、数量内容是否齐全,再保存
    For i = 1 To Grid2.Rows - 1
        If (Grid2.Cell(i, 2).Text = "") Or Val(Grid2.Cell(i, 4).Text) <= 0 Then
            MsgBox "请检查输入部件名称及数量", vbOKOnly, "名称、数量"
            Exit Sub
        End If
    Next i
    
    cpzltemp = 0  '小计产品重量
    For i = 1 To Grid2.Rows - 1
        griditem = Grid2.Cell(i, 1).Text
        Set rsTempA = oDb.Execute("select * from abj 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 & ",0"
            If Grid2.Cell(i, 5).Text <> "" Then griditem = griditem & "," & Grid2.Cell(i, 5).Text & "" Else griditem = griditem & ",0"
            If Grid2.Cell(i, 6).Text <> "" Then griditem = griditem & ",'" & Grid2.Cell(i, 6).Text & "'" Else griditem = griditem & ",''"
            If Grid2.Cell(i, 7).Text <> "" Then griditem = griditem & ",'" & Grid2.Cell(i, 7).Text & "'" Else griditem = griditem & ",''"
            If Grid2.Cell(i, 8).Text <> "" Then griditem = griditem & ",'" & Grid2.Cell(i, 8).Text & "'" Else griditem = griditem & ",''"
            If Grid2.Cell(i, 9).Text <> "" Then griditem = griditem & ",'" & Grid2.Cell(i, 9).Text & "'" Else griditem = griditem & ",''"
            If Grid2.Cell(i, 10).Text <> "" Then griditem = griditem & "," & Grid2.Cell(i, 10).Text & "" Else griditem = griditem & ",0"
            szSql = "insert abj (bjbh,bjmc,bjth,bjsl,bjzl,bjdate1,bjdate2,cpbh,cpmc,code) values (" & griditem & ")"
            oDb.Execute szSql
        Else
            szSql = "UPDATE abj SET bjmc='" & Grid2.Cell(i, 2).Text & "',bjth='" & Grid2.Cell(i, 3).Text & "',bjdate1='" & Grid2.Cell(i, 6).Text & "',bjsl=" & Grid2.Cell(i, 4).Text & ",bjzl=" & Grid2.Cell(i, 5).Text & " where bjbh='" & Grid2.Cell(i, 1).Text & "'"
            oDb.Execute szSql
        End If
        If Grid2.Cell(i, 5).Text <> "" Then cpzltemp = cpzltemp + Val(Grid2.Cell(i, 5).Text)
    Next i
    
    '产品库更新重量
    szSql = "UPDATE acp SET cpzl=" & cpzltemp & " where cpbh='" & txtcpbh.Text & "'"
    oDb.Execute szSql
    
    MsgBox "产品信息成功保存", vbOKOnly, "保存"
    Set rsTempA = oDb.Execute("select max(code) as maxcode from acp where dhrq= '" & Mskdate1.Text & "'")   'code号初始
    If IsNull(rsTempA!maxcode) Then
        txtcode1.Text = 1
        Else
        txtcode1.Text = rsTempA!maxcode + 1
    End If
End Sub
Private Sub dogridfirst()
    '表格1-产品信息表
    Grid1.AutoRedraw = False
    Grid1.DisplayFocusRect = False
    Grid1.Cols = 11
    Grid1.Rows = 1
    Grid1.FixedRows = 1
    
    Grid1.Column(0).Width = 5
    Grid1.Column(1).Width = 110
    Grid1.Column(2).Width = 130
    Grid1.Column(3).Width = 130
    Grid1.Column(4).Width = 60
    Grid1.Column(5).Width = 60
    Grid1.Column(6).Width = 60
    Grid1.Column(7).Width = 180
    Grid1.Column(8).Width = 80
    Grid1.Column(9).Width = 50
    Grid1.Column(10).Width = 2
    
    Grid1.AutoRedraw = True
    Grid1.Refresh
    Grid1.Column(1).Locked = True       '产品编号与单位编号、名称不能修改
    Grid1.Column(10).Locked = True
    Grid1.Column(6).CellType = cellComboBox
    Set rsTempA = oDb.Execute("select * from adh order by dhbh")
    Do Until rsTempA.EOF
        Grid1.ComboBox(6).AddItem rsTempA!dhbh
        rsTempA.MoveNext
    Loop
    
    '表格2-部件信息
    Grid2.AutoRedraw = False
    Grid2.AllowUserResizing = True
    Grid2.DisplayFocusRect = False
    
    Grid2.Cols = 12
    Grid2.Rows = 1
    Grid2.FixedRows = 1
    
    Grid2.Column(0).Width = 18
    Grid2.Column(1).Width = 120
    Grid2.Column(2).Width = 140
    Grid2.Column(3).Width = 140
    Grid2.Column(4).Width = 50
    Grid2.Column(5).Width = 60
    Grid2.Column(6).Width = 100
    Grid2.Column(7).Width = 100
    Grid2.Column(8).Width = 2
    Grid2.Column(9).Width = 2
    Grid2.Column(10).Width = 2
    Grid2.Column(11).Width = 2
    Grid2.AutoRedraw = True
    Grid2.Refresh
    Grid2.Column(1).Locked = True
    Grid2.Column(8).Locked = True
    Grid2.Column(9).Locked = True
    Grid2.Column(10).Locked = True
    Grid2.Column(11).Locked = True
    Grid2.Column(4).Mask = CellValue
    Grid2.Column(5).Mask = CellValue
    Grid2.Column(6).CellType = cellCalendar
    Grid2.Column(7).CellType = cellCalendar
End Sub
Private Sub dogridfill1()
    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 = "填制日期"
    Grid1.Cell(0, 9).Text = "是否统计"
    Grid1.Cell(0, 10).Text = "code"
    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 = "重量kg"
    Grid2.Cell(0, 6).Text = "计划完成日期"
    Grid2.Cell(0, 7).Text = "编制日期"
    Grid2.Cell(0, 8).Text = "产品编号"
    Grid2.Cell(0, 9).Text = "产品名称"
    Grid2.Cell(0, 10).Text = "产品型号"
    Grid2.Cell(0, 11).Text = "code"
    Grid2.Rows = 1
End Sub
Private Sub dogridfind()
    If chkyn.Value = False Then
            Set rsTempA = oDb.Execute("select * from acp  where cpyn='Y' and dhrq>='" & mskdate0.Text & "'order by cpbh")
        Else
            Set rsTempA = oDb.Execute("select * from acp  where  dhrq>='" & mskdate0.Text & "'order by cpbh")
    End If
    Do While Not rsTempA.EOF
        Grid1.AddItem (rsTempA!cpbh & Chr(9) & rsTempA!cpmc & Chr(9) & rsTempA!cpxh & Chr(9) & rsTempA!cpsl & Chr(9) & rsTempA!cpzl & Chr(9) & rsTempA!dhbh & Chr(9) & rsTempA!dhmc) & Chr(9) & rsTempA!dhrq & Chr(9) & rsTempA!cpyn
        rsTempA.MoveNext
    Loop
End Sub
Private Sub cmddate0_Click()
    MonthView1.Visible = True
End Sub
Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
    MonthView1.Visible = False
    mskdate0.Text = MonthView1.Value
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -