Пример #1
0
        /// <summary>
        /// 用户组信息修改
        /// </summary>
        /// <param name="group">用户组信息</param>
        /// <returns>执行结果</returns>
        public Result Update(sys_group group)
        {
            PermDAL perm = new PermDAL();
            Result  res  = new Result();

            try
            {
                if (perm.Update(group) == 0)
                {
                    res.Code    = RES.ERROR;
                    res.Message = "修改失败!";
                    return(res);
                }
                else
                {
                    res.Code    = RES.OK;
                    res.Message = "修改成功!";
                    return(res);
                }
            }
            catch
            {
                res.Code    = RES.ERROR;
                res.Message = "修改失败!";
                return(res);
            }
        }
Пример #2
0
        /// <summary>
        /// 根据id查找用户组
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public List <sys_group> SelectGroupByID(int id)
        {
            DataSet          ds            = new DataSet();
            string           sql           = "Select * from sys_group where id = @p1";
            SqlParameter     sqlParameter1 = new SqlParameter("@p1", id);
            List <sys_group> group2        = new List <sys_group>();

            ds = SqlHelper.ExecuteDataset(ConStr, CommandType.Text, sql, sqlParameter1);
            try
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    sys_group group1 = new sys_group();
                    group1.id          = (int)ds.Tables[0].Rows[i][nameof(sys_group.id)];
                    group1.group_name  = (string)ds.Tables[0].Rows[i][nameof(sys_group.group_name)];
                    group1.remark      = (string)ds.Tables[0].Rows[i][nameof(sys_group.remark)];
                    group1.create_time = (DateTime)ds.Tables[0].Rows[i][nameof(sys_group.create_time)];
                    group1.modify_time = (DateTime)ds.Tables[0].Rows[i][nameof(sys_group.modify_time)];
                    group2.Add(group1);
                }
            }
            catch (Exception e)
            {
                new LogSysDAL().Add(LogOperations.LogSys("id查询用户组" + e.Message));
            }
            return(group2);
        }
Пример #3
0
        /// <summary>
        /// 添加用户组
        /// </summary>
        /// <param name="group"></param>
        /// <returns>执行结果</returns>
        public Result Add(sys_group group)
        {
            Result  res  = new Result();
            PermDAL perm = new PermDAL();

            try
            {
                if (perm.Add(group) == 0)
                {
                    res.Code    = RES.ERROR;
                    res.Message = "添加失败!";
                    return(res);
                }
                else
                {
                    res.Code    = RES.OK;
                    res.Message = "添加成功!";
                    return(res);
                }
            }
            catch
            {
                res.Code    = RES.ERROR;
                res.Message = "添加失败!";
                return(res);
            }
        }
Пример #4
0
        private void BtnsearchGroup_Click(object sender, EventArgs e)
        {
            sys_group group = new sys_group();

            group.group_name       = TxtGroupName.Text;
            group.create_time      = TimeStartGroup.Value;
            group.modify_time      = TimeEditGroup.Value;
            DgvGroupMan.DataSource = null;
            DgvGroupMan.DataSource = new PermBLL().SelectGroupBy(group);
        }
Пример #5
0
        public HttpResponseMessage UpdateGroupInfo(string name, int id)
        {
            sys_group group = db.Sys_groupRepository.Find(id);

            group.OuName = name;
            db.Sys_groupRepository.Update(group, new string[] { "OuName" });
            db.Save();
            var res = new { Result = "OK" };

            return(new Models.JsonpResultAPI <object>(res));
        }
Пример #6
0
        public HttpResponseMessage UpdateGroupStatus(int ID, int Status)
        {
            sys_group group = db.Sys_groupRepository.Find(ID);

            group.Status = Status;
            db.Sys_groupRepository.Update(group, new string[] { "Status" });
            db.Save();
            var res = new { Result = "OK" };

            return(new Models.JsonpResultAPI <object>(res));
        }
Пример #7
0
 /// <summary>
 /// 用户组信息修改
 /// </summary>
 /// <param name="group">用户组信息</param>
 /// <returns>返回修改条数</returns>
 public int Update(sys_group group)
 {
     try {
         int          res;
         string       sql           = "update sys_group set group_name = @p2,remark = @p3,modify_time = getdate() where id= @p1";
         SqlParameter sqlParameter1 = new SqlParameter("@p1", group.id);
         SqlParameter sqlParameter2 = new SqlParameter("@p2", group.group_name);
         SqlParameter sqlParameter3 = new SqlParameter("@p3", group.remark);
         res = SqlHelper.ExecuteNonQuery(ConStr, CommandType.Text, sql, sqlParameter1, sqlParameter2, sqlParameter3);
         new LogUserDAL().Add(LogOperations.LogUser("修改用户组"));
         return(res);
     }
     catch (Exception e)
     {
         new LogSysDAL().Add(LogOperations.LogSys("修改用户组" + e.Message));
         return(0);
     }
 }
Пример #8
0
 /// <summary>
 ///添加用户组
 /// </summary>
 /// <param name="group">用户组信息</param>
 /// <returns>添加条数</returns>
 public int Add(sys_group group)
 {
     try
     {
         int          res;
         string       sql1          = "Insert into sys_group(group_name,remark,create_time,modify_time) values(@p1,@p2,getdate(),getdate())";
         SqlParameter sqlparameter1 = new SqlParameter("@p1", group.group_name);
         SqlParameter sqlparameter2 = new SqlParameter("@p2", group.remark);
         res = SqlHelper.ExecuteNonQuery(ConStr, CommandType.Text, sql1, sqlparameter1, sqlparameter2);
         new LogUserDAL().Add(LogOperations.LogUser("添加用户组"));
         return(res);
     }
     catch (Exception e)
     {
         new LogSysDAL().Add(LogOperations.LogSys("添加用户组" + e.Message));
         return(0);
     }
 }
Пример #9
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (Text.Equals("添加用户组"))
            {
                sys_group group = new sys_group();
                group.group_name = textBoxX1.Text;
                group.remark     = textBoxX2.Text;
                PermBLL perm   = new PermBLL();
                Result  result = new Result();
                result = perm.Add(group);
                if (result.Message == "添加成功!")
                {
                    MessageBoxCustom.Show("添加成功", "提示", this);
                }
                else
                {
                    MessageBoxCustom.Show("添加失败", "提示", this);
                }
            }
            else
            {
                PermBLL   perm   = new PermBLL();
                sys_group group1 = new sys_group();
                group1.group_name = textBoxX1.Text;
                group1.remark     = textBoxX2.Text;
                group1.id         = number;

                Result result = new Result();
                result = perm.Update(group1);
                if (result.Message == "修改成功!")
                {
                    MessageBoxCustom.Show("修改成功", "提示", this);
                }
                else
                {
                    MessageBoxCustom.Show("修改失败", "提示", this);
                }
            }
        }
Пример #10
0
        /// <summary>
        /// 查询用户组基本信息
        /// </summary>
        /// <param name="group">查询条件</param>
        /// <returns>用户组信息</returns>
        public List <sys_group> SelectGroupBy(sys_group group)
        {
            DataSet             ds      = new DataSet();
            string              sql     = "Select * from sys_group where 1=1";
            List <SqlParameter> sqlPara = new List <SqlParameter>();

            if (!string.IsNullOrEmpty(group.group_name))
            {
                sql += " and group_name like @group_name";
                sqlPara.Add(new SqlParameter("@group_name", "%" + group.group_name + "%"));
            }

            sql += " and create_time >= @createtime";
            sqlPara.Add(new SqlParameter("@createtime", group.create_time));
            sql += " and modify_time <= @modifytime";
            sqlPara.Add(new SqlParameter("@modifytime", group.modify_time));
            List <sys_group> group2 = new List <sys_group>();

            try
            {
                ds = SqlHelper.ExecuteDataset(ConStr, CommandType.Text, sql, sqlPara.ToArray());
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    sys_group group1 = new sys_group();
                    group1.id          = (int)ds.Tables[0].Rows[i][nameof(sys_group.id)];
                    group1.group_name  = (string)ds.Tables[0].Rows[i][nameof(sys_group.group_name)];
                    group1.remark      = (string)ds.Tables[0].Rows[i][nameof(sys_group.remark)];
                    group1.create_time = (DateTime)ds.Tables[0].Rows[i][nameof(sys_group.create_time)];
                    group1.modify_time = (DateTime)ds.Tables[0].Rows[i][nameof(sys_group.modify_time)];
                    group2.Add(group1);
                }
            }
            catch (Exception e)
            {
                new LogSysDAL().Add(LogOperations.LogSys("条件查询用户组" + e.Message));
            }
            return(group2);
        }
Пример #11
0
        public HttpResponseMessage SaveGroupInfo(string name, string parentOuID)
        {
            var res = new { Result = "OK" };

            if (db.Sys_groupRepository.Get(e => e.OuName == name && e.ParentOuID == parentOuID).Count() == 0)
            {
                sys_group group = new sys_group
                {
                    OuID       = Guid.NewGuid().ToString("N"),
                    OuName     = name,
                    ParentOuID = parentOuID == null ? "0" : parentOuID,
                    Status     = 1,
                    CreateTime = DateTime.Now,
                    UpdateTime = DateTime.Now
                };
                db.Sys_groupRepository.Insert(group);
                db.Save();
            }
            else
            {
                res = new { Result = "组织已存在" };
            }
            return(new Models.JsonpResultAPI <object>(res));
        }
Пример #12
0
        public ActionResult Add(FormCollection collection)
        {
            var model = new sys_group();

            this.TryUpdateModel <sys_group>(model);
            if (string.IsNullOrEmpty(model.groupName))
            {
                ModelState.AddModelError("error", "名称错误");
                return(View("Edit"));
            }

            string checkAll = collection.Get("checkAll");

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    var id = bll.AddEntities(model);
                    foreach (var item in checkAll.Split(','))
                    {
                        sys_acl_group models = new sys_acl_group();
                        models.access   = true;
                        models.groupID  = int.Parse(id.ToString());
                        models.actionID = int.Parse(item);
                        aclgroupBll.AddEntities(models);
                    }
                    scope.Complete();
                }
            }
            catch
            {
                return(View("Edit", model));
            }

            return(this.JscriptMsg("信息已添加成功", false, "Success"));
        }
Пример #13
0
        /// <summary>
        /// 查询所有用户组
        /// </summary>
        /// <param name="group"></param>
        /// <returns></returns>
        public List <sys_group> SelectGroup(sys_group group)
        {
            PermDAL perm = new PermDAL();

            return(perm.SelectGroup(group));
        }