📄 builderweb.cs
字号:
strclass.AppendSpaceLine(2,BLLSpace + " bll=new " + BLLSpace + "();" );
strclass.AppendSpaceLine(2, ModelSpace + " model=bll.GetModel(" + LTP.CodeHelper.CodeCommon.GetFieldstrlist(Keys) + ");" );
foreach (ColumnInfo field in Fieldlist)
{
string columnName = field.ColumnName;
string columnType = field.TypeName;
string deText = field.DeText;
bool ispk = field.IsPK;
bool IsIdentity = field.IsIdentity;
switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower())
{
case "int":
case "smallint":
case "float":
case "numeric":
case "decimal":
case "datetime":
case "smalldatetime":
if ((ispk) || (IsIdentity))
{
strclass.AppendSpaceLine(2,"this.lbl" + columnName + ".Text=model." + columnName + ".ToString();" );
}
else
{
strclass.AppendSpaceLine(2,"this.txt" + columnName + ".Text=model." + columnName + ".ToString();" );
}
break;
case "bool":
strclass.AppendSpaceLine(2,"this.chk" + columnName + ".Checked=model." + columnName + ";" );
break;
case "byte[]":
strclass.AppendSpaceLine(2,"this.txt" + columnName + ".Text=model." + columnName + ".ToString();" );
break;
default:
if ((ispk) || (IsIdentity))
{
strclass.AppendSpaceLine(2,"this.lbl" + columnName + ".Text=model." + columnName + ";" );
}
else
{
strclass.AppendSpaceLine(2,"this.txt" + columnName + ".Text=model." + columnName + ";" );
}
break;
}
}
strclass.AppendLine();
strclass.AppendSpaceLine(1,"}");
return strclass.Value;
}
/// <summary>
/// 得到表示层显示窗体的代码
/// </summary>
public string GetShowAspxCs()
{
StringPlus strclass = new StringPlus();
strclass.AppendLine();
string key = Key;
strclass.AppendSpaceLine(1,"private void ShowInfo(" + LTP.CodeHelper.CodeCommon.GetInParameter(Keys) + ")" );
strclass.AppendSpaceLine(1, "{" );
strclass.AppendSpaceLine(2, BLLSpace + " bll=new " + BLLSpace + "();" );
strclass.AppendSpaceLine(2, ModelSpace + " model=bll.GetModel(" + LTP.CodeHelper.CodeCommon.GetFieldstrlist(Keys) + ");" );
foreach (ColumnInfo field in Fieldlist)
{
string columnName = field.ColumnName;
string columnType = field.TypeName;
string deText = field.DeText;
bool ispk = field.IsPK;
bool IsIdentity = field.IsIdentity;
if ((ispk) || (IsIdentity))
{
continue;
}
switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower())
{
case "int":
case "smallint":
case "float":
case "numeric":
case "decimal":
case "datetime":
case "smalldatetime":
strclass.AppendSpaceLine(2,"this.lbl" + columnName + ".Text=model." + columnName + ".ToString();" );
break;
case "bool":
strclass.AppendSpaceLine(2,"this.chk" + columnName + ".Checked=model." + columnName + ";" );
break;
case "byte[]":
strclass.AppendSpaceLine(2,"this.lbl" + columnName + ".Text=model." + columnName + ".ToString();" );
break;
default:
strclass.AppendSpaceLine(2,"this.lbl" + columnName + ".Text=model." + columnName + ";" );
break;
}
}
strclass.AppendLine();
strclass.AppendSpaceLine(1,"}");
return strclass.ToString();
}
/// <summary>
/// 删除页面
/// </summary>
/// <returns></returns>
public string CreatDeleteForm()
{
StringPlus strclass = new StringPlus();
strclass.AppendSpaceLine(1,"if(!Page.IsPostBack)");
strclass.AppendSpaceLine(1,"{");
strclass.AppendSpaceLine(2,BLLSpace + " bll=new " + BLLSpace + "();");
switch (_keyType.Trim())
{
case "int":
case "smallint":
case "float":
case "numeric":
case "decimal":
case "datetime":
case "smalldatetime":
strclass.AppendSpaceLine(2,_keyType + " " + _key + "=" + _keyType + ".Parse(Request.Params[\"id\"]);");
break;
default:
strclass.AppendSpaceLine(2,"string " + _key + "=Request.Params[\"id\"];");
break;
}
strclass.AppendSpaceLine(2,"bll.Delete(" + _key + ");");
strclass.AppendSpaceLine(2,"Response.Redirect(\"index.aspx\");");
strclass.AppendSpaceLine(1,"}");
return strclass.Value;
}
public string CreatSearchForm()
{
StringPlus strclass = new StringPlus();
return strclass.Value;
}
#endregion//表示层
#region 生成aspx.designer.cs
/// <summary>
/// 增加窗体的html代码
/// </summary>
public string GetAddDesigner()
{
StringPlus strclass = new StringPlus();
strclass.AppendLine();
foreach (ColumnInfo field in Fieldlist)
{
string columnName = field.ColumnName;
string columnType = field.TypeName;
string deText = field.DeText;
bool ispk = field.IsPK;
bool IsIdentity = field.IsIdentity;
if ((ispk) || (IsIdentity))
{
continue;
}
switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower())
{
case "datetime":
case "smalldatetime":
strclass.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.TextBox txt" + columnName + ";");
break;
case "bool":
strclass.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.CheckBox chk" + columnName + ";");
break;
default:
strclass.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.TextBox txt" + columnName + ";");
break;
}
}
//按钮
strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Button btnAdd;");
strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Button btnCancel;");
return strclass.ToString();
}
/// <summary>
/// 修改窗体的html代码
/// </summary>
public string GetUpdateDesigner()
{
StringPlus strclass = new StringPlus();
foreach (ColumnInfo field in Fieldlist)
{
string columnName = field.ColumnName;
string columnType = field.TypeName;
string deText = field.DeText;
bool ispk = field.IsPK;
bool IsIdentity = field.IsIdentity;
if (deText.Trim() == "")
{
deText = columnName;
}
if ((ispk) || (IsIdentity))
{
strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Label lbl" + columnName + ";");
}
else
{
switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower())
{
case "datetime":
case "smalldatetime":
strclass.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.TextBox txt" + columnName + ";");
break;
case "bool":
strclass.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.CheckBox chk" + columnName + ";");
break;
default:
strclass.AppendSpaceLine(2, "protected global::System.Web.UI.WebControls.TextBox txt" + columnName + ";");
break;
}
}
}
//按钮
strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Button btnAdd;");
strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Button btnCancel;");
return strclass.Value;
}
/// <summary>
/// 显示窗体的html代码
/// </summary>
public string GetShowDesigner()
{
StringPlus strclass = new StringPlus();
foreach (ColumnInfo field in Fieldlist)
{
string columnName = field.ColumnName;
string columnType = field.TypeName;
string deText = field.DeText;
if (deText.Trim() == "")
{
deText = columnName;
}
switch (CodeCommon.DbTypeToCS(columnType.Trim().ToLower()).ToLower())
{
case "bool":
strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.CheckBox chk" + columnName + ";");
break;
default:
strclass.AppendSpaceLine(1, "protected global::System.Web.UI.WebControls.Label lbl" + columnName + ";");
break;
}
}
return strclass.ToString();
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -