-
-
-
Private WithEvents m_BillInterface As BillEvent
-
-
Public Sub Show(ByVal oBillInterface As Object)
-
-
-
-
Set m_BillInterface = oBillInterface
-
-
End Sub
-
-
Private Sub Class_Terminate()
-
-
-
-
Set m_BillInterface = Nothing
-
-
End Sub
Here I mainly write down an event that starts when a field value in the form header changes.
Here, there are several questions that need to be considered:
1. How does the value change event of the form trigger?
Change events of BillEvent objects can be triggered, for example:
-
Private Sub m_BillInterface_Change(ByVal <u>dct</u> As KFO.IDictionary, ByVal dctFld As KFO.IDictionary, ByVal Col As Long, ByVal Row As Long, Cancel As Boolean)
2. After obtaining the data dictionary, how do you know whether the form value changes or the form value changes?
-
Select Case dct.Value("Fpage")
-
Case 1
-
.......
-
End Select
Case 1 represents the header and case 2 represents the body (at present, this is only my guess, not authoritative, I do not know where to follow this information, if a friend knows it, also tell me).
3. How do you determine which field value change triggered the change of form value when it started?
-
If UCase(dct.Value("FFieldName")) = UCase("FBase") Then
-
.....
-
End If
dct.Value("FFieldName") can get the key fields of the control on the form, and I guess where I know it, but I don't know why. But it works.
UCase: Converts strings to uppercase. As for VB, I am still a beginner, so these basic knowledge points are still written at the beginning.
4. How to print the output information in the console for debugging or other purposes?
-
Debug.Print "Input the data you want to output......"
5. In the development of form plug-in, how to get data through SQL statements?
-
strSQL = "Select item.FNumber FNumber,item.FName FName,Scph,mu1.FNumber DhslUnit,Dhsl,mu2.FNumber ScslUnit,Scsl,YwgCount,isnull(JhDate,'') JhDate,Remark,FComboBox " & _
-
"From t_BOS200000035 bos " & _
-
"Join t_BOS200000035Entry2 bosEntry " & _
-
"On bos.FID = bosEntry.FID " & _
-
"Join t_Icitem item " & _
-
"On bosEntry.Hpdh = item.FItemID " & _
-
"Join t_MeasureUnit mu1 " & _
-
"On mu1.FMeasureUnitID = bosEntry.DhslUnit " & _
-
"Join t_MeasureUnit mu2 " & _
-
"On mu2.FMeasureUnitID = bosEntry.ScslUnit " & _
-
"Where bos.FBase = " & strCustomer
-
-
Debug.Print strSQL
-
-
Set rs = m_BillInterface.K3Lib.GetData(strSQL)
Using K3Lib.GetData("sql statement") you can get the result set after querying.
6. How to empty the data in the table?
-
For i = 1 To m_BillInterface.Data("Page2").UBound Step 1
-
m_BillInterface.RemoveRow False, 2, 1
-
Next
7. How to assign values to tables or insert data sets into tables?
-
j = 1
-
Do While Not rs.EOF
-
m_BillInterface.InsertNewRowAndFill 2, j, _
-
"FBase1", rs.Fields("FNumber").Value, _
-
"FText1", rs.Fields("Scph").Value, _
-
"FBase2", rs.Fields("DhslUnit").Value, _
-
"FQty", rs.Fields("Dhsl").Value, _
-
"FBase3", rs.Fields("ScslUnit").Value, _
-
"FQty1", rs.Fields("Scsl").Value, _
-
"FInteger", rs.Fields("YwgCount").Value, _
-
"FNOTE", rs.Fields("Remark").Value, _
-
"FDate2", rs.Fields("JhDate").Value, _
-
"FComboBox", rs.Fields("FComboBox").Value
-
rs.MoveNext
-
j = j + 1
-
Loop
InsertNewRowAndFill function
Insert a new row in the multi-entry document body and fill in the data.
grammar
Object.InsertNewRowAndFill (nPage As Long, nRow As Long, ParamArray vFieldsData() As Variant)
Notes
1. The parameter nRow must be a valid line number.
Namely: must be greater than or equal to 1, less than the largest row of document entries; must be continuous with the row of existing data.
For example, in order to add new lines and insert data in line 3 of a document entry, the first step is to confirm that the maximum line of a document entry is greater than 3, and the second is a single line.
The second line of the volume entry requires data.
2. Variable parameter vFieldsData format is:
[Field 1 Key Name, Value of Field 1], [Field 2 Key Name, Value of Field 2], [... ] [Key name of field n, value of field n]
Key field names can be found from the following, which is what I currently think of as a method:

