Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1) Private Function testGetTotal(ByVal idEntities As Integer, ByVal RefDate As Date) As IQueryable(Of Tbl_Contract)
- Dim returnValue = From contract In db.Tbl_Contracts _
- Where (contract.EndDate >= RefDate And contract.NextDuesInvoice <= RefDate Or contract.NextDuesInvoice Is Nothing) _
- And (contract.NumMonthsPaid < contract.TermMonths) And (contract.idContractStatus = 1) And (contract.idEntity = idEntities) _
- Select contract
- Return returnValue.AsQueryable()
- End Function
- 2) Private Function TESTTHISFUNCTION(ByVal contract As Tbl_Contract) As Tbl_Transaction
- Dim brTrans As New BRTransaction
- Dim Membership As Tbl_ContractProduct
- Dim EndDateFromContract As DateTime
- For Each contract In testGetTotal(46, Date.Now()) ' Find ValidContract
- ' Cycle through valid contracts (loop)
- Dim taxes = brTrans.GetTaxesPercent(PublicProperties.userLoggedEntity.idEntity, contract.idContact)
- 'Dim MembProd = (From p In db.Tbl_Products Where p.idProduct = Membership.idProduct).Single
- Dim DepositSQL = (From m In db.Tbl_ContractProducts _
- Where m.idContract = contract.idContract _
- And m.IdContractRelType = Grav_ContractRelationshipType.Deposit).SingleOrDefault
- Dim Deposit As Decimal
- Deposit = 0
- 'If (MembProd.membershipExpierType = 1) Then
- ' EndDateFromContract = MembProd.expiryDate
- 'Else
- ' EndDateFromContract = Today.AddMonths(MembProd.membershipLength)
- 'End If
- ' Add new Contract
- db.MakeNewContract(PublicProperties.userLoggedEntity.idEntity, PublicProperties.userLoggedEntity.idEntity, contract.idContact, Date.Now, _
- PublicProperties.idContactUser, Date.Now, PublicProperties.idContactUser, _
- Grav_ContractStatus.Pending, EndDateFromContract, 0, False, False, False, taxes.LabelTax1, _
- taxes.LabelTax2, taxes.LabelTax3, taxes.idGLTax1, taxes.Tax2, taxes.idGLTax3, Deposit, 0, 0, 0, _
- taxes.Tax1, taxes.Tax2, taxes.Tax3, 0, 0, 0, 0, 0, ((contract.SubTotal - contract.Deposit) / contract.TermMonths), _
- 0, 0, 0, Nothing, Nothing, False, False, 0, 0, 0, Nothing, Nothing, 0, Nothing, Nothing, Nothing, Nothing, _
- Nothing, Nothing, False, Nothing, contract.EndDate, Nothing, Nothing, 0, 0, 0, False, 0, 0, False, _
- 0)
- Next contract ' End loop
- End Function
- And calling the function I do this:
- TESTTHISFUNCTION(CType(testGetTotal(46, Date.Now()), Tbl_Contract))
- but I get this error message after testgettotal function is completely executed
- Unable to cast object of type 'System.Data.Linq.DataQuery`1[SoDBLogic.Tbl_Contract]' to type 'SoDBLogic.Tbl_Contract'.
Add Comment
Please, Sign In to add comment