private void SaveProject_Click(object sender, RoutedEventArgs e) { if (projectName.Length == 0 && mapPath.Length != 0) { System.Windows.Forms.MessageBox.Show("缺少工程文件名", "信息不全", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (projectName.Length != 0 && mapPath.Length == 0) { System.Windows.Forms.MessageBox.Show("缺少铁路信息源", "信息不全", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (projectName.Length == 0 && mapPath.Length == 0) { System.Windows.Forms.MessageBox.Show("缺少工程文件名和铁路信息文件", "信息不全", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { SaveFileDialog dialog = new SaveFileDialog();; dialog.Filter = "工程文件 (*.db)|*.db"; dialog.FilterIndex = 1; dialog.InitialDirectory = "d:\\"; dialog.RestoreDirectory = true; dialog.FileName = projectName; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { outputPath = dialog.FileName; databaseFile = new DatabaseFile(outputPath); databaseFile.InitDbFile(); //CAD文件 if (MapPath_comboBox.SelectedIndex == 0) { databaseFile.WriteProjectInfo(0, projectName); databaseFile.WriteCadMap(cadXmlFile); } //数字地图 else if (MapPath_comboBox.SelectedIndex == 1) { databaseFile.WriteProjectInfo(1, projectName); databaseFile.WriteDigitalMap(prjItem); } //如果有kml文件 if (kmlFile != null) { databaseFile.WriteKml(kmlFile); } //如果有excel文件 if (excelFile != null) { databaseFile.WriteExcel(excelFile); } System.Windows.MessageBox.Show("文件生成成功", "提示"); } } }