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

📄 ps_bomsingleform.frm

📁 即时通讯
💻 FRM
📖 第 1 页 / 共 5 页
字号:
    
        ' 根据BOM结点读出BOM数据
        ret = m_bomDAO.FindById(m_recordset, _
                                bomId)
        
        If ret Then                ' 找到了BOM记录
            ' 把选择的原料的BOM资料读出来显示在界面
            With m_recordset
                HFG_detail.TextMatrix(HFG_detail.row, 0) = "Y"
                HFG_detail.TextMatrix(HFG_detail.row, 1) = Trim(.Fields("name"))
                HFG_detail.TextMatrix(HFG_detail.row, 2) = Trim(.Fields("processName"))
                HFG_detail.TextMatrix(HFG_detail.row, 3) = Trim(.Fields("fee"))
                HFG_detail.TextMatrix(HFG_detail.row, 4) = Trim(.Fields("bomCost"))
    '            HFG_detail.TextMatrix(HFG_detail.Row, 5) = "数量"                        ' 明细的数量
                HFG_detail.TextMatrix(HFG_detail.row, 6) = Trim(.Fields("description"))
                HFG_detail.TextMatrix(HFG_detail.row, 7) = Trim(.Fields("bomId"))        ' 当为空时为新增BOM表,不空为修改
    '            HFG_detail.TextMatrix(HFG_detail.Row, 8) = ""                            ' 当为空时 - 新增明细(非根结点情况) 当不空时 - 修改明细(数量)
                HFG_detail.TextMatrix(HFG_detail.row, 9) = Trim(.Fields("materialType"))                           ' 0-原料 1-零件 2-产品
                HFG_detail.TextMatrix(HFG_detail.row, 10) = Trim(.Fields("materialId"))
            End With
            m_recordset.Close
            ListToTextbox
        Else
            m_recordset.Close
        End If
    End If
End Sub

'**************************************
'*    功 能 描 述 :在当前根结点的基础上新增根结点,则当前的根结点变成了新根结点的子结点
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub m_newFirstBom_Click()
    '
'    Dim s As String
'    If m_currentLevel < 1 Then           ' 当前正在编辑根结点,不能加入更多的行
'        MainForm.g_msgText = "你现在正在建立根BOM,再建新的根结点!"
'        HMsgBox MainForm.g_msgText, 0, 1
'    Else
'        CreateLastNode
'        TV_bomManage.Nodes.Item(1).Parent = TV_bomManage.Nodes.Item(2)
'    End If
End Sub

'**************************************
'*    功 能 描 述 :新增列表框中的行
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub m_newRow_Click()
    '
    If m_currentLevel < 1 Then           ' 当前正在编辑根结点,不能加入更多的行
        MainForm.g_msgText = "你现在正在建立根BOM,不能新建多行!"
        HMsgBox MainForm.g_msgText, 0, 1
    Else
        HFG_detail.AddItem ""
        m_detailRowCount = m_detailRowCount + 1
    End If
End Sub
'**************************************
'*    功 能 描 述 :重新把产品的BOM加载到生产计划单中,
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub m_reloadBom_Click()
    ' 重新从物料BOM中加载BOM资料
    LoadProductionBom
    
    TV_bomManage.Nodes.clear
    ' 重载BOM树资料到树中
    LoadBomData
End Sub
'**************************************
'*    功 能 描 述 :用户零件操作
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub m_selectBomPart_Click()
    m_selectPart_Click
End Sub


Private Sub m_selectPart_Click()
    Dim ret As Boolean
    ' 在能在原来的零件的基础上修改成其它的零件
    If Trim(HFG_detail.TextMatrix(HFG_detail.row, 10)) <> "" Then
        MainForm.g_msgText = "请选择一个空行进行零件选择操作!"
        HMsgBox MainForm.g_msgText, 0, 1
        Exit Sub
    End If
    
    ' 选择一种零件
    QueryFom.m_currentQuery = QUERY_PART
    QueryFom.show vbModal
    ' 如果此原料已有BOM记录,则调出些条BOM的信息
    ret = m_productionBomDAO.FindByMaterial(m_recordset, _
                                  MainForm.g_application.m_queryResultId, _
                                  "1")
    
    If ret Then                ' 找到了BOM记录
        ' 判断此零件的BOM是不是有供应商
        If Not m_productionBomDAO.CheckBomSupplier(Trim(m_recordset.Fields("bomId"))) Then
            MainForm.g_msgText = "零件树中有物料没有供货商,请检查并设置正确后再做!"
            HMsgBox MainForm.g_msgText, 0, 1
            GoTo EXITSUB
        End If
        
        ' 判断此零件是不是已存在在BOM列表中
        If ExistInList(MainForm.g_application.m_queryResultId) Then
            MainForm.g_msgText = "此零件已存在在零件列表中,不能选择此零件!"
            HMsgBox MainForm.g_msgText, 0, 1
            GoTo EXITSUB
        End If
        
        ' 把选择的原料的BOM资料读出来显示在界面
        With m_recordset
            HFG_detail.TextMatrix(HFG_detail.row, 0) = "Y"
            HFG_detail.TextMatrix(HFG_detail.row, 1) = Trim(.Fields("name"))
            HFG_detail.TextMatrix(HFG_detail.row, 2) = Trim(.Fields("processName"))
            HFG_detail.TextMatrix(HFG_detail.row, 3) = Trim(.Fields("fee"))
            HFG_detail.TextMatrix(HFG_detail.row, 4) = Trim(.Fields("bomCost"))
