先查询数据库中的登录名是否存在,如果存在根据登录名判断权限来进入不同的界面,比如有总经理,经理,员工
  我是一个新手,谁有这方面的例子,可以发给我吗?非常感谢了,有点急,希望各位大侠们帮帮忙。想要详细的代码。
  是winform类型的

解决方案 »

  1.   

    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();
    } 请大侠们帮着改改可以吗?着急解决,现在数据库里查询登录名,如果数据库中有在查权限,根据权限进入不同的界面。谢谢,有点急!!!
      

  2.   


    这个框架很符合你的要求,并且帮你做了很多的设计:http://www.cnblogs.com/allen0118/archive/2012/05/10/2494112.html
      

  3.   


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

  4.   

    根据不同的登录查询出用户组 然后显示不同页面就好了 不知道你是winform还是webform啊
      

  5.   

     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那应该怎么写呢?查到登录名再根据登录名查权限,再根据权限进入不同的界面
      

  6.   

    数据库配置用户的权限信息 与 特定权限用户的可访问地址。然后使用过滤器进行Session用户名以及网页访问地址的数据库查询  看一下用户是否有当前页的权限 然后。。你懂得