/// <summary> /// 导出 /// </summary> private void MasterToolBar_DoExport_Click(object sender, EventArgs e) { _currentDt = bExchange.GetList(GetConduction()).Tables[0]; if (isSearch && _currentDt != null) { foreach (DataRow row in _currentDt.Rows) { try { if (row["FROM_CURRENCY_CODE"] != null && bCommon.GetBaseMaster("CURRENCY", CConvert.ToString(row["FROM_CURRENCY_CODE"])) != null) { row["FROM_CURRENCY_NAME"] = bCommon.GetBaseMaster("CURRENCY", CConvert.ToString(row["FROM_CURRENCY_CODE"])).Name; } if (row["CREATE_USER"] != null && bCommon.GetBaseMaster("USER", CConvert.ToString(row["CREATE_USER"])) != null) { row["CREATE_USER"] = bCommon.GetBaseMaster("USER", CConvert.ToString(row["CREATE_USER"])).Name; } if (row["LAST_UPDATE_USER"] != null && bCommon.GetBaseMaster("USER", CConvert.ToString(row["LAST_UPDATE_USER"])) != null) { row["LAST_UPDATE_USER"] = bCommon.GetBaseMaster("USER", CConvert.ToString(row["LAST_UPDATE_USER"])).Name; } } catch { } } int result = CommonExport.DataTableToExcel(_currentDt, CConstant.EXCHANGE_HEADER, CConstant.EXCHANGE_COLUMNS, "EXCHANGE", "EXCHANGE"); if (result == CConstant.EXPORT_SUCCESS) { MessageBox.Show("数据已经成功导出!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result == CConstant.EXPORT_FAILURE) { MessageBox.Show("数据导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
/// <summary> /// 导出 /// </summary> private void MasterToolBar_DoExport_Click(object sender, EventArgs e) { _currentDt = bExchange.GetList(GetConduction()).Tables[0]; if (isSearch && _currentDt != null) { foreach (DataRow row in _currentDt.Rows) { try { if (row["FROM_CURRENCY_CODE"] != null && bCommon.GetBaseMaster("CURRENCY", CConvert.ToString(row["FROM_CURRENCY_CODE"])) != null) { row["FROM_CURRENCY_NAME"] = bCommon.GetBaseMaster("CURRENCY", CConvert.ToString(row["FROM_CURRENCY_CODE"])).Name; } if (row["CREATE_USER"] != null && bCommon.GetBaseMaster("USER", CConvert.ToString(row["CREATE_USER"])) != null) { row["CREATE_USER"] = bCommon.GetBaseMaster("USER", CConvert.ToString(row["CREATE_USER"])).Name; } if (row["LAST_UPDATE_USER"] != null && bCommon.GetBaseMaster("USER", CConvert.ToString(row["LAST_UPDATE_USER"])) != null) { row["LAST_UPDATE_USER"] = bCommon.GetBaseMaster("USER", CConvert.ToString(row["LAST_UPDATE_USER"])).Name; } } catch { } } SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_EXCHANGE_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; string header = "汇率时间\t货币编号\t货币名称\t汇率\t状态\t创建人员\t创建时间\t最后更新人\t最后更新时间\t\n"; if (sf.ShowDialog(this) == DialogResult.OK) { int result = CExport.DataTableToCsv(_currentDt, header, sf.FileName); if (result == 0) { MessageBox.Show("导出成功!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }