home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 February / PCWK0297.iso / lotus / english / lotus036.dsk / AMORTIZE.MPR / SCRIPT / ApproachDoc / Amortization / Body / butCreateAmort.s (.txt) < prev    next >
Null Bytes Alternating  |  1995-11-12  |  5KB  |  69 lines

  1. '++LotusScript Development Environment:2:5:(Options):0:66
  2.  
  3. '++LotusScript Development Environment:2:5:(Forward):0:1
  4. Declare Sub Click(Source As Button, X As Long, Y As Long, Flags As Long)
  5.  
  6. '++LotusScript Development Environment:2:5:(Declarations):0:2
  7.  
  8. '++LotusScript Development Environment:2:2:BindEvents:1:129
  9. Private Sub BindEvents(Byval Objectname_ As String)
  10.     Static Source As BUTTON
  11.     Set Source = Bind(Objectname_)
  12.     On Event Click From Source Call Click
  13. End Sub
  14.  
  15. '++LotusScript Development Environment:2:2:Click:1:12
  16. Sub Click(Source As Button, X As Long, Y As Long, Flags As Long)
  17.     Dim con As New connection
  18.     Dim QryLoan As New Query
  19.     Dim QryPayment As New Query
  20.     Dim RsLoan As New resultset
  21.     Dim RsPayment As New resultset
  22.     If source.startyear.text <> "" And source.initialamountofloan.text <> "" Then
  23.         If  con.connectto ("dbase IV") Then
  24.             Set QryPayment.connection=con
  25.             Set QryLoan.connection=con
  26.             QryPayment.tablename=currentdocument.path+"payment.dbf"
  27.             QryLoan.tablename=currentdocument.path+"loan.dbf"
  28.             Set RsPayment.query=QryPayment
  29.             Set RsLoan.query=QryLoan    
  30.             LoanNumberVariable=source.loan_no.text
  31.             QryPayment.sql="select * from """+QryPayment.tablename+""""+" WHERE Loan_no = "+LoanNumberVariable
  32.             If (RsPayment.execute) Then
  33.                 If (RsLoan.execute) Then
  34.                     Createmessage
  35.                     currentwindow.repaint
  36.                     If RsPayment.numrows<1 Then        
  37.                         BalanceVariable=source.InitialAmountofLoan1.text
  38.                         CummulativeInterest=0
  39.                         For i=1 To Val(source.number~ of~ payments.text)    
  40.                             RsPayment.addrow
  41.                             RsPayment.setvalue "Loan_no",LoanNumberVariable
  42.                             RsPayment.setvalue "BEGBAL",BalanceVariable
  43.                             interestamount=RsPayment.getvalue("BEGBAL")*((Val(source.interestrate.text))/1200)
  44.                             PaymentVariable=source.Payment_amount1.text
  45.                             PrinPaid=PaymentVariable-interestamount
  46.                             NewBalance=BalanceVariable-PrinPaid
  47.                             Smonth=source.startmonth.text
  48.                             Syear=source.startyear.text
  49.                             RsPayment.setvalue "Pay_Date",Datenumber(syear,smonth+(i-1),1)
  50.                             RsPayment.setvalue "BEGBAL",Newbal
  51.                             RsPayment.setvalue "Loan_no",LoanNumberVariable
  52.                             CummulativeInterest=CummulativeInterest+InterestAmount
  53.                             RsPayment.setvalue "Cumm_Int",CummulativeInterest
  54.                             RsPayment.updaterow
  55.                             BalanceVariable=NewBalance
  56.                         Next i
  57.                         Set a=source.txtCreateMessage
  58.                         Delete a
  59.                     Else
  60.                         Messagebox"You must delete the current amortization schedule in order to create a new one.  If you would like to leave this schedule and creat another, choose 'Create a New Customer Record'"                    
  61.                         Set a=source.txtCreateMessage
  62.                         Delete a                    
  63.                     End If
  64.                 End If
  65.             End If
  66.         End If
  67.         currentapplication.applicationwindow.domenucommand(IDM_refresh)
  68.     End If    
  69. End Sub