用户管理C#windows应用程序 [英] User management C# windows application

查看:82
本文介绍了用户管理C#windows应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!如何在C#windows应用程序中处理多个用户?我创建了一个应用程序来向数据库添加,编辑等记录。现在我想知道谁是添加记录的用户,我使用SELECT Top 1 username FROM tabletransactionlog ORDER BY username DESC来获取添加记录的用户的名称。现在如果有2个或更多用户的应用程序怎么办? s 选择最近登入的(TOP 1)用户不是一个选项。



我尝试了什么:



流程的应用程序:登录>主表单

所以在用户登录后,top 1 ... desc用户获取并记录为添加记录的用户添加记录并且与编辑相同,删除...

Hello! How can I handle multiple user in my C# windows application? I have an application created to add,edit etc. records to the database. Now I want to know who is the user who added the record and I used "SELECT Top 1 username FROM tabletransactionlog ORDER BY username DESC" to get the name of the user who added a record. Now what if there are 2 or more users of the application? selecting the recent(TOP 1) user who logged in isn't an option.

What I have tried:

flow of the app: Login>Main Form
so after the user logged in, top 1... desc user is fetch and recorded as the one who added a record if the user added a record and it goes the same with edit, delete...

推荐答案

您的事务日志应该记录时间戳,用户ID和行/表引用,以及操作代码(INSERT,UPDATE,DELETE)以告诉您已执行的操作。您还可以包含该行的图像之前和之后(以便您可以快退更改,并撤消删除)



请参阅此处:交易日志 - 维基百科 [ ^ ]摘要。



获取用户名排序的顶行效率低(用户名可能很长,与ID值)并且毫无意义,因为它将始终按字母顺序选择具有最后一个用户名的用户 - 您将始终获得ZebraMan而永远不会AntGirl!

相反,您将检索特定行的所有更改,按时间戳排序,然后查看最新的更改信息,包括用户ID。
Your transaction log should record the timestamp, userID, and a row / table reference, along with an action code (INSERT, UPDATE, DELETE) to tell you what was done. You can also include before and after images for the row (so that you can "rewind" changes, and undo deletes)

See here: Transaction log - Wikipedia[^] for a summary.

Fetching the top row ordered by username is both inefficient (usernames can be quite long, compared with an ID value) and pointless as it will always select the user with the last username alphabetically - you will always get "ZebraMan" and never "AntGirl"!
Instead, you would retrieve all changes for a particular row, ordered by the timestamp and then look at the latest change info, including the userID.


这篇关于用户管理C#windows应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