public string ExportDataX(DataSet data) { string fileName = string.Empty; this.DataSet.EnforceConstraints = false; DataTable dt = this.DataSet.Tables[0]; DataTable subDt = this.DataSet.Tables[1]; try { dt.BeginLoadData(); subDt.BeginLoadData(); foreach (DataRow currentRow in data.Tables[0].Rows) { DataRow newRow = dt.NewRow(); newRow.BeginEdit(); foreach (DataColumn col in data.Tables[0].Columns) { newRow[col.ColumnName] = currentRow[col.ColumnName]; } newRow.EndEdit(); dt.Rows.Add(newRow); } foreach (DataRow currentRow in data.Tables[1].Rows) { DataRow newRow = subDt.NewRow(); newRow.BeginEdit(); foreach (DataColumn col in data.Tables[1].Columns) { newRow[col.ColumnName] = currentRow[col.ColumnName]; } newRow.EndEdit(); subDt.Rows.Add(newRow); } } finally { dt.EndLoadData(); subDt.EndLoadData(); this.DataSet.EnforceConstraints = true; } fileName = string.Format("{0}-{1}.xls", this.ProgId, string.Format("{0}{1}", "UnitInfo", LibDateUtils.GetCurrentDateTime())); string filePath = System.IO.Path.Combine(AxCRL.Comm.Runtime.EnvProvider.Default.RuningPath, "TempData", "ExportData", fileName); AxCRL.Core.Excel.LibExcelHelper libExcelHelper = new Core.Excel.LibExcelHelper(); libExcelHelper.ExportToExcel(filePath, this.DataSet); //} return(fileName); }
public string ExportData(LibQueryCondition condition) { string fileName = string.Empty; bool ret = CheckHasPermission(FuncPermissionEnum.Export); if (ret) { this.GetData(condition); fileName = string.Format("{0}-{1}.xls", this.ProgId, LibDateUtils.GetCurrentDateTime()); string filePath = System.IO.Path.Combine(AxCRL.Comm.Runtime.EnvProvider.Default.RuningPath, "TempData", "ExportData", fileName); AxCRL.Core.Excel.LibExcelHelper libExcelHelper = new Core.Excel.LibExcelHelper(); libExcelHelper.ExportToExcel(filePath, this.DataSet); } return(fileName); }
public DataSet ImportData(string fileName) { bool ret = CheckHasPermission(FuncPermissionEnum.Import); if (ret) { AxCRL.Core.Excel.LibExcelHelper libExcelHelper = new Core.Excel.LibExcelHelper(); libExcelHelper.ImportToDataSet(System.IO.Path.Combine(AxCRL.Comm.Runtime.EnvProvider.Default.RuningPath, "TempData", "ImportData", fileName), this.DataSet, this.AfterImportDataInTable, this.AfterImportDataInRow); LibDBTransaction trans = this.DataAccess.BeginTransaction(); try { CheckImportData(this.DataSet); CheckDataHelper.CheckData(this); this.BeforeUpdate(); DataSetManager.SubmitData(this.DataSet, this.DataAccess); this.AfterUpdate(); if (this.ManagerMessage.IsThrow) { trans.Rollback(); this.DataSet.RejectChanges(); } else { trans.Commit(); } } catch { trans.Rollback(); this.DataSet.RejectChanges(); throw; } this.AfterCommintData(); this.AfterChangeData(this.DataSet); this.DataSet.AcceptChanges(); } return(this.DataSet); }
public string ExportData(LibQueryCondition condition) { string fileName = string.Empty; bool ret = CheckHasPermission(FuncPermissionEnum.Export); if (ret) { if (condition == null || condition.QueryFields.Count == 0) { DataSetManager.GetDataSet(this.DataSet, this.DataAccess, this.ProgId); } else { GetQueryData(condition); } this.AfterChangeData(this.DataSet); fileName = string.Format("{0}-{1}.xls", this.ProgId, LibDateUtils.GetCurrentDateTime()); string filePath = System.IO.Path.Combine(AxCRL.Comm.Runtime.EnvProvider.Default.RuningPath, "TempData", "ExportData", fileName); AxCRL.Core.Excel.LibExcelHelper libExcelHelper = new Core.Excel.LibExcelHelper(); libExcelHelper.ExportToExcel(filePath, this.DataSet); AfterExportData(); } return(fileName); }