hi,
How do i delete the selected records at listview and textfile (which keep the record from listview) and at the same time show the total current balance at listview.
any guidance plz help.
Imports System.Data.OleDb.OleDbCommand
Imports System.Data.OleDb
Imports System.IO
Imports System
Imports System.Text
Imports System.Windows.Forms
Imports System.Console
Public Class Form1
Public Class frmPaymentSummary
Dim nTotlistrec As Integer
Dim bNextPage As Boolean
Dim bPrevPage As Boolean
Private valRounded As String
Private blnRoundedValue As Boolean = False
Private YesPressed, NoPressed As Integer
Private Sub frmPaymentSummary_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Visible = False
lblServiceCharge.Text = ServiceC
lblBillAmountValue.Text = dTotal
dTotal = 0
ServiceC = 0
lblSummary.Font = myFont1
Label5.Font = myFont
Label6.Font = myFont
lblPrevious.Font = myFont
lblNext.Font = myFont
ListView1.Font = myFont2
lblPrevious.Text = GetButtonText("Previous")
lblNext.Text = GetButtonText("Confirm")
lblSummary.Text = GetButtonText("Summary")
Label5.Text = GetButtonText("TotalPayable")
ListView1.View = View.Details
ListView1.CheckBoxes = False
ListView1.Columns.Add(GetButtonText("Number"), 50, HorizontalAlignment.Center)
ListView1.Columns.Add(GetButtonText("AgencyName"), 290, HorizontalAlignment.Center)
ListView1.Columns.Add(GetButtonText("AccountNo"), 130, HorizontalAlignment.Center)
ListView1.Columns.Add(GetButtonText("BillNo"), 130, HorizontalAlignment.Center)
ListView1.Columns.Add(GetButtonText("BillAmount1"), 130, HorizontalAlignment.Center)
ListView1.Columns.Add(GetButtonText("ServiceCharge1"), 130, HorizontalAlignment.Center)
ListView1.Columns.Add(GetButtonText("Total1"), 130, HorizontalAlignment.Center)
Application.DoEvents()
End Sub
Private Sub frmPaymentSummary_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
Dim aStr(8) As String
Try
GetFileContents()
lblBillAmountValue.Text = Format(dTotal, "#,###,##0.00")
lblServiceCharge.Text = Format(ServiceC, "#,###,##0.00")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub addListView(ByVal p1 As String, ByVal p2 As String, ByVal p3 As String, ByVal p4 As String, ByVal p5 As String, ByVal p6 As String)
Dim str(8) As String
Dim itm As ListViewItem
str(0) = ListView1.Items.Count + 1
str(1) = p1
str(2) = p2
str(3) = p3
str(4) = p4
str(5) = p5
str(6) = p6
'str(7) = p7
' str(5) = vbTrue
itm = New ListViewItem(str)
ListView1.Items.Add(itm)
End Sub
Public Sub GetFileContents()
'Try
Dim aStr(8) As String
Dim FILE_NAME As String = "C:\Documents and SettingsDesktop\BillPaymentRecords.txt"
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Do While objReader.Peek() <> -1
aStr = Split(objReader.ReadLine(), ";")
SESSION_NAME = aStr(0)
SESSION_ACCNO = aStr(1)
SESSION_BILLNO = aStr(2)
SESSION_BILLAMO = aStr(5)
SESSION_BILLINT = aStr(4)
dTotal += aStr(5) '.Replace("RM", "")
ServiceC += aStr(4) 'Replace("RM", "")
nTotlistrec = ListView1.Items.Count
If nTotlistrec < 10 Then
addListView(aStr(0), aStr(1), aStr(2), aStr(3), aStr(4), aStr(5))
End If
Loop
Else
MsgBox("File Does Not Exist")
End If
End Sub
Private Sub pnlNext_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlNext.MouseDown
pnlNext.BackgroundImage = My.Resources.Next1_Down
End Sub
Private Sub pnlNext_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlNext.MouseUp
pnlNext.BackgroundImage = My.Resources.Next1_Up
frmMakePayment.Show()
Me.Close()
End Sub
Private Sub pnlPre_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlPre.MouseDown
pnlPre.BackgroundImage = My.Resources.Pre1_Down
End Sub
Private Sub pnlPre_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlPre.MouseUp
pnlPre.BackgroundImage = My.Resources.Pre1_Up
If ButtonClick = "POS" Then
frmStep1_AgencyDirect.Show()
ElseIf ButtonClick = "OTHER" Then
frmStep2_AgencyDirect.Show()
End If
Me.Close()
End Sub
Private Sub PnlDelete_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PnlDelete.MouseDown
PnlDelete.BackgroundImage = My.Resources.POS_Btn_Down
End Sub
Private Sub PnlDelete_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PnlDelete.MouseUp
Try
PnlDelete.BackgroundImage = My.Resources.POS_Btn_Up
ListView1.SelectedItems(0).Remove()
'File.Delete("C:\Documents and SettingsDesktop\\Bill Payment\BillPaymentRecords.txt")
'File.DeleteListView(aStr(0), aStr(1), aStr(2), aStr(3), aStr(4), aStr(5)))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Label6_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label6.MouseUp
ListView1.SelectedItems(0).Remove()
End Sub
Private Sub ListView1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseUp
ListView1.Select()
End Sub
End Class
End Class