public string CreateText(Tem tem, string msg, string tableName, DataXml data) { string text = Environment.NewLine; WebForm1 com = new WebForm1(); var modelList = data.TableXml.Where(x => x.TableName == tableName); StringBuilder GetModel = new StringBuilder(); string DDL = " yield return new NameValue() {{ Name = \"{0}\", Value = cod.GetDDLTextByValue(\"{1}\", entity.{0}) }};"; string noDDL = " yield return new NameValue() {{ Name = \"{0}\", Value = entity.{0}.ToString() }};"; string[] model = msg.Split('|'); for (int i = 0; i < model.Length; i++) { if (string.IsNullOrEmpty(tableName)) { text += string.Format(tem.ColText, com.GetSizeStatus(model[i], data.size), com.GetSizeStatus(model[i], data.size)); } else { text += string.Format(tem.ColText, model[i], com.GetChina(model[i], tableName, data)); var currData = modelList.Where(x => x.ColumnName == model[i]).FirstOrDefault(); if (string.IsNullOrEmpty(currData.DDL)) { GetModel.AppendFormat(noDDL, model[i]); } else { GetModel.AppendFormat(DDL, model[i], currData.DDL); } GetModel.Append(tem.NewLine); } if (i < model.Length - 1) { text += ","; } text += tem.NewLine; } var ColText = string.Format(tem.COLS, text); return(ColText + tem.NewLine + GetModel.ToString()); }
public string CreateText(Tem tem, string msg, string tableName, DataXml data) { string head = @"<?xml version=""1.0"" encoding=""gb2312"" ?> <freeforms> {0}</freeforms> "; msg = string.Format(head, msg); XmlDocument model = new XmlDocument(); //存放保存方法 StringBuilder SaveModel = new StringBuilder(); WebForm1 com = new WebForm1(); model.LoadXml(msg); StringReader sRead = new StringReader(msg); DataSet ds = new DataSet(); ds.ReadXml(sRead, XmlReadMode.InferTypedSchema); StringBuilder sb = new StringBuilder(); DataTable row = ds.Tables["row"]; DataTable col = ds.Tables["col"]; DataTable lab = ds.Tables["label"]; DataTable edit = ds.Tables["editor"]; for (int i = 0; i < row.Rows.Count; i++) { sb.Append("<tr>"); DataRow[] colView = col.AsDataView().Table.Select("row_ID= '" + i + "'"); var rowValue = ""; for (int k = 0; k < colView.Length; k++) { int num = (int)colView[k]["col_ID"]; if (num % 2 == 0) { rowValue = lab.Select("col_ID = " + num + "")[0]["dbname"] as string; sb.AppendFormat(@"<td class=""label-bg"" style=""width: 100px; "">{0}</td>", com.GetChina(rowValue, tableName, data)); } else { rowValue = edit.Select("col_ID = " + num + "")[0]["dbname"] as string; sb.AppendFormat(@"<td> <input type=""text"" size=""10"" id=""{0}"" name=""{0}"" value=""<%=model.{0}%>""/> </td>", rowValue); } sb.Append(Environment.NewLine); SaveModel.AppendFormat(" head.{0} = Post(\"{0}\");", rowValue); SaveModel.AppendLine(); } sb.Append("</tr>"); sb.Append(Environment.NewLine); } return(sb.ToString() + tem.NewLine + SaveModel.ToString()); }