Public Class Form1 '***************************************************************** ' Programmer: Michele Davis ' Date Modified: Oct. 14, 2008 ' Purpose: The program allows to user to output employee number 'name type of employee, hours worked, and weekly pay, with totals 'per employee/store and grand total '***************************************************************** ' Pseudocode ' 'I. Input ' A. Open sales.txt ' B. Click on button 'II. Process ' A. Compute the paytype, payrate, weekly pay, total per worker/store 'and grand total 'III. Output ' A. Print the employee number, name, type of employee, hours worked, and 'wkly pay, then the totals per employee/store and grand total 'IV. End Dim sr As IO.StreamReader = IO.File.OpenText("Sales.txt") Dim storehold As String Dim emplyhold As String Dim strnmb, emplynmb, payrate, hrswrk, rlhr, rate, wklypy, storetotal, totalpay, temppay, storetmp, grandtotal, grandtemp, tempstore As Double Dim emplyname, paytype, paycat, type, cat, empyhold As String Dim frm1 As String = "{0,-10}{1,8}{2,10}{3,10}{4,10:C2}" Dim pagenum As Double = 1 Dim linecntr As Double = 1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load sr = IO.File.OpenText("Sales.txt") storehold = sr.ReadLine emplyhold = sr.ReadLine sr.Close() End Sub Private Sub btnrpt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnrpt.Click Call PrintpgHeaders() sr = IO.File.OpenText("Sales.txt") Do While sr.Peek <> -1 strnmb = sr.ReadLine emplyname = sr.ReadLine emplynmb = sr.ReadLine paytype = sr.ReadLine payrate = sr.ReadLine paycat = sr.ReadLine hrswrk = sr.ReadLine If paytype = "H" Then type = "Hourly" ElseIf paytype = "C" Then type = "Comission" End If If paytype = "H" And payrate = "1" Then 'convert pay type and pay rate into rl numbers rate = 5.5 ElseIf paytype = "H" And payrate = "2" Then rate = 9.99 ElseIf paytype = "H" And payrate = "3" Then rate = 15.25 ElseIf paytype = "C" And payrate = "1" Then rate = 500.0 ElseIf paytype = "C" And payrate = "2" Then rate = 1000.0 ElseIf paytype = "C" And payrate = "3" Then rate = 1500.0 End If If paycat = "F" Then ' convert f and t into ft/pt cat = "Full Time" ElseIf paycat = "P" Then cat = "Part Time" ElseIf paycat = "X" Then cat = "Commission" End If If hrswrk = 1 Then 'convert 1-4 into rl numbers rlhr = 20 ElseIf hrswrk = 2 Then rlhr = 25 ElseIf hrswrk = 3 Then rlhr = 30 ElseIf hrswrk = 4 Then rlhr = 40 End If If paytype = "H" Then wklypy = rate * rlhr ElseIf paytype = "C" Then wklypy = rate End If If emplyname <> emplyhold Then Call emplyBreak() End If totalpay = totalpay + wklypy If strnmb <> storehold Then Call storeBreak() Call PrintHeaders() End If lstrpt.Items.Add(String.Format(frm1, emplynmb, emplyname, type, rlhr, wklypy)) linecntr = linecntr + 1 If linecntr >= 55 Then pagenum = pagenum + 1 Call PrintpgHeaders() End If linecntr = linecntr + 1 Loop Call emplyBreak() Call storeBreak() Call grandbreak() sr.Close() End Sub Sub PrintHeaders() lstrpt.Items.Add("Store " & storehold) lstrpt.Items.Add("") lstrpt.Items.Add(String.Format(frm1, "Emp", "Emp", "Pay", "Hours", "Weekly")) lstrpt.Items.Add(String.Format(frm1, "ID", "Name", "Type", "Worked", "Pay")) lstrpt.Items.Add("") linecntr = linecntr + 5 End Sub Sub PrintpgHeaders() lstrpt.Items.Add("10/14/08 Page " & pagenum) lstrpt.Items.Add(String.Format(frm1, "Emp", "Emp", "Pay", "Hours", "Weekly")) lstrpt.Items.Add(String.Format(frm1, "ID", "Name", "Type", "Worked", "Pay")) lstrpt.Items.Add("") linecntr = linecntr + 4 End Sub Sub storeBreak() storetotal = storetmp 'use temp variables so numbers are not lost lstrpt.Items.Add(String.Format(frm1, "Store Total", "", "", "", storetotal)) lstrpt.Items.Add("") storehold = strnmb 'use temp variables so numbers are not lost tempstore = storetotal 'use temp variables so numbers are not lost grandtemp = grandtemp + storetotal 'use temp variables so numbers are not lost storetmp = 0 linecntr = linecntr + 2 End Sub Sub emplyBreak() lstrpt.Items.Add(String.Format(frm1, "Employee Total:", "", "", "", totalpay)) lstrpt.Items.Add("") emplyhold = emplyname 'use temp variables so numbers are not lost temppay = totalpay 'use temp variables so numbers are not lost storetmp = storetmp + totalpay 'use temp variables so numbers are not lost totalpay = 0 linecntr = linecntr + 2 End Sub Sub grandbreak() grandtotal = grandtemp lstrpt.Items.Add(String.Format(frm1, "Grand Total:", "", "", "", grandtotal)) lstrpt.Items.Add("") linecntr = linecntr + 2 End Sub End Class