示例#1
0
        //加载XML文件,数据扔到类的成员allDesignNode
        public static Boolean LoadXMLFile(string sXmlFile)
        {
            //xml文档信息
            XmlDocument t_XmlDoc = new XmlDocument();

            try
            {
                File.Copy(sXmlFile, sXmlFile + ".bak", true); //create a backup-file
                t_XmlDoc.Load(sXmlFile);                      //use try to catch possible xml file format errors
                //选中表格名
                XmlNodeList nodelist = t_XmlDoc.SelectNodes("/*/designtable");

                DesignTree.m_AllDesignNode.Clear();
                foreach (XmlNode node in nodelist)
                {
                    DesignTree tmpNode = new DesignTree(node);

                    //if (tmpCmd.CMDParentId == 0)
                    DesignTree.m_AllDesignNode.Add(tmpNode);
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
示例#2
0
        //把对象信息加入表中
        public void AddNodeToDataSet(DesignTree node, ref DataTable table)
        {
            object[] t_Object = new object[table.Columns.Count];

            foreach (DataColumn col in table.Columns)
            {
                t_Object[col.Ordinal] = node.GetValue(col.ColumnName);
            }

            table.Rows.Add(t_Object);
        }
示例#3
0
 //读xml文件,信息读入绑定树控件的表中
 public void LoadDesignXML(string sxmlFile)
 {
     if (DesignTree.LoadXMLFile(sxmlFile))
     {
         //清空节点
         designTreeView.Nodes.Clear();
         //清除表格所有的数据
         m_DesignDataTable.Clear();
         foreach (DesignTree node in DesignTree.m_AllDesignNode)
         {
             AddNodeToDataSet(node, ref m_DesignDataTable);
         }
     }
 }