zoukankan      html  css  js  c++  java
  • 3.html+.ashx(删除学生信息)

    C03ListStu.ashx 

    0:false(删除);1:true(正常)。

    (数据库里定义个BOOL型,TRUE表示正常FALSE表示删除)
    <html>
     <head>
      <title> {@title} </title>
        <style type="text/css">
            #tbList {
                border:1px solid #0094ff;
                300px;
                margin:10px auto;
                border-collapse:collapse;
            }
            #tbList th,td{
                border:1px solid #0094ff;
                padding:5px;
            }
        </style>
        <script type="text/javascript">
            function doDel(id)
            {
                if (confirm("您确定要删除吗?"))
                {
                    alert(id);
                }
            }
        </script>
    </head>
    <body>
        <table id="tbList">
            <tr>
                <th>ID</th>
                <th>学员名称</th>
                <th>性别</th>
                <th>操作</th>
            </tr>
            {@trs}
        </table>
    </body>
    </html>
    public class C03ListStu : IHttpHandler<br>
        {
            public void ProcessRequest(HttpContext context)<br>
            {
                //从 url 中 获取名为 cid 的参数<br>
                string strClassId = context.Request.QueryString["cid"];<br>
    
                int intCid = 0;<br>
                if (!int.TryParse(strClassId, out intCid))<br>
                {
                    context.Response.Write("哥们~!您的 参数 不对啊~~!朝鲜来的?");<br>
                }
                else
                { 
                    //1.根据id 去数据库 查询 班级下的学员<br>
                   DataTable dt = DbHelperSQL.GetDataTable("select * from Students where cid = @cid", new SqlParameter("@cid", SqlDbType.SmallInt) { Value = intCid });<br>
                    //2.遍历生成表格行<br>
                    DataRow dr = null;<br>
                    System.Text.StringBuilder sbTrs = new System.Text.StringBuilder(200);<br>
                    for (int i = 0; i < dt.Rows.Count; i++)<br>
                    {
                        dr = dt.Rows[i];//取出一行<br>
                        sbTrs.Append("<tr>");<br>
                        sbTrs.Append("<td>" + dr["ID"] + "</td>");<br>
                        sbTrs.Append("<td>" + dr["Name"] + "</td>");<br>
                        sbTrs.Append("<td>" + dr["Gender"] + "</td>");<br>
                        sbTrs.Append("<td><a href='javascript:void(0)' onclick='doDel(" + dr["CID"] + ")'>删除</a></td>");<br>
                        sbTrs.AppendLine("</tr>");<br>
                    }
                    //3.读取学员页面的模版<br>
                    string strFile = PageHelper.ReadFile(context.Server.MapPath("C03ListStu.html"));<br>
                    //4.替换模版里的占位符<br>
                    strFile = strFile.Replace("{@trs}", sbTrs.ToString());<br>
                    //5.保存到Response中<br>
                    context.Response.Write(strFile);<br>
                }
    
            }
  • 相关阅读:
    PAT顶级 1015 Letter-moving Game (35分)
    PAT顶级 1008 Airline Routes (35分)(有向图的强连通分量)
    PAT顶级 1025 Keep at Most 100 Characters (35分)
    PAT顶级 1027 Larry and Inversions (35分)(树状数组)
    PAT 顶级 1026 String of Colorful Beads (35分)(尺取法)
    PAT顶级 1009 Triple Inversions (35分)(树状数组)
    Codeforces 1283F DIY Garland
    Codeforces Round #438 A. Bark to Unlock
    Codeforces Round #437 E. Buy Low Sell High
    Codeforces Round #437 C. Ordering Pizza
  • 原文地址:https://www.cnblogs.com/hehehehehe/p/5709402.html
Copyright © 2011-2022 走看看