⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addroomtype.aspx.cs

📁 酒店管理 主要实现了基础设施管理(客房管理、客房类型管理)、业务管理(入住、退房、数据库切换) 本系统简单明了,适合初学者学习,采用三层加抽象工厂实现
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Model;
using BLL;

public partial class AddRoomType : System.Web.UI.Page
{
    private RoomTypeOperatorBLL roomTypeOp = new RoomTypeOperatorBLL();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack && Request.QueryString["id"] != null)
        {
            string id = Request.QueryString["id"].ToString();
            if (!string.IsNullOrEmpty(id))
                SetData(int.Parse(id));
        }
    }

    private void SetData(int id)
    {
        RoomType roomType = roomTypeOp.GetRoomTypeByID(id);
        if (roomType != null)
        {
            this.txt_TypeName.Text = roomType.Typename;
            this.txt_TypePrice.Text = roomType.Typeprice.ToString();
            this.txt_Remark.Text = roomType.Remark;
            this.txt_AddBedPrice.Text = roomType.Addbedprice.ToString();
            if (roomType.Isaddbed.Trim().Equals("是"))
                this.radbtn_yes.Checked = true;
            else
                this.radbtn_no.Checked = true;
            this.btn_Confirm.Text = "  更  新  ";
            this.btn_Confirm.ToolTip = "更新";
        }
    }
    protected void btn_Confirm_Click(object sender, EventArgs e)
    {
        string typeName = this.txt_TypeName.Text;
        string typePrice = this.txt_TypePrice.Text;
        string addBedPrice = this.txt_AddBedPrice.Text;
        string remark = this.txt_Remark.Text;
        string isAddBed = "是";
        if (radbtn_no.Checked)
            isAddBed = "否";

        RoomType roomType = new RoomType();
        roomType.Typename = typeName;
        roomType.Typeprice = Convert.ToDouble(typePrice);
        roomType.Addbedprice = Convert.ToDouble(addBedPrice);
        roomType.Isaddbed = isAddBed;
        roomType.Remark = remark;

        if (this.btn_Confirm.ToolTip.Equals("确定"))
        {
            if (roomTypeOp.SelectDataForRoomTypeByRoomTypeName(typeName) != null)
            {
                lbl_Message.Text = "已经存在的类型名称!!";
            }
            else
            {
                if (roomTypeOp.AddRoomType(roomType))
                {
                    Response.Write("<script>alert('添加成功!')</script>");
                    Server.Transfer("~\\ViewRoomType.aspx");
                }
                else
                    Response.Write("<script>alert('添加失败!')</script>");
            }
        }
        else
        {
            string id = Request.QueryString["id"].ToString();
            if (!string.IsNullOrEmpty(id))
                roomType.Typeid = int.Parse(id);
            if (roomTypeOp.ModifyRoomType(roomType))
            {
                Response.Write("<script>alert('修改成功!')</script>");
                Server.Transfer("~\\ViewRoomType.aspx");
            }
            else
                Response.Write("<script>alert('修改失败!')</script>");
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -