How to get opening balance

  • Thread starter Thread starter Omi4u
  • Start date Start date
O

Omi4u

Guest
hi everyone

i was waiting for the reply... let me show u all my code or u can say an idea of ledger

this is my structure of ledger

[dbo].[ledgerreport](
[ledgerautonumber] [int] IDENTITY(1,1) NOT NULL,
[serialno] [varchar](50) NULL,
[accountiddr] [varchar](50) NULL,
[accountnamedr] [varchar](50) NULL,
[accountidcr] [varchar](50) NULL,
[accountnamecr] [varchar](50) NULL,
[dateledger] [date] NULL,
[voucherid] [varchar](50) NULL,
[debitamount] [decimal](18, 2) NULL,
[creditamount] [decimal](18, 2) NULL,
[description] [varchar](50) NULL,
[closingbalance] [decimal](18, 2) NULL,
[unit] [varchar](50) NULL

and below is my code im using


Try
con = New SqlConnection(appx.myconnection)
con.Open()
Dim cb2 As String = "insert into ledgerreport(serialno,dateledger,voucherid,debitamount,creditamount,description,closingbalance,unit,accountiddr,accountnamedr,accountidcr,accountnamecr) VALUES (@d100,@d101,@d102,@d103,@d104,@d105,@d106,@d107,@d108,@d109,@d110,@d111)"
cmd = New SqlCommand(cb2)
cmd.Connection = con
' Prepare command for repeated execution
cmd.Prepare()
' Data to be inserted
For Each row As DataGridViewRow In DataGridView1.Rows
If Not row.IsNewRow Then
cmd.Parameters.AddWithValue("@d100", row.Cells(0).Value) 'serial no
cmd.Parameters.AddWithValue("@d101", row.Cells(3).Value) 'dateledger
cmd.Parameters.AddWithValue("@d102", row.Cells(2).Value) 'voucher id
cmd.Parameters.AddWithValue("@d103", row.Cells(7).Value) 'debit amount
cmd.Parameters.AddWithValue("@d104", row.Cells(8).Value) 'credit amount
cmd.Parameters.AddWithValue("@d105", row.Cells(6).Value) 'description
cmd.Parameters.AddWithValue("@d106", row.Cells(13).Value) 'closing balance
cmd.Parameters.AddWithValue("@d107", row.Cells(1).Value) 'unit
cmd.Parameters.AddWithValue("@d108", row.Cells(4).Value) 'accountiddr
cmd.Parameters.AddWithValue("@d109", row.Cells(5).Value) 'accoutnamedr
cmd.Parameters.AddWithValue("@d110", AccountidcrTextEdit.Text) 'accountidcr
cmd.Parameters.AddWithValue("@d111", cashaccounttxtedit.Text) ' accountnamecr


cmd.ExecuteNonQuery()
cmd.Parameters.Clear()
End If
Next
con.Close()
Catch ex As Exception
MsgBox(ex.Message & " " & "Error Code : CPV-LG-002", vbOKOnly + vbCritical, "Error Code : CPV-LG-002")
End Try


now what im doing here.whenever user do a transection in cash payment, the ledger code save the details in sql table...and in report i use fields and parameters to generate report. but im not able to get the opening balance that is the closing balance of my last day report. here im facing issue. how i can get openingbalance using my above codes

Continue reading...
 
Back
Top