Example #1
0
 public Security( priCode c,string uC,string uN, string uX )
 {
     s = c;
     userCode = uC;
     userName = uN;
     userXy = uX;
 }
Example #2
0
 public Security()
 {
     s = priCode.none;
     userCode = "";
     userName = "";
     userXy = "";
 }
Example #3
0
 public void setSecurity( priCode c )
 {
     s = c;
 }
Example #4
0
    public string getUnameByUcode(string ucode, priCode uType)
    {
        SqlCommand comm = new SqlCommand();
        SqlDataAdapter sda = new SqlDataAdapter();
        DataTable dt = new DataTable();
        int rows = 0;
        switch (uType)
        {
            case priCode.xtgly:

                comm.Connection = conn;
                //管理员类型0是系统管理员,1是教务管理员,2是实验室管理员

                comm.CommandText = "select GLYXM from T_GLYXXB where DLM=@username and  GLYLX=0";
                comm.Parameters.Clear();
                comm.Parameters.AddWithValue("username", ucode);
                sda.SelectCommand = comm;

                rows = sda.Fill(dt);
                if (rows == 0)
                {
                    return "error!";
                }
                else if (rows > 1)
                {
                    return "error!";
                }
                else //rows == 1
                {
                    return dt.Rows[0]["GLYXM"].ToString();
                }
            case priCode.xs:
                comm.Connection = conn;
                //管理员类型0是系统管理员,1是教务管理员,2是实验室管理员

                comm.CommandText = "select xsxm from t_xsxxb where xsxh=@username";
                comm.Parameters.Clear();
                comm.Parameters.AddWithValue("username", ucode);
                sda.SelectCommand = comm;

                rows = sda.Fill(dt);
                if (rows == 0)
                {
                    return "error!";
                }
                else if (rows > 1)
                {
                    return "error!";
                }
                else //rows == 1
                {
                    return dt.Rows[0]["xsxm"].ToString();
                }
                break;
            case priCode.js:
                comm.Connection = conn;
                //管理员类型0是系统管理员,1是教务管理员,2是实验室管理员

                comm.CommandText = "select jsxm from t_jsxxb where gzh=@username ";
                comm.Parameters.Clear();
                comm.Parameters.AddWithValue("username", ucode);
                sda.SelectCommand = comm;

                rows = sda.Fill(dt);
                if (rows == 0)
                {
                    return "error!";
                }
                else if (rows > 1)
                {
                    return "error!";
                }
                else //rows == 1
                {
                    return dt.Rows[0]["jsxm"].ToString();
                }
                break;
            case priCode.jwgly:

                comm.Connection = conn;
                //管理员类型0是系统管理员,1是教务管理员,2是实验室管理员

                comm.CommandText = "select GLYXM from T_GLYXXB where DLM=@username and  GLYLX=1";
                comm.Parameters.Clear();
                comm.Parameters.AddWithValue("username", ucode);
                sda.SelectCommand = comm;

                rows = sda.Fill(dt);
                if (rows == 0)
                {
                    return "error!";
                }
                else if (rows > 1)
                {
                    return "error!";
                }
                else //rows == 1
                {
                    return dt.Rows[0]["GLYXM"].ToString();
                }
                break;
            case priCode.sygly:

                comm.Connection = conn;
                //管理员类型0是系统管理员,1是教务管理员,2是实验室管理员

                comm.CommandText = "select GLYXM from T_GLYXXB where DLM=@username and  GLYLX=2";
                comm.Parameters.Clear();
                comm.Parameters.AddWithValue("username", ucode);
                sda.SelectCommand = comm;

                rows = sda.Fill(dt);
                if (rows == 0)
                {
                    return "error!";
                }
                else if (rows > 1)
                {
                    return "error!";
                }
                else //rows == 1
                {
                    return dt.Rows[0]["GLYXM"].ToString();
                }
                break;
            default:
                return "error!";
        }
    }