Guest User

Untitled

a guest
May 21st, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.00 KB | None | 0 0
  1. 1) Private Function testGetTotal(ByVal idEntities As Integer, ByVal RefDate As Date) As IQueryable(Of Tbl_Contract)
  2.         Dim returnValue = From contract In db.Tbl_Contracts _
  3.                Where (contract.EndDate >= RefDate And contract.NextDuesInvoice <= RefDate Or contract.NextDuesInvoice Is Nothing) _
  4.                       And (contract.NumMonthsPaid < contract.TermMonths) And (contract.idContractStatus = 1) And (contract.idEntity = idEntities) _
  5.                Select contract
  6.  
  7.  
  8.         Return returnValue.AsQueryable()
  9.     End Function
  10.  
  11. 2) Private Function TESTTHISFUNCTION(ByVal contract As Tbl_Contract) As Tbl_Transaction
  12.  
  13.         Dim brTrans As New BRTransaction
  14.         Dim Membership As Tbl_ContractProduct
  15.         Dim EndDateFromContract As DateTime
  16.  
  17.         For Each contract In testGetTotal(46, Date.Now()) ' Find ValidContract
  18.            ' Cycle through valid contracts (loop)
  19.  
  20.             Dim taxes = brTrans.GetTaxesPercent(PublicProperties.userLoggedEntity.idEntity, contract.idContact)
  21.             'Dim MembProd = (From p In db.Tbl_Products Where p.idProduct = Membership.idProduct).Single
  22.            Dim DepositSQL = (From m In db.Tbl_ContractProducts _
  23.                           Where m.idContract = contract.idContract _
  24.                             And m.IdContractRelType = Grav_ContractRelationshipType.Deposit).SingleOrDefault
  25.            Dim Deposit As Decimal
  26.            Deposit = 0
  27.  
  28.            'If (MembProd.membershipExpierType = 1) Then
  29.             '    EndDateFromContract = MembProd.expiryDate
  30.            'Else
  31.             '    EndDateFromContract = Today.AddMonths(MembProd.membershipLength)
  32.            'End If
  33.             ' Add new Contract
  34.            db.MakeNewContract(PublicProperties.userLoggedEntity.idEntity, PublicProperties.userLoggedEntity.idEntity, contract.idContact, Date.Now, _
  35.                               PublicProperties.idContactUser, Date.Now, PublicProperties.idContactUser, _
  36.                               Grav_ContractStatus.Pending, EndDateFromContract, 0, False, False, False, taxes.LabelTax1, _
  37.                               taxes.LabelTax2, taxes.LabelTax3, taxes.idGLTax1, taxes.Tax2, taxes.idGLTax3, Deposit, 0, 0, 0, _
  38.                               taxes.Tax1, taxes.Tax2, taxes.Tax3, 0, 0, 0, 0, 0, ((contract.SubTotal - contract.Deposit) / contract.TermMonths), _
  39.                               0, 0, 0, Nothing, Nothing, False, False, 0, 0, 0, Nothing, Nothing, 0, Nothing, Nothing, Nothing, Nothing, _
  40.                               Nothing, Nothing, False, Nothing, contract.EndDate, Nothing, Nothing, 0, 0, 0, False, 0, 0, False, _
  41.                               0)
  42.  
  43.        Next contract  ' End loop
  44.     End Function
  45.  
  46.  
  47. And calling the function I do this:
  48.  
  49.    TESTTHISFUNCTION(CType(testGetTotal(46, Date.Now()), Tbl_Contract))
  50.  
  51. but I get this error message after testgettotal function is completely executed
  52.  
  53. 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