正确使用数据库类的方法(Proper way to use a database class)

编程入门 行业动态 更新时间:2024-10-27 06:31:51
正确使用数据库类的方法(Proper way to use a database class)

我现在一直在寻找这个,但似乎无法找到实现目标的方法。

首先,我目前正在尝试编写的是我们的IT部门使用的票务应用程序,主要是帮助我们跟踪不同机器和某些可能需要进一步培训的人员在网站上使用。 我创建了一些表来跟踪所执行的工作,问题和任何相关的注释。 最终产品将不仅仅是一个票务系统,而是一个有点全面的IT支持应用程序。

我的目标是让技术人员通过向我们的数据库系统提供他/她的用户名和密码来“登录”应用程序。 从那里开始,技术人员的权限将被加载为技术可以和不能使用门票。 当技术人员想要查看门票或编辑门票时,我希望应用程序加载任何相关的门票(即打开门票,关闭门票,PC门票,打印机门票等等)。

我有一个票证类,其中包含存储在数据库中的所有属性,但我的问题是如何正确地将第一个登录信息链接到票证类。

例如,在我的课堂上,我有类似的东西:

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 } }

那么,我如何正确地将类添加到我可以添加正确的用户名和密码的位置以包含技术的用户名和密码? 我之前有类似的项目,但我几乎总是使用另一个人的硬编码用户名和密码。 为此,如果用户名和密码对这些表无效,我不希望其他人使用该应用程序更改任何票证信息。

不好意思,但是想要提供一个基本的应用程序,以防有人有更好的想法。 我愿意接受建议,特别是关于将信息从应用程序传递到类然后将数据传递回应用程序的正确方法。

该数据库是一个iSeries。 我们使用IBM iSeries 32位ODBC驱动程序从Windows连接,如果这有帮助的话。 大多数编码将使用Visual Studio 2013在C#中完成。

感谢您的任何帮助。

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.

最满意答案

创建一个单独的类来保存给用户:

public class TechUser { public string UserName {get; private set;} public string Password{get; private set;} public TechUser(string userName, string password) { UserName = userName; Password = password; } }

然后将其传递给create函数:

TechUser user = new TechUser("name", "pw"); ticket t = new ticket(); t.Create(user)

Create a separate class to hold to user:

public class TechUser { public string UserName {get; private set;} public string Password{get; private set;} public TechUser(string userName, string password) { UserName = userName; Password = password; } }

Then pass it in to the create function:

TechUser user = new TechUser("name", "pw"); ticket t = new ticket(); t.Create(user)

更多推荐

本文发布于:2023-07-26 02:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1269618.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库类   正确   方法   class   database

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!