标签:信息 nbsp listen led datarow builder body pre 修改
HTML:
<div style="margin:8px;"> <h1>1.添加记录</h1> <a class="button" href="?act=add" style="margin:10px;"><span><i>添加</i></span></a> <h1>2.修改记录</h1> <a class="button" href="?act=edit" style="margin:10px;"><span><i>修改</i></span></a> <h1>3.删除记录</h1> <a class="button" href="?act=del" style="margin:10px;" onclick="javascript:return confirm(‘确认要删除吗?‘);"><span><i>删除</i></span></a> <h1>4.读取记录(不分页)</h1> <a class="button" href="?act=list" style="margin:10px;"><span><i>读取</i></span></a> <h1>5.读取记录(分页)</h1> <a class="button" href="?act=page" style="margin:10px;"><span><i>读取</i></span></a> <h1>执行结果:</h1> <p style="padding:10px;line-height:25px;"><asp:Literal id="litBody" runat="server" /></p> </div>
CS:
public eAction action; protected void Page_Load(object sender, EventArgs e) { action = new eAction(); action.Actioning += action_Actioning; action.Listen(); } protected void action_Actioning(string Action) { string sql = ""; string ID = ""; switch (Action) { case "": litBody.Text = "无"; break; case "add": sql = "insert into Demo_Persons (FullName,Account,PassWord) values (‘测试‘,‘test‘,‘" + eBase.GetMD5("123456",16) +"‘)"; eOleDB.Execute(sql); litBody.Text = "添加成功,ID=" + eOleDB.ID; break; case "edit": //sql = "update Demo_Persons set FullName=FullName + ‘a‘ where ID=3";//修改指定条件记录 sql = "select ID from Demo_Persons where delTag=0 order by ID desc"; //修改最后一条记录 ID = eOleDB.getValue(sql); sql = "update Demo_Persons set FullName=FullName + ‘a‘ where ID=" + ID; eOleDB.Execute(sql); litBody.Text = "修改成功,ID=" + ID; break; case "del": sql = "select ID from Demo_Persons where delTag=0 order by ID desc"; ID = eOleDB.getValue(sql); //要删除记录的ID //sql = "update Demo_Persons set delTag=1 where ID=" + ID;//假删除 sql = "delete from Demo_Persons where ID=" + ID;//真删除 eOleDB.Execute(sql); litBody.Text = "删除成功,ID=" + ID; break; case "list": sql = "select top 5 ID,FullName from Demo_Persons where delTag=0 order by NewID()";//随机取 DataTable tb = eOleDB.getDataTable(sql); StringBuilder sb = new StringBuilder(); foreach (DataRow dr in tb.Rows) { sb.Append("ID=" + dr["ID"].ToString() + ",FullName=" + dr["FullName"].ToString() + "<BR>\r\n"); } litBody.Text = sb.ToString(); break; case "page": sql = "select ID,FullName from Demo_Persons where delTag=0 order by ID desc"; int page = 1; int pagesize = 2; int pagecount = 0; int recordscount = 0; DataTable dt = eOleDB.getDataTable(sql,pagesize,page,out recordscount,out pagecount); StringBuilder sbr = new StringBuilder(); foreach (DataRow dr in dt.Rows) { sbr.Append("ID=" + dr["ID"].ToString() + ",FullName=" + dr["FullName"].ToString() + "<BR>\r\n"); } sbr.Append("共" + recordscount.ToString() + "条信息,分" + pagecount.ToString() + "页显示,每页显示" + pagesize.ToString() + "条,当前显示第" + page.ToString() + "页"); litBody.Text = sbr.ToString(); break; } }
标签:信息 nbsp listen led datarow builder body pre 修改
原文地址:https://www.cnblogs.com/eketeam/p/8915537.html