📄 roombuildingadd.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.Odbc;
using System.Configuration;
namespace RoomMngSystem.Operator
{
/// <summary>
/// RoomBuildingMng 的摘要说明。
/// </summary>
public class RoomBuildingMng : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.Label Label7;
protected System.Web.UI.WebControls.Label Label8;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.TextBox Textbox1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label9;
protected System.Web.UI.WebControls.TextBox Textbox2;
protected System.Web.UI.WebControls.TextBox Textbox3;
protected System.Web.UI.WebControls.TextBox Textbox4;
protected System.Web.UI.WebControls.TextBox Textbox5;
protected System.Web.UI.WebControls.TextBox Textbox6;
protected System.Web.UI.WebControls.TextBox Textbox7;
protected System.Web.UI.WebControls.TextBox Textbox8;
protected System.Web.UI.WebControls.Label Label10;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.WebControls.Image Image1;
protected System.Web.UI.WebControls.Button Button2;
private void Page_Load(object sender, System.EventArgs e)
{
string user;
try
{
user=Session["UserName"].ToString();
}
catch
{
this.Response.Redirect("../Enter.aspx");
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button3.Click += new System.EventHandler(this.Button3_Click);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
if(""!=Textbox1.Text)
{
OdbcConnection conn = new OdbcConnection();
conn.ConnectionString=ConfigurationSettings.AppSettings["oCn_Str"];
string sqlcom;
//打开数据连接
conn.Open();
try
{
sqlcom="insert into [buildinginfo] (bno,totalarea,buildingarea,roomnum,tchroom,officeroom,labroom,floornum) values('"+Textbox1.Text+"','"+Textbox2.Text+"','"+Textbox3.Text+"','"+Textbox4.Text+"','"+Textbox5.Text+"','"+Textbox6.Text+"','"+Textbox7.Text+"','"+Textbox8.Text+"')";
//定义命令对象
OdbcCommand cmd = new OdbcCommand(sqlcom,conn);
//执行SQL命令
cmd.ExecuteNonQuery();
Label9.Text="添加成功";
}
catch
{
Label9.Text="添加失败";
}
//关闭连接对象
conn.Close();
this.Response.Redirect("RoomBuildingInfoMng.aspx");
}
else
{
Label9.Text="请填写楼号!";
}
}
private void Button2_Click(object sender, System.EventArgs e)
{
Textbox1.Text="";
Textbox2.Text="";
Textbox3.Text="";
Textbox4.Text="";
Textbox5.Text="";
Textbox6.Text="";
Textbox7.Text="";
Textbox8.Text="";
}
private void Button3_Click(object sender, System.EventArgs e)
{
this.Response.Redirect("RoomBuildingInfoMng.aspx");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -