/// <summary> /// 记录绑定的DataTable里面变化的数据的日志 /// </summary> /// <param name="tableCaption">数据表的中文标题</param> /// <param name="dataTable_NoHandle">未处理的DataTable</param> /// <param name="primaryKeyColumn">主键列名</param> public static string RecordLog_DataTable(SqlCommand cmd, string tableCaption, DataTable dataTable_NoHandle, string primaryKeyColumn) { string partLogStr = ""; string typeStr = ""; string pkCaption = ""; string pkValue = ""; for (int i = 0; i < dataTable_NoHandle.Rows.Count; i++) { DataRow dr = dataTable_NoHandle.Rows[i]; if (dr.RowState == DataRowState.Added) { for (int j = 0; j < dataTable_NoHandle.Columns.Count; j++) { if (dataTable_NoHandle.Columns[j].ColumnName == primaryKeyColumn) { pkCaption = dataTable_NoHandle.Columns[j].Caption; pkValue = DataTypeConvert.GetString(dr[j]); continue; } string tmpValue = DataTypeConvert.GetString(dr[j]); if (tmpValue != "") { //partLogStr += string.Format("{0}的值为[{1}],", dataTable_NoHandle.Columns[j].Caption, tmpValue); partLogStr += string.Format("{0}" + f.tsmiDzw.Text + "[{1}],", dataTable_NoHandle.Columns[j].Caption, tmpValue); } } //typeStr = "新增"; typeStr = f.tsmiXz.Text; } else if (dr.RowState == DataRowState.Modified) { for (int j = 0; j < dataTable_NoHandle.Columns.Count; j++) { if (dataTable_NoHandle.Columns[j].ColumnName == primaryKeyColumn) { pkCaption = dataTable_NoHandle.Columns[j].Caption; pkValue = DataTypeConvert.GetString(dr[j]); continue; } string oldValue = DataTypeConvert.GetString(dr[j, DataRowVersion.Original]); string newValue = DataTypeConvert.GetString(dr[j, DataRowVersion.Current]); if (oldValue != newValue) { //partLogStr += string.Format("{0}的值由[{1}]变为[{2}],", dataTable_NoHandle.Columns[j].Caption, oldValue, newValue); partLogStr += string.Format("{0}" + f.tsmiDzy.Text + "[{1}]" + f.tsmiBw.Text + "[{2}],", dataTable_NoHandle.Columns[j].Caption, oldValue, newValue); } } //typeStr = "修改"; typeStr = f.tsmiXg.Text; } else if (dr.RowState == DataRowState.Deleted) { for (int j = 0; j < dataTable_NoHandle.Columns.Count; j++) { if (dataTable_NoHandle.Columns[j].ColumnName == primaryKeyColumn) { pkCaption = dataTable_NoHandle.Columns[j].Caption; pkValue = DataTypeConvert.GetString(dr[j, DataRowVersion.Original]); continue; } string tmpValue = DataTypeConvert.GetString(dr[j, DataRowVersion.Original]); if (tmpValue != "") { //partLogStr += string.Format("{0}的原值为[{1}],", dataTable_NoHandle.Columns[j].Caption, tmpValue); partLogStr += string.Format("{0}" + f.tsmiDyzw.Text + "[{1}],", dataTable_NoHandle.Columns[j].Caption, tmpValue); } } //typeStr = "删除"; typeStr = f.tsmiSc.Text; } } //string logStr = string.Format("对[{0}]表进行[{1}]操作:主键[{2}]的值为[{3}],{4}", tableCaption, typeStr, pkCaption, pkValue, partLogStr); string logStr = string.Format(f.tsmiD.Text + "[{0}]" + f.tsmiBjx.Text + "[{1}]" + f.tsmiCz.Text + ":" + f.tsmiZj.Text + "[{2}]" + f.tsmiDzw.Text + "[{3}],{4}", tableCaption, typeStr, pkCaption, pkValue, partLogStr); //MessageHandler.ShowMessageBox(logStr); RecordLog(cmd, logStr); return(logStr); }
/// <summary> /// 处理报表打印 /// </summary> /// <param name="tableNameStr">数据表名</param> /// <param name="bindingDataSet">绑定的DataSet</param> /// <param name="paraList">参数列表</param> /// <param name="handleType">处理类型:1 预览 2 打印 3 设计</param> public void XtraReport_Handle(string tableNameStr, DataSet bindingDataSet, List <Parameter> paraList, int handleType) { FrmDocumentTempletDAO docDAO = new FrmDocumentTempletDAO(); DataTable docTempletTable = docDAO.QueryDocTemplet(tableNameStr); if (docTempletTable.Rows.Count == 0) { //MessageHandler.ShowMessageBox("未查询到当前单据模板的信息记录,操作错误。"); MessageHandler.ShowMessageBox(f.tsmiWcxddq.Text); return; } string path = DataTypeConvert.GetString(docTempletTable.Rows[0]["DocPath"]) + DataTypeConvert.GetString(docTempletTable.Rows[0]["DocFileName"]); string docVerStr = DataTypeConvert.GetString(docTempletTable.Rows[0]["DocVersion"]); string iniPath = System.Windows.Forms.Application.StartupPath + "\\Report\\DocTemplet.ini"; string sectionStr = "DocTemplet"; FileHandler fileHandler = new FileHandler(); if (File.Exists(path)) { if (File.Exists(iniPath)) { string localVerStr = fileHandler.IniReadValue(iniPath, sectionStr, tableNameStr); if (localVerStr != docVerStr && handleType != 3) { Byte[] fileByte = docDAO.QueryDocTemplet_FileByte(tableNameStr); fileHandler.ByteArrayToFile(fileByte, path); fileHandler.IniWriteValue(iniPath, sectionStr, tableNameStr, docVerStr); } } else { Byte[] fileByte = docDAO.QueryDocTemplet_FileByte(tableNameStr); fileHandler.ByteArrayToFile(fileByte, path); fileHandler.IniWriteValue(iniPath, sectionStr, tableNameStr, docVerStr); } } else { Byte[] fileByte = docDAO.QueryDocTemplet_FileByte(tableNameStr); fileHandler.ByteArrayToFile(fileByte, path); fileHandler.IniWriteValue(iniPath, sectionStr, tableNameStr, docVerStr); } XtraReport report = new XtraReport(); report.LoadLayout(path); report.DataSource = bindingDataSet; if (paraList != null) { foreach (Parameter para in paraList) { try { report.Parameters[para.Name].Value = para.Value; } catch { report.Parameters.Add(para); } } } report.RequestParameters = false; report.CreateDocument(); ReportPrintTool rptPrintTool = new ReportPrintTool(report); PrintingSystemBase prtSysBase = rptPrintTool.PrintingSystem; prtSysBase.SetCommandVisibility(new PrintingSystemCommand[] { //PrintingSystemCommand.Background, //PrintingSystemCommand.ClosePreview, //PrintingSystemCommand.Customize, //PrintingSystemCommand.DocumentMap, //PrintingSystemCommand.EditPageHF, //PrintingSystemCommand.ExportCsv, //PrintingSystemCommand.ExportFile, //PrintingSystemCommand.ExportGraphic, //PrintingSystemCommand.ExportHtm, //PrintingSystemCommand.ExportMht, //PrintingSystemCommand.ExportPdf, //PrintingSystemCommand.ExportRtf, //PrintingSystemCommand.ExportTxt, //PrintingSystemCommand.ExportXls, //PrintingSystemCommand.ExportXlsx, //PrintingSystemCommand.ExportXps, //PrintingSystemCommand.File, //PrintingSystemCommand.FillBackground , //PrintingSystemCommand.Find, //PrintingSystemCommand.HandTool, //PrintingSystemCommand.Magnifier, //PrintingSystemCommand.MultiplePages, //PrintingSystemCommand.Open, //PrintingSystemCommand.PageLayout, //PrintingSystemCommand.PageLayoutContinuous, //PrintingSystemCommand.PageMargins, //PrintingSystemCommand.PageOrientation, //PrintingSystemCommand.PageSetup, //PrintingSystemCommand.PaperSize, PrintingSystemCommand.Parameters, //PrintingSystemCommand.Pointer, //PrintingSystemCommand.Print, //PrintingSystemCommand.PrintDirect , //PrintingSystemCommand.Save, //PrintingSystemCommand.SendCsv, //PrintingSystemCommand.SendFile, //PrintingSystemCommand.SendGraphic, //PrintingSystemCommand.SendMht, //PrintingSystemCommand.SendPdf, //PrintingSystemCommand.SendRtf, //PrintingSystemCommand.SendTxt, //PrintingSystemCommand.SendXls, //PrintingSystemCommand.SendXlsx, //PrintingSystemCommand.SendXps, PrintingSystemCommand.SubmitParameters, //PrintingSystemCommand.View, //PrintingSystemCommand.Watermark }, DevExpress.XtraPrinting.CommandVisibility.None); switch (handleType) { case 1: XtraReport_Preview(report); break; case 2: XtraReport_Print(report); break; case 3: XtraReport_Designer(report, path); break; } }