开发管理系统 [英] developing management system

查看:96
本文介绍了开发管理系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

海,目前正在vb.net上开发软件.它可以插入,编辑和删除学生信息..我想知道如何为不同的用户隐藏一些行.例如,如果管理员登录,他/她可以看到1.edit 2.删除3.add用户..但是对于非管理员,他们可以查看1.edit 2. delete ..如何执行..另一个问题,如何在vb(基本窗口应用程序)中使用会话变量.我需要你们所有人的一些代码才能理解..tq..

Hai, currently im developing a software in vb.net. which can insert,edit and delete student information..I want to know how to hide some rows for different user. Example if admin login, he/she can see row 1.edit 2. delete 3.add user..but for non-admin they one can view 1.edit 2. delete..how to do it..Another problem, how to use session variable in vb (window base application). i need some code from u all to get idea..tq..

推荐答案

对我来说,您是否要限制其他用户的观看并不清楚不同的行,或者您想限制某些用户的某些类型的操作(例如无法修改行等).

假设您使用SQL Server存储信息,那么首先要确定的是无法看到/修改行的标准是什么.例如,如果用户只能看到自己的行,则可以在表中添加一列,以标识创建(或拥有)该行的用户,并在查询中使用该行(在WHERE子句中消除其他行).对于管理员,您不要在WHERE子句中包含此条件.

一个例子.如果要限制Shipper表中的行,则可以有一个名为UserToShipper的表,例如
For me it wasn''t exactly clear if you want to restrict different users from seeing different rows or if you want to restrict certain types of operations from some users (like not being able to modify a row etc).

Taken that you use SQL Server to store the information, first thing you have to decide is what is the criteria for not being able to see/modify a row. For example if a user can see only his own rows, you can add a column to the table identifying the user who created (or owns) the row and use that in your queries (in WHERE clauses to eliminate other rows). For admin people you don''t include this condition in the WHERE clause.

An example. If you want to restrict rows in a table called Shipper, you could have a table called UserToShipper, e.g.
Shipper-table
- ShipperId (primary key)
- Name


UserToShipper-table
- ShipperId (foreign key)
- UserName (person who can see the shipper)



托运人包含3行:



The shipper contains 3 rows:

ShipperId Name
--------- --------
1         Shipper 1
2         Shipper 2
3         Shipper 3


并且UserToShipper表包含以下行:


And the UserToShipper table contains rows:

ShipperId UserName
--------- --------
1         Danny
1         Alex
2         Danny


现在使用这些表,如果您以Danny的身份登录,则可以看到发货人1和2,但看不到3.SQL语句可能类似于:


Now with these tables if you''re logged in as Danny you can see shippers 1 and 2 but not 3. The SQL statement could be something like:

SELECT *
FROM Shipper s
WHERE EXISTS (SELECT 1 
              FROM UserToShipper us
              WHERE us.ShipperId = s.ShipperId
              AND   us.UserName = 'Danny')


如果将Alex更改为用户名,则只能看到发货人1而不是2或3.

而且,如果管理员已登录,则只需不使用exist子句.

这只是一个简单的示例,在现实生活中,您不应使用这样的用户名,而在代码中则应使用参数而不是文字等.


If you change Alex to the user name you can see only shipper 1 not 2 or 3.

And if an admin is logged in you simply do not use the exists clause.

This is just a simple example and in real life you shouldn''t use username like that and from the code you should use parameters instead of literals and so on.


这篇关于开发管理系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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