2014-09-02 3 views
0

그래서 SQL을 통해 데이터를 검색하고 명령문 페이지를 찾습니다. 고객, 날짜, 거래, 직불, 신용 및 잔액 항목이 있습니다. 이제 신용 및 대변이 아닌 거래의 경우 표시되지 않습니다.SQL이 데이터를 검색/표시하지 않습니다.

예 : - 당신은 크레딧이 표시되지 않는 볼 수 있습니다 위 http://oi57.tinypic.com/16m1yeq.jpg

확인 이미지. 표시되지 않는 이유에 대한 문제가있는 경우 도와주세요! "nDrTotal"을 수정하는 코드에 뭔가가 있다는 것을 알고 있습니다. & nCrTotal

고마워요! 질문은 ... 음수 금액이 차변 테이블에 표시되지 않는 이유는 무엇입니까?

Function ApplyStatementDetails(ByVal sContent As String, ByVal sClientID As String, ByVal sDate As String, ByVal sSection As String) As String 
    Dim sSQL As String, sOut As String, rsStatement As SqlDataReader, sHTML As String = "", iLines As Integer, iCount As Integer 
    Dim nInvTotal As Double, n90Days As Double = 0, n60Days As Double = 0, n30Days As Double = 0, nCurrent As Double = 0, dCompareDate As Date 
    Dim nBalance As Double = 0 

    sOut = ApplyCompanyDetails(sContent) 

    'response.write sSQl: response.end 
    rsStatement = New SqlCommand(sSQL, cnStatemnt).ExecuteReader 

    Dim bFirst As Boolean = True, sClient As String = "", sAddress As String = "" 
    Dim nDRTotal As Double = 0, nCRTotal As Double = 0, nPaymentsAlloc As Double = 0 
    Do While rsStatement.Read 
     If bFirst Then 
      iCount = 0 
      sClient = EmptyIfNull(rsStatement("Company")) 
      If sClient = "" Then sClient = EmptyIfNull(rsStatement("Salutation")) 
      sAddress = DesignAddress(rsStatement("Address1"), rsStatement("Address2"), rsStatement("Address3"), rsStatement("Address4"), rsStatement("Postcode")) 
      sOut = Replace(sOut, "$$Client_ID$$", sClientID) 
      sOut = Replace(sOut, "$$Client_Name$$", nbspIfEmpty(sClient)) 
      sOut = Replace(sOut, "$$Client_Address$$", sAddress) 
      If Request.QueryString("date") <> "" Then 
       sOut = Replace(sOut, "$$Statement_Date$$", Request.QueryString("date")) 
      Else 
       sOut = Replace(sOut, "$$Statement_Date$$", sDate) 
      End If 
      bFirst = False 
     End If 
     nDRTotal = Math.Round(ZeroIfNull(rsStatement("InvoicesPH")) + ZeroIfNull(rsStatement("InvoicesContract")) + ZeroIfNull(rsStatement("InvoicesFE")) + ZeroIfNull(rsStatement("InvoicesCMP")), 2) 
     If nDRTotal = 0 Then 
      nCRTotal = ZeroIfNull(rsStatement("Payments")) 
      nPaymentsAlloc = -ZeroIfNull(rsStatement("CreditsAlloc")) 
      nInvTotal = Math.Round(-nPaymentsAlloc - nCRTotal, 2) 
     Else 
      nCRTotal = -ZeroIfNull(rsStatement("Payments")) + ZeroIfNull(rsStatement("Adjustments")) + ZeroIfNull(rsStatement("Credits")) - ZeroIfNull(rsStatement("CreditsAlloc")) 
      nPaymentsAlloc = 0 
      Select Case rsStatement("Type") 
       Case "TR", "CH", "CA", "CC" 
        nPaymentsAlloc = GetPaymentsAlloc(rsStatement("InvoiceNo")) 
      End Select 
      nInvTotal = Math.Round(ZeroIfNull(rsStatement("InvoicesPH")) + ZeroIfNull(rsStatement("InvoicesContract")) + ZeroIfNull(rsStatement("InvoicesFE")) + ZeroIfNull(rsStatement("InvoicesCMP")) - ZeroIfNull(rsStatement("Payments")) + ZeroIfNull(rsStatement("Adjustments")) + ZeroIfNull(rsStatement("Credits")) - ZeroIfNull(rsStatement("CreditsAlloc")) + nPaymentsAlloc, 2) 
     End If 
     '    
     If nInvTotal <> 0 Then 
      iLines = iLines + 10 
      sHTML = sHTML & "<tr><td class=""data"" align=""center"">" & FormatDate(rsStatement("InvoiceDate"), sDateFormat) & "</td>" & _ 
      "<td class=""data"">" & FormatRef(rsStatement("Type"), rsStatement("InvoiceNo")) & "</td>" & _ 
      "<td class=""data"" align=""right"">" & ShowValue(nDRTotal, rsStatement("Type"), "DR") & "</td>" & _ 
      "<td class=""data"" align=""right"">" & ShowValue(nCRTotal, "CR", "CR") & "</td>" & _ 
      "<td class=""data"" align=""right"">" & ShowValue(nInvTotal, rsStatement("Type"), "TOTAL") & "</td></tr>" 
      '"<td class=""data"" align=""right"">" & ShowValue(nDRTotal + nCRTotal + nPaymentsAlloc, rsStatement("Type"), "TOTAL") & "</td></tr>"    

      dCompareDate = rsStatement("InvoiceDate") 

      ' 12/11/13 changed statement ageing to days base for statements dated mid-month MB 
      If DateDiff("d", dCompareDate, CDate(sDate)) >= 90 Then 
       n90Days = n90Days + nInvTotal 
      ElseIf DateDiff("d", dCompareDate, CDate(sDate)) >= 60 Then 
       n60Days = n60Days + nInvTotal 
      ElseIf DateDiff("d", dCompareDate, CDate(sDate)) >= 30 Then 
       n30Days = n30Days + nInvTotal 
      Else 
       nCurrent = nCurrent + nInvTotal 
      End If 
     End If 
    Loop 

    sOut = Replace(sOut, "$$Statement_Data$$", sHTML) 
    sOut = Replace(sOut, "$$90Days_Amount$$", ShowBalance(n90Days)) 
    sOut = Replace(sOut, "$$60Days_Amount$$", ShowBalance(n60Days)) 
    sOut = Replace(sOut, "$$30Days_Amount$$", ShowBalance(n30Days)) 
    sOut = Replace(sOut, "$$Current_Amount$$", ShowBalance(nCurrent)) 
    sOut = Replace(sOut, "$$Total_Amount$$", ShowBalance(n90Days + n60Days + n30Days + nCurrent)) 
    rsStatement.Close() : rsStatement = Nothing 

    If sSection <> "" Then 
     ApplyStatementDetails = GetDocumentSection(sOut, "all") & GetDocumentSection(sOut, sSection) 
    Else 
     ApplyStatementDetails = sOut 
    End If 
