?? admindb.cs
字號:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
namespace qminoa.DA
{
public class AdminDB
{
public bool InsertRoleInfo(string RoleName,string RoleDescription)
{
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("sysInsertRoleInfo", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter parameterRoleName = new SqlParameter("@rolename", SqlDbType.VarChar, 20);
parameterRoleName.Value = RoleName;
myCommand.Parameters.Add(parameterRoleName);
SqlParameter parameterRoleDescription = new SqlParameter("@roledescription", SqlDbType.VarChar, 100);
parameterRoleDescription.Value = RoleDescription;
myCommand.Parameters.Add(parameterRoleDescription);
myConnection.Open();
int result = myCommand.ExecuteNonQuery();
myConnection.Close();
if(result>0)
{
return true;
}
else
{
return false;
}
}
public bool InsertFuncInfo(string FuncName,string FuncDescription)
{
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("sysInsertFuncInfo", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter parameterFuncName = new SqlParameter("@Funcname", SqlDbType.VarChar, 20);
parameterFuncName.Value = FuncName;
myCommand.Parameters.Add(parameterFuncName);
SqlParameter parameterFuncDescription = new SqlParameter("@Funcdescription", SqlDbType.VarChar, 100);
parameterFuncDescription.Value = FuncDescription;
myCommand.Parameters.Add(parameterFuncDescription);
myConnection.Open();
int result = myCommand.ExecuteNonQuery();
myConnection.Close();
if(result>0)
{
return true;
}
else
{
return false;
}
}
public bool UpdateRoleInfo(int roleid, String rolename,String roledes)
{
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("sysUpdateRoleInfo", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter parameterRoleID = new SqlParameter("@roleid", SqlDbType.Int, 4);
parameterRoleID.Value = roleid;
myCommand.Parameters.Add(parameterRoleID);
SqlParameter parameterRoleName = new SqlParameter("@rolename", SqlDbType.NVarChar, 50);
parameterRoleName.Value = rolename;
myCommand.Parameters.Add(parameterRoleName);
SqlParameter parameterRoleDes = new SqlParameter("@roledes", SqlDbType.NVarChar, 50);
parameterRoleDes.Value = roledes;
myCommand.Parameters.Add(parameterRoleDes);
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
}
catch
{
return false;
}
return true;
}
public void UpdateFuncRoleRight(int funcid,int roleid ,int rightflag)
{
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("sysUpdateFuncRoleRight", 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);
SqlParameter parameterFlag = new SqlParameter("@rightflag", SqlDbType.Int, 4);
parameterFlag.Value = rightflag;
myCommand.Parameters.Add(parameterFlag);
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
}
public void UpdateUserInfo(int empid, String loginid)
{
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("sysUpdateEmpInfo", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter paraEmpID = new SqlParameter("@empid", SqlDbType.Int, 4);
paraEmpID.Value = empid;
myCommand.Parameters.Add(paraEmpID);
SqlParameter paraLoginID = new SqlParameter("@loginid", SqlDbType.NVarChar, 50);
paraLoginID.Value = loginid;
myCommand.Parameters.Add(paraLoginID);
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
}
public void UpdateFuncInfo(int funcid, String funcname ,String funcdes)
{
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("sysUpdateFuncInfo", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter paraFuncID = new SqlParameter("@funcid", SqlDbType.Int, 4);
paraFuncID.Value = funcid;
myCommand.Parameters.Add(paraFuncID);
SqlParameter paraFuncName = new SqlParameter("@funcname", SqlDbType.NVarChar, 50);
paraFuncName.Value = funcname;
myCommand.Parameters.Add(paraFuncName);
SqlParameter parameterFuncDes = new SqlParameter("@funcdes", SqlDbType.NVarChar, 50);
parameterFuncDes.Value = funcdes;
myCommand.Parameters.Add(parameterFuncDes);
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
}
public SqlDataReader GetUserRoles(int UserId)
{
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("sysGetEmpRoles", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter paraEmpID = new SqlParameter("@empid", SqlDbType.Int, 4);
paraEmpID.Value = UserId;
myCommand.Parameters.Add(paraEmpID);
myConnection.Open();
SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
return dr;
}
public SqlDataReader GetFuncRole(int funcid)
{
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("sysGetFuncRoles", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter paraFuncID = new SqlParameter("@funcid", SqlDbType.Int, 4);
paraFuncID.Value = funcid;
myCommand.Parameters.Add(paraFuncID);
myConnection.Open();
SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
return dr;
}
public SqlDataReader GetRoleFunc(int roleid)
{
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("sysGetRoleFunc", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
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 SqlDataReader GetRoleUser(int roleid)
{
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("sysGetRoleEmp", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -