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

📄 productschemesingleform.frm

📁 即时通讯
💻 FRM
📖 第 1 页 / 共 2 页
字号:
        If m_operatorType = 0 Then
            Call NewProductScheme
        ElseIf m_operatorType = 1 Then
            Call ModifyProductScheme
        End If
        Unload Me
    End If
End Sub

Private Sub Command1_Click()

    ' 调用商品查询窗体
    QueryFom.m_currentQuery = QUERY_BOM_PRODUCTIONPART
    QueryFom.show vbModal
    
    SelectBomProcess         ' 选择BOM后的处理
End Sub
'**************************************
'*    功 能 描 述 :用户选择了BOM后的处理操作
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Function SelectBomProcess()
    Dim ret As Boolean
    Dim bomCost As Double    ' BOM成本

    ' 找到要做生产计划单的物料的BOM记录
    ret = m_bomDAO.FindById(m_recordset, MainForm.g_application.m_queryResultId)
    
   
    If ret Then
        If Not m_bomDAO.CheckBomSupplier(Trim(m_recordset.Fields("bomId"))) Then
            MainForm.g_msgText = "物料树中有物料没有供货商,请检查并设置正确后再做生产计划单!"
            HMsgBox MainForm.g_msgText, 0, 1
            Exit Function
        End If
    
        ' 重新计算BOM成本
        bomCost = m_bomDAO.CalBomCost(Trim(m_recordset.Fields("bomId")))  ' 重新计算成本
        
        T_costPrice.text = bomCost + _
                           CDbl(m_recordset.Fields("fee"))
        T_production.text = Trim(m_recordset.Fields("name"))
        T_production.Tag = Trim(m_recordset.Fields("materialId"))
        T_name.text = Trim(m_recordset.Fields("name")) + "生产计划单"
        m_materialType = Trim(m_recordset.Fields("materialType"))
        c_save.Enabled = True
    Else
        MainForm.g_msgText = "物料BOM没有找到,请重新查找!"
        HMsgBox MainForm.g_msgText, 0, 1
        
        c_new.Enabled = False
        c_save.Enabled = False
    End If
    
    m_recordset.Close

    
    T_no.text = GetBillNo(0)
    
    T_makeBillDate.text = CStr(Date)
End Function

Private Sub Command4_Click()

End Sub

Private Sub Command2_Click()

    Call CallDateControl(1, Trim(T_beginDate.text))
    If Len(XT_calendar.Xtfhcs) <> 0 Then
            T_beginDate.text = XT_calendar.Xtfhcs                              ' 将日历窗体里取得的值传给建档日期的文本框
    End If

End Sub

Private Sub Command3_Click()

    Call CallDateControl(1, Trim(T_finishDate.text))
    If Len(XT_calendar.Xtfhcs) <> 0 Then
            T_finishDate.text = XT_calendar.Xtfhcs                              ' 将日历窗体里取得的值传给建档日期的文本框
    End If

End Sub

'**************************************
'*    功 能 描 述 :窗体装载函数
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub Form_Load()
    '
    Me.Height = 5685
    Me.Width = 5610
    SetToCenter Me
    
    Set m_productionDAO = New productionDAO
    Set m_dao = New ProductSchemeDAO
    Set m_bomDAO = New BomDAO
    Set m_recordset = New ADODB.Recordset
    
    If m_operatorType = 0 Then
        Me.caption = "生产计划资料_新增"
        
        clear
    Else
        Me.caption = "生产计划资料_修改"
        Command1.Visible = False
        
        If Trim(Me.m_schemeState) <> "0" Then
            c_new.Enabled = False
            Command2.Enabled = False
            Command3.Enabled = False
            T_totalNum.Enabled = False
            T_name.Enabled = False
            
        End If
        
        FindByIdRefresh
    End If
End Sub
'**************************************
'*    功 能 描 述 :清除界面上文本框里的所有内容
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub clear()
    Dim sMonth As String
    
    T_name.text = ""
    T_specification.text = "SS"
    T_singleNum.text = "0"
    T_totalNum.text = "0"
    T_costPrice.text = "0"
    T_totalMoney.text = "0"

    sMonth = Month(Date)
    If Len(sMonth) < 2 Then
        sMonth = "0" & sMonth
    End If
    T_groupNo.text = Right(Year(Date), 2) & sMonth

    T_makeBillDate.text = ""
    T_beginDate.text = ""
    T_finishDate.text = ""
    T_memo.text = ""
    T_no.text = ""
    T_production.text = ""
