阳光网驿-企业信息化交流平台【DTC零售连锁全渠道解决方案】

 找回密码
 注册

QQ登录

只需一步,快速开始

扫描二维码登录本站

手机号码,快捷登录

老司机
查看: 6287|回复: 0

[转帖] 一个工业单据插件开发实例

[复制链接]
  • TA的每日心情
    开心
    2019-3-4 11:49
  • 签到天数: 2 天

    [LV.1]初来乍到

    发表于 2008-3-25 15:03:25 | 显示全部楼层 |阅读模式
    Option Explicit
    Private WithEvents m_BillTransfer As k3BillTransfer.Bill
    Public Sub Show(ByRef o As Object)
    Set m_BillTransfer = o
    End Sub
    Private Sub m_BillTransfer_BeforeSave(ByVal bNew As Boolean, Return
    Code As Long)
    Dim vsEntrys As fpSpread
    Dim EntryCtl As Variant
    Dim vQty As Variant
    Dim i As Long
    Dim j As Long
    Dim sum As Double
    sum = 0
    EntryCtl = m_BillTransfer.EntryCtl
    Set vsEntrys = m_BillTransfer.BillForm.vsEntrys
    For i = 1 To UBound(m_BillTransfer.EntryCtl)
    If UCase(EntryCtl(i).FieldName) = "FQTY" Then
    Exit For
    End If
    Next
    For j = 1 To vsEntrys.MaxCols
    vsEntrys.GetText i, j, vQty
    sum = sum + vQty
    If vQty > 1000 Then
    MsgBox "单据分录的最大数量为1000,请将该分录拆分!"
    ReturnCode = -1
    Exit Sub
    ElseIf vQty <= 0 Then
    Exit For
    End If
    Next
    m_BillTransfer.SetSumGridText 1, i, sum
    Dim dict As KFO.Dictionary
    If m_BillTransfer.SaveVect.Size < 2 Then
    Set dict = New KFO.Dictionary
    dict("Added") = InputBox("请输入你要存储的附加数据", "Add", "附加
    数据")
    m_BillTransfer.SaveVect.Add dict
    Else
    m_BillTransfer.SaveVect.Item(2)("Added") = InputBox("请输入你要存
    储的附加数据", "Add", "附加数据")
    End If
    End Sub
    Private Sub m_BillTransfer_BeforGridLookUp(ByVal Row As Long, ByVal
    Col As Long, ByVal nLookUpClsID As Long, Cancel As Boolean)
    If nLookUpClsID = 7 Then
    MsgBox "单位查找被取消"
    Cancel = True
    End If
    End Sub
    Private Sub m_BillTransfer_BillInitialize()
    m_BillTransfer.AddUserMenuItem "计算器", "用户菜单"
    m_BillTransfer.AddUserMenuItem "记事本", "用户菜单"
    m_BillTransfer.AddUserMenuItem "录入数据", "用户菜单"
    End Sub
    Private Sub m_BillTransfer_EndBillFormActive()
    '/重新设置单据体的锁定状态,设置金额为不可编辑状态
    End Sub
    Private Sub m_BillTransfer_EndSave(ByVal BillNo As String)
    m_BillTransfer_EndBillFormActive
    End Sub
    Private Sub m_BillTransfer_HeadChange(ByVal CtlIndex As Long, ByVal
    Value As Variant, ByVal bNewBill As Boolean, Cancel As Boolean)
    Dim head As Variant
    head = m_BillTransfer.HeadCtl
    If InStr(head(CtlIndex).Caption, "购货单位") > 0 Then
    MsgBox "你更改了购货单位,这更改相应的物料和价格!"
    End If
    End Sub
    Private Sub m_BillTransfer_LoadBillEnd(ByVal ShowType As Long)
    Dim THeadCtl As Variant
    Dim i As Long
    If ShowType = 0 Then '/新增状态下,把制单人设为“张三”
    THeadCtl = m_BillTransfer.HeadCtl
    For i = 1 To UBound(THeadCtl)
    If UCase(THeadCtl(i).FieldName) = "FBILLERID" Then
    m_BillTransfer.head(i).text = "张三"
    Exit For
    End If
    Next
    End If
    End Sub
    Private Sub m_BillTransfer_UserMenuClick(ByVal Index As Long, ByVal
    Caption As String)
    '/用户在这实现菜单的响应
    Select Case Index
    Case 1
    Shell "D:\WINNT\System32\calc.exe", vbNormalFocus
    Case 2
    Shell "D:\WINNT\System32\notepad.exe", vbNormalFocus
    Case 3
    FatchData
    End Select
    End Sub
    Private Sub FatchData()
    Dim file As New CommonDialog
    Dim fs As New FileSystemObject
    Dim text As TextStream
    Dim strData As String
    Dim i As Long
    On Error GoTo HError
    file.ShowOpen
    Set text = fs.OpenTextFile(file.FileName, ForReading, False)
    i = 1
    While Not text.AtEndOfStream
    strData = text.ReadLine()
    If strData <> "" Then
    m_BillTransfer.SetGridText i, 5, strData
    m_BillTransfer.BillForm.InsertRow
    i = i + 1
    End If
    Wend
    HError:
    Set file = Nothing
    Set fs = Nothing
    End Sub
    楼主热帖
    启用邀请码注册,提高发帖质量,建设交流社区
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    快速回复 返回顶部 返回列表