private string GenerateTableCode(List <TableControl> tables) { StringBuilder sb = new StringBuilder(); int i = 0; foreach (TableControl t in tables) { i++; TableEntity te = t.GetTableEntity(); if (te.GetSchema() == null) { sb.AppendLine("CREATE TABLE " + te.GetName()); } else { sb.AppendLine("CREATE TABLE " + te.GetSchema() + "." + te.GetName()); } sb.AppendLine("("); foreach (ColumnEntity ce in te.GetColumns()) { sb.Append("\t" + ce.GetColumnName() + "\t\t" + ce.GetColumnType() + "(" + ce.GetColumnLength() + ")"); if (i == tables.Count) { sb.AppendLine(); } else { sb.AppendLine(","); } } sb.AppendLine(");\n\n / \n\n"); } return(sb.ToString()); }
protected override void OnCreateControl() { this.Text = tableEntity.GetSchema() + "." + tableEntity.GetName(); this.AutoSize = true; Padding p = new Padding(); p.All = 5; this.Padding = p; this.ForeColor = textColor; this.BackColor = tableColor; this.TextAlign = ContentAlignment.MiddleLeft; }
private string GenerateViewCode(List <TableControl> tables, List <JoinControl> joins) { StringBuilder sb = new StringBuilder(); sb.AppendLine("CREATE OR REPLACE VIEW"); sb.AppendLine("AS"); sb.AppendLine("SELECT"); //sb.Append("\t"); sb.AppendLine("\t*"); sb.Append("FROM "); int i = 0; foreach (TableControl t in tables) { i++; TableEntity te = t.GetTableEntity(); sb.Append(te.GetSchema()); sb.Append("."); if (i < tables.Count) { sb.AppendLine(te.GetName()); sb.Append("JOIN "); } else { sb.Append(te.GetName()); } } sb.Append(";"); return(sb.ToString()); }