Ejemplo n.º 1
0
        /// <summary>
        /// 新增用户
        /// </summary>
        /// <param name="name">用户名</param>
        /// <param name="context"></param>
        public void adduser(string name, HttpContext context)
        {
            string nono = "对不起,你没有权限进行此操作!";
            string[] xy = { "【运行所】", "【系统管理员】" }; //需要的权限才能操作

            if (testQX(xy, context) == false)
            {
                context.Response.Write(nono);
                return;
            }

            string SQL = "INSERT INTO [WebApp].[dbo].[DL_用户名]([用户名],[密码],[权限])VALUES('{0}','f379eaf3c831b04de153469d1bec345e','【普通】')";
            SQL = string.Format(SQL, name.Trim());

            DAL dal = new DAL();

            bool ok = dal.RunSqlExists("SELECT [ID] FROM [WebApp].[dbo].[DL_用户名] where 用户名='" + name.Trim() + "'");
            if (ok == true)
            {
                context.Response.Write("添加失败:用户[" + name.Trim() + "]已经存在!");

            }
            else
            {
                dal.RunSql(SQL);
                if (dal.ExecuteRowCount == 1)
                {
                    setupUserML(name);
                    Sys.addSteps(getname(context), "新增用户:" + name.Trim(), "[用户管理]");
                    context.Response.Write("成功");
                }
                else
                {
                    context.Response.Write(dal.ErrorMsg);
                }
            }
        }