public bool SaveFile(string path) { SaveLayout(); List <DataGridViewConsoleForm.Message> messageList; DataGridViewConsoleForm.Level verifyLevel = VerifierUtility.VerifyWithVerifier(m_Layout.Verifier, m_DataGridView, out messageList); DataGridViewConsoleForm.ShowForm(messageList, m_DataGridView, "保存文件"); bool canSave = false; if (verifyLevel == DataGridViewConsoleForm.Level.Info) { canSave = true; } else if (verifyLevel == DataGridViewConsoleForm.Level.Warning) { if (MessageBox.Show("您现在有Warning,确定存储吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { canSave = true; } } if (canSave) { // 保存文件 CsvExport myExport = new CsvExport(",", false); try { for (int rowIdx = 0; rowIdx < m_DataTable.Rows.Count; rowIdx++) { myExport.AddRow(); DataRow dataRow = m_DataTable.Rows[rowIdx]; for (int colIdx = 0; colIdx < m_DataTable.Columns.Count; colIdx++) { string value = (string)dataRow[colIdx]; myExport[colIdx.ToString()] = value; } } myExport.ExportToFile(path); } catch (Exception ex) { DebugUtility.ShowExceptionMessageBox(string.Format("保存文件({0})失败", path), ex); return(false); } return(true); } else { MessageBox.Show(string.Format("保存文件({0})失败", path), "提示"); return(false); } }
public DataGridViewConsoleForm.Level VerifySelf(out List <DataGridViewConsoleForm.Message> messageList) { return(VerifierUtility.VerifyWithVerifier(m_Layout.Verifier, m_DataGridView, out messageList)); }