Role.cs
资源名称:yjal.rar [点击查看]
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:2k
源码类别:
Email客户端
开发平台:
Visual C++
- /********************************************************************************
- ** 作者:ebDoing
- ** 创始时间: 2008-10-22
- ** 描述:
- ** 主要用于后台管理员进行用户的角色分配,…
- ** 表:
- *********************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Data.SqlClient;
- using System.Configuration;
- namespace background
- {
- public class Role
- {
- SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["TZroomConnectionString"].ConnectionString);
- /// <summary>
- ///
- /// </summary>
- /// <param name="name">普通用户的名字</param>
- /// <returns></returns>
- public bool popedom(String name) {
- String T_name = name;
- String sql = "insert into administrator(administrator,password) select UserName,Password from U_Info where UserName='" + T_name + "'";
- SqlCommand cmd = new SqlCommand(sql, conn);
- int Result = -1;
- try
- {
- conn.Open();
- Result = cmd.ExecuteNonQuery();
- int delyes = -1;
- delyes = del(T_name);
- if (Result != -1 && delyes != -1)
- {
- return true;
- }
- else {
- return false;
- }
- }
- catch (Exception ex)
- {
- throw (ex);
- }
- finally {
- conn.Close();
- }
- }
- public int del(String name) {
- String T_name = name;
- String sql = "delete from U_Info where UserName='" + T_name + "'";
- SqlCommand cmd = new SqlCommand(sql, conn);
- int Result = -1;
- try
- {
- Result = cmd.ExecuteNonQuery();
- if (Result != -1)
- {
- return 1;
- }
- else {
- return -1;
- }
- }
- catch (Exception ex)
- {
- throw (ex);
- }
- }
- }
- }