mardi 5 mai 2015

Proper way to use a database class

I've been searching for this for a little while now and cannot seem to find a way to accomplish my goal.

First, what I'm currently trying to code is a ticketing app for our IT department to use, mostly to help us keep track of what has and hasn't been done to different machines and some people that may need further training in the software that is used on site. I have a few tables created to keep tracking of work performed, issues, and any relevant notes. The final product will be more than a ticketing system, but a somewhat comprehensive IT support app.

My goal in the use is to have the tech "sign in" to the app by providing his/her username and password to our database system. From there the tech's permissions will be loaded as to what a tech can and can't do with tickets. When the tech would like to view tickets or edit tickets I want the app to load any relevant tickets (i.e. open tickets, closed tickets, PC tickets, printer tickets,...etc.).

I have a ticket class that contains all of the properties that are stored within the database, but my question is how to properly link the first sign on information to the ticket class.

For example in my class I have something like:

    public class ticket
    {
         public int TicketNumber {get;set;}
         public string Tech {get;set;}
         public string Category {get;set;}
         public string ReportedBy {get;set;}

         public void Save()
         {
            //Code to update record in DB
         }

         public void Create()
         {
            //Code to add a new record to DB
         }
     }

So, how do I properly get the class to where I can add the proper user name and password to this to include the tech's user name and password? I've had similar projects working before, but I have pretty much always used another person's user name and password hard coded. For this I would not want someone else using the application to be changing any of the ticket information if their user name and password was not valid for these tables.

Sorry for being wordy, but wanted to provide a basic look at what the app is in case someone has a better idea. I am open to suggestions especially on proper ways to pass the sign on information from app to class then data back to app.

The database is an iSeries. We use the IBM iSeries 32-bit ODBC driver to connect from Windows, if this helps. Most of the coding will be done in C# using Visual Studio 2013.

Thank you for any help.

Aucun commentaire:

Enregistrer un commentaire