数据对象类代码的生成小工具
闲着没事做了一个数据对象类代码生成的小工具,本来原来做过一个,是在1.1 下面的,后来找不到了,现在做程序没办法,自己写一个吧,小兴趣的朋友随便看看吧,下面是代码 :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.gridview {}{
color: #333333;
background-color: #CCDDEE;
width: 100%;
text-align: left;
}
.even {}{
color: #333333;
background-color: #FFFFFF;
}
.gridview a {}{
font-weight: bold;
color: #3399FF;
}
.gridview th a {}{
color: #FFFFFF;
font-weight: bold;
}
.gridview th {}{
background-color: #666666;
padding: 3px;
}
h2 {}{
color: #3399FF;
}
.gridview td {}{
padding: 3px;
}
body {}{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 110%;
text-align: center;
}
strong {}{
color: #336699;
}
li {}{
color: #333333;
}
em {}{
color: #FF9966;
}
#main {}{
width: 760px;
text-align: left;
text-indent: 20px;
border: 1px dashed #009933;
padding: 10px;
margin-top: 5px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
background-repeat: repeat-x;
}
-->
</style>
</head>
<body>
<form id="form1" runat="server">
<div id = "main" style="filter:progid:DXImageTransform.Microsoft.Gradient(startColorStr='#CEDFF6', endColorStr='#4B92D9', gradientType='0')">
<h4>Data object code generator by Darkangle 29 Mar,2006</h4>
<div id = "MYNameSpace">
<table class="gridview">
<tr>
<td>Name Space : </td>
<td> <asp:TextBox ID="NameSpace" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="NameSpace"
ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>Class Name :</td>
<td><asp:TextBox ID="ClassName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ClassName"
ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator></td>
</tr>
</table>
</div>
<hr />
<table class="gridview">
<tr>
<th><span style="color: White;">Property Name</span></th>
<th><span style="color: White;">Read | Write | Property Type</span></th>
</tr>
<tr>
<td><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
<td><asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
<asp:ListItem>Read</asp:ListItem>
<asp:ListItem>Write</asp:ListItem>
</asp:CheckBoxList>
<asp:TextBox ID="PropertyType1" Text="string" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td>
<td><asp:CheckBoxList ID="CheckBoxList2" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
<asp:ListItem>Read</asp:ListItem>
<asp:ListItem>Write</asp:ListItem>
</asp:CheckBoxList>
<asp:TextBox ID="PropertyType2" Text="string" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td><asp:TextBox ID="TextBox3" runat="server"></asp:TextBox></td>
<td><asp:CheckBoxList ID="CheckBoxList3" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
<asp:ListItem>Read</asp:ListItem>
<asp:ListItem>Write</asp:ListItem>
</asp:CheckBoxList>
<asp:TextBox ID="PropertyType3" Text="string" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td><asp:TextBox ID="TextBox4" runat="server"></asp:TextBox></td>
<td><asp:CheckBoxList ID="CheckBoxList4" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
<asp:ListItem>Read</asp:ListItem>
<asp:ListItem>Write</asp:ListItem>
</asp:CheckBoxList>
<asp:TextBox ID="PropertyType4" Text="string" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td><asp:TextBox ID="TextBox5" runat="server"></asp:TextBox></td>
<td><asp:CheckBoxList ID="CheckBoxList5" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
<asp:ListItem>Read</asp:ListItem>
<asp:ListItem>Write</asp:ListItem>
</asp:CheckBoxList>
<asp:TextBox ID="PropertyType5" Text="string" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td><asp:TextBox ID="TextBox6" runat="server"></asp:TextBox></td>
<td><asp:CheckBoxList ID="CheckBoxList6" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
<asp:ListItem>Read</asp:ListItem>
<asp:ListItem>Write</asp:ListItem>
</asp:CheckBoxList>
<asp:TextBox ID="PropertyType6" Text="string" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td><asp:TextBox ID="TextBox7" runat="server"></asp:TextBox></td>
<td><asp:CheckBoxList ID="CheckBoxList7" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
<asp:ListItem>Read</asp:ListItem>
<asp:ListItem>Write</asp:ListItem>
</asp:CheckBoxList>
<asp:TextBox ID="PropertyType7" Text="string" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td><asp:TextBox ID="TextBox8" runat="server"></asp:TextBox></td>
<td><asp:CheckBoxList ID="CheckBoxList8" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
<asp:ListItem>Read</asp:ListItem>
<asp:ListItem>Write</asp:ListItem>
</asp:CheckBoxList>
<asp:TextBox ID="PropertyType8" Text="string" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td><asp:TextBox ID="TextBox9" runat="server"></asp:TextBox></td>
<td><asp:CheckBoxList ID="CheckBoxList9" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
<asp:ListItem>Read</asp:ListItem>
<asp:ListItem>Write</asp:ListItem>
</asp:CheckBoxList>
<asp:TextBox ID="PropertyType9" Text="string" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td><asp:TextBox ID="TextBox10" runat="server"></asp:TextBox></td>
<td><asp:CheckBoxList ID="CheckBoxList10" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
<asp:ListItem>Read</asp:ListItem>
<asp:ListItem>Write</asp:ListItem>
</asp:CheckBoxList>
<asp:TextBox ID="PropertyType10" Text="string" runat="server"></asp:TextBox>
</td>
</tr>
</table>
<hr />
<asp:Button ID="Button1" runat="server" Text="Get Code Now !" OnClick="Button1_Click" />
<div id = "MYcode">
<asp:Literal ID="code" runat="server"></asp:Literal>
</div>
</div>
</form>
</body>
</html>
下面是后台代码 :
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CodeGenerator_DataObject : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.Text.StringBuilder sb1 = new System.Text.StringBuilder();
System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
System.Text.StringBuilder sb3 = new System.Text.StringBuilder();
System.Text.StringBuilder sb4 = new System.Text.StringBuilder();
sb.Append("namespace " + NameSpace.Text + " {<br />");
sb.Append("public class " + ClassName.Text + " {<br />");
//加入空的构造函数
sb3.Append("public " + ClassName.Text + "() {}<br />");
sb3.Append("public " + ClassName.Text + "(");
for(int i = 1;i < 11;i++)
{
TextBox tb = (TextBox)Page.FindControl("TextBox" + i);
TextBox propertytype = (TextBox)Page.FindControl("PropertyType" + i);
CheckBoxList cbl = (CheckBoxList)Page.FindControl("CheckBoxList" + i);
//属性名不为空
if(!(tb.Text == String.Empty))
{
sb1.Append("private " + propertytype.Text + " _" + tb.Text + ";<br />");
sb2.Append("public " + propertytype.Text + " " + tb.Text + " {<br />");
if(cbl.Items[0].Selected)
sb2.Append("get { return _" + tb.Text + "; }<br />");
if(cbl.Items[1].Selected)
sb2.Append("set { _" + tb.Text + " = value; }<br />");
sb2.Append("}<br />");
sb3.Append(propertytype.Text + " " + tb.Text + ",");
//注意,这里最后会多出来一个逗号,要去掉它
sb4.Append("this._" + tb.Text + " = " + tb.Text + ";<br />");
}
}
//去掉最后一个逗号
sb3.Replace(",","",(sb3.Length - 1), 1);
sb.Append(sb1.ToString());
sb.Append(sb3.ToString());
sb.Append(") {<br />");
sb.Append(sb4.ToString());
sb.Append("}<br />");
sb.Append(sb2.ToString());
sb.Append("}<br />}<br />");
code.Text = sb.ToString();
}
}
数据对象类代码的生成小工具相关推荐
- 发布一个实体类属性生成小工具,给开发加点料
做了很久的代码生成工具,基本上都是基于表生成实体类属性的,把数据库表的信息拿出来,然后之乎者也后生成一个标准的实体类,包含字段.属性.描述等东西. 是基于整个数据库生成整个框架代码的工具,如我的代码生 ...
- python︱写markdown一样写网页,代码快速生成web工具:streamlit 数据探索案例(六)
系列参考: python︱写markdown一样写网页,代码快速生成web工具:streamlit介绍(一) python︱写markdown一样写网页,代码快速生成web工具:streamlit 重 ...
- 数据访问层代码自动生成
<%-- Name: 数据访问层代码自动生成 Author: 水木 Description: 用来生成三层结构数据访问层代码 --%> <%@ CodeTemplate Lang ...
- python︱写markdown一样写网页,代码快速生成web工具:streamlit lay-out布局(四)
文章目录 1 `streamlit.beta_container()` 2 分列展示 3 按照比例分列展示 4 折叠/展开 系列参考: python︱写markdown一样写网页,代码快速生成web工 ...
- C#实战:基于ItextSharp技术标签生成小工具
目录 1.运行主界面 2.标签生成界面 3.需要引入的依赖包 4.解决方案目录 5.主要代码 1.新建PdfUtils工具类 2.Form1.cs 窗体主要代码 IT技术分享社区 / Itext Sh ...
- python︱写markdown一样写网页,代码快速生成web工具:streamlit 缓存(五)
系列参考: python︱写markdown一样写网页,代码快速生成web工具:streamlit介绍(一) python︱写markdown一样写网页,代码快速生成web工具:streamlit 重 ...
- python︱写markdown一样写网页,代码快速生成web工具:streamlit 展示组件(三)
系列参考: python︱写markdown一样写网页,代码快速生成web工具:streamlit介绍(一) python︱写markdown一样写网页,代码快速生成web工具:streamlit 重 ...
- python︱写markdown一样写网页,代码快速生成web工具:streamlit 重要组件介绍(二)
python︱写markdown一样写网页,代码快速生成web工具:streamlit(一) 上篇主要是steamlit的介绍以及streamlit的一些初始化,这篇是一些组件的介绍,当然风格是直接上 ...
- 小程序源码:炫酷手持滚动弹幕生成小工具微信小程序-多玩法安装简单
这是一款滚动弹幕生成微信小程序源码 让弹幕文字在手机屏幕上跑起来,LED弹幕 手机弹幕,告白神奇,等 支持多种模板,每一种模板都支持自定义颜色等等 字体跳动,字体表白等等 另外用户也可以支持自定义文字 ...
最新文章
- Blender建筑可视化技能学习视频教程
- 【Paper】2021_Observer-Based Controllers for Incrementally Quadratic Nonlinear Systems With Disturbanc
- SQL Server 2016 列存储技术做实时分析
- Ubuntu下添加定时任务执行php文件
- C++ 字符数组和String类
- 【渝粤教育】国家开放大学2018年秋季 0248-21T电工电子技术 参考试题
- 【电力负荷预测】基于matlab日特征气象因素支持向量机SVM电力负荷预测【含Matlab源码 1612期】
- 计算机硬件常识知识,计算机硬件基础知识大全
- 摄氏度和开氏度的换算_摄氏度与开氏度换算(开氏度和摄氏度的换算公式)
- JSP之java.lang.ClassNotFoundException
- 网络操作系统 Linux配置与管理,网络操作系统—Linux配置与管理
- 利用requestxpath爬取网站图片以及图片信息
- 速记计算机键盘,键盘字母排列的速记公式
- echarts设置label添加下划线
- 计算机网络概述 第二部分
- 常见网络故障排查方法
- databricks spark 读取postgresql表
- 豆瓣电台WP7客户端 开发记录3
- 零基础编程——块语言编程游戏攻略之动画篇
- BlackBerry 开发笔记入门