You can find it in the drop-down list in the properties window.
8. The key code of the above example:
-
Private Sub m_BillInterface_Change(ByVal dct As KFO.IDictionary, ByVal dctFld As KFO.IDictionary, ByVal Col As Long, ByVal Row As Long, Cancel As Boolean)
-
-
Dim strSQL As String, i As Integer, j As Integer
-
Dim rs As ADODB.Recordset
-
Dim Fnumber As String
-
-
Dim strCustomer As String
-
Select Case dct.Value("Fpage")
-
Case 1
-
If UCase(dct.Value("FFieldName")) = UCase("FBase") Then
-
-
strCustomer = m_BillInterface.GetFieldValue("FBase", -1, Enu_ValueType_FFLD)
-
strSQL = "Select item.FNumber FNumber,item.FName FName,Scph,mu1.FNumber DhslUnit,Dhsl,mu2.FNumber ScslUnit,Scsl,YwgCount,isnull(JhDate,'') JhDate,Remark,FComboBox " & _
-
"From t_BOS200000035 bos " & _
-
"Join t_BOS200000035Entry2 bosEntry " & _
-
"On bos.FID = bosEntry.FID " & _
-
"Join t_Icitem item " & _
-
"On bosEntry.Hpdh = item.FItemID " & _
-
"Join t_MeasureUnit mu1 " & _
-
"On mu1.FMeasureUnitID = bosEntry.DhslUnit " & _
-
"Join t_MeasureUnit mu2 " & _
-
"On mu2.FMeasureUnitID = bosEntry.ScslUnit " & _
-
"Where bos.FBase = " & strCustomer
-
Debug.Print strSQL
-
-
Set rs = m_BillInterface.K3Lib.GetData(strSQL)
-
For i = 1 To m_BillInterface.Data("Page2").UBound Step 1
-
m_BillInterface.RemoveRow False, 2, 1
-
Next
-
-
j = 1
-
Do While Not rs.EOF
-
-
m_BillInterface.InsertNewRowAndFill 2, j, _
-
"FBase1", rs.Fields("FNumber").Value, _
-
"FText1", rs.Fields("Scph").Value, _
-
"FBase2", rs.Fields("DhslUnit").Value, _
-
"FQty", rs.Fields("Dhsl").Value, _
-
"FBase3", rs.Fields("ScslUnit").Value, _
-
"FQty1", rs.Fields("Scsl").Value, _
-
"FInteger", rs.Fields("YwgCount").Value, _
-
"FNOTE", rs.Fields("Remark").Value, _
-
"FDate2", rs.Fields("JhDate").Value, _
-
"FComboBox", rs.Fields("FComboBox").Value
-
rs.MoveNext
-
j = j + 1
-
Loop
-
End If
-
End Select
-
-
End Sub
How does 9.K3 BOS call stored procedures?
-
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Proc_K3_ProductionOrdersByCustomer]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
-
drop procedure [dbo].[Proc_K3_ProductionOrdersByCustomer]
-
GO
-
-
-
-
-
-
-
CREATE PROCEDURE Proc_K3_ProductionOrdersByCustomer
-
@strCustomer int
-
AS
-
Select item.FNumber FNumber,item.FName FName,Scph,mu1.FNumber DhslUnit,Dhsl,mu2.FNumber ScslUnit,Scsl,YwgCount,isnull(JhDate,'') JhDate,Remark,FComboBox
-
From t_BOS200000035 bos
-
Join t_BOS200000035Entry2 bosEntry
-
On bos.FID = bosEntry.FID
-
Join t_Icitem item
-
On bosEntry.Hpdh = item.FItemID
-
Join t_MeasureUnit mu1
-
On mu1.FMeasureUnitID = bosEntry.DhslUnit
-
Join t_MeasureUnit mu2
-
On mu2.FMeasureUnitID = bosEntry.ScslUnit
-
Where bos.FBase = @strCustomer
-
GO
-
-
exec Proc_K3_ProductionOrdersByCustomer 878
Called in Bos as follows:
-
strSQL = "exec Proc_K3_ProductionOrdersByCustomer " & strCustomer
-
-
Set rs = m_BillInterface.K3Lib.GetData(strSQL)
Personally, I understand that statements passed in by m_BillInterface.K3Lib.GetData() can be executed in GetData statements as long as they are executable under the query analyzer.