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代码!

  • 相关阅读:
    The best programmers are the quickest to Google
    NetBeans 时事通讯(刊号 # 117 Sep 16, 2010)
    Apache HttpClient 4.0.3 GA 发布
    warning LNK4070的解决办法
    看泡沫
    早秋精神
    NetBeans 时事通讯(刊号 # 117 Sep 16, 2010)
    Maven 3.0 RC1 发布
    关于类的数据成员的访问权限设计的一些思考
    看泡沫
  • 原文地址:https://www.cnblogs.com/yaoxc/p/3134399.html
Copyright © 2011-2022 走看看