private void MapPath_Click(object sender, RoutedEventArgs e)
 {
     //CAD文件转换所得xml文件
     if (MapPath_comboBox.SelectedIndex == 0)
     {
         OpenFileDialog dialog = new OpenFileDialog();
         dialog.InitialDirectory = "d:\\";
         dialog.RestoreDirectory = true;
         dialog.Filter           = "Xml文件 (*.xml) | *.xml";
         if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             MapPath_textBox.Text = dialog.FileName;
             mapPath    = dialog.FileName;
             cadXmlFile = new CadXmlFile(mapPath);
         }
     }
     //数字地图
     else if (MapPath_comboBox.SelectedIndex == 1)
     {
         FolderBrowserDialog dialog = new FolderBrowserDialog();
         if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             string path = dialog.SelectedPath;
             if (!PrjItem.isDirectoryValid(path))
             {
                 System.Windows.MessageBox.Show("当前路径不符合数字地图文件要求", "错误");
                 return;
             }
             prjItem = new PrjItem(path);
             //获取选中的文件夹
             this.MapPath_textBox.Text = dialog.SelectedPath;
             mapPath = dialog.SelectedPath;
         }
     }
 }
        //写入CAD地图信息
        public void WriteCadMap(CadXmlFile cadXmlFile)
        {
            dbFileConnection.Open();
            cmd   = dbFileConnection.CreateCommand();
            trans = dbFileConnection.BeginTransaction();

            cadXmlFile.CadXmlRead();

            try
            {
                //写入Line表
                foreach (LineData lineData in cadXmlFile.LineDataList)
                {
                    cmd.CommandText = "INSERT INTO Line VALUES " +
                                      "("
                                      + "'" + lineData.Layer + "', "
                                      + "'" + lineData.Coordinate_start.Longitude + "', "
                                      + "'" + lineData.Coordinate_start.Latitude + "', "
                                      + "'" + lineData.Coordinate_end.Longitude + "', "
                                      + "'" + lineData.Coordinate_end.Latitude + "'"
                                      + ")";
                    cmd.ExecuteNonQuery();
                }

                //写入Circle表
                foreach (CircleData circleData in cadXmlFile.CircleDataList)
                {
                    cmd.CommandText = "INSERT INTO Circle VALUES " +
                                      "("
                                      + "'" + circleData.Layer + "', "
                                      + "'" + circleData.Coordinate.Longitude + "', "
                                      + "'" + circleData.Coordinate.Latitude + "', "
                                      + "'" + circleData.Radious + "'"
                                      + ")";
                    cmd.ExecuteNonQuery();
                }

                //写入Poly表
                foreach (CadXmlParser.PolyData polyData in cadXmlFile.PolyDataList)
                {
                    cmd.CommandText = "INSERT INTO Poly VALUES " +
                                      "("
                                      + "'" + polyData.Layer + "', "
                                      + "'" + polyData.Id + "', "
                                      + "'" + polyData.OrderId + "', "
                                      + "'" + polyData.Coordinate.Longitude + "', "
                                      + "'" + polyData.Coordinate.Latitude + "', "
                                      + "'" + polyData.Name + "'"
                                      + ")";
                    cmd.ExecuteNonQuery();
                }

                //写入Text表
                foreach (TextData textData in cadXmlFile.TextDataList)
                {
                    cmd.CommandText = "INSERT INTO Text VALUES " +
                                      "("
                                      + "'" + textData.Layer + "', "
                                      + "'" + textData.Coordinate.Longitude + "', "
                                      + "'" + textData.Coordinate.Latitude + "', "
                                      + "'" + textData.Content + "', "
                                      + "'" + textData.Type + "'"
                                      + ")";
                    cmd.ExecuteNonQuery();
                }

                //写入P2DPoly表
                foreach (P2DPolyData p2DPolyData in cadXmlFile.P2DPolyDataList)
                {
                    cmd.CommandText = "INSERT INTO P2DPoly VALUES " +
                                      "("
                                      + "'" + p2DPolyData.Layer + "', "
                                      + "'" + p2DPolyData.Id + "', "
                                      + "'" + p2DPolyData.OrderId + "', "
                                      + "'" + p2DPolyData.Coordinate.Longitude + "', "
                                      + "'" + p2DPolyData.Coordinate.Latitude + "'"
                                      + ")";
                    cmd.ExecuteNonQuery();
                }

                trans.Commit();
            }
            catch (Exception e)
            {
                trans.Rollback();
            }

            cmd.Dispose();
            dbFileConnection.Close();
        }