Beispiel #1
0
        private void frmMapProperty_Load(object sender, EventArgs e)
        {
            //显示图件名称
            labNewname.Text = thisNode.Parent.Parent.Text + thisNode.Parent.Text + thisNode.Text;

            //获取专题类型
            string strSubType = thisNode.Tag.ToString();//专题类型代码

            labNewType.Text = thisNode.Parent.Text;

            //生成连接数据库字符串
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string mypath = dIndex.GetDbInfo();
            string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";
            //获取年度
            string strYear = thisNode.Text.Substring(0, 4);

            labNewYear.Text = strYear;

            //获取比例尺及其代码
            GeoDataCenterDbFun dDbFun = new GeoDataCenterDbFun();
            int    iStartPos          = thisNode.Text.IndexOf("【");
            int    iEndPos            = thisNode.Text.IndexOf("】");
            int    iLength            = iEndPos - iStartPos - 1;
            string strScaleName       = thisNode.Text.Substring(iStartPos + 1, iLength);

            labNewScale.Text = strScaleName;

            string strExp       = "select 代码 from 比例尺代码表 where 描述 ='" + strScaleName + "'";
            string strScaleCode = dDbFun.GetInfoFromMdbByExp(strCon, strExp);

            //获取行政区划
            labNewDivision.Text = thisNode.Parent.Parent.Text;

            //从地图入库信息表中获取已入库数据信息(图层组成)
            strExp = "select 图层组成 from 地图入库信息表 where 行政名称 ='" + thisNode.Parent.Parent.Text + "'" + "And " + " 年度='" +
                     strYear + "'" + "And " + " 比例尺='" + strScaleCode + "'" + "And " + " 专题类型='" + strSubType + "'";
            string strLayerGroup = dDbFun.GetInfoFromMdbByExp(strCon, strExp);

            string[] array = strLayerGroup.Split("/".ToCharArray());
            for (int i = 0; i < array.Length; i++)
            {
                strExp = "select 描述 from 标准图层信息表 where 代码='" + array[i] + "'";
                string strBussinessName = dDbFun.GetInfoFromMdbByExp(strCon, strExp);
                listLayer.Items.Add(strBussinessName);
            }
        }
Beispiel #2
0
        //添加叶子节点
        public void AddLeafItem(TreeNode treeNode, XmlNode xmlNode)
        {
            string             constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + m_mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"; //生成连接数据库字符串
            string             strExp = "";
            GeoDataCenterDbFun db     = new GeoDataCenterDbFun();
            string             layer  = "";

            strExp = "select 关键图层 from 标准专题信息表 where 专题类型='" + m_Typecode + "'";
            layer  = db.GetInfoFromMdbByExp(constr, strExp);
            strExp = "select 描述 from 标准图层信息表 where 代码='" + layer + "'";
            layer  = db.GetInfoFromMdbByExp(constr, strExp);

            if (treeNode != null && xmlNode != null)
            {
                TreeNode    tNewNode;
                string      strLayerDescribed = ""; //图层名称 地类图斑等
                string      strFileName       = "";
                XmlNodeList xmlNdList;
                xmlNdList = xmlNode.ChildNodes;
                foreach (XmlNode xmlChild in xmlNdList)
                {
                    strLayerDescribed = "";
                    XmlElement xmlElent = (XmlElement)xmlChild;
                    strLayerDescribed = xmlElent.GetAttribute("sDemo");     //描述
                    strFileName       = xmlElent.GetAttribute("sItemName"); //名称

                    //修改sfile名称
                    tNewNode      = new TreeNode();
                    tNewNode.Text = strLayerDescribed;
                    tNewNode.Name = strFileName;
                    tNewNode.Tag  = 3;
                    treeNode.Nodes.Add(tNewNode);
                    tNewNode.ImageIndex         = 3;
                    tNewNode.SelectedImageIndex = 3;
                    if (strFileName.Trim().CompareTo(layer.Trim()) == 0)
                    {
                        tNewNode.ForeColor = Color.Red;
                    }
                }
                treeNode.ExpandAll();
            }
        }
Beispiel #3
0
 private void comboBoxAreaCode_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBoxAreaCode.Text != "")
     {
         string             mypath = m_dIndex.GetDbInfo();
         string             strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"; //生成连接数据库字符串
         string             strExp = "select 行政名称 from 数据单元表 where 行政代码='" + comboBoxAreaCode.Text + "'";
         GeoDataCenterDbFun db     = new GeoDataCenterDbFun();
         txtAreaName.Text = db.GetInfoFromMdbByExp(strCon, strExp);
     }
 }
        private void ToTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            labelCode.Text = "";
            if (ToTreeView.SelectedNode != e.Node)
            {
                ToTreeView.SelectedNode = e.Node;
            }
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
            string             strExp   = "select 行政代码 from  标准数据单元表 where 行政名称='" + ToTreeView.SelectedNode.Text + "' and 数据单元级别=" + ToTreeView.SelectedNode.Tag + "";
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();

            labelCode.Text = db.GetInfoFromMdbByExp(strCon, strExp);
        }
Beispiel #5
0
        /// <summary>
        /// 创建专题节点
        /// </summary>
        /// <param name="tRootItem">县级行政区节点</param>
        /// <param name="strCon">连接语句</param>
        public void CreateSubTreeItem(TreeNode tRootItem, string strCon)
        {
            string             strXzqCode = tRootItem.Name;
            GeoDataCenterDbFun dDbFun     = new GeoDataCenterDbFun();
            string             strExp     = "select distinct 专题类型 from 地图入库信息表 where 行政代码 = '" + strXzqCode + "'";
            OleDbConnection    mycon      = new OleDbConnection(strCon); //定义OleDbConnection对象实例并连接数据库
            OleDbCommand       aCommand   = new OleDbCommand(strExp, mycon);

            try
            {
                mycon.Open();
                OleDbDataReader aReader        = aCommand.ExecuteReader();
                string          strSql         = "";
                string          strSubType     = "";
                string          strSubTypeName = "";
                TreeNode        tSubItem;

                while (aReader.Read())
                {
                    strSubType = aReader["专题类型"].ToString();

                    //获取专题类型
                    strSql         = "select 描述 from 标准专题信息表 where 专题类型 ='" + strSubType + "'";
                    strSubTypeName = dDbFun.GetInfoFromMdbByExp(strCon, strSql);


                    tSubItem      = new TreeNode();
                    tSubItem.Text = strSubTypeName;
                    tRootItem.Nodes.Add(tSubItem);
                    //tRootItem.ExpandAll();
                }

                //关闭reader对象
                aReader.Close();

                //关闭连接
                mycon.Close();
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Beispiel #6
0
        //设置成关键图层
        private void MenuItemMainLayer_Click(object sender, EventArgs e)
        {
            string             constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + m_mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"; //生成连接数据库字符串
            string             strExp = "";
            GeoDataCenterDbFun db     = new GeoDataCenterDbFun();
            string             layer  = "";

            // strExp = "select 关键图层 from 标准专题信息表 where 专题类型='" + m_Typecode + "'";
            //string  Mainlayer = db.GetInfoFromMdbByExp(constr, strExp);

            layer  = treeViewControl.SelectedNode.Name;
            strExp = "select 代码 from 标准图层信息表 where 描述 ='" + layer + "'";
            layer  = db.GetInfoFromMdbByExp(constr, strExp);
            strExp = "update 标准专题信息表 set 关键图层='" + layer + "' where 专题类型='" + m_Typecode + "'";
            db.ExcuteSqlFromMdb(constr, strExp);
            ChangeColor();
            treeViewControl.SelectedNode.ForeColor = Color.Red;
            MenuItemCanceMainLayer.Enabled         = true;
            treeViewControl.ExpandAll();
            treeViewControl.Refresh();
        }
Beispiel #7
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (comBoxName.Text == "")
            {
                MessageBox.Show("字段名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (textBoxDefault.Text == "")
            {
                MessageBox.Show("缺省值不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();
            string             strExp;

            if (m_flag == 1)
            {
                strExp = "select max(排序) from 图层命名初始化表";
                int index = Convert.ToInt32(db.GetInfoFromMdbByExp(strCon, strExp)) + 1;
                strExp = string.Format("insert into 图层命名初始化表(字段名称,描述,字段类型,字段长度,缺省,可变,排序) values('{0}','{1}','{2}','{3}','{4}',{5},'{6}')",
                                       comBoxName.Text, textBoxDescribe.Text, comboBoxType.Text, textBoxLength.Text, textBoxDefault.Text, checkBoxChange.Checked, index.ToString());
                db.ExcuteSqlFromMdb(strCon, strExp);
                MessageBox.Show("添加字段成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                strExp = string.Format("update 图层命名初始化表 set 字段名称='{0}',描述='{1}',字段类型='{2}',字段长度='{3}',缺省='{4}',可变={5} where ID={6}",
                                       comBoxName.Text, textBoxDescribe.Text, comboBoxType.Text, textBoxLength.Text, textBoxDefault.Text, checkBoxChange.Checked, id);
                db.ExcuteSqlFromMdb(strCon, strExp);
                MessageBox.Show("编辑字段成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            this.Close();
        }
        //进入
        private void btnIn_Click(object sender, EventArgs e)
        {
            //从 数据单元表 中获取信息
            GetDataTreeInitIndex dIndex     = new GetDataTreeInitIndex();
            string             mypath       = dIndex.GetDbInfo();
            string             strDispLevel = dIndex.GetXmlElementValue("UnitTree", "tIsDisp");                                                                         //是否从市级开始创建数据单元树
            string             constr       = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"; //生成连接数据库字符串
            string             strExp       = "select 行政名称 from 数据单元表 where 数据单元级别='1'";
            GeoDataCenterDbFun db           = new GeoDataCenterDbFun();
            string             strProvince  = db.GetInfoFromMdbByExp(constr, strExp);

            //获取当前点击节点 省、市节点
            //ToTreeView.Nodes.Clear();
            TreeNode tFromSelNode = FromTreeView.SelectedNode;

            if (tFromSelNode != null)
            {
                //是省级节点 包含整个市的
                if (tFromSelNode.Tag.Equals(1))
                {
                    ToTreeView.Nodes.Clear();
                    //获取该省级节点的所有子节点
                    TreeNode tRootNode;
                    TreeNode tCityNode;
                    TreeNode tCountyNode;
                    tRootNode            = new TreeNode();
                    tRootNode.Name       = tFromSelNode.Name;
                    tRootNode.Text       = tFromSelNode.Text;
                    tRootNode.Tag        = tFromSelNode.Tag;
                    tRootNode.ImageIndex = tFromSelNode.ImageIndex;
                    ToTreeView.Nodes.Add(tRootNode);
                    m_NewRootNode = tRootNode;

                    int iNodeCount = tFromSelNode.GetNodeCount(false);
                    tCityNode = new TreeNode();
                    TreeNode tOldCityNode = tFromSelNode.FirstNode;
                    tCityNode.Name       = tOldCityNode.Name;
                    tCityNode.Text       = tOldCityNode.Text;
                    tCityNode.Tag        = tOldCityNode.Tag;
                    tCityNode.ImageIndex = tOldCityNode.ImageIndex;
                    while (iNodeCount > 0)
                    {
                        tRootNode.Nodes.Add(tCityNode);
                        int iLeafCount = tOldCityNode.GetNodeCount(false);
                        tCountyNode = new TreeNode();
                        TreeNode tOldCountyNode = tOldCityNode.FirstNode;
                        tCountyNode.Name       = tOldCountyNode.Name;
                        tCountyNode.Text       = tOldCountyNode.Text;
                        tCountyNode.Tag        = tOldCountyNode.Tag;
                        tCountyNode.ImageIndex = tOldCountyNode.ImageIndex;
                        tCountyNode.ExpandAll();
                        while (iLeafCount > 0)
                        {
                            tCityNode.Nodes.Add(tCountyNode);
                            if (tOldCountyNode != tOldCityNode.LastNode)
                            {
                                tOldCountyNode         = tOldCountyNode.NextNode;
                                tCountyNode            = new TreeNode();
                                tCountyNode.Name       = tOldCountyNode.Name;
                                tCountyNode.Text       = tOldCountyNode.Text;
                                tCountyNode.Tag        = tOldCountyNode.Tag;
                                tCountyNode.ImageIndex = tOldCountyNode.ImageIndex;
                                tCountyNode.ExpandAll();
                            }

                            iLeafCount--;
                        }

                        if (tOldCityNode != tFromSelNode.LastNode)
                        {
                            tOldCityNode         = tOldCityNode.NextNode;
                            tCityNode            = new TreeNode();
                            tCityNode.Name       = tOldCityNode.Name;
                            tCityNode.Text       = tOldCityNode.Text;
                            tCityNode.Tag        = tOldCityNode.Tag;
                            tCityNode.ImageIndex = tOldCityNode.ImageIndex;
                            tCityNode.ExpandAll();
                        }
                        iNodeCount--;
                        tRootNode.Expand();
                    }
                    // ToTreeView.Refresh();
                }
                else if (tFromSelNode.Tag.Equals(2)) //是市级节点 要包含省的
                {
                    //获取省级节点 然后该市级节点包含子节点
                    TreeNode tParentNode = tFromSelNode.Parent;
                    TreeNode tRootNode   = null;
                    TreeNode tCityNode   = null;
                    TreeNode tCountyNode = null;
                    if (ToTreeView.Nodes.Count >= 1)
                    {
                        if (strProvince != (tParentNode.Text) && ToTreeView.Nodes[0].Text != tParentNode.Text)//是该省节点
                        {
                            ToTreeView.Nodes.Clear();
                            tRootNode = new TreeNode();
                            //插入省节点
                            tRootNode.Name       = tParentNode.Name;
                            tRootNode.Text       = tParentNode.Text;
                            tRootNode.Tag        = tParentNode.Tag;
                            tRootNode.ImageIndex = tParentNode.ImageIndex;
                            ToTreeView.Nodes.Add(tRootNode);
                        }
                        else
                        {
                            tRootNode = ToTreeView.Nodes[0];
                        }
                        if (ToTreeView.Nodes[0].Nodes.Count > 0)//已经有市节点
                        {
                            foreach (TreeNode node in ToTreeView.Nodes[0].Nodes)
                            {
                                if ((node.Text.Trim() == tFromSelNode.Text.Trim()))//市节点已存在,
                                {
                                    DialogResult result = MessageBox.Show("是否替换该市节点?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                                    if (result == DialogResult.No) //不替换
                                    {
                                        return;                    //不做反应,直接返回
                                    }
                                    else//替换
                                    {
                                        node.Remove();//移除该节点
                                    }
                                }
                            }
                        }

                        tCityNode = new TreeNode();
                        //插入市节点
                        tCityNode.Name       = tFromSelNode.Name;
                        tCityNode.Text       = tFromSelNode.Text;
                        tCityNode.Tag        = tFromSelNode.Tag;
                        tCityNode.ImageIndex = tFromSelNode.ImageIndex;
                        tRootNode.Nodes.Add(tCityNode);
                        tRootNode.Expand();
                    }
                    else
                    {
                        tRootNode = new TreeNode();
                        //插入省节点
                        tRootNode.Name       = tParentNode.Name;
                        tRootNode.Text       = tParentNode.Text;
                        tRootNode.Tag        = tParentNode.Tag;
                        tRootNode.ImageIndex = tParentNode.ImageIndex;
                        ToTreeView.Nodes.Add(tRootNode);;

                        tCityNode = new TreeNode();
                        //插入市节点
                        tCityNode.Name       = tFromSelNode.Name;
                        tCityNode.Text       = tFromSelNode.Text;
                        tCityNode.Tag        = tFromSelNode.Tag;
                        tCityNode.ImageIndex = tFromSelNode.ImageIndex;
                        tRootNode.Nodes.Add(tCityNode);
                        tRootNode.Expand();
                    }
                    m_NewRootNode = tRootNode;

                    //插入县级节点
                    int iNodeCount = tFromSelNode.GetNodeCount(false);
                    tCountyNode = new TreeNode();
                    TreeNode tOldCountyNode = tFromSelNode.FirstNode;
                    if (tOldCountyNode != null)
                    {
                        tCountyNode.Name       = tOldCountyNode.Name;
                        tCountyNode.Text       = tOldCountyNode.Text;
                        tCountyNode.Tag        = tOldCountyNode.Tag;
                        tCountyNode.ImageIndex = tOldCountyNode.ImageIndex;
                    }
                    while (iNodeCount > 0)
                    {
                        tCityNode.Nodes.Add(tCountyNode);
                        tCountyNode = new TreeNode();
                        if (tOldCountyNode != tFromSelNode.LastNode)
                        {
                            tOldCountyNode         = tOldCountyNode.NextNode;
                            tCountyNode.Name       = tOldCountyNode.Name;
                            tCountyNode.Text       = tOldCountyNode.Text;
                            tCountyNode.Tag        = tOldCountyNode.Tag;
                            tCountyNode.ImageIndex = tOldCountyNode.ImageIndex;
                        }
                        iNodeCount--;
                    }
                }
                else if (tFromSelNode.Tag.Equals(3))  //县级节点
                {
                    //获取省级节点 然后该市级节点包含子节点
                    TreeNode tParentNode = tFromSelNode.Parent.Parent;
                    TreeNode tRootNode   = null;
                    TreeNode tCityNode   = null;
                    TreeNode tCountyNode = null;
                    if (ToTreeView.Nodes.Count >= 1)
                    {
                        if (strProvince != (tParentNode.Text) && ToTreeView.Nodes[0].Text != tParentNode.Text)//是该省节点
                        {
                            ToTreeView.Nodes.Clear();
                            tRootNode = new TreeNode();
                            //插入省节点
                            tRootNode.Name       = tParentNode.Name;
                            tRootNode.Text       = tParentNode.Text;
                            tRootNode.Tag        = tParentNode.Tag;
                            tRootNode.ImageIndex = tParentNode.ImageIndex;
                            ToTreeView.Nodes.Add(tRootNode);
                        }
                        else
                        {
                            tRootNode = ToTreeView.Nodes[0];
                        }
                        if (ToTreeView.Nodes[0].Nodes.Count > 0)//已经有市节点
                        {
                            foreach (TreeNode node in ToTreeView.Nodes[0].Nodes)
                            {
                                if ((node.Text.Trim() == tFromSelNode.Parent.Text.Trim()))//市节点已存在,
                                {
                                    tCityNode = node;
                                }
                            }
                        }
                        if (tCityNode == null)//没有该市节点,添加一个市节点
                        {
                            tCityNode = new TreeNode();
                            //插入市节点
                            tCityNode.Name       = tFromSelNode.Parent.Name;
                            tCityNode.Text       = tFromSelNode.Parent.Text;
                            tCityNode.Tag        = tFromSelNode.Parent.Tag;
                            tCityNode.ImageIndex = tFromSelNode.Parent.ImageIndex;
                            tRootNode.Nodes.Add(tCityNode);
                            tRootNode.ExpandAll();
                            tCityNode.ExpandAll();
                        }
                    }
                    else
                    {
                        tRootNode = new TreeNode();
                        //插入省节点
                        tRootNode.Name       = tParentNode.Name;
                        tRootNode.Text       = tParentNode.Text;
                        tRootNode.Tag        = tParentNode.Tag;
                        tRootNode.ImageIndex = tParentNode.ImageIndex;
                        ToTreeView.Nodes.Add(tRootNode);

                        tCityNode = new TreeNode();
                        //插入市节点
                        tCityNode.Name       = tFromSelNode.Parent.Name;
                        tCityNode.Text       = tFromSelNode.Parent.Text;
                        tCityNode.Tag        = tFromSelNode.Parent.Tag;
                        tCityNode.ImageIndex = tFromSelNode.Parent.ImageIndex;
                        tRootNode.Nodes.Add(tCityNode);
                    }

                    m_NewRootNode = tRootNode;
                    tRootNode.Expand();
                    //插入县级节点
                    if (tCityNode.Nodes.Count > 0)
                    {
                        foreach (TreeNode node in tCityNode.Nodes)
                        {
                            if ((node.Text.Trim() == tFromSelNode.Text.Trim()))//县节点已存在,
                            {
                                MessageBox.Show("该节点已存在!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                                return;
                            }
                        }
                    }
                    tCountyNode            = new TreeNode();
                    tCountyNode.Name       = tFromSelNode.Name;
                    tCountyNode.Text       = tFromSelNode.Text;
                    tCountyNode.Tag        = tFromSelNode.Tag;
                    tCountyNode.ImageIndex = tFromSelNode.ImageIndex;
                    tCountyNode.ExpandAll();
                    tCityNode.Nodes.Add(tCountyNode);
                    tCityNode.ExpandAll();
                    tCountyNode.ExpandAll();
                }
            }
        }
Beispiel #9
0
        //编辑图层
        private void MenuItemEditLayer_Click(object sender, EventArgs e)
        {
            string   strCurSubName = null;//组节点的text
            TreeNode tparentNode   = null;
            TreeNode tNode         = null;

            strCurSubName = treeViewControl.SelectedNode.Parent.Text;
            tparentNode   = treeViewControl.SelectedNode.Parent;
            tNode         = treeViewControl.SelectedNode;
            string       stroldText = tNode.Name;//记录原有节点名称
            AddLayerForm dlg        = new AddLayerForm(m_xmldoc, tNode);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                tNode.Text               = dlg.m_strLayerDescri;
                tNode.Name               = dlg.m_strLayerName;
                tNode.Tag                = 3;
                tNode.ImageIndex         = 3;
                tNode.SelectedImageIndex = 3;
                tparentNode.ExpandAll();
                treeViewControl.Refresh();

                //更新xml文件
                //删除原有节点
                string  strSearch = "//Layer[@sItemName='" + stroldText + "']";
                XmlNode xmlNode   = m_xmldoc.SelectSingleNode(strSearch);
                //xmlNode.ParentNode.RemoveChild(xmlNode);//
                //string strSearchRoot = "//SubGroup[@sItemName = '" + strCurSubName + "']";
                //XmlNode xmlNodeRoot = m_xmldoc.SelectSingleNode(strSearchRoot);
                //XmlElement xmlElemGroup = (XmlElement)xmlNodeRoot;
                //XmlElement xmlElemt= m_xmldoc.CreateElement("Layer");
                XmlElement xmlElemt = xmlNode as XmlElement;
                xmlElemt.SetAttribute("sDemo", tNode.Text);
                xmlElemt.SetAttribute("sDispScale", dlg.m_strScale);
                xmlElemt.SetAttribute("sDiaphaneity", dlg.m_strTransp);
                xmlElemt.SetAttribute("sItemName", tNode.Name);
                //xmlElemGroup.AppendChild(xmlElemt);

                //添加 文件名称 业务大类代码  业务小类代码
                string          constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + m_mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"; //生成连接数据库字符串
                OleDbConnection mycon  = new OleDbConnection(constr);                                                                                                //定义OleDbConnection对象实例并连接数据库
                string          strExp = "";
                strExp = "select  * from 标准图层信息表 where 描述 = '" + tNode.Name + "'";
                OleDbCommand aCommand = new OleDbCommand(strExp, mycon);

                strExp = "select 图层组成 from 标准专题信息表 where 专题类型='" + m_Typecode + "'";
                GeoDataCenterDbFun db    = new GeoDataCenterDbFun();
                string             layer = db.GetInfoFromMdbByExp(constr, strExp);
                try
                {
                    mycon.Open();

                    //创建datareader   对象来连接到表单
                    OleDbDataReader aReader = aCommand.ExecuteReader();
                    while (aReader.Read())
                    {
                        xmlElemt.SetAttribute("sFile", aReader["代码"].ToString());
                        xmlElemt.SetAttribute("sBigClass", aReader["业务大类代码"].ToString());
                        xmlElemt.SetAttribute("sSubClass", aReader["业务小类代码"].ToString());

                        if (layer == "")
                        {
                            layer = aReader["代码"].ToString();
                        }
                        else if (!GetExists(aReader["代码"].ToString(), layer))
                        {
                            layer += "/" + aReader["代码"].ToString();//更改图层组成
                        }
                    }

                    //关闭reader对象
                    aReader.Close();

                    //关闭连接,这很重要
                    mycon.Close();

                    //更新标准专题信息表
                    strExp = "update 标准专题信息表 set 图层组成='" + layer + "' where 专题类型='" + m_Typecode + "'";
                    db.ExcuteSqlFromMdb(constr, strExp);
                }

                catch (System.Exception err)
                {
                }

                //更新xml文件
                m_xmldoc.Save(m_xmlPath);
            }
        }
Beispiel #10
0
        //添加组
        private void MenuItemTreeAddGroup_Click(object sender, EventArgs e)
        {
            AddGroupForm dlg = new AddGroupForm();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                //修改树视图
                TreeNode tNewGroupNode = new TreeNode();
                tNewGroupNode.Name               = "【" + dlg.m_strSubName + "】";
                tNewGroupNode.Text               = "【" + dlg.m_strSubName + "】";
                tNewGroupNode.Tag                = 2;
                tNewGroupNode.ImageIndex         = 2;
                tNewGroupNode.SelectedImageIndex = 2;
                m_tMapNode.Nodes.Add(tNewGroupNode);
                m_tMapNode.ExpandAll();

                //修改xml文件
                string     strSearchRoot = "//GisMap";
                XmlNode    xmlNodeRoot   = m_xmldoc.SelectSingleNode(strSearchRoot);
                XmlElement xmlElentRoot  = (XmlElement)xmlNodeRoot;
                XmlElement xmlElemGroup  = m_xmldoc.CreateElement("SubGroup");
                string     strGroupName  = "【" + dlg.m_strSubName + "】";
                xmlElemGroup.SetAttribute("sItemName", strGroupName);
                xmlElemGroup.SetAttribute("sType", "GROUP");
                xmlElentRoot.AppendChild(xmlElemGroup);


                //获取组内图层列表
                TreeNode tNewNode = null;
                foreach (TreeNode fCurNode in dlg.totreeView.Nodes)
                {
                    XmlNode boolnode = m_xmldoc.SelectSingleNode("//Layer[@sItemName='" + fCurNode.Text + "']");
                    if (boolnode != null)
                    {
                        MessageBox.Show(fCurNode.Text + "图层已存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        continue;
                    }
                    XmlElement xmlElemt = m_xmldoc.CreateElement("Layer");
                    xmlElemt.SetAttribute("sDemo", fCurNode.Text);
                    xmlElemt.SetAttribute("sItemName", fCurNode.Text);


                    //添加 文件名称 业务大类代码  业务小类代码
                    string          constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + m_mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"; //生成连接数据库字符串
                    OleDbConnection mycon  = new OleDbConnection(constr);                                                                                                //定义OleDbConnection对象实例并连接数据库
                    string          strExp = "";
                    strExp = "select  * from 标准图层信息表 where 描述 = '" + fCurNode.Text + "'";
                    OleDbCommand aCommand = new OleDbCommand(strExp, mycon);
                    strExp = "select 图层组成 from 标准专题信息表 where 专题类型='" + m_Typecode + "'";
                    GeoDataCenterDbFun db    = new GeoDataCenterDbFun();
                    string             layer = db.GetInfoFromMdbByExp(constr, strExp);
                    try
                    {
                        mycon.Open();

                        //创建datareader   对象来连接到表单
                        OleDbDataReader aReader = aCommand.ExecuteReader();
                        while (aReader.Read())
                        {
                            xmlElemt.SetAttribute("sFile", aReader["代码"].ToString());
                            xmlElemt.SetAttribute("sBigClass", aReader["业务大类代码"].ToString());
                            xmlElemt.SetAttribute("sSubClass", aReader["业务小类代码"].ToString());


                            if (layer == "")
                            {
                                layer = aReader["代码"].ToString();
                            }
                            else if (!GetExists(aReader["代码"].ToString(), layer))
                            {
                                layer += "/" + aReader["代码"].ToString();//更改图层组成
                            }
                        }

                        //关闭reader对象
                        aReader.Close();

                        //关闭连接,这很重要
                        mycon.Close();
                        //更新标准专题信息表
                        strExp = "update 标准专题信息表 set 图层组成='" + layer + "' where 专题类型='" + m_Typecode + "'";
                        db.ExcuteSqlFromMdb(constr, strExp);
                    }
                    catch (System.Exception err)
                    {
                    }
                    //更新树
                    tNewNode                    = new TreeNode();
                    tNewNode.Text               = fCurNode.Text;
                    tNewNode.Name               = fCurNode.Name;
                    tNewNode.Tag                = 3;
                    tNewNode.ImageIndex         = 3;
                    tNewNode.SelectedImageIndex = 3;
                    tNewGroupNode.Nodes.Add(tNewNode);
                    tNewGroupNode.ExpandAll();

                    xmlElemGroup.AppendChild(xmlElemt);
                }
                treeViewControl.Refresh();

                //更新xml文件
                m_xmldoc.Save(m_xmlPath);
            }
        }
Beispiel #11
0
        //修改专题
        private void MenuItemModifySub_Click(object sender, EventArgs e)
        {
            if (listViewControl.SelectedItems.Count <= 0)
            {
                MessageBox.Show("请选择要修改的专题!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //获取数据库中信息 更改
            //获取数值添加到“标准专题信息表”中
            string             constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + m_mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"; //生成连接数据库字符串
            OleDbConnection    mycon  = new OleDbConnection(constr);                                                                                                //定义OleDbConnection对象实例并连接数据库
            string             strExp = "";
            GeoDataCenterDbFun db     = new GeoDataCenterDbFun();
            //获取节点名称
            string strSubOldName      = null;
            string strSubOldCode      = null;
            string strSubOldIndexFile = null;
            string strSubOldMapFile   = null;

            SubAttForm dlg = new SubAttForm();

            dlg.strSubCode     = listViewControl.SelectedItems[0].Text;
            strSubOldCode      = listViewControl.SelectedItems[0].Text;
            dlg.strSubName     = listViewControl.SelectedItems[0].SubItems[1].Text;
            strSubOldName      = listViewControl.SelectedItems[0].SubItems[1].Text;
            dlg.strIndexFile   = listViewControl.SelectedItems[0].SubItems[2].Text;
            strSubOldIndexFile = listViewControl.SelectedItems[0].SubItems[2].Text;
            strExp             = "select 配图方案文件 from 标准专题信息表 where " + "专题类型 = '" + strSubOldCode + "' ";
            strSubOldMapFile   = dlg.strMapSymIndexFile = db.GetInfoFromMdbByExp(constr, strExp);
            dlg.SetFormTextBoxAtt();
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                //没发生变化
                if (strSubOldCode.Equals(dlg.strSubCode) && strSubOldName.Equals(dlg.strSubName) && strSubOldIndexFile.Equals(dlg.strIndexFile) && strSubOldMapFile.Equals(dlg.strMapSymIndexFile))
                {
                    return;
                }

                //修改listview
                listViewControl.SelectedItems[0].Text             = dlg.strSubCode;
                listViewControl.SelectedItems[0].SubItems[1].Text = dlg.strSubName;
                listViewControl.SelectedItems[0].SubItems[2].Text = dlg.strIndexFile;
                listViewControl.Refresh();
            }


            //   strExp = "update 标准专题信息表 set 专题类型 = '" + dlg.strSubCode + "'," + "描述 = '" + dlg.strSubName + "' where " + "专题类型 = '" + strSubOldCode + "'";
            strExp = "update 标准专题信息表 set 专题类型 = '" + dlg.strSubCode + "'," + "描述 = '" + dlg.strSubName + "'," + "脚本文件 = '" + dlg.strIndexFile + "'," + "配图方案文件 = '" + dlg.strMapSymIndexFile + "' where " + "专题类型 = '" + strSubOldCode + "'";
            OleDbCommand aCommand = new OleDbCommand(strExp, mycon);

            try
            {
                mycon.Open();

                //g更新记录
                int iRows = aCommand.ExecuteNonQuery();

                //关闭连接,这很重要
                mycon.Close();
            }
            catch (System.Exception err)
            {
                Console.WriteLine(err.Message);
            }
            strExp = "update 地图入库信息表 set 专题类型='" + dlg.strSubCode + "' where " + "专题类型 = '" + strSubOldCode + "'";
            db.ExcuteSqlFromMdb(constr, strExp);
            string strModFile   = Application.StartupPath + "\\..\\Template\\StandardBlank.xml";
            string strIndexFile = Application.StartupPath + "\\..\\Template\\" + dlg.strIndexFile;

            if (strSubOldIndexFile.CompareTo(dlg.strIndexFile) != 0)
            {
                if (!File.Exists(strIndexFile))
                {
                    File.Copy(strModFile, strIndexFile, true);
                }
            }
            if (strSubOldName.CompareTo(dlg.strSubName) != 0)  //修改了专题描述才修改对应的xml文件
            {
                //加载文件并修改GisMap ItemName=""
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(strIndexFile);
                string     strSearchRoot = "//GisMap";
                XmlNode    xmlNodeRoot   = xmldoc.SelectSingleNode(strSearchRoot);
                XmlElement xmlElentRoot  = (XmlElement)xmlNodeRoot;
                xmlElentRoot.SetAttribute("sItemName", dlg.strSubName);
                xmldoc.Save(strIndexFile);
            }
        }
Beispiel #12
0
        public void InitDataUnitTree()
        {
            //从 数据单元表 中获取信息
            GetDataTreeInitIndex dIndex  = new GetDataTreeInitIndex();
            string          mypath       = dIndex.GetDbInfo();
            string          strDispLevel = dIndex.GetXmlElementValue("UnitTree", "tIsDisp");                                                                         //是否从市级开始创建数据单元树
            string          constr       = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"; //生成连接数据库字符串
            OleDbConnection mycon        = new OleDbConnection(constr);                                                                                              //定义OleDbConnection对象实例并连接数据库
            string          strExp       = "";

            strExp = "select * from " + "数据单元表";
            OleDbCommand aCommand = new OleDbCommand(strExp, mycon);

            try
            {
                mycon.Open();

                //创建datareader   对象来连接到表单
                OleDbDataReader aReader = aCommand.ExecuteReader();
                m_Hook.DataUnitTree.Nodes.Clear();
                TreeNode tparent;
                tparent      = new TreeNode();
                tparent.Text = "数据单元";
                tparent.Tag  = 0;

                TreeNode tRoot;
                tRoot = new TreeNode();
                tRoot = tparent;
                TreeNode tNewNode;
                TreeNode tNewNodeClild;
                TreeNode tNewLeafNode;
                m_Hook.DataUnitTree.Nodes.Add(tparent);
                while (aReader.Read())
                {
                    //如果是行政区级别是1就是根节点
                    //此处默认都已经排序合理,针对排序的维护在数据字典维护界面中实现
                    if (aReader["数据单元级别"].ToString().Equals("1")) //省级节点
                    {
                        if (strDispLevel.Equals("0"))
                        {
                            tNewNode      = new TreeNode();
                            tNewNode.Text = aReader["行政名称"].ToString();
                            tNewNode.Name = aReader["行政代码"].ToString();
                            tparent.Nodes.Add(tNewNode);
                            tparent.Expand();
                            tparent             = tNewNode;
                            tNewNode.Tag        = 1;
                            tNewNode.ImageIndex = 17;
                        }
                    }
                    else if (aReader["数据单元级别"].ToString().Equals("2")) //市级节点
                    {
                        tNewNodeClild      = new TreeNode();
                        tNewNodeClild.Text = aReader["行政名称"].ToString();
                        tNewNodeClild.Name = aReader["行政代码"].ToString();
                        tparent.Nodes.Add(tNewNodeClild);
                        tparent.Expand();
                        tRoot                    = tNewNodeClild;
                        tNewNodeClild.Tag        = 2;
                        tNewNodeClild.ImageIndex = 17;
                    }
                    else if (aReader["数据单元级别"].ToString().Equals("3"))//县级节点
                    {
                        tNewLeafNode      = new TreeNode();
                        tNewLeafNode.Text = aReader["行政名称"].ToString();
                        tNewLeafNode.Name = aReader["行政代码"].ToString();
                        tRoot.Nodes.Add(tNewLeafNode);
                        tRoot.Expand();
                        tNewLeafNode.Tag        = 3;
                        tNewLeafNode.ImageIndex = 17;

                        string strSql         = "";
                        string strScaleName   = "";
                        string strSubTypeName = "";
                        string strLeafName    = "";
                        string strYear        = "";
                        string strSubType     = "";
                        string strXzqName     = "";
                        string strScale       = "";

                        //插入专题节点
                        CreateSubTreeItem(tNewLeafNode, constr);

                        //插入叶子节点
                        TreeNode           tLeafItem;
                        TreeNode           tFindParentItem;
                        GeoDataCenterDbFun dDbFun = new GeoDataCenterDbFun();
                        strExp = "select * from 地图入库信息表 where 行政代码 = '" + tNewLeafNode.Name + "'";
                        OleDbCommand    aCommand2 = new OleDbCommand(strExp, mycon);
                        OleDbDataReader aReader2  = aCommand2.ExecuteReader();
                        while (aReader2.Read())
                        {
                            strYear    = aReader2["年度"].ToString();
                            strSubType = aReader2["专题类型"].ToString();
                            strXzqName = aReader2["行政名称"].ToString();
                            strScale   = aReader2["比例尺"].ToString();

                            //获取比例尺
                            strSql       = "select 描述 from 比例尺代码表 where 代码 ='" + strScale + "'";
                            strScaleName = dDbFun.GetInfoFromMdbByExp(constr, strSql);

                            //获取专题类型
                            strSql         = "select 描述 from 标准专题信息表 where 专题类型 ='" + strSubType + "'";
                            strSubTypeName = dDbFun.GetInfoFromMdbByExp(constr, strSql);


                            //组织树节点
                            strLeafName = strYear + "年【" + strScaleName + "】";

                            //获取上级节点
                            tFindParentItem = FindNode(tNewLeafNode, strSubTypeName);

                            tFindParentItem.ImageIndex         = 9;
                            tFindParentItem.SelectedImageIndex = 10;
                            //此次默认 地图入库信息表中所有记录已经按照 数据单元、专题类型排序
                            tLeafItem      = new TreeNode();
                            tLeafItem.Text = strLeafName;
                            tLeafItem.Tag  = strSubType; //临时把专题类型记录在tag中
                            tFindParentItem.Nodes.Add(tLeafItem);
                            //tFindParentItem.ExpandAll();
                            tLeafItem.ImageIndex         = 7;
                            tLeafItem.SelectedImageIndex = 8;
                        }
                        aReader2.Close();
                    }
                    else
                    {
                        tNewNodeClild      = new TreeNode();
                        tNewNodeClild.Text = aReader["行政名称"].ToString();
                        tNewNodeClild.Name = aReader["行政代码"].ToString();
                        tparent.Nodes.Add(tNewNodeClild);
                        tparent.ExpandAll();
                        tNewNodeClild.Tag = 1;
                    }
                }

                //关闭reader对象
                aReader.Close();


                //关闭连接,这很重要
                mycon.Close();
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }