I have an application with a Login form.
Right now, I have:
Public EmpID as Integer
setting the value in a module called Settings.vb.
When the user logs in, the Employee ID is grabbed from the database and assigned to EmpID. I can then use that variable in any form in my application. The issue is, maybe I need the Employee's name or birthday or security level. Each of those would need to be set in the module as a variable and would be assigned at login time - or I would take the EmpID and a new call would need to be made to the database on the forms that need the extra data.
It seems to me, an easier way would be to create a class called Employee. It would have all the properties of an Employee, and maybe methods such as ClockIn and ClockOut.
An instance of the Employee class could be instantiated with the Login form and destroyed upon logout or application exit.
However, I don't know how to do this and keep the instance in scope across all the forms. I mean, I suppose I could use this on frmLogin.vb:
Public CurrentEmp as New Employee(EmpID)
and then refer to it as frmLogin.CurrentEmp in other forms, but it seems like there should be a better way.
It would be nice just to refer to the instance as CurrentEmp. Also, if the login form is closed after the login is complete, the use of the instance goes away, doesn't it?
I hope this question makes sense.
Thanks for the help!!!