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

📄 ps_bomsingleform.frm

📁 即时通讯
💻 FRM
📖 第 1 页 / 共 5 页
字号:
      Left            =   4560
      TabIndex        =   8
      Top             =   720
      Width           =   810
   End
   Begin VB.Label TsLabel 
      AutoSize        =   -1  'True
      Caption         =   "BOM 名称:"
      Height          =   180
      Index           =   1
      Left            =   4560
      TabIndex        =   7
      Top             =   240
      Width           =   810
   End
   Begin VB.Menu PM_treeOperator 
      Caption         =   "PM_treeOperator"
      Visible         =   0   'False
      Begin VB.Menu m_newFirstBom 
         Caption         =   "新建根BOM"
         Visible         =   0   'False
      End
      Begin VB.Menu m_modiFirstNode 
         Caption         =   "修改根BOM"
         Visible         =   0   'False
      End
      Begin VB.Menu m_cooperateBill 
         Caption         =   "外 协 单"
         Visible         =   0   'False
      End
      Begin VB.Menu m_reloadBom 
         Caption         =   "重载BOM"
      End
      Begin VB.Menu m_setFinishNum 
         Caption         =   "设置完成数量"
         Visible         =   0   'False
      End
      Begin VB.Menu m_calCost 
         Caption         =   "计算成本"
      End
   End
   Begin VB.Menu PM_listOperator 
      Caption         =   "PM_listOperator"
      Visible         =   0   'False
      Begin VB.Menu m_newRow 
         Caption         =   "新增物料"
      End
      Begin VB.Menu m_deleteRow 
         Caption         =   "删除物料"
      End
      Begin VB.Menu m_selectBomPart 
         Caption         =   "选择零件"
      End
      Begin VB.Menu m_selectMateral 
         Caption         =   "选择Bom"
         Visible         =   0   'False
         Begin VB.Menu m_selectGoods 
            Caption         =   "原料"
         End
         Begin VB.Menu m_selectPart 
            Caption         =   "零件"
         End
         Begin VB.Menu m_selectProduction 
            Caption         =   "产品"
         End
         Begin VB.Menu m_selectBom 
            Caption         =   "BOM"
         End
      End
   End
End
Attribute VB_Name = "PS_BomSingleForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private m_bomDAO As PS_BomDAO          ' 仓库数据库操作类
Private m_productionBomDAO As BomDAO   ' 仓库数据库操作类
Private m_productSchemeDAO As ProductSchemeDAO ' 生产计划单数据库操作类
Private m_recordset As ADODB.Recordset ' 数据操作数据集对象

Public m_operatorType As Integer       ' 操作类型  1 - 生产计划单还在设计状态时调用
Public m_productSchemeId As String     ' 物产计划单编号
Public m_productionId    As String
Public m_schemeState As String         ' 生产计划单的状态
'Public m_bomId As String               ' 管理的BOM表的BOM ID(树中当前选中的)
Private m_parentBom   As BomNode         '  树中当前选中的BOM节点,列表中节点的父节点
Public m_currentLevel As Integer       ' 当前操作树所选择的层 1 - 产品层(只有一个结点) 0 - 树结点中为空
Public m_currentNode  As Integer       ' 当前选中的树结点的序号

Public m_detailRowCount As Integer     ' 明细列表的总行总
Private m_onTextChange  As Boolean     ' 输入框改变事件是否可行 事件执行开关
Private m_currentSelectNode As Node    ' 当前选中的节点
Private m_parentNode As Node           ' 当前选中节点的父节点
'**************************************
'*    功 能 描 述 :把列表中的记录更新到树中的操作
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub C_modify_Click()
    ' 检查当前编辑的父结点是原料结点则不能保存其下一级的各结点
    If m_currentLevel > 1 Then
        If m_parentBom.materialType = 0 Then
            MainForm.g_msgText = "现在的父结点是零件,不能新增子BOM"
            HMsgBox MainForm.g_msgText, 0, 1
            Exit Sub
        End If
    End If
    ' 保存进树中
    SaveListToTree
End Sub