'            HFG_detail.TextMatrix(HFG_detail.Row, 5) = "数量"                        ' 明细的数量
            HFG_detail.TextMatrix(HFG_detail.row, 6) = Trim(.Fields("description"))
'            HFG_detail.TextMatrix(HFG_detail.row, 7) = Trim(.Fields("bomId"))        ' 当为空时为新增BOM表,不空为修改
'            HFG_detail.TextMatrix(HFG_detail.Row, 8) = ""                            ' 当为空时 - 新增明细(非根结点情况) 当不空时 - 修改明细(数量)
            HFG_detail.TextMatrix(HFG_detail.row, 9) = "1"                           ' 0-原料 1-零件 2-产品
            HFG_detail.TextMatrix(HFG_detail.row, 10) = _
               MainForm.g_application.m_queryResultId
            HFG_detail.TextMatrix(HFG_detail.row, 11) = Trim(.Fields("relatePartId"))
        End With
    Else                    ' 没找到BOM记录 ,查找物料记录
        MainForm.g_msgText = "你选择的零件还没有建立BOM,请先建立其BOM再进行操作!"
        HMsgBox MainForm.g_msgText, 0, 1
        GoTo EXITSUB
    End If

    ListToTextbox
    
EXITSUB:
    m_recordset.Close
End Sub


Private Sub m_setFinishNum_Click()
    If F_setFinishNum.Visible Then
        F_setFinishNum.Visible = False
    Else
        F_setFinishNum.Visible = True
    End If
End Sub

Private Sub T_bomCost_Change()
    Call OnTextChanged
End Sub

'Private Sub T_bomCost_KeyPress(KeyAscii As Integer)
'    InputFieldLimit T_bomCost, 5, KeyAscii
'End Sub

Private Sub T_fee_Change()
    Call OnTextChanged
End Sub

'Private Sub T_fee_KeyPress(KeyAscii As Integer)
'    InputFieldLimit T_fee, 5, KeyAscii
'End Sub

Private Sub T_memo_Change()
    Call OnTextChanged
End Sub

Private Sub T_name_Change()
    Call OnTextChanged
End Sub

Private Sub T_number_Change()
    Call OnTextChanged
End Sub

Private Sub T_number_KeyPress(KeyAscii As Integer)
    InputFieldLimit T_number, 3, KeyAscii
End Sub

Private Sub T_ProcessName_Change()
    Call OnTextChanged
End Sub

Private Sub T_setToNum_KeyPress(KeyAscii As Integer)
    InputFieldLimit T_setToNum, 5, KeyAscii
End Sub

Private Sub TV_bomManage_GotFocus()
'    MsgBox "ss"
End Sub
'**************************************
'*    功 能 描 述 :操作树的点击操作
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub TV_bomManage_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button And vbRightButton Then
        PopupMenu PM_treeOperator
    End If
End Sub
'**************************************
'*    功 能 描 述 :当输入框中的数据修改时的处理函数
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub OnTextChanged()
    If m_onTextChange Then
        HFG_detail.TextMatrix(HFG_detail.row, 1) = Trim(T_name.text)
        HFG_detail.TextMatrix(HFG_detail.row, 2) = Trim(T_ProcessName.text)
        HFG_detail.TextMatrix(HFG_detail.row, 3) = Replace(Trim(T_fee.text), "¥", "")
        HFG_detail.TextMatrix(HFG_detail.row, 4) = Replace(Trim(T_bomCost.text), "¥", "")
        HFG_detail.TextMatrix(HFG_detail.row, 5) = Trim(T_number.text)
        HFG_detail.TextMatrix(HFG_detail.row, 6) = Trim(T_memo.text)
    End If
End Sub
'**************************************
'*    功 能 描 述 :把list中的一条记录提取到各个TEXTBOX中去
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub ListToTextbox()
    m_onTextChange = False
    T_name.text = Trim(HFG_detail.TextMatrix(HFG_detail.row, 1))
    T_ProcessName.text = Trim(HFG_detail.TextMatrix(HFG_detail.row, 2))
    T_fee.text = "¥" & Trim(HFG_detail.TextMatrix(HFG_detail.row, 3))
    T_bomCost.text = "¥" & Trim(HFG_detail.TextMatrix(HFG_detail.row, 4))
    T_number.text = Trim(HFG_detail.TextMatrix(HFG_detail.row, 5))
    T_memo.text = Trim(HFG_detail.TextMatrix(HFG_detail.row, 6))
    m_onTextChange = True
