Esempio n. 1
0
        // 删除用户
        private string deleteUser()
        {
            myJson json = new myJson();

            try
            {
                string id = Funcs.Get("userId"); //用户类型id
                if (!Funcs.IsNumber(id))
                {
                    json.flag = 0;
                    json.msg  = "参数错误,请刷新重试";
                    return(JsonConvert.SerializeObject(json));
                }
                string strSql = "update system_users set userStatus=2 where id=" + id;
                int    result = Utility.SqlHelper.ExecuteNonQuery(strSql);
                if (result > 0)
                {
                    json.flag = 1;
                    json.msg  = "删除用户成功";
                    return(JsonConvert.SerializeObject(json));
                }
                json.flag = 0;
                json.msg  = "删除用户失败";
                return(JsonConvert.SerializeObject(json));
            }
            catch (Exception ex)
            {
                json.flag = 0;
                json.msg  = "删除用户失败:" + ex.Message;
                return(JsonConvert.SerializeObject(json));
            }
        }
Esempio n. 2
0
        // 获取用户信息
        private string getUserInfo()
        {
            myJson my = new myJson();

            try
            {
                var userId = Funcs.Get("userId");//用户Id

                SqlParameter[] param = new SqlParameter[] {
                    new SqlParameter("@userId", SqlDbType.Int)
                    {
                        Value = userId
                    }
                };

                string    strSql = "select * from system_users where id=@userId";
                DataTable dt     = Utility.SqlHelper.GetDataTable(strSql, param);
                if (dt == null || dt.Rows.Count < 1)
                {
                    my.flag = 0;
                    my.msg  = "获取用户信息失败!";
                }
                my.flag = 1;
                my.obj  = dt;
                my.msg  = "获取用户信息成功!";
                return(JsonConvert.SerializeObject(my));
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.msg  = "获取用户信息失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }
Esempio n. 3
0
        // 获取文章类型信息
        private string getCategoryInfo()
        {
            myJson my = new myJson();

            try
            {
                var categoryId = Funcs.Get("categoryId");//文章类型Id

                SqlParameter[] param = new SqlParameter[] {
                    new SqlParameter("@categoryId", SqlDbType.VarChar)
                    {
                        Value = categoryId
                    }
                };

                string    strSql = "select * from tb_category where categoryId=@categoryId";
                DataTable dt     = Utility.SqlHelper.GetDataTable(strSql, param);
                if (dt == null || dt.Rows.Count < 1)
                {
                    my.flag = 0;
                    my.msg  = "获取文章类型信息失败!";
                }
                my.flag = 1;
                my.obj  = dt;
                my.msg  = "获取文章类型信息成功!";
                return(JsonConvert.SerializeObject(my));
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.msg  = "获取文章类型信息失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }
Esempio n. 4
0
        // 删除博客导航
        private string deleteBlogMenu()
        {
            myJson json = new myJson();

            try
            {
                string id = Funcs.Get("bolgMenuId"); //博客导航Id
                if (!Funcs.IsNumber(id))
                {
                    json.flag = 0;
                    json.msg  = "参数错误,请刷新重试";
                    return(JsonConvert.SerializeObject(json));
                }
                string strSql = "update tb_blogMenu set status=0 where id=" + id;
                int    result = Utility.SqlHelper.ExecuteNonQuery(strSql);
                if (result > 0)
                {
                    json.flag = 1;
                    json.msg  = "删除导航成功";
                    return(JsonConvert.SerializeObject(json));
                }
                json.flag = 0;
                json.msg  = "删除导航失败";
                return(JsonConvert.SerializeObject(json));
            }
            catch (Exception ex)
            {
                json.flag = 0;
                json.msg  = "删除导航失败:" + ex.Message;
                return(JsonConvert.SerializeObject(json));
            }
        }
Esempio n. 5
0
        //获取用户菜单
        private string getUserMenu()
        {
            myJson json = new myJson();

            try
            {
                var            userId = Funcs.Get("userId");//用户Id
                string         strSql = "select * from system_power where userId=@userId";
                SqlParameter[] param  = new SqlParameter[] {
                    new SqlParameter("@userId", SqlDbType.Int)
                    {
                        Value = userId
                    },
                };
                DataTable dt = Utility.SqlHelper.GetDataTable(strSql, param);
                json.flag = 1;
                json.obj  = dt;
                return(JsonConvert.SerializeObject(json));
            }
            catch (Exception ex)
            {
                json.flag = 0;
                json.msg  = "获取用户菜单失败:" + ex.Message;
                return(JsonConvert.SerializeObject(json));
            }
        }
Esempio n. 6
0
        // 删除文章类型
        private string deleteCategory()
        {
            myJson json = new myJson();

            try
            {
                string         categoryId = Funcs.Get("categoryId"); //文章类型id
                SqlParameter[] param      = new SqlParameter[] {
                    new SqlParameter("@categoryId", SqlDbType.VarChar)
                    {
                        Value = categoryId
                    }
                };
                string strSql = "delete from tb_category where categoryId=@categoryId";
                int    count  = Utility.SqlHelper.ExecuteNonQuery(strSql, param);
                if (count > 0)
                {
                    json.flag = 1;
                    json.msg  = "删除成功";
                    return(JsonConvert.SerializeObject(json));
                }
                json.flag = 0;
                json.msg  = "删除失败";
                return(JsonConvert.SerializeObject(json));
            }
            catch (Exception ex)
            {
                json.flag = 0;
                json.msg  = "删除失败:" + ex.Message;
                return(JsonConvert.SerializeObject(json));
            }
        }
Esempio n. 7
0
        // 删除文章
        private string deleteArticle()
        {
            myJson json = new myJson();

            try
            {
                string articleId = Funcs.Get("articleId"); //文章id
                if (!Funcs.IsNumber(articleId))
                {
                    json.flag = 0;
                    json.msg  = "参数错误,请刷新重试";
                    return(JsonConvert.SerializeObject(json));
                }
                string strSql = "update tb_article set status=2 where id=" + articleId;
                int    count  = Utility.SqlHelper.ExecuteNonQuery(strSql);
                if (count > 0)
                {
                    json.flag = 1;
                    json.msg  = "删除成功";
                    return(JsonConvert.SerializeObject(json));
                }
                json.flag = 0;
                json.msg  = "删除失败";
                return(JsonConvert.SerializeObject(json));
            }
            catch (Exception ex)
            {
                json.flag = 0;
                json.msg  = "删除失败:" + ex.Message;
                return(JsonConvert.SerializeObject(json));
            }
        }
Esempio n. 8
0
        // 删除用户类型
        private string deleteUserType()
        {
            myJson json = new myJson();

            try
            {
                string id = Funcs.Get("id"); //用户类型id
                if (!Funcs.IsNumber(id))
                {
                    json.flag = 0;
                    json.msg  = "参数错误,请刷新重试";
                    return(JsonConvert.SerializeObject(json));
                }
                string strSql = "delete from system_params where id=" + id;
                int    count  = Utility.SqlHelper.ExecuteNonQuery(strSql);
                if (count > 0)
                {
                    json.flag = 1;
                    json.msg  = "删除成功";
                    return(JsonConvert.SerializeObject(json));
                }
                json.flag = 0;
                json.msg  = "删除失败";
                return(JsonConvert.SerializeObject(json));
            }
            catch (Exception ex)
            {
                json.flag = 0;
                json.msg  = "删除失败:" + ex.Message;
                return(JsonConvert.SerializeObject(json));
            }
        }
Esempio n. 9
0
        // 获取下拉框
        public string selectList()
        {
            myJson        my  = new myJson();
            StringBuilder sbr = new StringBuilder();

            try
            {
                string tableName = Funcs.Get("tableName");
                string key       = Funcs.Get("key");
                string value     = Funcs.Get("value");
                string where = Funcs.Get("where");
                string orderBy = Funcs.Get("orderBy");
                string name    = Funcs.Get("name");
                if (name != "")
                {
                    sbr.Append("<option value=''>-请选择" + name + "-</option>");
                }
                string strSql = "select " + key + " as 'key', " + value + " as 'value'  from " + tableName + " where 1=1";
                if (where.Length > 0)
                {
                    strSql += " and " + where;
                }
                if (orderBy.Length > 0)
                {
                    strSql += " order by " + orderBy;
                }
                DataTable dt = SqlHelper.GetDataTable(strSql);
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        sbr.Append("<option value='" + item["value"].ToString() + "'>" + item["key"].ToString() + "</option>");
                    }
                    my.flag = 1;
                    my.obj  = sbr.ToString();
                    return(JsonConvert.SerializeObject(my));
                }
                else
                {
                    my.flag = 0;
                    my.obj  = sbr.ToString();
                    my.msg  = "获取下拉框列表失败!";
                    return(JsonConvert.SerializeObject(my));
                }
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.obj  = sbr.ToString();
                my.msg  = "获取下拉框列表失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }
Esempio n. 10
0
        // 新增或编辑文章类型
        private string addOrEditCategory()
        {
            myJson my = new myJson();

            try
            {
                var oldCategoryId = Funcs.Get("oldCategoryId");                       //文章类型旧Id
                var newCategoryId = Funcs.Get("newCategoryId");                       //文章类型新Id
                var categoryName  = GlobalObject.unescape(Funcs.Get("categoryName")); //文章类型名称
                var parentId      = Funcs.Get("parentId");                            //父类型

                SqlParameter[] param = new SqlParameter[] {
                    new SqlParameter("@param_oldCategoryId", SqlDbType.VarChar)
                    {
                        Value = oldCategoryId
                    },
                    new SqlParameter("@param_newCategoryId", SqlDbType.VarChar)
                    {
                        Value = newCategoryId
                    },
                    new SqlParameter("@param_categoryName", SqlDbType.VarChar)
                    {
                        Value = categoryName
                    },
                    new SqlParameter("@param_parentId", SqlDbType.VarChar)
                    {
                        Value = parentId
                    },
                    new SqlParameter("@param_retCode", SqlDbType.Int)
                    {
                        Direction = ParameterDirection.Output
                    },
                    new SqlParameter("@param_retMsg", SqlDbType.VarChar)
                    {
                        Direction = ParameterDirection.Output, Size = 50
                    }
                };

                Utility.SqlHelper.ExecProcNonQuery("sp_AddOrEditCategory", param);

                my.flag = System.Convert.ToInt32(param[4].Value);
                my.msg  = param[5].Value.ToString();
                return(JsonConvert.SerializeObject(my));
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.msg  = "保存失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 返回登录
        /// </summary>
        /// <returns></returns>
        public string returnLogin()
        {
            myJson my = new myJson();

            if (MySession.GetSessionStringValue("userName") == "")
            {
                my.flag = -100;
                my.msg  = "无权访问!";
            }
            else
            {
                my.flag = -101;
                my.msg  = "您的帐号在其他地方登录,被迫下线!";
            }
            return(JsonConvert.SerializeObject(my));
        }
Esempio n. 12
0
        // 上传img
        private string uploadImg()
        {
            HttpContext    context = System.Web.HttpContext.Current;
            HttpPostedFile file    = context.Request.Files[0];
            myJson         json    = new myJson();

            try
            {
                if (file.ContentLength <= 0 || string.IsNullOrEmpty(file.FileName))
                {
                    json.flag = 0;
                    json.msg  = "上传错误,没有选择文件";
                    return(JsonConvert.SerializeObject(json));
                }

                string Extension = Path.GetExtension(file.FileName).ToLower();
                if (Extension == ".jpg" || Extension == ".jpeg" || Extension == ".png" || Extension == ".bmp")
                {
                    byte[] buffer = new byte[file.InputStream.Length];
                    file.InputStream.Read(buffer, 0, buffer.Length);
                    string name         = ImageLibrary.md5(buffer);
                    string path         = imgfilePath + "/" + date + "/";
                    string absolutePath = context.Server.MapPath(path);
                    if (!Directory.Exists(absolutePath))
                    {
                        Directory.CreateDirectory(absolutePath);
                    }
                    file.SaveAs(absolutePath + name + Extension);
                    json.flag = 1;
                    json.obj  = path + name + Extension;
                    return(JsonConvert.SerializeObject(json));
                }
                else
                {
                    json.flag = 0;
                    json.msg  = "类型错误,只能上传图片";
                    return(JsonConvert.SerializeObject(json));
                }
            }
            catch (Exception ex)
            {
                json.flag = 0;
                json.msg  = "上传失败:" + ex.Message;
                return(JsonConvert.SerializeObject(json));
            }
        }
Esempio n. 13
0
        // 修改密码
        private string changePwd()
        {
            myJson json = new myJson();

            try
            {
                string id       = Funcs.Get("userId");                          //用户id
                string password = GlobalObject.unescape(Funcs.Get("password")); //密码
                if (!Funcs.IsNumber(id))
                {
                    json.flag = 0;
                    json.msg  = "参数错误,请刷新重试";
                    return(JsonConvert.SerializeObject(json));
                }
                string strSql = "update system_users set password=@password where id=@id";

                SqlParameter[] param = new SqlParameter[] {
                    new SqlParameter("@password", SqlDbType.VarChar)
                    {
                        Value = Funcs.MD5(password)
                    },
                    new SqlParameter("@id", SqlDbType.Int)
                    {
                        Value = id
                    }
                };

                int result = Utility.SqlHelper.ExecuteNonQuery(strSql, param);
                if (result > 0)
                {
                    json.flag = 1;
                    json.msg  = "修改密码成功";
                    return(JsonConvert.SerializeObject(json));
                }
                json.flag = 0;
                json.msg  = "修改密码失败";
                return(JsonConvert.SerializeObject(json));
            }
            catch (Exception ex)
            {
                json.flag = 0;
                json.msg  = "修改密码失败:" + ex.Message;
                return(JsonConvert.SerializeObject(json));
            }
        }
Esempio n. 14
0
        // 添加或编辑用户类型
        private string addOrEditUserType()
        {
            myJson my = new myJson();

            try
            {
                var id         = Funcs.Get("id") == "" ? "0" : Funcs.Get("id");  //用户类型Id
                var paramsName = GlobalObject.unescape(Funcs.Get("paramsName")); //用户类型名称

                SqlParameter[] param = new SqlParameter[] {
                    new SqlParameter("param_id", SqlDbType.Int)
                    {
                        Value = id
                    },
                    new SqlParameter("param_parentId", SqlDbType.Int)
                    {
                        Value = 1
                    },
                    new SqlParameter("param_paramsName", SqlDbType.VarChar)
                    {
                        Value = paramsName
                    }
                };

                int count = Utility.SqlHelper.ExecProcNonQuery("sp_AddOrUpdateParam", param);

                if (count > 0)
                {
                    my.flag = 1;
                    my.msg  = "保存成功!";
                    return(JsonConvert.SerializeObject(my));
                }
                my.flag = 0;
                my.msg  = "保存失败!";
                return(JsonConvert.SerializeObject(my));
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.msg  = "保存失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }
Esempio n. 15
0
        // 获得用户权限
        private string getUserPower()
        {
            myJson my = new myJson();

            try
            {
                var userId = Funcs.Get("userId");//用户Id

                SqlParameter[] parameters = new SqlParameter[1];

                parameters[0]       = new SqlParameter("userId", SqlDbType.Int);
                parameters[0].Value = userId;

                string    strSql = "select * from system_menu";
                DataTable dt     = Utility.SqlHelper.GetDataTable(strSql);
                if (dt == null || dt.Rows.Count < 1)
                {
                    my.flag = 0;
                    my.msg  = "获取菜单列表失败!";
                }
                my.obj = dt;
                strSql = @"select sm.id,sm.parentId from system_menu sm 
                           left join system_power sp on sm.id=sp.menuId 
                           where sp.userId=@userId order by sortValue";
                dt     = Utility.SqlHelper.GetDataTable(strSql, parameters);
                if (dt == null)
                {
                    my.flag = 0;
                    my.msg  = "获取当前用户权限失败!";
                }
                my.obj2 = dt;
                my.flag = 1;
                my.msg  = "获取用户权限成功!";
                return(JsonConvert.SerializeObject(my));
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.msg  = "获取用户权限失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }
Esempio n. 16
0
        // 访问文章
        private string clickArticle()
        {
            myJson my = new myJson();

            try
            {
                var        articleId = Funcs.Get("articleId"); //文章id
                ArticleDAL dal       = new ArticleDAL();
                dal.clickArticle(articleId, HttpContext.Current.Request.UserHostAddress);
                my.flag = 1;
                my.msg  = "访问文章成功!";
                return(JsonConvert.SerializeObject(my));
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.msg  = "访问文章失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }
Esempio n. 17
0
        //绑定菜单
        private string getMenuTree()
        {
            myJson json = new myJson();

            try
            {
                string strSql = "select * from system_menu order by parentId,sortvalue";
                dtMenu = Utility.SqlHelper.GetDataTable(strSql);
                strbMenu.Append("[");
                MenuBuild("0");
                strbMenu.Append("]");
                json.flag = 1;
                json.obj  = strbMenu.ToString();
                return(JsonConvert.SerializeObject(json));
            }
            catch (Exception ex)
            {
                json.flag = 0;
                json.msg  = "菜单绑定错误:" + ex.Message;
                return(JsonConvert.SerializeObject(json));
            }
        }
Esempio n. 18
0
        // 保存权限
        private string savePowers()
        {
            myJson my = new myJson();

            try
            {
                string userid = Funcs.Get("userid");
                string idlist = Funcs.Get("ids").TrimEnd(',');
                if (!Funcs.IsNumber(userid) || idlist.Length < 1)
                {
                    my.flag = 0;
                    my.msg  = "参数错误,请刷新重试";
                    return(JsonConvert.SerializeObject(my));
                }

                SqlParameter[] parameters = new SqlParameter[2];
                parameters[0]       = new SqlParameter("@param_userid", SqlDbType.Int);
                parameters[1]       = new SqlParameter("@param_addids", SqlDbType.VarChar);
                parameters[0].Value = userid;
                parameters[1].Value = idlist.ToString();

                int count = Utility.SqlHelper.ExecProcNonQuery("sp_AddOrUpdatePower", parameters);
                if (count > 0)
                {
                    my.flag = 1;
                    my.msg  = "保存成功";
                    return(JsonConvert.SerializeObject(my));
                }
                my.flag = 0;
                my.msg  = "保存失败";
                return(JsonConvert.SerializeObject(my));
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.msg  = "保存失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }
Esempio n. 19
0
        // 获取文章信息
        private string getArticleInfo()
        {
            myJson my = new myJson();

            try
            {
                var articleId = Funcs.Get("articleId");//文章Id

                SqlParameter[] param = new SqlParameter[] {
                    new SqlParameter("@articleId", SqlDbType.Int)
                    {
                        Value = articleId
                    }
                };

                string    strSql = "select * from tb_article where id=@articleId";
                DataTable dt     = Utility.SqlHelper.GetDataTable(strSql, param);
                if (dt == null || dt.Rows.Count < 1)
                {
                    my.flag = 0;
                    my.msg  = "获取导航信息失败!";
                    return(JsonConvert.SerializeObject(my));
                }
                strSql = "select * from tb_article_tag where articleId=@articleId";
                DataTable dt2 = Utility.SqlHelper.GetDataTable(strSql, param);
                my.flag = 1;
                my.obj  = dt;
                my.obj2 = dt2;
                my.msg  = "获取导航信息成功!";
                return(JsonConvert.SerializeObject(my));
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.msg  = "获取导航信息失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }
Esempio n. 20
0
        // 获取参数下拉框
        public string selectParams()
        {
            myJson        my  = new myJson();
            StringBuilder sbr = new StringBuilder();

            try
            {
                string    parentId = Funcs.Get("parentId");
                string    strSql   = "select id, paramsName from system_params where parentid=" + parentId;
                DataTable dt       = SqlHelper.GetDataTable(strSql);
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        sbr.Append("<option value='" + item["id"].ToString() + "'>" + item["paramsName"].ToString() + "</option>");
                    }
                    my.flag = 1;
                    my.obj  = sbr.ToString();
                    return(JsonConvert.SerializeObject(my));
                }
                else
                {
                    my.flag = 0;
                    my.obj  = sbr.ToString();
                    my.msg  = "获取参数下拉框列表失败!";
                    return(JsonConvert.SerializeObject(my));
                }
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.obj  = sbr.ToString();
                my.msg  = "获取参数下拉框列表失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }
Esempio n. 21
0
        // 新增或编辑文章
        private string addOrEditArticle()
        {
            myJson my = new myJson();

            try
            {
                var articleId = Funcs.Get("articleId") == "" ? "0" : Funcs.Get("articleId"); //文章Id
                var title     = GlobalObject.unescape(Funcs.Get("title"));                   //标题
                var category  = Funcs.Get("category");                                       //文章类型
                var tags      = GlobalObject.unescape(Funcs.Get("tags"));                    //标签
                var isTop     = Funcs.Get("isTop");                                          //是否置顶
                var img       = Funcs.Get("img");                                            //图片
                var content   = GlobalObject.unescape(Funcs.Get("content"));                 //文章内容

                SqlParameter[] param = new SqlParameter[] {
                    new SqlParameter("@param_articleId", SqlDbType.Int)
                    {
                        Value = articleId
                    },
                    new SqlParameter("@param_title", SqlDbType.VarChar)
                    {
                        Value = title
                    },
                    new SqlParameter("@param_category", SqlDbType.VarChar)
                    {
                        Value = category
                    },
                    new SqlParameter("@param_tags", SqlDbType.VarChar)
                    {
                        Value = tags
                    },
                    new SqlParameter("@param_isTop", SqlDbType.Int)
                    {
                        Value = isTop
                    },
                    new SqlParameter("@param_img", SqlDbType.VarChar)
                    {
                        Value = img
                    },
                    new SqlParameter("@param_content", SqlDbType.Text)
                    {
                        Value = content
                    },
                    new SqlParameter("@param_userId", SqlDbType.Int)
                    {
                        Value = MySession.GetUserID()
                    }
                };

                Utility.SqlHelper.ExecProcNonQuery("sp_AddOrEditArticle", param);

                my.flag = 1;
                my.msg  = "保存成功!";
                return(JsonConvert.SerializeObject(my));
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.msg  = "保存失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }
Esempio n. 22
0
        // 用户登录
        private string userLogin()
        {
            myJson my = new myJson();

            try
            {
                #region 检测用户名,密码
                string userName = Funcs.Get("userName"); //用户名
                string pwd      = Funcs.Get("pwd");      //密码

                string         strSql = "select su.*,sp.paramsName userTypeName from system_users su inner join system_params sp on su.userType=sp.id where su.userName=@userName and su.password=@pwd";
                SqlParameter[] param  = new SqlParameter[] {
                    new SqlParameter("@userName", SqlDbType.VarChar)
                    {
                        Value = userName
                    },
                    new SqlParameter("@pwd", SqlDbType.VarChar)
                    {
                        Value = Funcs.MD5(pwd)
                    }
                };

                DataTable tb = Utility.SqlHelper.GetDataTable(strSql, param);
                if (tb == null || tb.Rows.Count < 1)
                {
                    my.flag = 0;
                    my.msg  = "用户名或密码错误!";
                    return(JsonConvert.SerializeObject(my));
                }
                if (int.Parse(tb.Rows[0]["userstatus"].ToString()) == 0)
                {
                    my.flag = 0;
                    my.msg  = "您的帐号已暂停使用,请联系管理员!";
                    return(JsonConvert.SerializeObject(my));
                }
                #endregion

                #region 保存用户信息,权限到Session
                string loginUserId = tb.Rows[0]["id"].ToString();
                //防止一个帐号多处登录
                Global.Add(int.Parse(loginUserId), HttpContext.Current.Session.SessionID);


                //保存用户的信息到Session
                MySession.Add("userId", tb.Rows[0]["id"]);
                MySession.Add("userName", tb.Rows[0]["userName"]);
                MySession.Add("userTypeName", tb.Rows[0]["userTypeName"]);
                MySession.Add("trueName", tb.Rows[0]["trueName"]);

                #endregion

                my.flag = 1;
                my.msg  = "登录成功";
                return(JsonConvert.SerializeObject(my));
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.msg  = "登录失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }
Esempio n. 23
0
        // 新增或编辑博客导航
        private string addOrEditBlogMenu()
        {
            myJson my = new myJson();

            try
            {
                var blogMenuId = Funcs.Get("blogMenuId") == "" ? "0" : Funcs.Get("blogMenuId"); //博客菜单Id
                var menuName   = GlobalObject.unescape(Funcs.Get("menuName"));                  //菜单名称
                var menuUrl    = GlobalObject.unescape(Funcs.Get("menuUrl"));                   //菜单Url
                var menuKey    = GlobalObject.unescape(Funcs.Get("menuKey"));                   //菜单Key
                var category   = Funcs.Get("category");                                         //文章类型
                var parentId   = Funcs.Get("parentId");                                         //父菜单
                var showType   = Funcs.Get("showType");                                         //列表显示类型
                var sort       = Funcs.Get("sort");                                             //排序


                SqlParameter[] param = new SqlParameter[] {
                    new SqlParameter("param_blogMenuId", SqlDbType.Int)
                    {
                        Value = blogMenuId
                    },
                    new SqlParameter("param_menuName", SqlDbType.VarChar)
                    {
                        Value = menuName
                    },
                    new SqlParameter("param_menuUrl", SqlDbType.VarChar)
                    {
                        Value = menuUrl
                    },
                    new SqlParameter("param_menuKey", SqlDbType.VarChar)
                    {
                        Value = menuKey
                    },
                    new SqlParameter("param_category", SqlDbType.VarChar)
                    {
                        Value = category
                    },
                    new SqlParameter("param_parentId", SqlDbType.Int)
                    {
                        Value = parentId
                    },
                    new SqlParameter("param_showType", SqlDbType.Int)
                    {
                        Value = showType
                    },
                    new SqlParameter("param_sort", SqlDbType.Int)
                    {
                        Value = sort
                    }
                };

                int count = Utility.SqlHelper.ExecProcNonQuery("sp_AddOrEditBlogMenu", param);

                if (count > 0)
                {
                    my.flag = 1;
                    my.msg  = "保存成功!";
                    return(JsonConvert.SerializeObject(my));
                }
                my.flag = 0;
                my.msg  = "保存失败!";
                return(JsonConvert.SerializeObject(my));
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.msg  = "保存失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }
Esempio n. 24
0
        // 新增或编辑用户
        private string addOrEditUser()
        {
            myJson my = new myJson();

            try
            {
                var userId     = Funcs.Get("userId") == "" ? "0" : Funcs.Get("userId"); //用户Id
                var userName   = GlobalObject.unescape(Funcs.Get("userName"));          //用户名
                var nikeName   = GlobalObject.unescape(Funcs.Get("nikeName"));          //昵称
                var password   = GlobalObject.unescape(Funcs.Get("password"));          //密码
                var truename   = GlobalObject.unescape(Funcs.Get("truename"));          //真实姓名
                var userType   = Funcs.Get("userType");                                 //用户类型
                var userStatus = Funcs.Get("userStatus");                               //用户状态

                SqlParameter[] param = new SqlParameter[] {
                    new SqlParameter("@param_userId", SqlDbType.Int)
                    {
                        Value = userId
                    },
                    new SqlParameter("@param_userName", SqlDbType.VarChar)
                    {
                        Value = userName
                    },
                    new SqlParameter("@param_nikeName", SqlDbType.VarChar)
                    {
                        Value = nikeName
                    },
                    new SqlParameter("@param_pwd", SqlDbType.VarChar)
                    {
                        Value = Funcs.MD5(password)
                    },
                    new SqlParameter("@param_trueName", SqlDbType.VarChar)
                    {
                        Value = truename
                    },
                    new SqlParameter("@param_userType", SqlDbType.Int)
                    {
                        Value = userType
                    },
                    new SqlParameter("@param_userStatus", SqlDbType.Int)
                    {
                        Value = userStatus
                    },
                    new SqlParameter("@param_createTime", SqlDbType.DateTime)
                    {
                        Value = DateTime.Now
                    }
                };
                //判断此用户名是否被使用
                string sql   = "select count(*) from system_users where username=@param_userName and id!=@param_userId and userstatus!=2";
                int    count = System.Convert.ToInt32(Utility.SqlHelper.ExecuteScalar(sql, param));
                if (count > 0)
                {
                    my.flag = 0;
                    my.msg  = "此用户名已存在,请更换!";
                    return(JsonConvert.SerializeObject(my));
                }

                count = Utility.SqlHelper.ExecProcNonQuery("sp_AddOrUpdateUser", param);

                if (count > 0)
                {
                    my.flag = 1;
                    my.msg  = "保存成功!";
                    return(JsonConvert.SerializeObject(my));
                }
                my.flag = 0;
                my.msg  = "保存失败!";
                return(JsonConvert.SerializeObject(my));
            }
            catch (Exception ex)
            {
                my.flag = 0;
                my.msg  = "保存失败:" + ex.Message;
                return(JsonConvert.SerializeObject(my));
            }
        }