Private Sub C_readTree_Click()
'    Dim q As queryType
'    Dim s As String
'    q.name = "jackyc"
'    s = q.name
End Sub
'**************************************
'*    功 能 描 述 :设置物料的完成数量
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub C_set_Click()
    Dim ret As Boolean
    
    If Trim(T_requirement.Tag) <> "" And Trim(T_setToNum.text) <> "" Then
        ret = m_productSchemeDAO.SetPsMaterialNum(m_recordset, Trim(T_requirement.Tag), _
                               CDbl(T_setToNum.text))
    End If
End Sub

Private Sub Form_Load()
    Set m_bomDAO = New PS_BomDAO
    Set m_productionBomDAO = New BomDAO
    Set m_productSchemeDAO = New ProductSchemeDAO
    Set m_recordset = New ADODB.Recordset
    
    m_onTextChange = True
    
    Me.caption = "生产计划单BOM表管理"
    Me.Height = 6810
    Me.Width = 8505
    SetToCenter Me
    
    If m_schemeState = "0" Then        ' 当生产计划单是在设计进,生产BOM可以修改
        C_modify.Enabled = True
        m_reloadBom.Enabled = True
    Else                              ' 当生产计划单不在设计进,生产BOM不可以修改
        C_modify.Enabled = False
        m_reloadBom.Enabled = False
    End If
'    If m_schemeState = "1" Then
'        m_cooperateBill.Visible = True
'        m_setFinishNum.Visible = True
'    End If
    
    RefreshListTitle
    
    ' 新建BOM树的根节点
    'CreateLastNode
    
    If m_operatorType = 0 Then              ' 新增
        m_currentLevel = 0                  ' 当前操作的层为产品层
        m_currentNode = 0                   ' 当前没有选中的BOM树节点
        m_detailRowCount = 1                ' 明细里面的数据行的行数
        
        HFG_detail.TextMatrix(1, 10) = "0"
    End If
    If m_operatorType = 1 Then              ' 对生产计划单的
        ' 根据生产编号查找些生产计划的BOM表结构,如果不存在,要从产品
        ' BOM表中读出并写进生产计划BOM表中,并在树中显示生产计划BOM表
        LoadBomData
    End If
End Sub
'**************************************
'*    功 能 描 述 :刷新BOM明细列表的标题栏
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub RefreshListTitle()
    HFG_detail.Cols = 12
    
    HFG_detail.TextMatrix(0, 0) = "."
    HFG_detail.TextMatrix(0, 1) = "BOM名称"
    HFG_detail.TextMatrix(0, 2) = "工序名称"
    HFG_detail.TextMatrix(0, 3) = "工序费用"
    HFG_detail.TextMatrix(0, 4) = "BOM成本"
    HFG_detail.TextMatrix(0, 5) = "数量"                   ' 明细的数量
    HFG_detail.TextMatrix(0, 6) = "备注"
    HFG_detail.TextMatrix(0, 7) = "bomId"                  ' 明细联接到的BOM记录
    HFG_detail.TextMatrix(0, 8) = "bomDetailId"            ' 当为空时 - 新增明细(非根结点情况) 当不空时 - 修改明细(数量)
    HFG_detail.TextMatrix(0, 9) = "materialType"           ' 0-原料 1-零件 2-产品
    HFG_detail.TextMatrix(0, 10) = "materialId"            ' 物料ID
    HFG_detail.TextMatrix(0, 11) = "relatePartId"          ' 相关零件的ID
    

    '设置列对齐方式  7-右对齐 5-居中对齐 2-左对齐
    HFG_detail.ColAlignment(0) = 2
    HFG_detail.ColAlignment(1) = 2
    HFG_detail.ColAlignment(2) = 2
    HFG_detail.ColAlignment(3) = 8
    HFG_detail.ColAlignment(4) = 8
    HFG_detail.ColAlignment(5) = 8
    HFG_detail.ColAlignment(6) = 2
    HFG_detail.ColAlignment(7) = 2
    HFG_detail.ColAlignment(8) = 2
    HFG_detail.ColAlignment(9) = 8
    HFG_detail.ColAlignment(10) = 2

    
    HFG_detail.ColWidth(0) = 200
    HFG_detail.ColWidth(7) = 0
    HFG_detail.ColWidth(8) = 0
    HFG_detail.ColWidth(9) = 0
    HFG_detail.ColWidth(10) = 0
    HFG_detail.ColWidth(11) = 0
