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