OpenNTF.org - Public Class Sales
My Links (Not logged in)
Code Bin Search
 
Hosted by Prominic.NET
Rate This Code
5 - brilliant stuff
4 - very nice
3 - average
2 - needs work
1 - bad
   OpenNTF Code Bin
About This Code
Brief Description:
Public Class Sales 
Rating:
Not Rated Yet 
Contributor:
Andrew Jones 
Category:
Lotusscript 
Type:
Miscellaneous 
Last Modified:
17 Jun 2002 
OpenNTF Disclaimer

All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.

Code / Description
Usage / Example
Public Class Sales

Private DivisionName As String
Private SalesAmount As Currency
Private ReturnsAmount As Currency
Private totalCount As Long
Property Set Division As String
DivisionName = Division
End Property
Property Get Division As String
Division = DivisionName
End Property
Property Set Sales As Currency
SalesAmount = SalesAmount + Sales
End Property
Property Get Sales As Currency
Sales = SalesAmount
End Property
Property Set Returns As Currency
ReturnsAmount = ReturnsAmount + Returns
End Property
Property Get Returns As Currency
Returns = ReturnsAmount
End Property
Property Get Count As Long
Count = totalCount
End Property
Property Set Count As Long
totalCount = totalCount + Count
End Property
End Class

Public oneFlag As Variant
Public twoFlag As Variant
Public threeFlag As Variant
Public fourFlag As Variant
Public fiveFlag As Variant
Public sixFlag As Variant
Public allFlag As Variant

Sub setFlags(passedDoc As NotesDocument)
oneFlag = False
twoFlag = False
threeFlag = False
fourFlag = False
fiveFlag = False
sixFlag = False
allFlag = False
Forall v In passedDoc.division
Select Case v
Case "One" : oneFlag = True
Case "Two" : twoFlag = True
Case "Three" : threeFlag = True
Case "Four" : fourFlag = True
Case "Five" : fiveFlag = True
Case "Six" : sixFlag = True
Case "All" : allFlag = True
End Select
End Forall
End Sub

Function setSearchString As String
Dim oneString As String, twoString As String, threeString As String
Dim fourString As String, fiveString As String, sixString As String
Dim orString As String
oneString = | (FIELD divisionName = "One") |
twoString = | (FIELD divisionName = "Two") |
threeString = | (FIELD divisionName = "Three") |
fourString = | (FIELD divisionName = "Four") |
fiveString = | (FIELD divisionName = "Five") |
sixString = | (FIELD divisionName = "Six") |
orString = " OR "
Dim FirstTime
If (allFlag) Then
setSearchString = oneString & orString & twoString & orString & threeString & orString & FourString & orString & fiveString & orString & sixString
Else
FirstTime = True
If (oneFlag) Then
setSearchString = oneString
FirstTime = False
End If
If (twoFlag) Then
If (FirstTime) Then
setSearchString = twoString
FirstTime = False
End If
setSearchString = setSearchString & orString & twoString
End If
If (threeFlag) Then
If (FirstTime) Then
setSearchString = threeString
FirstTime = False
End If
setSearchString = setSearchString & orString & threeString
End If
If (fourFlag) Then
If (FirstTime) Then
setSearchString = fourString
FirstTime = False
End If
setSearchString = setSearchString & orString & fourString
End If
If (fiveFlag) Then
If (FirstTime) Then
setSearchString = fiveString
FirstTime = False
End If
setSearchString = setSearchString & orString & fiveString
End If
If (sixFlag) Then
If (FirstTime) Then
setSearchString = sixString
FirstTime = False
End If
setSearchString = setSearchString & orString & sixString
End If
End If
End Function

Sub Click(Source As Button)
Dim uiw As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument, fedoc As NotesDocument
Set uidoc = uiw.CurrentDocument
Set fedoc = uidoc.Document
Dim dc As NotesDocumentCollection
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.CurrentDatabase
Set dc = db.AllDocuments
Dim searchString As String
If (fedoc.HasItem("division")) Then
Call setFlags(fedoc)
searchString = setSearchString
Call dc.FTSearch(|FIELD FORM = "salesRecord"|,0)
Call dc.FTSearch(searchString,0)
If (dc.Count > 0) Then
Dim salesArray() As Sales
For x = 1 To dc.Count
Set doc = dc.GetNthDocument(x)
If ((doc.HasItem("divisionName")) And (doc.HasItem("salesAmount"))) Then
If (x = 1) Then
Redim salesArray(0) As Sales
Set salesArray(0) = New Sales
salesArray(0).division = doc.divisionName(0)
salesArray(0).sales = doc.salesAmount(0)
salesArray(0).returns = doc.returnAmount(0)
salesArray(0).count = 1
Else
Found = False
For y = 1 To Ubound(salesArray)
If (salesArray(y).division = doc.divisionName(0)) Then
salesArray(y).sales = doc.salesAmount(0)
salesArray(y).returns = doc.returnAmount(0)
salesArray(0).count = 1
Found = True
End If
Next y
If (Found = False) Then
Redim Preserve salesArray(Ubound(salesArray) + 1) As Sales
Set salesArray(Ubound(salesArray)) = New Sales
salesArray(Ubound(salesArray)).division = doc.divisionName(0)
salesArray(Ubound(salesArray)).sales = doc.salesAmount(0)
salesArray(Ubound(salesArray)).returns = doc.returnAmount(0)
salesArray(Ubound(salesArray)).count = 1
End If
End If
End If
Next x
End If
If (Isarray(salesArray)) Then
Dim reportDoc As NotesDocument
Set reportDoc = db.CreateDocument
reportDoc.Form = "divisionReport"
reportTitle = Inputbox$("Please enter a title for the report")
For z = 1 To Ubound(salesArray)
valueString = valueString + Cstr(salesArray(z).sales) + Chr(10)
titleString = titleString + Cstr(salesArray(z).division) + Chr(10)
returnString = returnString + Cstr(salesArray(z).returns) + Chr(10)
Next z
Set valueItem = New NotesItem(reportDoc, "values", valueString)
Set labelItem = New NotesItem(reportDoc, "labels", titleString)
Set titleItem = New NotesItem(reportDoc, "title", reportTitle)
Set returnItem = New NotesItem(reportDoc, "returns", returnString)
titleItem.IsSummary = True
Call reportDoc.Save(True,True)
End If
End If
End Sub

 Comments

No documents found

 Add your comment!