End Sub
'**************************************
'*    功 能 描 述 :列表的点击操作
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub HFG_detail_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button And vbRightButton Then                   ' 用户点击右键,调出快捷菜单
        If m_currentLevel = 2 And _
           m_parentBom.materialType = "2" And _
           m_schemeState = "0" Then                    ' 选中的节点层是第2层,并且上级是产品
            PopupMenu PM_listOperator
        End If
    ElseIf Button And vbLeftButton Then
'        MainForm.g_msgText = "LEFT"
'        HMsgBox MainForm.g_msgText, 0, 1
    End If
End Sub
'**************************************
'*    功 能 描 述 :新增节点操作
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub m_newNode_Click()
    ' 新增节点
    Dim s As Integer
    s = TV_bomManage.Nodes.Count
    s = Val(TV_bomManage.Nodes(1).Key)
'Add a node using tvwFirst
    Dim skey As String
    Dim iIndex As Integer
    Dim oNodex As Node
    
    On Error GoTo myerr 'if the treeview does not have a node selected
    ' the next line of code will return an error number 91
    iIndex = TV_bomManage.SelectedItem.Index 'Check to see if a Node is selected
    skey = GetNextKey() ' Get a key for the new Node
    TV_bomManage.Nodes.Add iIndex, tvwFirst, skey, "First " & skey, 1, 2
    Exit Sub
myerr:
    'Display a messge telling the user to select a node
    MsgBox ("You must select a Node to do an Add First" & vbCrLf _
       & "If the TreeView is empty us Add Last to create the first node")
    TV_bomManage.Nodes.Add , tvwLast, skey, "Last " & skey, 1, 2
    Exit Sub
End Sub

Private Sub HFG_detail_SelChange()
    ListToTextbox
End Sub

Private Sub m_calCost_Click()
    ' 计算成本
    On Error GoTo EXITSUB
    m_bomDAO.CalBomCost Trim(TV_bomManage.SelectedItem.Tag)
    
    TV_bomManage_NodeClick TV_bomManage.SelectedItem
    
    MainForm.g_msgText = "重新计算成本成功!"
    HMsgBox MainForm.g_msgText, hxxdOKOnly, hxxdInfomation
EXITSUB:
End Sub
'**************************************
'*    功 能 描 述 :生成外协生产单
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub m_cooperateBill_Click()
    '
    If Trim(TV_bomManage.SelectedItem.text) <> "" Then
        CooperateSingleForm.m_operatorType = 0
        CooperateSingleForm.m_productSchemeId = m_productSchemeId
        CooperateSingleForm.m_psbomId = TV_bomManage.SelectedItem.Tag
        CooperateSingleForm.show
    End If
End Sub

'**************************************
'*    功 能 描 述 :删除一行
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub m_deleteRow_Click()
    If HFG_detail.Rows < 3 Then
        MainForm.g_msgText = "只有一行不能删除!"
        HMsgBox MainForm.g_msgText, 0, 1
        Exit Sub
    End If
    If HFG_detail.row > 0 Then
        HFG_detail.TextMatrix(HFG_detail.row, 0) = "N"
        HFG_detail.col = 0
        HFG_detail.CellBackColor = vbBlue
    End If
End Sub
'**************************************
'*    功 能 描 述 :修改当前树结点的根结点
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub m_modiFirstNode_Click()
    ' 修改当前树的根结点
    Dim ret As Boolean
    Dim bomId As String
    ' 修改当前树的根结点
    m_currentLevel = 1        ' 把当前设置成编辑根结点
    
    If TV_bomManage.Nodes.Count > 0 Then
        bomId = Trim(TV_bomManage.Nodes(1).Tag)
'        TV_bomManage.Nodes.clear
        
        HFG_detail.clear
        HFG_detail.Rows = 2
        RefreshListTitle
    

⌨️ 快捷键说明

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