zoukankan      html  css  js  c++  java
  • Web层

    表现层:由需求网页构成,调用业务逻辑层的方法。该层一般不出现SQL语句相关的内容,就算出现,也不能出现能执行的SQL语句。
     
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    using HotelManager.Models;
    using HotelManager.BLL;
    
    namespace HotelManager
    {
        public partial class RoomTypeAdd : System.Web.UI.Page
        {
            RoomTypeManager roomTypeManager = new RoomTypeManager();
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
    
                RoomType addRoomType = new RoomType();
                addRoomType.TypeName = txtTypeName.Text.Trim();
                addRoomType.Price = Convert.ToDecimal(txtPrice.Text.Trim());
                addRoomType.AddBed = rbtnYes.Checked ? true : false;
                addRoomType.BedPrice = Convert.ToDecimal
    
    (txtAddPrice.Text.Trim());
                addRoomType.Remark = txtRemark.Text;
    
    
                try
                {
                    roomTypeManager.AddRoomType(addRoomType);
    
    		///添加javaScript代码的方式
                    ////在<form>标签前部输出脚本
                    Page.ClientScript.RegisterClientScriptBlock
    
    (this.GetType(), Guid.NewGuid().ToString(), "alert('添加成功!')", true);
    
                }
                catch (Exception ex)
                {
                    //在<form>标签后部输出脚本
                    Page.ClientScript.RegisterStartupScript(this.GetType(), 
    
    Guid.NewGuid().ToString(), "alert('添加失败!"+ex.Message+"')", true);
                }
    
    
    
                
            }
        }
    }
    

      

    注意:如何向网页中集成javaScript代码!

  • 相关阅读:
    P4549 【模板】裴蜀定理
    POJ1606 Jugs
    2. 数据库连接池规范
    14. BootStrap * 组件
    BootStarpt
    13. Flex 弹性布局2 BootStrap
    12. Flex 弹性布局 BootStrap
    CSS3
    21. Servlet3.0 / 3.1 文件上传 Plus
    20. Servlet3.0 新特性
  • 原文地址:https://www.cnblogs.com/yaoxc/p/3134399.html
Copyright © 2011-2022 走看看