开发目的:
自动生成C#、HTML、JS、Ajax 代码 、可以节省大量的时间来做业务逻辑的代码,那些重复的代码就不需要、、、、了
环境支持:
硬件环境:window 、VS2010+、支持SQLServer最低版本2000
架构:基于BS架构
Server服务端(专门生成代码的):www.10086bank.com 平台下面的“代码工厂”:
client客户端: 免费下载、、、、 http://pan.baidu.com/s/1hqtGGlA
怎样使用:
使用方法请看:http://www.cnblogs.com/chinhi/p/howtousewatticg.html
代码生成:
html+JS:
<!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> <meta charset="utf-8"> <title>ICGS</title> <!-- The styles --> <link href="css/bootstrap-cerulean.css" rel="stylesheet" /> <link type="text/css" href="css/bootstrap-responsive.css" rel="stylesheet" /> <link type="text/css" href="css/charisma-app.css" rel="stylesheet" /> <link type="text/css" href="css/jquery-ui-1.8.21.custom.css" rel="stylesheet" /> <link type="text/css" href=‘css/fullcalendar.css‘ rel=‘stylesheet‘ /> <link type="text/css" href=‘css/fullcalendar.print.css‘ rel=‘stylesheet‘ media=‘print‘ /> <link type="text/css" href=‘css/chosen.css‘ rel=‘stylesheet‘ /> <link type="text/css" href=‘css/uniform.default.css‘ rel=‘stylesheet‘ /> <link type="text/css" href=‘css/colorbox.css‘ rel=‘stylesheet‘ /> <link type="text/css" href=‘css/jquery.cleditor.css‘ rel=‘stylesheet‘ /> <link type="text/css" href=‘css/jquery.noty.css‘ rel=‘stylesheet‘ /> <link type="text/css" href=‘css/noty_theme_default.css‘ rel=‘stylesheet‘ /> <link type="text/css" href=‘css/elfinder.min.css‘ rel=‘stylesheet‘ /> <link type="text/css" href=‘css/elfinder.theme.css‘ rel=‘stylesheet‘ /> <link type="text/css" href=‘css/jquery.iphone.toggle.css‘ rel=‘stylesheet‘ /> <link type="text/css" href=‘css/opa-icons.css‘ rel=‘stylesheet‘ /> <link type="text/css" href=‘css/uploadify.css‘ rel=‘stylesheet‘ /> <link href="js/asyncbox/skins/ZCMS/asyncbox.css" type="text/css" rel="stylesheet" /> <link href="Script/validationEngine/css/validationEngine.jquery.css" rel="stylesheet" type="text/css" /> <!--jquery and javascript begin--> <script type="text/javascript" src="js/jquery-1.8.0.js"></script> <script language="javascript" type="text/javascript" src="Script/My97DatePicker/WdatePicker.js"></script> <script type="text/javascript" src=‘Script/validationEngine/languages/jquery.validationEngine-zh_CN.js‘></script> <script type="text/javascript" src=‘Script/validationEngine/jquery.validationEngine.js‘></script> <script type="text/javascript" src="js/asyncbox/AsyncBox.v1.4.5.js"></script> <script type="text/javascript"> var userid = "feifei", tiptime = 2000, pagesize = 10, TESTTABID = -1; //当前主ID var SLarray = []; //clear data obj var endtime = ""; //common data begin var myidarray = []; //for-----code myidarray.push("housenum"); myidarray.push("housename"); myidarray.push("permonth"); myidarray.push("abouthouse"); myidarray.push("hosueadminer"); myidarray.push("admintel"); myidarray.push("Aera"); myidarray.push("pointto"); myidarray.push("housetype"); myidarray.push("anercar"); myidarray.push("houseimg"); myidarray.push("biuldyear"); $(function () { jQuery("#divadd").validationEngine(); //验证 $("select").trigger("liszt:updated"); $("select").chosen(); //新增 $("#btnadd").click(function () { ZRHouseID = -1; for (var s = 0; s < myidarray.length; s++) { var fileobj = $("#" + myidarray[s]).html(); if (fileobj == null || fileobj == undefined || fileobj == "") { $("input[myid=‘" + myidarray[s] + "‘]").val(""); } else { $("#" + myidarray[s]).attr("path", ""); $("#" + myidarray[s]).html(""); $("#" + myidarray[s]).parent().children("a").hide(); } fileobj = null; } $("label[name=‘labsting‘]").hide(); $("input").show(); $("#btnsave").show(); $("#btnedit").hide(); $("#btncancel").show(); $("a[name=‘adelete‘]").hide(); $("select").val("请选择"); $("select").trigger("liszt:updated"); $("select").chosen(); $("#divadd").show(); }); //取消新增 $("#btncancel").click(function () { $("#divadd").hide(); $("#divlist").show(); }); //保存方法 $("#btnsave").click(function () { if (!jQuery("#divadd").validationEngine("validate")) { return false; } var temparray = []; for (var s = 0; s < myidarray.length; s++) { if (myidarray[s] == "pointto") { temparray.push($("select[myid=‘" + myidarray[s] + "‘]").find("option:selected").attr("myval")); continue; } if (myidarray[s] == "housetype") { temparray.push($("select[myid=‘" + myidarray[s] + "‘]").find("option:selected").attr("myval")); continue; } var fileobj = $("#" + myidarray[s]).html(); if (fileobj == null || fileobj == undefined || fileobj == "") { temparray.push($("input[myid=‘" + myidarray[s] + "‘]").val()); } else { temparray.push($("#" + myidarray[s]).attr("path") + "#[email protected]#@" + $("#" + myidarray[s]).html()); //path+name } fileobj = null; } $.post("userajax/ZRHouseOP.aspx?" + new Date().toTimeString(), { "type": "add", "myidarray": temparray.toString(), "userid": userid, "ZRHouseID": ZRHouseID }, function (data) { endtime = ""; //时间默认值 ZRHouseID = -1; if (data.length == 36) { success("保存成功!"); for (var s = 0; s < myidarray.length; s++) $("input[myid=‘" + myidarray[s] + "‘]").val(""); temparray = null; } $("#divadd").hide(); $("#divlist").show(); getlist(); //获取前20条 }); }); //页面第一次加载进行渲染 function load() { var obj = $("select[name=‘SLData‘]"); $(obj).each(function () { $(this).chosen(); }); } //加载页面渲染 load(); getlist(); $("#btnmore").click(function () { getlist(); }); //编辑按钮进行修改 $("#btnedit").click(function () { $(this).hide(); $("#btnsave").show(); $("label[name=‘labsting‘]").hide(); $("input").show(); $(".divfeifeisl").show(); $("a[name=‘adelete‘]").show(); ckisexts(); }); })//dom end //getone function getone(id) { ZRHouseID = id; $("#divadd").show(); $("#divlist").hide(); if (edittype == "view") { $("label[name=‘labsting‘]").show(); $("#btnedit").show(); $("input").hide(); $("#btnsave").hide(); $("a[name=‘adelete‘]").hide(); $(".divfeifeisl").hide(); $("#btncancel").show(); } else { $("label[name=‘labsting‘]").hide(); $("#btnedit").hide(); $("input").show(); $("#btnsave").show(); $("a[name=‘adelete‘]").show(); $(".divfeifeisl").show(); $("#btncancel").show(); } $("a[name=‘labsh‘]").show(); $.post("userajax/ZRHouseOP.aspx?" + new Date().toTimeString(), { "type": "getone", "id": id }, function (data) { var obj = $.parseJSON(data); if (obj == null || obj == "") { ckisexts(); return; } for (var s = 0; s < myidarray.length; s++) { if (obj[0][myidarray[s]] == "") continue; //附件 if (obj[0][myidarray[s]].indexOf("#[email protected]#@") > -1) { $("#" + myidarray[s]).html(obj[0][myidarray[s]].split("#[email protected]#@")[1]); //name $("#" + myidarray[s]).attr("path", obj[0][myidarray[s]].split("#[email protected]#@")[0]); //path } else { $("input[myid=" + myidarray[s] + "]").val((obj[0][myidarray[s]]).replace(" 0:00:00", "")); $("label[labid=‘" + myidarray[s] + "‘]").html((obj[0][myidarray[s]]).replace(" 0:00:00", "")); try { $("#selecttype" + myidarray[s]).val((obj[0][myidarray[s]]).replace(" 0:00:00", "")); $("#selecttype" + myidarray[s]).trigger("liszt:updated"); $("#selecttype" + myidarray[s]).chosen(); } catch (ex) { } } } ckisexts(); }); } //获取10行数据 function getlist() { //$("#tbodydatalist").html(""); $.post("userajax/ZRHouseOP.aspx?" + new Date().toTimeString(), { "type": "getlist", "pagesize": pagesize, "endtime": endtime }, function (data) { if (data == "nodata") { alerttip("无数据、您可以新增数据!"); $("#btnmore").hide(); } var obj = $.parseJSON(data); if (obj.length < pagesize) { $("#btnmore").hide(); } if (endtime == "") $("#tbodydatalist").html(""); for (var i = 0; i < obj.length; i++) { $("#tbodydatalist").append("<tr id=‘tr" + obj[i].ID + "‘><td class=‘center‘>" + obj[i].housename.replace(" 0:00:00", "") + "</td><td class=‘center‘>" + obj[i].permonth.replace(" 0:00:00", "") + "</td><td class=‘center‘>" + obj[i].hosueadminer.replace(" 0:00:00", "") + "</td><td class=‘center‘>" + obj[i].admintel.replace(" 0:00:00", "") + "</td><td class=‘center‘>" + obj[i].Aera.replace(" 0:00:00", "") + "</td><td class=‘center‘>" + obj[i].pointto.replace(" 0:00:00", "") + "</td><td class=‘center‘>" + obj[i].biuldyear.replace(" 0:00:00", "") + "</td><td class=‘center‘><a class=‘btn btn-success‘ onclick=domains(‘view‘,‘" + obj[i].ID + "‘)><i class=‘icon-zoom-in icon-white‘></i>查看</a> <a class=‘btn btn-info‘ onclick=domains(‘edit‘,‘" + obj[i].ID + "‘)><i class=‘icon-edit icon-white‘></i>修改</a> <a class=‘btn btn-danger‘ onclick=domains(‘delete‘,‘" + obj[i].ID + "‘)><i class=‘icon-trash icon-white‘></i> 删除</a></td></tr>"); if (i == (obj.length - 1)) { endtime = obj[i].CreatTime; } } }) } //domain //检查附件是否有值 function ckisexts() { var obja = $("a[name=‘labsh‘]") $(obja).each(function () { if ($(this).html().length < 2) { $(this).parent().children("a").hide(); } }); } var edittype = "view"; function domains(type, id) { if (type == "delete") { if (confirm("确定删除吗?") == false) return; $.post("userajax/ZRHouseOP.aspx?" + new Date().toTimeString(), { "type": "delete", "id": id, "userid": userid }, function (data) { if (data == "0") { error("您没有权限删除此条数据"); return; } else if (data == "1") { $("#tr" + id).remove(); success("删除成功!"); } }); } else if (type == "view") { SLarray = []; edittype = "view"; getone(id); } else if (type == "edit") { SLarray = []; edittype = "edit"; getone(id); } } //判断是否为第二次点击 function SLexists(myenumid) { for (var i = 0; i < SLarray.length; i++) { if (SLarray[i] == myenumid) return true; } return false; } /////----------------------common JS------------------------------------- //错误 var timeoutlength = 3000; function error(name) { $.noty({ "text": name + "</br>" + new Date().toTimeString(), "layout": "topRight", "type": "error", "timeout": timeoutlength }); return; asyncbox.tips(name, ‘error‘, tiptime); } //成功 function success(name) { $.noty({ "text": name + "</br>" + new Date().toTimeString(), "layout": "topRight", "type": "success", "timeout": timeoutlength }); return; asyncbox.tips(name, ‘success‘, tiptime); } //消息 function alerttip(name) { $.noty({ "text": name + "</br>" + new Date().toTimeString(), "layout": "topRight", "type": "success", "timeout": timeoutlength }); //aler return; asyncbox.tips(name, ‘alert‘, tiptime); } //等待 function waittips() { asyncbox.tips("请稍后...!", ‘wait‘, tiptime * 3); } </script> </head> <body> <!-- content starts --> <div class="row-fluid sortable" id="divadd" style="display: none"> <div class="box span12"> <div class="box-header well" data-original-title> <h2> <i class="icon-edit"></i>新增数据</h2> <div class="box-icon"> <a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a> <a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a> </div> </div> <div class="box-content"> <form class="form-horizontal"> <fieldset> <div class="control-group success"> <label class="control-label" for="inputSuccess"> 房源编号:</label> <div class="controls"> <input class="validate[maxSize[100],custom[noSpecialCaracters]]" myid="housenum" type="text" /> <label name="labsting" labid="housenum"> </label> </div> </div> <div class="control-group success"> <label class="control-label" for="inputSuccess"> 描述:</label> <div class="controls"> <input class="validate[required,maxSize[100],custom[noSpecialCaracters]]" myid="housename" type="text" /> <label name="labsting" labid="housename"> </label> </div> </div> <div class="control-group success"> <label class="control-label" for="inputSuccess"> 月租:</label> <div class="controls"> <input class="validate[required,custom[number]]" myid="permonth" type="text" /> <label name="labsting" labid="permonth"> </label> </div> </div> <div class="control-group success"> <label class="control-label" for="inputSuccess"> 房屋概况:</label> <div class="controls"> <input class="validate[maxSize[1000],custom[noSpecialCaracters]]" myid="abouthouse" type="text" /> <label name="labsting" labid="abouthouse"> </label> </div> </div> <div class="control-group success"> <label class="control-label" for="inputSuccess"> 管家:</label> <div class="controls"> <input class="validate[required,maxSize[50],custom[noSpecialCaracters]]" myid="hosueadminer" type="text" /> <label name="labsting" labid="hosueadminer"> </label> </div> </div> <div class="control-group success"> <label class="control-label" for="inputSuccess"> 管家电话:</label> <div class="controls"> <input class="validate[required,maxSize[50],custom[noSpecialCaracters]]" myid="admintel" type="text" /> <label name="labsting" labid="admintel"> </label> </div> </div> <div class="control-group success"> <label class="control-label" for="inputSuccess"> 面积:</label> <div class="controls"> <input class="validate[required,custom[number]]" myid="Aera" type="text" /> <label name="labsting" labid="Aera"> </label> </div> </div> <div class="control-group"> <label class="control-label" for="selectError"> 朝向:</label> <div class="controls"> <div class="divfeifeisl" style="width: 130px"> <select id="selecttypepointto" myid="pointto"> <option myval="请选择">请选择</option> <option myval="西">西</option> <option myval="南">南</option> <option myval="北">北</option> <option myval="东">东</option> </select> </div> <label name="labsting" labid="pointto"> </label> </div> </div> <div class="control-group"> <label class="control-label" for="selectError"> 户型:</label> <div class="controls"> <div class="divfeifeisl" style="width: 130px"> <select id="selecttypehousetype" myid="housetype"> <option myval="请选择">请选择</option> <option myval="2室1厅">2室1厅</option> <option myval="1室1厅">1室1厅</option> <option myval="3室1厅">3室1厅</option> <option myval="4室1厅">4室1厅</option> <option myval="5室1厅">5室1厅</option> </select> </div> <label name="labsting" labid="housetype"> </label> </div> </div> <div class="control-group success"> <label class="control-label" for="inputSuccess"> 附近公交:</label> <div class="controls"> <input class="validate[maxSize[100],custom[noSpecialCaracters]]" myid="anercar" type="text" /> <label name="labsting" labid="anercar"> </label> </div> </div> <div class="control-group success"> <label class="control-label" for="inputSuccess"> 房源图片:</label> <div class="controls"> <a style="cursor: pointer" name="labsh" id="houseimg" path="" isfile="1"></a><a name="adelete" adeleteid="houseimg"> 删除</a> <span name="fileup" myid="houseimg" class="icon32 icon-color icon-link" title=".icon32 .icon-color .icon-link "></span> </div> </div> <div class="control-group success"> <label class="control-label" for="inputSuccess"> 建成年代:</label> <div class="controls"> <input class="validate[required,custom[integer]]" myid="biuldyear" type="text" /> <label name="labsting" labid="biuldyear"> </label> </div> </div> <div class="form-actions"> <button type="button" class="btn btn-primary" id="btnsave"> 保存</button> <button id="btnedit" class="btn btn-primary" type="button"> 修改</button> <input type="button" class="btn" value="取消" id="btncancel" /> </div> </fieldset> </form> </div> </div> </div> <div class="row-fluid sortable" id="divlist"> <div class="box span12"> <div class="box-header well" data-original-title> <h2> <i class="icon-edit"></i>数据列表</h2> <div class="box-icon"> <a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a> <a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a> </div> </div> <div class="box-content"> <div align="center"> <span class="icon32 icon-color icon-add" id="btnadd"></span> <table class="table table-striped table-bordered bootstrap-datatable datatable"> <thead> <tr> <th> 描述 </th> <th> 月租 </th> <th> 管家 </th> <th> 管家电话 </th> <th> 面积 </th> <th> 朝向 </th> <th> 建成年代 </th> <th width="18%"> 操作 </th> </tr> </thead> <tbody id="tbodydatalist"> </tbody> </table> <span class="icon32 icon-color icon-arrowthick-s" id="btnmore"></span> </div> </div> </div> </div> <!-- jQuery UI --> <script src="js/jquery-ui-1.8.21.custom.min.js"></script> <!-- transition / effect library --> <script src="js/bootstrap-transition.js"></script> <!-- alert enhancer library --> <script src="js/bootstrap-alert.js"></script> <!-- modal / dialog library --> <script src="js/bootstrap-modal.js"></script> <!-- custom dropdown library --> <script src="js/bootstrap-dropdown.js"></script> <!-- scrolspy library --> <script src="js/bootstrap-scrollspy.js"></script> <!-- library for creating tabs --> <script src="js/bootstrap-tab.js"></script> <!-- library for advanced tooltip --> <script src="js/bootstrap-tooltip.js"></script> <!-- popover effect library --> <script src="js/bootstrap-popover.js"></script> <!-- button enhancer library --> <script src="js/bootstrap-button.js"></script> <!-- accordion library (optional, not used in demo) --> <script src="js/bootstrap-collapse.js"></script> <!-- carousel slideshow library (optional, not used in demo) --> <script src="js/bootstrap-carousel.js"></script> <!-- autocomplete library --> <script src="js/bootstrap-typeahead.js"></script> <!-- tour library --> <script src="js/bootstrap-tour.js"></script> <!-- library for cookie management --> <script src="js/jquery.cookie.js"></script> <!-- calander plugin --> <script src="js/fullcalendar.min.js"></script> <!-- data table plugin --> <script src="js/jquery.dataTables.min.js"></script> <!-- select or dropdown enhancer --> <script src="js/jquery.chosen.min.js"></script> <!-- checkbox, radio, and file input styler --> <script src="js/jquery.uniform.min.js"></script> <!-- plugin for gallery image view --> <script src="js/jquery.colorbox.min.js"></script> <!-- rich text editor library --> <script src="js/jquery.cleditor.min.js"></script> <!-- notification plugin --> <script src="js/jquery.noty.js"></script> <!-- file manager library --> <script src="js/jquery.elfinder.min.js"></script> <!-- star rating plugin --> <script src="js/jquery.raty.min.js"></script> <!-- for iOS style toggle switch --> <script src="js/jquery.iphone.toggle.js"></script> <!-- autogrowing textarea plugin --> <script src="js/jquery.autogrow-textarea.js"></script> <!-- multiple file upload plugin --> <script src="js/jquery.uploadify-3.1.min.js"></script> <!-- history.js for cross-browser state change on ajax --> <script src="js/jquery.history.js"></script> <!-- application script for Charisma demo --> <script src="js/charisma.js"></script> <script src="Script/ajax_upload.js"></script> <script type="text/javascript" src="Script/fileup.js"></script> </body> </html>
底层:
using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; using DBS; using WATTIBD; namespace ICGSystemWeb.userajax { //ajax底层处理代码 public partial class ZRHouseOPajax : System.Web.UI.Page { //实例化 DBHelper DB = new DBHelper(); ZRHouseOP DAL = new ZRHouseOP(); protected void Page_Load(object sender, EventArgs e) { object obj = Request.Form.Get("type"); if (obj == null || obj.ToString() == "") { obj = null; Response.Write("nodata"); Response.End(); }//非法请求end string type = obj.ToString(); obj = null; //获取对应的枚举项 if (type == "getenumitembyid") type = GetEnumItemData(Request.Form.Get("myenumid"), Request.Form.Get("userid")); //新增 else if (type == "add") type = AddOrUpdateDB(); //获取用户定义数量的数据列表 else if (type == "getlist") type = GetTopNumberData(); //获取一天修改数据 else if (type == "getone") type = getone(Request.Form.Get("id").Trim()); //删除 else if (type == "delete") type = delete(Request.Form.Get("id"), Request.Form.Get("userid")); Response.Write(type); Response.End(); } //删除 private string delete(string id, string userid) { return DAL.DeleteDB(id); } //获取一个 private string getone(string id) { id = CommonData.DataTableToJson(DAL.GetOneDataByGuid(id)); id = id == "" ? "nodata" : id; return id; } //获取用户定义数量的数据列表 private string GetTopNumberData() { string endtime = Request.Form.Get("endtime"); if (endtime == "") endtime = DateTime.Now.AddDays(1).ToString(); endtime = CommonData.DataTableToJson(DAL.GetTopNumberData(int.Parse(Request.Form.Get("pagesize")), endtime)); if (endtime == "") endtime = "nodata"; return endtime; } //获取枚举项BY ID private string GetEnumItemData(string enumid, string userid) { if (enumid == null || enumid == "" || userid == null || userid == "") return CommonData.nodata; string sql = string.Format("select NAME,VAL from ICGEnumItemTab where enumid=‘{0}‘ and userid=‘{1}‘ ", enumid, userid); sql = CommonData.DataTableToJson(DB.GetDataTable(sql, null)); if (sql == "") sql = CommonData.nodata; return sql; } private string AddOrUpdateDB() { string[] a = Request.Form.Get("myidarray").Split(‘,‘); string guid = Request.Form.Get("ZRHouseID"); if (guid == "-1") { guid = Guid.NewGuid().ToString(); DAL.AddDB(guid, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], guid); a = null; return guid; } else { DAL.UpdateDB(guid, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], guid); a = null; return guid; } } } }
其他:
ICG-智能代码生成器.(权限控制.融入平台).(表单引擎).(最低兼容IE8)
这是我见过最厉害的--智能代码生成器、html+js+底层+sql全都有、瓦特平台
时间: 2024-10-30 10:49:25