//批量导入(新) private void barBtnImportNew_ItemClick(object sender, ItemClickEventArgs e) { this.folderBrowserDialog.Description = "批量导入新能源填报数据"; string msg = string.Empty; if (folderBrowserDialog.ShowDialog(this) != DialogResult.OK) { return; } try { LoadingHandler.Show(this, args => { var utils = new ImportNewInfoUtils(); msg = utils.ImportNewTemplate(folderBrowserDialog.SelectedPath); }); } catch (System.Exception ex) { msg += String.Format("异常,操作出现错误:{0}", ex.Message); } using (var mf = new MessageForm(msg) { Text = "导入操作结果" }) { mf.ShowDialog(); if (mf.DialogResult == DialogResult.Cancel) { this.SearchLocal(1); } } }
//导出模板 private void barBtnExportFloder_ItemClick(object sender, ItemClickEventArgs e) { try { var dtExport = (DataTable)this.gcDataInfo.DataSource; string msg = string.Empty; if (dtExport == null || dtExport.Rows.Count < 1) { MessageBox.Show("当前没有数据可以操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } FolderDialog openFolder = new FolderDialog(); if (openFolder.DisplayDialog() == DialogResult.OK) { if (string.IsNullOrEmpty(Settings.Default.ClearYear) || string.IsNullOrEmpty(Settings.Default.Vehicle_MFCS)) { MessageBox.Show("请先设置车辆生存企业名称和清算年份!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DialogResult dr = MessageBox.Show(String.Format("确定要导出【{0}】,清算年份为【{1}】的数据吗?", Settings.Default.Vehicle_MFCS, Settings.Default.ClearYear), "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (dr == DialogResult.OK) { try { LoadingHandler.Show(this, args => { var exutils = new ExportNewInfoUtils(); msg = exutils.ExportNewTemplate(openFolder.Path, ""); }); if (String.IsNullOrEmpty(msg)) { MessageBox.Show("导出完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { using (var mf = new MessageForm(msg) { Text = "校验结果" }) { mf.ShowDialog(); } } } catch (System.Exception ex) { MessageBox.Show("操作出现错误:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } catch (System.Exception ex) { } }