Example #1
0
        //根据name type parent_id获取
        public static NodeStruct getNodeStruct(String name, String type, String parent_id)
        {
            string sql = "select * from structure where name=@name and type=@type and parent_id=@parent_id";

            SqlParameter[] para = new SqlParameter[3];
            para[0] = new SqlParameter("@name", name);
            para[1] = new SqlParameter("@type", type);
            para[2] = new SqlParameter("@parent_id", parent_id);
            NodeStruct node = new NodeStruct();

            try
            {
                DataTable dt = Factory.Execute().ExecuteTable(sql, CommandType.Text, para);
                node.Id         = dt.Rows[0]["struct_id"].ToString();
                node.Name       = dt.Rows[0]["name"].ToString();
                node.Parent_id  = dt.Rows[0]["parent_id"].ToString();
                node.Type       = dt.Rows[0]["type"].ToString();
                node.Admin_user = dt.Rows[0]["admin_user"].ToString();
                return(node);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #2
0
        //编辑节点
        public static int Edit(NodeStruct s)
        {
            string sql = "update structure set parent_id=@parent_id,name=@name,type=@type,admin_user=@admin_user where struct_id=@id)";

            SqlParameter[] para = new SqlParameter[5];
            para[0] = new SqlParameter("@id", s.Id);
            para[1] = new SqlParameter("@parent_id", s.Parent_id);
            para[2] = new SqlParameter("@name", s.Name);
            para[3] = new SqlParameter("@type", s.Type);
            para[4] = new SqlParameter("@admin_user", s.Admin_user);


            try
            {
                return(Factory.Execute().ExecuteNonQuery(sql, CommandType.Text, para));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #3
0
        //添加节点
        public static int Add(NodeStruct s)
        {
            string sql = "insert into structure values (@id,@parent_id,@name,@type,@admin_user)";

            SqlParameter[] para = new SqlParameter[5];
            para[0] = new SqlParameter("@id", s.Id);
            para[1] = new SqlParameter("@parent_id", s.Parent_id);
            para[2] = new SqlParameter("@name", s.Name);
            para[3] = new SqlParameter("@type", s.Type);
            para[4] = new SqlParameter("@admin_user", s.Admin_user);



            try
            {
                return(Factory.Execute().ExecuteNonQuery(sql, CommandType.Text, para));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #4
0
 public static int init()
 {
     if (NodeStructPro.isExistById(root_id) != 1)
     {
         NodeStruct node = new NodeStruct(root_id, "", "root", "root", "");
         NodeStructPro.Add(node);
     }
     if (NodeStructPro.isExistById(sheng_id) != 1)
     {
         NodeStruct node = new NodeStruct(sheng_id, root_id, "河南省", "sheng", "");
         NodeStructPro.Add(node);
     }
     if (NodeStructPro.isExistById(shi_id) != 1)
     {
         NodeStruct node = new NodeStruct(shi_id, sheng_id, "洛阳市", "shi", "");
         NodeStructPro.Add(node);
     }
     if (NodeStructPro.isExistById(qu_id) != 1)
     {
         NodeStruct node = new NodeStruct(qu_id, shi_id, "鄢陵县", "qu", "");
         NodeStructPro.Add(node);
     }
     return(1);
 }