End Function 
+0

질문의 형식을 지정하십시오. 또한 인라인 SQL 대신 SP를 사용하지 마십시오 – Seminda

+0

@Seminda 위의 질문에 – user3566985

+0

사용자 입력 신뢰와 같은 몇 가지 보안 취약점이 있습니다 : 'Out = Replace (sOut, "$$ Statement_Date $$", Request.QueryString ("date"))' – ErikE

답변

0

이 코드는 더 VB.Net보다는 VBScript를 보이는 - 여기가 데이터를 가져 오는 위치를 내 코드입니다. VB.Net은 매우 다르며 VB.Net을 사용할 때 vbscript에서 배운 많은 규칙이 더 이상 적합하지 않습니다.

방법을 읽고, 나는이 상단 참조 :

Dim sSQL As String 

이에 의해 곧 이어 :

어디 사이에
rsStatement = New SqlCommand(sSQL, cnStatemnt).ExecuteReader 

그러나 이제까지 sSQL에 할당 된 값입니다. 빈 SQL 문자열을 실행 중입니다.

+0

오래 전부터 SQL 문을 게시물에서 삭제했는데 SQL 문과 관련이 없다고 생각합니다. 나는 SQL의 정의를 잘한다. 계정의 신용이 음수 일 때 테이블에 표시되지 않는다. – user3566985

관련 문제