[C#] 纯文本查看 复制代码
/// <summary>
/// 权限类
/// </summary>
/// <param name="form_name">窗体名称</param>
/// <param name="users">用户编号</param>
/// <param name="pro_num">程序名称</param>
public void search_role_ff(Form form_name,string users,string pro_num)
{
SqlConnection con = new SqlConnection(ClassL.EncodeAndDecode.passString()); // 字符串解密, SqlDataAdapte 无须open和close
string commString = string.Format("select User_Role_dt.users,sys_admin,pro_num,pro_role from User_Role_dt left join User_Role_ds on User_Role_ds.users=User_Role_dt.users and pro_num=@pro_num where User_Role_dt.users = @users");
SqlDataAdapter sqldata = new SqlDataAdapter(commString, con);
sqldata.SelectCommand.Parameters.Add("@pro_num",SqlDbType.Char,20).Value = pro_num;
sqldata.SelectCommand.Parameters.Add("@users",SqlDbType.Char,10).Value = users;
DataTable datatable1 = new DataTable();
sqldata.Fill(datatable1);
if (datatable1.Rows.Count == 0)
{
MessageBoxEx.Show("没有可进入的授权,请联系系统管理员!","提示:",MessageBoxButtons.OK,MessageBoxIcon.Hand);
}
else
{
if (datatable1.Rows[0]["sys_admin"].ToString() == "Y")
{
ClassL.classL.UserRole_Form.value = "YYYYYYY";
form_name.Show();
}
else //非超级管理员
{
if ( string.IsNullOrEmpty(datatable1.Rows[0]["pro_role"].ToString()))
{
MessageBoxEx.Show("没有可进入的授权,请联系系统管理员!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
else
{
ClassL.classL.UserRole_Form.value = datatable1.Rows[0]["pro_role"].ToString();//执行成功后则将 该窗体权限赋值给该窗体
form_name.Show();
}
}
}
}