End Sub

'**************************************
'*    功 能 描 述 :新增一条生产计划单并保存在数据库中
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub NewProductScheme()
    Dim ret As String
    

    
        ret = m_dao.NewProductScheme(m_recordset, _
                            Trim(T_production.Tag), _
                            Trim(T_name.text), _
                            Trim(T_specification.text), _
                            CInt(T_singleNum.text), _
                            CInt(T_totalNum.text), _
                            CDbl(T_costPrice.text), _
                            CDbl(T_totalMoney.text), _
                            CDate(T_makeBillDate.text), _
                            CDate(T_beginDate.text), _
                            CDate(T_finishDate.text), _
                            Trim(T_groupNo.text), _
                            Trim(T_memo.text), _
                            Trim(T_no.text), _
                            m_materialType)

End Sub
'**************************************
'*    功 能 描 述 :修改生产计划单处理函数
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub ModifyProductScheme()
    '
    Dim ret As Boolean
    

    
        ret = m_dao.ModifyProductScheme(m_recordset, _
                            Trim(T_production.Tag), _
                            Trim(T_name.text), _
                            Trim(T_specification.text), _
                            CInt(T_singleNum.text), _
                            CInt(T_totalNum.text), _
                            CDbl(T_costPrice.text), _
                            CDbl(T_totalMoney.text), _
                            CDate(T_makeBillDate.text), _
                            CDate(T_beginDate.text), _
                            CDate(T_finishDate.text), _
                            Trim(T_groupNo.text), _
                            Trim(T_memo.text), _
                            Trim(T_no.text), _
                            m_schemeId, _
                            m_materialType)

End Sub
'**************************************
'*    功 能 描 述 :根据ID找到生产计划单并显示相应信息
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Sub FindByIdRefresh()
    Dim ret As Boolean
    
    ret = m_dao.FindSchemeById(m_recordset, m_schemeId)
    ' 读出找到的生产计划单数据
    If ret Then
      With m_recordset
        T_name.text = Trim(.Fields("name"))
        T_no.text = Trim(.Fields("billNo"))
        T_specification.text = Trim(.Fields("specification"))
        T_singleNum.text = Trim(.Fields("singlenum"))
        T_totalNum.text = Trim(.Fields("totalnum"))
        T_costPrice.text = Trim(.Fields("costprice"))
        
        T_totalMoney.text = Trim(.Fields("totalmoney"))
        T_groupNo.text = Trim(.Fields("groupNo"))
        T_makeBillDate.text = Trim(.Fields("makeBillDate"))
        T_beginDate.text = Trim(.Fields("beginSchemeDate"))
        T_finishDate.text = Trim(.Fields("finishSchemeDate"))
        T_memo.text = Trim(.Fields("memo"))
        
        T_production.Tag = Trim(.Fields("productionid"))
        m_materialType = Trim(.Fields("materialType"))
      End With
    Else
        MainForm.g_msgText = "计划单编码不正确,请重新操作!"
        HMsgBox MainForm.g_msgText, 0, 1
        Unload Me
    End If
    
    m_recordset.Close
    ' 找到产品信息
    If T_production.Tag <> "" Then
        ret = m_bomDAO.FindByMaterial(m_recordset, T_production.Tag, m_materialType)
        
        If ret Then
            T_production.text = Trim(m_recordset.Fields("name"))
        End If
        
        m_recordset.Close
    End If