End Sub
'**************************************
'*    功 能 描 述 :把HFG_detail中的子BOM列表放入数据库中及树中
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub SaveListToTree()
    Dim i As Integer         ' 循环变量
    Dim id As String         ' 记录的ID
    Dim ret As Boolean

    ClearSubTree

    ' 把列表中的数据保存到数据库中,并把结点加入到树中
    If m_currentLevel = 1 Then                 ' 新增根结点
        ret = Check(0, 1)
        If ret = False Then
            GoTo EXITSUB
        End If

        If Trim(HFG_detail.TextMatrix(1, 7)) = "" Then   ' 如果要新增BOM记录
            id = m_bomDAO.NewBom(m_recordset, _
                             Trim(HFG_detail.TextMatrix(1, 1)), _
                             Trim(HFG_detail.TextMatrix(1, 6)), _
                             CDbl(HFG_detail.TextMatrix(1, 3)), _
                             Trim(HFG_detail.TextMatrix(1, 2)), _
                             CDbl(HFG_detail.TextMatrix(1, 4)), _
                             Trim(HFG_detail.TextMatrix(1, 10)), _
                             Trim(HFG_detail.TextMatrix(1, 9)), _
                             Trim(m_productSchemeId), _
                             Trim(HFG_detail.TextMatrix(1, 11)))
        Else                                            ' 修改BOM记录
            id = Trim(HFG_detail.TextMatrix(1, 7))
            ret = m_bomDAO.ModifyBom(m_recordset, _
                             Trim(HFG_detail.TextMatrix(1, 1)), _
                             Trim(HFG_detail.TextMatrix(1, 6)), _
                             CDbl(HFG_detail.TextMatrix(1, 3)), _
                             Trim(HFG_detail.TextMatrix(1, 2)), _
                             CDbl(HFG_detail.TextMatrix(1, 4)), _
                             Trim(HFG_detail.TextMatrix(1, 10)), _
                             Trim(HFG_detail.TextMatrix(1, 9)), _
                             id)
        End If
        If id <> "" Then                       ' 新增BOM表成功
            CreateLastNode                           ' 新建树的总结点
            TV_bomManage.Nodes(1).Tag = id           ' 保存bom的ID进入树结点
            TV_bomManage.Nodes(1).text = HFG_detail.TextMatrix(1, 1)
'            HFG_detail.TextMatrix(1, 10) = "1"       ' 把当前结点改成修改

            ' 把新加入的结点存入当前列表的父节点中
            m_parentBom.bomCost = Trim(HFG_detail.TextMatrix(1, 4))
            m_parentBom.bomId = Trim(HFG_detail.TextMatrix(1, 7))
            m_parentBom.description = Trim(HFG_detail.TextMatrix(1, 6))
            m_parentBom.fee = Trim(HFG_detail.TextMatrix(1, 3))
            m_parentBom.materialId = Trim(HFG_detail.TextMatrix(1, 10))
            m_parentBom.materialType = Trim(HFG_detail.TextMatrix(1, 9))
            m_parentBom.name = Trim(HFG_detail.TextMatrix(1, 1))
            m_parentBom.processName = Trim(HFG_detail.TextMatrix(1, 2))
            m_parentBom.relatePartId = Trim(HFG_detail.TextMatrix(1, 11))

            TV_bomManage.Nodes(1).Selected = True
            m_currentLevel = 1                              ' 设置当前结点为根结点
            m_currentNode = TV_bomManage.SelectedItem.Index ' 当前选中的结点
'            m_currentSelectNode = TV_bomManage.Nodes(1)
'            m_detailRowCount = 1                           ' 当前明细中的行数

            ReadChildrenNodes id, TV_bomManage.Nodes(1)     ' 读取子BOM列表

            ClearAllLine                                    ' 清除子BOM列表的所有行
            ClearAllText
            'm_recordset.Fields.Item(1).Name                ' 字段名子
        Else                                                ' 新增BOM表成功
            MainForm.g_msgText = "新增记录失败!"
            HMsgBox MainForm.g_msgText, 0, 1
        End If
    Else                                                    ' 子BOM列表达式
        ' 对每一行BOM表进行处理
        For i = 1 To HFG_detail.Rows - 1
            If Trim(HFG_detail.TextMatrix(i, 0)) = "Y" Then ' 本行需要处理
                MoveOneLineToTree i
            ElseIf Trim(HFG_detail.TextMatrix(i, 8)) <> "" Then  ' 从BOM明细中删除此条BOM明细表
                ' 需要进一步处理,把删除节节点的子节点也清除掉
                DeleteBomNode Trim(HFG_detail.TextMatrix(i, 7))

            End If
        Next i
    End If

EXITSUB:
End Sub
'**************************************
'*    功 能 描 述 :把一行数据放入数据库中及树中
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub MoveOneLineToTree(line As Integer)
    Dim ret As Boolean
    Dim id As String            ' BOM的ID

⌨️ 快捷键说明

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