ESql修改之插入SQLServer数据库记录实例
发布时间:2020-12-12 12:50:24 所属栏目:MsSql教程 来源:网络整理
导读:一个政府网站维护内容的实例,添加信息 信息编辑页面 主题、顺序及栏目节点 table border="0" cellpadding="0" cellspacing="0" align="center" width="96%" tr height="30" td 主 题/td tdinput name="SUBJECT" size="98"/td /trchtmlesql module=base id=c
一个政府网站维护内容的实例,添加信息 信息编辑页面 主题、顺序及栏目节点
<table border="0" cellpadding="0" cellspacing="0" align="center" width="96%"> <tr height="30"> <td> 主 题</td> <td><input name="SUBJECT" size="98"></td> </tr> <chtml><esql module=base id=count>Select max(WE_SORT) as max1 from SITE_NEWS where CLASSIFY=@{pPage:only}</esql></chtml> <tr height="30"> <td> 顺 序</td> <td><input name="we_sort" size="8" value="@{int:@{count:max1}+1}"></td> </tr> <tr> <td>?</td> <td></td> </tr><input type="hidden" value="@{pPage:only}" name="only"><input type="hidden" value="@{pPage:n}" name="n"> </table>引入编辑器(老版,现在已经不在使用,新编辑器请参照 上一篇) <table border="0" cellpadding="0" cellspacing="0" width="96%" align="center"> <textarea name="BODY" style="display:none"></textarea> <tr> <td> <chtml file="help/editor/edit.html"/> </td> </tr> </table>完整的编辑表单代码(上两部分加起来) <br><!-- 信息表单 --> <form id=save action="add_save.chtml" method="post"> <table border="0" cellpadding="0" cellspacing="0" align="center" width="96%"> <tr height="30"> <td> 主 题</td> <td><input name="SUBJECT" size="98"></td> </tr> <chtml><esql module=base id=count>Select max(WE_SORT) as max1 from SITE_NEWS where CLASSIFY=@{pPage:only}</esql></chtml> <tr height="30"> <td> 顺 序</td> <td><input name="we_sort" size="8" value="@{int:@{count:max1}+1}"></td> </tr> <tr> <td>?</td> <td></td> </tr><input type="hidden" value="@{pPage:only}" name="only"><input type="hidden" value="@{pPage:n}" name="n"> </table> <table border="0" cellpadding="0" cellspacing="0" width="96%" align="center"> <textarea name="BODY" style="display:none"></textarea> <tr> <td> <chtml file="help/editor/edit.html"/> </td> </tr> </table> </form>提交的脚本 function doSubmit() { var saves = document.forms['save']; if(saves['SUBJECT'].value=="") {alert("主题不能空!");saves['SUBJECT'].focus();return;} saves['BODY'].value=GetHtml(); if(saves['BODY'].value=="") {alert("内容不能空!");GetCompFocus();return;} saves.submit(); } 信息保存的页面 判断编辑权限 <chtml><Bag id=sys><we name=NodeID>c0.4.0</we></Bag></chtml><!-- 栏目节点 --> <chtml file="base/ac/checkAcl.htm"/><!-- 引入权限检查文件 --> <chtml> <!-- 权限判断 --> <if x="@{sys:canDo}" else=1> <we x=true> ...... </we> <script>alert("您没有权限!");history.back();</script> </if> </chtml>修正显示顺序 <esql module=base id=count>select min(we_sort) as min1 from site_news where we_sort>=@{pPage:we_sort} and classify='@{pPage:only}'</esql> <if x="@{pPage:we_sort}"> <esql x="@{count:min1}" module=base act=edit>update site_news set we_sort=we_sort+1 where we_sort>=@{pPage:we_sort} and classify='@{pPage:only}'</esql> </if>插入记录 <ESql module=dc act=edit> Insert Into SITE_NEWS(SUBJECT,we_sort,CLASSIFY,AUTHOR,ONDATE,BODY ) Values( @{pPage:SUBJECT:string},'@{int:@{pPage:we_sort}+0}','@{pPage:only}','@{session:we_id}',@{sys:date:datetime},@{pPage:BODY:memo} ) </ESql>返回列表页 <script> location.href='@{sys:face}@{sys:curPath}list.html?n=@{pPage:n}'; </script>完整的网页代码 <html> <chtml><Bag id=sys><we name=NodeID>c0.4.0</we></Bag></chtml><!-- 栏目节点 --> <chtml file="base/ac/checkAcl.htm"/><!-- 引入权限检查文件 --> <chtml> <!-- 权限判断 --> <if x="@{sys:canDo}" else=1> <we x=true> <esql module=base id=count>select min(we_sort) as min1 from site_news where we_sort>=@{pPage:we_sort} and classify='@{pPage:only}'</esql> <if x="@{pPage:we_sort}"> <esql x="@{count:min1}" module=base act=edit>update site_news set we_sort=we_sort+1 where we_sort>=@{pPage:we_sort} and classify='@{pPage:only}'</esql> </if> <ESql module=dc act=edit> Insert Into SITE_NEWS(SUBJECT,@{pPage:BODY:memo} ) </ESql> </we> <script>alert("您没有权限!");history.back();</script> </if> </chtml> <script> location.href='@{sys:face}@{sys:curPath}list.html?n=@{pPage:n}'; </script> </html>跟上一篇比结构和代码内容都非常类似,只是SQL的语法换成了SQLServer,但应用场景却发生了根本变化,轻开平台的优势就是能轻松应对这种变化,很酷吧 轻开平台资源下载及说明
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- .net – Linq to SQL怎么了?
- 如何在SQL Server 2008中启用Integration Services(SSIS)?
- .net – 使用不同算法的UUID碰撞风险
- Linux系统下自行编译安装MySQL及基础配置全过程解析
- sql-server-2008 – 在SQL Server Management Studio中查看
- 安装 – 为SQL Server 2012安装设置/ SECURITYMODE为混合模
- sql-server – 如何编写SQL Server作业的脚本以进行迁移
- 安装sqlserver2000出现的问题
- SQLServer2008客户端软件
- 三分钟学会Sql Server的复制功能