⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admindb.cs

📁 asp.net办公自动化实例导航——非常经典的OA源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
			SqlParameter paraRoleID = new SqlParameter("@roleid", SqlDbType.Int, 4);
			paraRoleID.Value = roleid;
			myCommand.Parameters.Add(paraRoleID);

			myConnection.Open();
			SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

			return dr;
		}

		public void AddUserRole(int EmpId,int RoleId) 
		{
			SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("sysAddEmpRole", myConnection);

			myCommand.CommandType = CommandType.StoredProcedure;

			SqlParameter parameterEmpID = new SqlParameter("@empid", SqlDbType.Int, 4);
			parameterEmpID.Value = EmpId;
			myCommand.Parameters.Add(parameterEmpID);
			SqlParameter parameterRoleID = new SqlParameter("@roleid", SqlDbType.Int, 4);
			parameterRoleID.Value = RoleId;
			myCommand.Parameters.Add(parameterRoleID);
			myConnection.Open();
			myCommand.ExecuteNonQuery();
			myConnection.Close();
		}

		public void AddFuncRole(int funcid, int roleid) 
		{
			SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("sysAddFuncRole", myConnection);

			myCommand.CommandType = CommandType.StoredProcedure;

			SqlParameter parameterFuncID = new SqlParameter("@funcid", SqlDbType.Int, 4);
			parameterFuncID.Value = funcid;
			myCommand.Parameters.Add(parameterFuncID);
			SqlParameter parameterRoleID = new SqlParameter("@roleid", SqlDbType.Int, 4);
			parameterRoleID.Value = roleid;
			myCommand.Parameters.Add(parameterRoleID);

			myConnection.Open();
			myCommand.ExecuteNonQuery();
			myConnection.Close();
		}

		public bool DeleteRoleUser(int EmpId,int RoleId) 
		{
			SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("sysDeleteRoleUser", myConnection);

			myCommand.CommandType = CommandType.StoredProcedure;

			SqlParameter parameterEmpId = new SqlParameter("@empid", SqlDbType.Int, 4);
			parameterEmpId.Value = EmpId;
			myCommand.Parameters.Add(parameterEmpId);
			SqlParameter parameterRoleID = new SqlParameter("@roleid", SqlDbType.Int, 4);
			parameterRoleID.Value = RoleId;
			myCommand.Parameters.Add(parameterRoleID);

			try
			{
				myConnection.Open();
				myCommand.ExecuteNonQuery();
				myConnection.Close();
			}
			catch
			{
				return false;
			}
			return true;
		}
			

		public bool DeleteFuncRole(int FuncID,int RoleId) 
		{
			SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("sysDeleteFuncRole", myConnection);
			myCommand.CommandType = CommandType.StoredProcedure;
			SqlParameter parameterFuncID = new SqlParameter("@funcid", SqlDbType.Int, 4);
			parameterFuncID.Value = FuncID;
			myCommand.Parameters.Add(parameterFuncID);
			SqlParameter parameterRoleID = new SqlParameter("@roleid", SqlDbType.Int, 4);
			parameterRoleID.Value = RoleId;
			myCommand.Parameters.Add(parameterRoleID);

			try
			{
				myConnection.Open();
				myCommand.ExecuteNonQuery();
				myConnection.Close();
			}
			catch
			{
					return false;
			}
			return true;
		}
       
		public SqlDataReader GetEmpInfo(int pkid ,String type) 
		{
			SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("sysGetEmpByType", myConnection);
			myCommand.CommandType = CommandType.StoredProcedure;
			SqlParameter paraID = new SqlParameter("@pkid", SqlDbType.Int, 4);
			paraID.Value = pkid;
			myCommand.Parameters.Add( paraID);
			SqlParameter paraType = new SqlParameter("@type", SqlDbType.VarChar,10);
			paraType.Value = type;
			myCommand.Parameters.Add( paraType);
			myConnection.Open();
			SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
			return dr;
		}

		public bool DeleteFuncRoleUser(int pkid,String type) 
		{
			SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("sysDeleteFuncRoleUser", myConnection);
			myCommand.CommandType = CommandType.StoredProcedure;
			SqlParameter paraID = new SqlParameter("@pkid", SqlDbType.Int, 4);
			paraID.Value = pkid;
			myCommand.Parameters.Add(paraID);
			SqlParameter paraType = new SqlParameter("@type", SqlDbType.VarChar,10);
			paraType.Value = type;
			myCommand.Parameters.Add( paraType);

			try
			{
				myConnection.Open();
				myCommand.ExecuteNonQuery();
				myConnection.Close();
			}
			catch
			{
				return false;
			}
			return true;
		}
  
		public SqlDataReader GetFuncInfo(int funcid) 
		{
			SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("sysGetFuncInfo", myConnection);

			myCommand.CommandType = CommandType.StoredProcedure;
			SqlParameter paraID = new SqlParameter("@funcid", SqlDbType.Int, 4);
			paraID.Value = funcid;
			myCommand.Parameters.Add( paraID);
			
			myConnection.Open();
			SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
			return dr;
		}

		public SqlDataReader GetRoleInfo(int roleid) 
		{
			SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("sysGetRoleInfo", myConnection);

			myCommand.CommandType = CommandType.StoredProcedure;
			SqlParameter paraID = new SqlParameter("@roleid", SqlDbType.Int, 4);
			paraID.Value = roleid;
			myCommand.Parameters.Add( paraID);
			myConnection.Open();
			SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
			return dr;
		}

		public SqlDataReader GetAllFuncs() 
		{
			SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("sysGetAllFuncs", myConnection);
			myCommand.CommandType = CommandType.StoredProcedure;
			myConnection.Open();
			SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
			return dr;
		}

		public SqlDataReader GetAllRoles() 
		{   
			SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("sysGetAllRoles", myConnection);
			myCommand.CommandType = CommandType.StoredProcedure;
			myConnection.Open();
			SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
			return dr;
		}

		public SqlDataReader GetAllBranch() 
		{
			SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("sysGetAllBranch", myConnection);
			myCommand.CommandType = CommandType.StoredProcedure;
			myConnection.Open();
			SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
			return dr;
		}

		public SqlDataReader GetDepByBranch(int BranchID) 
		{
			SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
			SqlCommand myCommand = new SqlCommand("sysGetDepByBranch", myConnection);
			myCommand.CommandType = CommandType.StoredProcedure;
			SqlParameter paraBranchID = new SqlParameter("@branchid", SqlDbType.Int, 4);
			 paraBranchID.Value = BranchID;
			myCommand.Parameters.Add( paraBranchID);
			myConnection.Open();
			SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
			return dr;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -