Exemplo n.º 1
0
 public JsonResult Edit(OrganModel model)
 {
     try
     {
         if (model.Id == 1 || ViewDatas.GetInstance().GetUser(Request).RoleId != UserType.SysAdmin)
         {
             return(Json(new { State = false, Message = "您无权限编辑该组织!" }));
         }
         else
         {
             _business.Update(model);
             return(Json(new JsonResultLogModel
             {
                 State = true,
                 Message = "组织信息修改成功!",
                 Log = $" 用户 {SiteUser.Username} 编辑组织 {model.Name} ",
                 LogType = LogType.OrganManage,
                 Username = SiteUser.Username
             }));
         }
     }
     catch (Exception ex)
     {
         return(Json(new { State = false, Message = ex.Message }));
     }
 }
Exemplo n.º 2
0
 public void Insert(OrganModel model)
 {
     using (MySqlConnection conn = new MySqlConnection(_connStr))
     {
         conn.Open();
         conn.Execute(INSERT, model);
     }
 }
Exemplo n.º 3
0
        public ActionResult Add(int id)
        {
            OrganModel model = _business.GetItem(id);

            return(View(new OrganModel()
            {
                ParentId = id, ParentOrganizationName = model == null ? "无" : model.Name
            }));
        }
Exemplo n.º 4
0
        public void Update(string condition, OrganModel model)
        {
            string sql = GetUpdateSql("Name=@Name,Description=@Description,SMSTelephone=@SMSTelephone,X=@X,Y=@Y", condition);

            using (MySqlConnection conn = new MySqlConnection(_connStr))
            {
                conn.Open();
                conn.Execute(sql, model);
            }
        }
Exemplo n.º 5
0
        public void ChangeState(string condition, OrganModel item)
        {
            string sql = GetUpdateSql(
                "State = @State"
                , condition);

            using (MySqlConnection conn = new MySqlConnection(_connStr))
            {
                conn.Execute(sql, new { Id = item.Id, State = item.State });
            }
        }
Exemplo n.º 6
0
        public void Update(OrganModel model)
        {
            string condition = "AND Id = @Id";
            var    item      = _provider.GetItem(condition, new { Id = model.Id });

            if (item == null)
            {
                throw new Exception("所要修改的信息不存在,请重试");
            }
            _provider.Update(condition, model);
        }
Exemplo n.º 7
0
        private TagBuilder GetOrganNode(OrganModel item, List <OrganModel> items, string action, Dictionary <string, string> htmlAttributes)
        {
            TagBuilder node;
            var        children = items.Where(n => n.ParentId == item.Id);

            if (children.Count() > 0)
            {
                TagBuilder li = new TagBuilder("li");
                li.AddCssClass("dropdown-submenu");
                TagBuilder a = new TagBuilder("a");
                a.Attributes.Add("tabindex", "0");
                a.InnerHtml.Append(item.Name);

                //删除下面这一行就只能选择根节点
                a.Attributes.Add("onclick", $"{action}('{item.Id}','{item.Name}')");

                TagBuilder ul = new TagBuilder("ul");
                if (htmlAttributes != null)
                {
                    foreach (var attribute in htmlAttributes)
                    {
                        ul.Attributes.Add(attribute);
                    }
                }
                ul.AddCssClass("dropdown-menu");
                foreach (var child in children)
                {
                    ul.InnerHtml.AppendHtml(GetOrganNode(child, items, action, htmlAttributes));
                }
                li.InnerHtml.AppendHtml(ul);
                li.InnerHtml.AppendHtml(a);
                node = li;
            }
            else
            {
                TagBuilder li = new TagBuilder("li");
                TagBuilder a  = new TagBuilder("a");
                a.Attributes.Add("tabindex", "0");
                a.Attributes.Add("onclick", $"{action}('{item.Id}','{item.Name}')");
                a.InnerHtml.Append(item.Name);
                li.InnerHtml.AppendHtml(a);
                node = li;
            }
            return(node);
        }
Exemplo n.º 8
0
 public JsonResult Add(OrganModel model)
 {
     try
     {
         //model.SMSTelephone= model.SMSTelephone.Substring(0, model.SMSTelephone.Length-1);
         _business.Insert(model);
         return(Json(new JsonResultLogModel
         {
             State = true,
             Message = "组织添加成功!",
             Log = $" 用户 {SiteUser.Username} 添加组织 {model.Name} ",
             LogType = LogType.OrganManage,
             Username = SiteUser.Username
         }));
     }
     catch (Exception ex)
     {
         return(Json(new { State = false, Message = ex.Message }));
     }
 }
Exemplo n.º 9
0
        public void Del(int id)
        {
            OrganModel root = GetItem(id);

            if (root.ParentId != 0)
            {
                string condition = "AND ParentId = @ParentId";
                var    searchObj = new
                {
                    ParentId = id
                };
                List <OrganModel> result = _provider.GetAllItems(condition, searchObj, "");
                if (result.Count > 0)
                {
                    throw new Exception("请先删除该节点下的所有子节点!");
                }
                _provider.Del(" AND Id =@Id ", id);
            }
            else
            {
                throw new Exception("不能删除根节点!");
            }
        }
Exemplo n.º 10
0
 public void Insert(OrganModel model)
 {
     _provider.Insert(model);
 }