• 04Add.ashx(新增班级)


    04Add.html

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>新增班级</title>
        <style type="text/css">
            #tbList {
                border:1px solid #0094ff;
                border-collapse:collapse;
                300px;
                margin:50px auto;
            }
            #tbList th,td{
                border:1px solid #0094ff;
                padding:5px;
            }
        </style>
    </head>
    <body>
        <form method="post" action="04Add.ashx">
            <table id="tbList">
                <tr>
                    <td>班级名称:</td>
                    <td><input type="text" id="txtName" name="txtName"/></td>
                </tr>
                <tr>
                    <td>班级人数:</td>
                    <td><input type="text" id="txtCount" name="txtCount" /></td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="submit" value="确定" />
                        <input type="button" id="btnCancel" value="取消" onclick="window.location='01List.ashx'" />
                    </td>
                </tr>
            </table>
        </form>
    </body>
    </html>

    04Add.ashx

    using System;
    using System.Collections.Generic;
    using System.Data.SqlClient;
    using System.Linq;
    using System.Web;
    
    namespace AspNetAshx
    {
        /// <summary>
        /// _04Add 的摘要说明
        /// </summary>
        public class _04Add : IHttpHandler
        {
    
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/html";
    
                //1.获取用户表单post提交的数据
                string strName = HttpContext.Current.Request.Form["txtName"].Trim();
                string strCount = HttpContext.Current.Request.Form["txtCount"];
                //2.验证数据
                if (string.IsNullOrEmpty(strName) || !CommonHelper.IsNum(strCount))
                {
                    CommonHelper.WriteJs("对不起,您输入的数据格式错误~请仔细检查~~", "04Add.html");
                }
                else
                {
                    //3.更新到数据库中
                    SqlParameter[] paras = { 
                                       new SqlParameter("Cname",strName),
                                       new SqlParameter("CCount",strCount)
                                       };
                    int res = SqlHelper.ExcuteNoneQuery("insert into Classes (CName,CCount) values(@Cname,@CCount)", paras);
                    if (res > 0)
                    {
                        CommonHelper.WriteJs("新增成功~!", "01List.ashx");
                    }
                    else
                    {
                        CommonHelper.WriteJs("新增失败~!如果您是美女,请联系管理员~~~qq:111111", "04Add.html");
                    }
                }
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }
  • 相关阅读:
    OpenCV 创建Mat图像
    OpenCV Mat数据类型及位数总结
    OpenCV 使用at和ptr指针访问像素的区别
    OpenCV 16位深度图片显示并保存
    PyCharm 安装教程(Windows)
    Qt 安装图解(Windows平台)
    Qt 下载(多种下载通道+所有版本)
    QtCreator怎样编辑运行Python脚本
    Python 怎么运行代码
    Qt for Python 怎样搭建开发环境
  • 原文地址:https://www.cnblogs.com/hehehehehe/p/5105899.html
Copyright © 2020-2023  润新知