Hey I need some help. I cant figure out whats going on. I'm working on a Restaurant Management System, and I can create an employee, but then when I try to create another after I created one, it wont work. My Post Tools aint working so I'm gonna wing it on the CODE Tags. So sorry if it's messy. Maybe big_k can wrap em up till I figure out my problem. Here is the code that saves the employee info to file, and the code to show a message box if that employee number file already exists.
Sub Save() File.WriteAllText(My.Application.Info.DirectoryPath & "\" & number & ".emp", _ "-Employee Name Info-:" + vbCrLf _ & first + " " & middle + " " & last + vbCrLf _ & "-Employee Address Info-:" + vbCrLf _ & address + vbCrLf & city + vbCrLf & state + vbCrLf & zip + vbCrLf _ & "-Employee Info-:" + vbCrLf _ & bday + vbCrLf & hphone + vbCrLf & cphone + vbCrLf _ & "-Employee Social Security Number-:" + vbCrLf _ & ssn) managercp.txtfirst.Text = "" managercp.txtmiddle.Text = "" managercp.txtlast.Text = "" managercp.txtaddress.Text = "" managercp.txtcity.Text = "" managercp.txtstate.Text = "" managercp.txtzip.Text = "" managercp.txtbday.Text = "" managercp.txthome.Text = "" managercp.txtcell.Text = "" managercp.txtssn.Text = "" managercp.txtnumber.Text = "" End Sub Sub EmpExists() MsgBox("Employee File with that number already exists. Please specify a new number, or delete the existing Employee File.", _ MsgBoxStyle.Critical, "Employee File Error") End Sub Here is my code for the Save Employee Button:
Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Click If My.Computer.FileSystem.FileExists(My.Application.Info.DirectoryPath & "\" & txtnumber.Text & ".emp") Then Employee.EmpExists() Else Employee.Save() End If End Sub
Like I said everything would work, if I only wanted to create one employee file. But it wont let me write to another file. When I click save, it erases the text boxes, and if I try to create a file with a duplicate employee number, it handle the error. It just wont create the file. I typed in my info for all the info i needed, clicked save, the text was "" in the textboxes, but no file was created. Am I missing somehtign in my code, guess I've been looking at it for the past hour and a half trying to see it, but i don't. Either I'm tired, or I can't program. I'll let yall be the judge of that. But just help me, if ya can. Thanks