CheckUser.cs
上传用户:tree100901
上传日期:2007-06-03
资源大小:2295k
文件大小:5k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using System.Web.Security;
  5. namespace OA
  6. {
  7. /// <summary>
  8. /// CheckUser 的摘要说明。
  9. /// </summary>
  10. public class CheckUser
  11. {
  12. private string Is_UserName;
  13. public int Is_UserID;
  14. public string JobID;
  15. public SqlConnection MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
  16. public CheckUser()
  17. {
  18. Is_UserName = null;
  19. //
  20. // TODO: 在此处添加构造函数逻辑
  21. //
  22. }
  23. public string UserName
  24. {
  25. get
  26. {
  27. return Is_UserName;
  28. }
  29. set
  30. {
  31. Is_UserName = value;
  32. if(Is_UserName!="")
  33. {
  34. SqlConnection MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
  35. SqlCommand MyCommand00 = new SqlCommand("PersonID",MyConnection);
  36. MyCommand00.CommandType = CommandType.StoredProcedure;
  37. MyCommand00.Parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar, 50));
  38. MyCommand00.Parameters["@Name"].Value = Is_UserName;
  39. if(MyConnection.State.ToString()=="Closed")
  40. MyConnection.Open();
  41. SqlDataReader myReader00 =  MyCommand00.ExecuteReader();
  42. while(myReader00.Read())
  43. Is_UserID = Int32.Parse(myReader00.GetInt32(0).ToString());
  44. JobID = myReader00["JobID"].ToString().Trim();
  45. }
  46. myReader00.Close();
  47. MyConnection.Close();
  48. }
  49. }
  50. }
  51. public int UserID
  52. {
  53. get
  54. {
  55. return Is_UserID;
  56. }
  57. }
  58. public bool Is_SystemManager()
  59. {
  60. string  SMJOBID = "";
  61. SqlConnection MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
  62. SqlCommand MyCommand0 = new SqlCommand("SelectSystemManager",MyConnection);
  63. MyCommand0.CommandType = CommandType.StoredProcedure;
  64. if(MyConnection.State.ToString()=="Closed")
  65. MyConnection.Open();
  66. SqlDataReader myReader0 =  MyCommand0.ExecuteReader();
  67. while(myReader0.Read())
  68. SMJOBID = myReader0["JobID"].ToString();
  69. }
  70. myReader0.Close();
  71. MyConnection.Close();
  72. int FJOBID= JobID.ToString().Trim().IndexOf(SMJOBID);
  73. if(FJOBID<0)
  74. return false;
  75. else
  76. return true;
  77. }
  78. public bool Is_FileManager()
  79. {
  80. string  FMJOBID = "";
  81. SqlConnection MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
  82. SqlCommand MyCommand0 = new SqlCommand("SelectFileManager",MyConnection);
  83. MyCommand0.CommandType = CommandType.StoredProcedure;
  84. if(MyConnection.State.ToString()=="Closed")
  85. MyConnection.Open();
  86. SqlDataReader myReader0 =  MyCommand0.ExecuteReader();
  87. while(myReader0.Read())
  88. FMJOBID = myReader0["JobID"].ToString();
  89. }
  90. myReader0.Close();
  91. MyConnection.Close();
  92. int FJOBID = JobID.ToString().Trim().IndexOf(FMJOBID);
  93. if(FJOBID<0)
  94. return false;
  95. else
  96. return true;
  97. }
  98. public string isSetUser(string UserName,string Password)
  99. {
  100. SqlConnection MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
  101. SqlCommand MyCommand = new SqlCommand("CheckSetUser",MyConnection);
  102. MyCommand.CommandType = CommandType.StoredProcedure;
  103. MyCommand.Parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar,50));
  104. MyCommand.Parameters["@Name"].Value = UserName;
  105. MyCommand.Parameters.Add(new SqlParameter("@Password", SqlDbType.NVarChar,50));
  106. MyCommand.Parameters["@Password"].Value = FormsAuthentication.HashPasswordForStoringInConfigFile(Password,"MD5");
  107. SqlParameter BoolSetUser = MyCommand.Parameters.Add(new SqlParameter("@SetUser", SqlDbType.Char,10));
  108. BoolSetUser.Direction = ParameterDirection.Output;
  109. SqlParameter UserState = MyCommand.Parameters.Add(new SqlParameter("@State", SqlDbType.Char,10));
  110. UserState.Direction = ParameterDirection.Output;
  111. SqlParameter PersonID = MyCommand.Parameters.Add(new SqlParameter("@PersonID", SqlDbType.Int,4));
  112. PersonID.Direction = ParameterDirection.Output;
  113. if(MyConnection.State.ToString()=="Closed")
  114. MyConnection.Open();
  115. try
  116. {
  117. MyCommand.ExecuteNonQuery();
  118. }
  119. catch
  120. {
  121. }
  122. MyConnection.Close();
  123. MyCommand.Parameters.Clear();
  124. return BoolSetUser.Value.ToString()+"|"+UserState.Value.ToString();
  125. }
  126. public bool isOnlineUser(string UserName)
  127. {
  128. SqlCommand MyCommand = new SqlCommand("CheckOnlineUser",MyConnection);
  129. MyCommand.CommandType = CommandType.StoredProcedure;
  130. MyCommand.Parameters.Add(new SqlParameter("@UserName", SqlDbType.NVarChar,50));
  131. MyCommand.Parameters["@UserName"].Value = UserName;
  132. SqlParameter BoolUserOnline = MyCommand.Parameters.Add(new SqlParameter("@UserOnline", SqlDbType.Char,10));
  133. BoolUserOnline.Direction = ParameterDirection.Output;
  134. if(MyConnection.State.ToString()=="Closed")
  135. MyConnection.Open();
  136. try
  137. {
  138. MyCommand.ExecuteNonQuery();
  139. }
  140. catch
  141. {
  142. }
  143. MyConnection.Close();
  144. MyCommand.Parameters.Clear();
  145. return Convert.ToBoolean(BoolUserOnline.Value.ToString());
  146. }
  147. }
  148. }