CheckUser.cs
资源名称:OA_at.rar [点击查看]
上传用户:tree100901
上传日期:2007-06-03
资源大小:2295k
文件大小:5k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Data;
- using System.Data.SqlClient;
- using System.Web.Security;
- namespace OA
- {
- /// <summary>
- /// CheckUser 的摘要说明。
- /// </summary>
- public class CheckUser
- {
- private string Is_UserName;
- public int Is_UserID;
- public string JobID;
- public SqlConnection MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
- public CheckUser()
- {
- Is_UserName = null;
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- public string UserName
- {
- get
- {
- return Is_UserName;
- }
- set
- {
- Is_UserName = value;
- if(Is_UserName!="")
- {
- SqlConnection MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
- SqlCommand MyCommand00 = new SqlCommand("PersonID",MyConnection);
- MyCommand00.CommandType = CommandType.StoredProcedure;
- MyCommand00.Parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar, 50));
- MyCommand00.Parameters["@Name"].Value = Is_UserName;
- if(MyConnection.State.ToString()=="Closed")
- MyConnection.Open();
- SqlDataReader myReader00 = MyCommand00.ExecuteReader();
- while(myReader00.Read())
- {
- Is_UserID = Int32.Parse(myReader00.GetInt32(0).ToString());
- JobID = myReader00["JobID"].ToString().Trim();
- }
- myReader00.Close();
- MyConnection.Close();
- }
- }
- }
- public int UserID
- {
- get
- {
- return Is_UserID;
- }
- }
- public bool Is_SystemManager()
- {
- string SMJOBID = "";
- SqlConnection MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
- SqlCommand MyCommand0 = new SqlCommand("SelectSystemManager",MyConnection);
- MyCommand0.CommandType = CommandType.StoredProcedure;
- if(MyConnection.State.ToString()=="Closed")
- MyConnection.Open();
- SqlDataReader myReader0 = MyCommand0.ExecuteReader();
- while(myReader0.Read())
- {
- SMJOBID = myReader0["JobID"].ToString();
- }
- myReader0.Close();
- MyConnection.Close();
- int FJOBID= JobID.ToString().Trim().IndexOf(SMJOBID);
- if(FJOBID<0)
- return false;
- else
- return true;
- }
- public bool Is_FileManager()
- {
- string FMJOBID = "";
- SqlConnection MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
- SqlCommand MyCommand0 = new SqlCommand("SelectFileManager",MyConnection);
- MyCommand0.CommandType = CommandType.StoredProcedure;
- if(MyConnection.State.ToString()=="Closed")
- MyConnection.Open();
- SqlDataReader myReader0 = MyCommand0.ExecuteReader();
- while(myReader0.Read())
- {
- FMJOBID = myReader0["JobID"].ToString();
- }
- myReader0.Close();
- MyConnection.Close();
- int FJOBID = JobID.ToString().Trim().IndexOf(FMJOBID);
- if(FJOBID<0)
- return false;
- else
- return true;
- }
- public string isSetUser(string UserName,string Password)
- {
- SqlConnection MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
- SqlCommand MyCommand = new SqlCommand("CheckSetUser",MyConnection);
- MyCommand.CommandType = CommandType.StoredProcedure;
- MyCommand.Parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar,50));
- MyCommand.Parameters["@Name"].Value = UserName;
- MyCommand.Parameters.Add(new SqlParameter("@Password", SqlDbType.NVarChar,50));
- MyCommand.Parameters["@Password"].Value = FormsAuthentication.HashPasswordForStoringInConfigFile(Password,"MD5");
- SqlParameter BoolSetUser = MyCommand.Parameters.Add(new SqlParameter("@SetUser", SqlDbType.Char,10));
- BoolSetUser.Direction = ParameterDirection.Output;
- SqlParameter UserState = MyCommand.Parameters.Add(new SqlParameter("@State", SqlDbType.Char,10));
- UserState.Direction = ParameterDirection.Output;
- SqlParameter PersonID = MyCommand.Parameters.Add(new SqlParameter("@PersonID", SqlDbType.Int,4));
- PersonID.Direction = ParameterDirection.Output;
- if(MyConnection.State.ToString()=="Closed")
- MyConnection.Open();
- try
- {
- MyCommand.ExecuteNonQuery();
- }
- catch
- {
- }
- MyConnection.Close();
- MyCommand.Parameters.Clear();
- return BoolSetUser.Value.ToString()+"|"+UserState.Value.ToString();
- }
- public bool isOnlineUser(string UserName)
- {
- SqlCommand MyCommand = new SqlCommand("CheckOnlineUser",MyConnection);
- MyCommand.CommandType = CommandType.StoredProcedure;
- MyCommand.Parameters.Add(new SqlParameter("@UserName", SqlDbType.NVarChar,50));
- MyCommand.Parameters["@UserName"].Value = UserName;
- SqlParameter BoolUserOnline = MyCommand.Parameters.Add(new SqlParameter("@UserOnline", SqlDbType.Char,10));
- BoolUserOnline.Direction = ParameterDirection.Output;
- if(MyConnection.State.ToString()=="Closed")
- MyConnection.Open();
- try
- {
- MyCommand.ExecuteNonQuery();
- }
- catch
- {
- }
- MyConnection.Close();
- MyCommand.Parameters.Clear();
- return Convert.ToBoolean(BoolUserOnline.Value.ToString());
- }
- }
- }