/// <summary>
        /// 查询所有的SQL语句
        /// </summary>
        /// <param name="firstResult">起始值</param>
        /// <param name="pagesize">页面大小</param>
        /// <param name="orderBy">排序列</param>
        /// <param name="condition">查询条件</param>
        /// <returns></returns>
        public Object Search(int firstResult, int pagesize, string orderBy, string condition)
        {
            int totalCount = 0;  //总的数据记录条数I_NoticesType
            condition = HttpUtility.UrlDecode(condition);
            if (condition.Length > 3) //说明不是默认查找,而是带有参数的查找
            {
                string substringfront = condition.Substring(0, 4); //获取condition的前四个字符串
                int substringfrontlength = substringfront.Length;//获取子字串的长度
                int conLength = condition.Length; //获取字符串的长度
                string substringbehind = condition.Substring(5, conLength - substringfrontlength - 1);//获取condition的其余条件
                if (substringfront == "(Id") //判断是否是按id查询
                {
                    substringfront = "(Id"; //修正id
                    condition = substringfront + substringbehind; //重新组合查询条件
                }

            }
            List<NewSqlQuery> resultList = new List<NewSqlQuery>();
            IList<TbSqlQuery> QueryList = new SqlQueryDAO().GetByPageDataBase(firstResult, pagesize, orderBy, condition, out totalCount);
            if (QueryList.Count > 0)
            {
                foreach (var item in QueryList)
                {
                    NewSqlQuery tempNewSqlQuery = new NewSqlQuery();
                    int id = int.Parse(item.ICreateID.ToString());
                    TbSysUser tempUser = new SysUserDAO().GetByID(id);
                    tempNewSqlQuery.Id = item.Id;
                    tempNewSqlQuery.SSqlName = item.SSqlName;
                    tempNewSqlQuery.SSqlStr = item.SSqlStr;
                    tempNewSqlQuery.ICreateID = item.ICreateID;
                    tempNewSqlQuery.SUserName = tempUser.SUserName;
                    tempNewSqlQuery.DCreate = item.DCreate;
                    tempNewSqlQuery.ISort = item.ISort;
                    resultList.Add(tempNewSqlQuery);
                }
            }
            return this.Json(new
            {
                DataCount = totalCount,
                Data = resultList
            }, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 验证用户名唯一
 /// </summary>
 /// <param name="UserName"></param>
 /// <returns></returns>
 public JsonResult ValidateUserName(string UserName)
 {
     string whereClause = "SUserName='******'";
     IList<TbSysUser> userList = new SysUserDAO().GetByPage(whereClause, 0, int.MaxValue);
     if (userList.Count > 0)
     {
         return Json(1, JsonRequestBehavior.AllowGet);
     }
     else
     {
         return Json(0, JsonRequestBehavior.AllowGet);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 更新密码
        /// </summary>
        /// <param name="Password"></param>
        /// <returns></returns>
        public JsonResult SysUpdatePassword(string Password,String OtherPassword="")
        {
            TbSysUser item = new SysUserDAO().GetByID(SysUserInfo.GetUserID());
            if (item != null)
            {
                Password = Utitil.MD5(Password);
                item.SPassword = Password;

                //使用了更新密码功能
                  LogWriter.Default.WriteWarning("使用了更新密码功能,ip:" + Utitil.getIP() + ",用户名" + item.SUserName );

                  if (OtherPassword!= "")
                  {

                      item.SPassword = Utitil.MD5(OtherPassword);

                  }

                  suDao.Update(item);

                return Json(1, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(0, JsonRequestBehavior.AllowGet);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 验证当前密码是否与原密码一致
        /// </summary>
        /// <returns></returns>
        public JsonResult SysCheckPassword(string Password)
        {
            int result = 0;
            if (!string.IsNullOrEmpty(Password))
            {
                Password = Utitil.MD5(Password);  //把密码进行MD5加密
                TbSysUser item = new SysUserDAO().GetByID(SysUserInfo.GetUserID());
                if (item != null)
                {
                    if (Password == item.SPassword)
                    {
                        result = 1;
                    }
                }

            }
            return Json(result, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新用户角色
        /// </summary>
        /// <param name="item"></param>
        /// <param name="RoleIds"></param>
        /// <returns></returns>
        public int PutUserAndUserRole(TbSysUser item, string RoleIds)
        {
            try
            {
                TbSysUser tempuser = new SysUserDAO().GetByID(item.Id);
                if (tempuser != null)
                {
                    item.DCreateDate = tempuser.DCreateDate;    //更新时不更新用户的创建时间
                }

                //在对密码进行加密前先验证客户端传过来的密码是否非空
                if (!String.IsNullOrEmpty(item.SPassword))
                {
                    item.SPassword = Utitil.MD5(item.SPassword);  //对密码进行md5加密

                    //使用了更新密码功能
                    LogWriter.Default.WriteWarning("使用了管理员更新密码功能,ip:" + Utitil.getIP()
                        + ",更改的用户名" + item.SUserName + ",当前用户id:" + SysUserInfo.GetUserID());

                }
                else
                {
                    item.SPassword = tempuser.SPassword;  //在未更改密码的情况下,使用原密码
                }

                if (!String.IsNullOrEmpty(item.SOtherPassword))
                {
                    item.SOtherPassword = Utitil.MD5(item.SOtherPassword);  //对密码进行md5加密

                    //使用了更新密码功能
                    LogWriter.Default.WriteWarning("使用了管理员更新第二密码功能,ip:" + Utitil.getIP()
                        + ",更改的用户名" + item.SUserName + ",当前用户id:" + SysUserInfo.GetUserID());

                }
                else
                {
                    item.SOtherPassword = tempuser.SOtherPassword;  //在未更改密码的情况下,使用原密码
                }

                if (!string.IsNullOrEmpty(RoleIds))
                {
                    string[] IRoleIds;
                    string SRoleName = "";
                    IRoleIds = RoleIds.Split(new char[] { ',' });//拆分角色Id;
                    TbSysUserRole UserRole = new TbSysUserRole();//userRole添加的对象
                    UserRole.IUserId = item.Id;
                    IList<TbSysUserRole> OldUserRole = sysUserRoleDao.GetByPage("IUserId =" + item.Id, 0, int.MaxValue);//找到以前拥有的所有角色
                    if (OldUserRole.Count > 0)
                    {
                        sysUserRoleDao.Del(OldUserRole);  //通过对象集的方法删除
                    }

                    //添加user新的角色
                    foreach (string id in IRoleIds)
                    {
                        UserRole.IRoleId = int.Parse(id);
                        SRoleName = srDao.GetByID(int.Parse(id)).SRoleName + "," + SRoleName;//拼装角色字符串
                        if (sysUserRoleDao.Insert(UserRole) == 0)
                            return 0;//添加失败
                    }
                    SRoleName = SRoleName.Substring(0, SRoleName.Length - 1);
                    item.SRoleName = SRoleName;
                }
                suDao.Update(item);
                return 1;
            }
            catch (Exception ex)
            {

                return 0;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 重读获取当前管理员的部门号,用于此用户失败的情况
        /// </summary>
        /// <returns></returns>
        public static int ReloadPartID()
        {
            HttpSessionState tempSession = System.Web.HttpContext.Current.Session;
            int curUser = GetUserID();
            if (curUser > 0)
            {
                TbSysUser userItem = new SysUserDAO().GetByID(curUser);
                tempSession["PartID"] = userItem.IPart;

                return Convert.ToInt32(tempSession["PartID"]);

            }
            return -1;
        }