End Sub
'**************************************
'*    功 能 描 述 :新增一条生产计划单并保存在数据库中
'*    输 入 参 数 :无
'*    输 出 能 数 :无
'**************************************
Private Function Check() As Boolean
    Check = True

    If Trim(T_production.text) = "" Then
        Check = False
        MainForm.g_msgText = "你必须选择一个产品才能做生产计划单!"
        HMsgBox MainForm.g_msgText, 0, 1
        T_name.SetFocus
        Exit Function
    End If
    If Trim(T_singleNum.text) = "" Then
        Check = False
        MainForm.g_msgText = "请填定单件数!"
        HMsgBox MainForm.g_msgText, 0, 1
        T_singleNum.SetFocus
        Exit Function
    End If
    
    If Trim(T_name.text) = "" Then
        Check = False
        MainForm.g_msgText = "请填定单名称!"
        HMsgBox MainForm.g_msgText, 0, 1
        T_name.SetFocus
        Exit Function
    End If
    If Trim(T_specification.text) = "" Then
        Check = False
        MainForm.g_msgText = "请填产品规格!"
        HMsgBox MainForm.g_msgText, 0, 1
        T_specification.SetFocus
        Exit Function
    End If
    If Trim(T_totalNum.text) = "" Then
        Check = False
        MainForm.g_msgText = "请填定单总数量!"
        HMsgBox MainForm.g_msgText, 0, 1
        T_totalNum.SetFocus
        Exit Function
    End If
    
    If CDbl(Trim(T_totalNum.text)) <= 0 Then
        Check = False
        MainForm.g_msgText = "定单总数量不能小于零!"
        HMsgBox MainForm.g_msgText, 0, 1
        T_totalNum.SetFocus
        Exit Function
    End If
    
    If Trim(T_costPrice.text) = "" Then
        Check = False
        MainForm.g_msgText = "请填定单成本!"
        HMsgBox MainForm.g_msgText, 0, 1
        T_costPrice.SetFocus
        Exit Function
    End If
    If Trim(T_groupNo.text) = "" Then
        Check = False
        MainForm.g_msgText = "请填定单批号!"
        HMsgBox MainForm.g_msgText, 0, 1
        T_groupNo.SetFocus
        Exit Function
    End If
    If Trim(T_makeBillDate.text) = "" Then
        Check = False
        MainForm.g_msgText = "请填定单制定日期!"
        HMsgBox MainForm.g_msgText, 0, 1
        Exit Function
    End If
    If Trim(T_beginDate.text) = "" Then
        Check = False
        MainForm.g_msgText = "请填定单开始执行日期!"
        HMsgBox MainForm.g_msgText, 0, 1
        Exit Function
    End If
    If Trim(T_finishDate.text) = "" Then
        Check = False
        MainForm.g_msgText = "请填定单完成日期!"
        HMsgBox MainForm.g_msgText, 0, 1
        Exit Function
    End If

    If CDate(Trim(T_finishDate.text)) < CDate(Trim(T_beginDate.text)) Then
        Check = False
        MainForm.g_msgText = "完成日期不能小于开始日期!"
        HMsgBox MainForm.g_msgText, 0, 1
        Exit Function
    End If
    
    
End Function

Private Sub T_beginDate_GotFocus()
    Command2.Visible = True
End Sub

Private Sub T_beginDate_LostFocus()
    Command2.Visible = False
End Sub

Private Sub T_costPrice_Change()
    T_totalNum_Change
End Sub

Private Sub T_costPrice_KeyPress(KeyAscii As Integer)
    InputFieldLimit T_costPrice, 5, KeyAscii
End Sub

Private Sub T_finishDate_GotFocus()
    Command3.Visible = True
End Sub

Private Sub T_finishDate_LostFocus()
    Command3.Visible = False
End Sub

Private Sub T_production_GotFocus()
   Command1.Visible = True
End Sub

Private Sub T_production_LostFocus()
    Command1.Visible = False
End Sub

Private Sub T_singleNum_KeyPress(KeyAscii As Integer)
    InputFieldLimit T_singleNum, 4, KeyAscii
End Sub

Private Sub T_totalMoney_KeyPress(KeyAscii As Integer)
    InputFieldLimit T_totalMoney, 5, KeyAscii
End Sub

Private Sub T_totalNum_Change()
    On Error GoTo EXITSUB
    T_totalMoney.text = CDbl(T_totalNum.text) * CDbl(T_costPrice.text)
EXITSUB:
End Sub

Private Sub T_totalNum_KeyPress(KeyAscii As Integer)
    InputFieldLimit T_totalNum, 4, KeyAscii
End Sub

⌨️ 快捷键说明

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