hi,
Below is my code for DELETE button. What i want is if the user select the transaction from the listview and press the DELETE button it must be able to delete the transaction from listview and text file(temporary log file) which i keep all the transaction record. At the same time the list view must able show the total current balance from the deleted trnsaction.
The problem is my code just do function to delete the transaction from list view but it does not delete the record form text file and the total amount till the same as it is....
Please guide me base on my code.
PLEASE HELP !!! TQ
Private Sub PnlDelete_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PnlDelete.MouseUp
PnlDelete.BackgroundImage = My.Resources.BtnUp
Try
'Dim stringToFind As String = ListView1.SelectedItems(0)
Dim stringToFind As String = ListView1.SelectedItems(0).SubItems(0).Text & ";" _
& ListView1.SelectedItems(0).SubItems(1).Text & ";" _
& ListView1.SelectedItems(0).SubItems(2).Text & ";" _
& ListView1.SelectedItems(0).SubItems(3).Text & ";" _
& ListView1.SelectedItems(0).SubItems(4).Text
PnlDelete.BackgroundImage = My.Resources.POS_Btn_Up
ListView1.SelectedItems(0).Remove()
Dim line As String
Dim input As StreamReader
Dim strFile As New ArrayList
input = File.OpenText("C:\Program Files\POS\Autopay Terminal\BillPaymentRecords.txt")
While input.Peek <> -1
line = input.ReadLine
If Not line.Contains(stringToFind) Then
strFile.Add(line)
End If
End While
input.Close()
If File.Exists("C:\Program Files\POS\Autopay Terminal\BillPaymentRecords.txt") Then
File.Delete("C:\Program Files\POS\Autopay Terminal\BillPaymentRecords.txt")
End If
Dim writer As New StreamWriter("C:\Program Files\POS\Autopay Terminal\BillPaymentRecords.txt", True)
For Each item As String In strFile
writer.WriteLine(item)
Next
writer.Flush()
writer.Close()
GetFileContents()
lblBillAmountValue.Text = Format(dTotal, "#,###,##0.00")
lblServiceCharge.Text = Format(ServiceC, "#,###,##0.00")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub