public override void BindData() { DataTable columns1 = service.GetColumnDataTable(this.RecordID); DataTable columns2 = columns1.Copy(); DataBind.BindCombox(this.cboDataKey, columns1, "Field"); DataBind.BindCombox(this.cboSortName, columns2, "Field"); TableEntity entity = service.GetTableById(this.RecordID); txtTableName.Text = entity.TableName; txtAttr.Text = entity.Attr; txtRemark.Text = entity.Remark; cboDataKey.Text = entity.DataKey; cboDataKeyType.Text = entity.DataKeyType.ToString(); cboSortMode.Text = entity.DefaultSortMode.ToString(); cboSortName.Text = entity.DefaultSortName; }
public void BindGrid() { ColumnsSource = service.GetColumnDataTable(TableID); this.grid.DataSource = ColumnsSource; }
private void ExportWord() { if (Tables != null) { var columns = Columns; using (Docx.DocX doc = Docx.DocX.Create(FileName)) { //表格的边框样式 Docx.Border border = new Docx.Border(); border.Tcbs = Docx.BorderStyle.Tcbs_single; int n = 0; foreach (TableEntity tableEntity in Tables) { string tableId = tableEntity.ID.ToString(); //插入表名 Docx.Paragraph title = doc.InsertParagraph(); title.Append(tableEntity.TableName + "(" + tableEntity.Attr + ")"); title.Alignment = Docx.Alignment.center; title.FontSize(15); title.Bold(); title.SetLineSpacing(Docx.LineSpacingType.After, 1); title.SetLineSpacing(Docx.LineSpacingType.Before, 1); DataTable fields = service.GetColumnDataTable(tableId); int rowCount = (fields == null ? 0 : fields.Rows.Count) + 1; //计算表格多少行,多少列 Docx.Table table = doc.InsertTable(rowCount, columns.Count); //先生成列头 Docx.Row colRow = table.Rows[0]; int k = 0; foreach (string colKey in columns.Keys) { Docx.Cell colCell = colRow.Cells[k]; colCell.Paragraphs[0].Append(columns[colKey]).Alignment = Docx.Alignment.center; colCell.SetBorder(Docx.TableCellBorderType.Top, border); colCell.SetBorder(Docx.TableCellBorderType.Bottom, border); colCell.SetBorder(Docx.TableCellBorderType.Left, border); colCell.SetBorder(Docx.TableCellBorderType.Right, border); k++; } for (int i = 0; i < fields.Rows.Count; i++) { //一个属性为一行 Docx.Row row = table.Rows[i + 1]; //循环每列 int j = 0; foreach (string key in columns.Keys) { Docx.Cell cell = row.Cells[j]; string text = fields.Rows[i][key].ToString(); if (key == requiredKey) { text = text.ToLower() == "true" ? "是" : ""; } cell.Paragraphs[0].Append(text).Alignment = Docx.Alignment.center; cell.Paragraphs[0].FontSize(10); cell.SetBorder(Docx.TableCellBorderType.Top, border); cell.SetBorder(Docx.TableCellBorderType.Bottom, border); cell.SetBorder(Docx.TableCellBorderType.Left, border); cell.SetBorder(Docx.TableCellBorderType.Right, border); j++; } } n++; if (OnProgress != null) { OnProgress(this, new ProgressEventArgs() { Max = Tables.Count, Value = n }); } } doc.Save(); } } }