C#中不同的用户进入不同的界面

WQ_degin 2012-07-18 04:30:55
先查询数据库中的登录名是否存在,如果存在根据登录名判断权限来进入不同的界面,比如有总经理,经理,员工
我是一个新手,谁有这方面的例子,可以发给我吗?非常感谢了,有点急,希望各位大侠们帮帮忙。想要详细的代码。
是winform类型的
...全文
683 20 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
永远的小鱼 2012-07-20
  • 打赏
  • 举报
回复
数据库配置用户的权限信息 与 特定权限用户的可访问地址。然后使用过滤器进行Session用户名以及网页访问地址的数据库查询 看一下用户是否有当前页的权限 然后。。你懂得
wfdqxl 2012-07-20
  • 打赏
  • 举报
回复
帮顶,我也想要这方面的东东
leotao841024 2012-07-19
  • 打赏
  • 举报
回复
在数据库中简历组一列,根据不同的组导向不同的界面,当然还有有一个组表,里面放的是组的类别
十二恨 2012-07-19
  • 打赏
  • 举报
回复

private void button1_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection();
cn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["china"].ConnectionString;
cn.Open();
SqlCommand cmd = new SqlCommand();
if (comboBox1.Text == "读者")
{
string str=string.Format("select rno,rpwd from reader where rno='{0}'and rpwd='{1}'",textBox1.Text.Trim(),textBox2.Text.Trim());
cmd.CommandText=str;
cmd.Connection=cn;
SqlDataReader dr=cmd.ExecuteReader();
if(dr.Read()){
pwd = textBox2.Text.Trim();//密码
userid = textBox1.Text.Trim();
reader r=new reader();
r.Show();
this.Hide();
}
else
{ MessageBox.Show("用户名或密码错误");
textBox1.Text = null;
textBox2.Text = null;
}
}
else if (comboBox1.Text == "管理人员") {
string str = string.Format("select mno,mpwd from management where mno='{0}'and mpwd='{1}'", textBox1.Text.Trim(), textBox2.Text.Trim());
cmd.CommandText = str;
cmd.Connection = cn;
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
pwd = textBox2.Text.Trim();//密码
userid = textBox1.Text.Trim();
manager m = new manager();
m.Show();
 this.Hide();
}
else
{ MessageBox.Show("用户名或密码错误");
textBox1.Text = null;
textBox2.Text = null;
}
}
else { MessageBox.Show("请选着职称");
textBox1.Text = null;
textBox2.Text = null;
}
}
mizuho_2006 2012-07-19
  • 打赏
  • 举报
回复
用户和权限不要直接关联,用户分属于不同角色,管理员为角色分配不同的权限。
allen0118 2012-07-19
  • 打赏
  • 举报
回复

这个框架很符合你的要求,并且帮你做了很多的设计:

http://www.cnblogs.com/allen0118/archive/2012/05/10/2494112.html
Wesley82 2012-07-19
  • 打赏
  • 举报
回复
初学者,哈,多多练习吧,都是这么混过来的。
WQ_degin 2012-07-19
  • 打赏
  • 举报
回复
名字是主键
stiff_neck 2012-07-19
  • 打赏
  • 举报
回复
名字是主键么,可能有重名的问题
WQ_degin 2012-07-19
  • 打赏
  • 举报
回复
cmd.CommandText = "select * from dbo.工作微博 where 姓名='" + textBox1.Text + "' and 密码 ='" + textBox2.Text + "'";
cmd.CommandType = CommandType.Text;
cmd.ExecuteReader();
if ("Select 权限 from dbo.工作微博 where 姓名='" + textBox1.Text + "'"=="0")
{
Form2 f2 = new Form2();
f2.Show();

}else if ("Select 权限 from dbo.工作微博 where 姓名='" + textBox1.Text + "'"=="1")
{
Form3 f3 = new Form3();
f3.Show();

} else
{
Form1 f1 = new Form1();
f1.Show();
}

请大侠们帮着改改可以吗?着急解决,现在数据库里查询登录名,如果数据库中有在查权限,根据权限进入不同的界面。谢谢,有点急!!!
allen0118 2012-07-19
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 的回复:]
cn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandText = "select * from dbo.工作微博 where 姓名='" + textBox1.Text + "' and 密码 ='" + textBox2.Text + "'";
cmd.CommandT……
[/Quote]

最好还是做成动态的,那样很容易扩展,从数据库读取菜单。
WQ_degin 2012-07-19
  • 打赏
  • 举报
回复
cn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandText = "select * from dbo.工作微博 where 姓名='" + textBox1.Text + "' and 密码 ='" + textBox2.Text + "'";
cmd.CommandType = CommandType.Text;

cmd.ExecuteReader();
if ()
{


switch ()
{
case "0":
Form2 f2 = new Form2();
f2.Show();
break;//break一定不能少!
case "1":
Form3 f3 = new Form3();
f3.Show();
break;
case "2":
Form1 f1 = new Form1();
f1.Show();
break;

}
}
if那应该怎么写呢?查到登录名再根据登录名查权限,再根据权限进入不同的界面
WQ_degin 2012-07-19
  • 打赏
  • 举报
回复
winform
Ricky_lu 2012-07-19
  • 打赏
  • 举报
回复
帮忙顶一下,我也想了解一下!
wy811007 2012-07-19
  • 打赏
  • 举报
回复
根据不同的登录查询出用户组 然后显示不同页面就好了 不知道你是winform还是webform啊
WQ_degin 2012-07-18
  • 打赏
  • 举报
回复
用C#写的
熙风 2012-07-18
  • 打赏
  • 举报
回复
在51aspx上面找
熙风 2012-07-18
  • 打赏
  • 举报
回复
没有详细的代码的
全栈极简 2012-07-18
  • 打赏
  • 举报
回复
你说的这个是权限系统了,根据账号来判断显示的内容。目前身边没有例子,帮你顶一下。

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