| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 5338 人关注过本帖
标题:c# 做登陆界面如何在代码中判断权限
取消只看楼主 加入收藏
zjq409421884
Rank: 1
来 自:余姚
等 级:新手上路
帖 子:56
专家分:0
注 册:2010-5-8
结帖率:100%
收藏
 问题点数:0 回复次数:7 
c# 做登陆界面如何在代码中判断权限
string strcmd;
                if (txtloginname.Text != "" && txtpassword.Text != "")
                {
                    strcmd = "select * from EmployeesCompetence where employeeid=" + txtloginname.Text + " and pwd='" + txtpassword.Text + "'";
                    login.Select(strcmd, "login");
                    if (sql.ds.Tables["login"].Rows.Count != 0)
                    {
                        Form mainfrm = new FrmMain();
                        mainfrm.Show();
                        this.Hide();
                    }
                    else
                        MessageBox.Show("用户名或密码错误!");
                }
这个是我做的登陆界面确定的代码,怎么在这里加上权限判断呢,先谢啦
搜索更多相关主题的帖子: 权限 界面 代码 登陆 判断 
2010-12-20 10:11
zjq409421884
Rank: 1
来 自:余姚
等 级:新手上路
帖 子:56
专家分:0
注 册:2010-5-8
收藏
得分:0 
版主可以加q么,我正在做一个课程设计,有很多东西不懂啊

谁教我C#呀...愁
2010-12-20 10:17
zjq409421884
Rank: 1
来 自:余姚
等 级:新手上路
帖 子:56
专家分:0
注 册:2010-5-8
收藏
得分:0 
。。。。。。。。在那段代码中加一个什么字段来判断权限呢

谁教我C#呀...愁
2010-12-20 10:22
zjq409421884
Rank: 1
来 自:余姚
等 级:新手上路
帖 子:56
专家分:0
注 册:2010-5-8
收藏
得分:0 
是在select语句中加入这张权限表,然后where语句查询这个权限的字段,判断在登陆界面选择的权限是否与这个表中的数据一致对么?

谁教我C#呀...愁
2010-12-20 10:36
zjq409421884
Rank: 1
来 自:余姚
等 级:新手上路
帖 子:56
专家分:0
注 册:2010-5-8
收藏
得分:0 
恩,谢谢版主啊,我搞下试试,不行的话我在问啊

谁教我C#呀...愁
2010-12-20 10:42
zjq409421884
Rank: 1
来 自:余姚
等 级:新手上路
帖 子:56
专家分:0
注 册:2010-5-8
收藏
得分:0 
版主在么,做完登录界面后,程序崩溃,显示数据库登录失败: public static  DataSet ds = new DataSet();
        public static string connstring = "server=.;database=ssxt;uid=sa;pwd=123456;";
        //执行select命令,并返回结果写入数据集的表中
        public bool  Select(string cmdstr, string tablename)
        {

               SqlConnection  conn = new SqlConnection(connstring);
                conn.Open();
                SqlCommand cmd = new SqlCommand(cmdstr, conn);
                cmd.ExecuteNonQuery();
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                sda.Fill(ds, tablename);
                conn.Close();
                return true;

        }
        public void Insert(string cmdstr)
        {
            SqlConnection conn = new SqlConnection(connstring);
            conn.Open();
            SqlCommand cmd = new SqlCommand(cmdstr, conn);
            cmd.ExecuteNonQuery();
            conn.Close();
        }
        public void Update(string cmdstr)
        {
            SqlConnection conn = new SqlConnection(connstring);
            conn.Open();
            SqlCommand cmd = new SqlCommand(cmdstr, conn);
            cmd.ExecuteNonQuery();
            conn.Close();
        }
        public void Delete(string cmdstr)
        {
            SqlConnection conn = new SqlConnection(connstring);
            conn.Open();
            SqlCommand cmd = new SqlCommand(cmdstr, conn);
            cmd.ExecuteNonQuery();
            conn.Close();
这个是我编写的类,运行后出现:  这个是我的按钮代码: sql login = new sql();
        private void button1_Click(object sender, EventArgs e)
        {
            string strcmd;
            if (txtloginname.Text != "" && txtpassword.Text != "")
            {
                strcmd = "select * from ygb where yg_id=" + txtloginname.Text + " and mm='" + txtpassword.Text + "'";
                login.Select(strcmd, "login");
                if (sql.ds.Tables["login"].Rows.Count != 0)
                {
                    Form GLYJM = new frmlogin();
                    GLYJM.Show();
                    this.Hide();
                }
                else
                    MessageBox.Show("用户名或密码错误!");
            }

谁教我C#呀...愁
2010-12-20 14:52
zjq409421884
Rank: 1
来 自:余姚
等 级:新手上路
帖 子:56
专家分:0
注 册:2010-5-8
收藏
得分:0 
就这个

谁教我C#呀...愁
2010-12-20 18:16
zjq409421884
Rank: 1
来 自:余姚
等 级:新手上路
帖 子:56
专家分:0
注 册:2010-5-8
收藏
得分:0 
未处理 System.Data.SqlClient.SqlException
  Message="无法打开登录所请求的数据库 \"ssxt\"。登录失败。\r\n用户 'sa' 登录失败。"
  Source=".Net SqlClient Data Provider"
  ErrorCode=-2146232060
  Class=11
  LineNumber=65536
  Number=4060
  Procedure=""
  Server="."
  State=1
  StackTrace:
       在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
       在 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       在 System.Data.SqlClient.(Boolean enlistOK)
       在 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
       在 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
       在 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
       在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
       在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
       在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
       在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
       在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
       在 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
       在 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       在 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       在 System.Data.SqlClient.SqlConnection.Open()
       在 WindowsFormsApplication1.sql.Select(String cmdstr, String tablename) 位置 E:\C#实训\c#实训界面设计\WindowsFormsApplication1\sql.cs:行号 20
       在 WindowsFormsApplication1.frmlogin.button1_Click(Object sender, EventArgs e) 位置 E:\C#实训\c#实训界面设计\WindowsFormsApplication1\frmlogin.cs:行号 26
       在 System.Windows.Forms.Control.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
       在 System.Windows.Forms.Button.WndProc(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       在 System.Windows.Forms.(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.Run(Form mainForm)
       在 WindowsFormsApplication1.Program.Main() 位置 E:\C#实训\c#实训界面设计\WindowsFormsApplication1\Program.cs:行号 18
       在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()
  InnerException: 就这个

谁教我C#呀...愁
2010-12-20 18:19
快速回复:c# 做登陆界面如何在代码中判断权限
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014878 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved