📄 dindan.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.SqlClient;
namespace hotel
{
/// <summary>
/// dindan 的摘要说明。
/// </summary>
public class dindan : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.DropDownList DropDownList2;
protected System.Web.UI.WebControls.DropDownList DropDownList3;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.DropDownList DropDownList4;
private void Page_Load(object sender, System.EventArgs e)
{
if(Session["username"]==null)
{
Response.Write("<script language='javascript'>alert('请先登录');location='Index.aspx';</script>");
}
// 在此处放置用户代码以初始化页面
if(!this.IsPostBack)
{
SqlConnection con=DB.createCon();
con.Open();
SqlCommand cmd=new SqlCommand("select * from rummery",con);
SqlDataReader sdr=cmd.ExecuteReader();
this.DropDownList1.DataSource=sdr;
this.DropDownList1.DataTextField="rummeryname";
this.DropDownList1.DataValueField="rummeryid";
this.DropDownList1.DataBind();
sdr.Close();
SqlCommand cmd1=new SqlCommand("select * from scape",con);
SqlDataReader sdr1=cmd1.ExecuteReader();
this.DropDownList2.DataSource=sdr1;
this.DropDownList2.DataTextField="scapename";
this.DropDownList2.DataValueField="scapeid";
this.DropDownList2.DataBind();
sdr1.Close();
SqlCommand cmd2=new SqlCommand("select * from line",con);
SqlDataReader sdr2=cmd2.ExecuteReader();
this.DropDownList3.DataSource=sdr2;
this.DropDownList3.DataTextField="linename";
this.DropDownList3.DataValueField="lineid";
this.DropDownList3.DataBind();
sdr2.Close();
SqlCommand cmd3=new SqlCommand("select * from ciceroni",con);
SqlDataReader sdr3=cmd3.ExecuteReader();
this.DropDownList4.DataSource=sdr3;
this.DropDownList4.DataTextField="name";
this.DropDownList4.DataValueField="ciceroniid";
this.DropDownList4.DataBind();
sdr3.Close();
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
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)
{ string rummeryname=this.DropDownList1.SelectedItem.Text.ToString();
string username=Convert.ToString(Session["username"]);
string scapename=this.DropDownList2.SelectedItem.Text.ToString();
string linename=this.DropDownList3.SelectedItem.Text.ToString();
string name=this.DropDownList4.SelectedItem.Text.ToString();
string remark=this.TextBox1.Text;
SqlConnection con=DB.createCon();
con.Open();
// SqlCommand cmd=new SqlCommand("select max(orderid) from dindan",con);
// int maxid=Convert.ToInt32(cmd.ExecuteScalar());
// cmd.ExecuteNonQuery();
// maxid=maxid+1;
SqlCommand cmd1 = new SqlCommand("insert into dindan(username,rummeryname,scapename,linename,name,ordertime,remark) values('"+username+"','"+rummeryname+"','"+scapename+"','"+linename+"','"+name+"','"+System.DateTime.Now+"','"+remark+"')",con);
cmd1.ExecuteNonQuery();
con.Close();
}
private void Button2_Click(object sender, System.EventArgs e)
{
Response.Redirect("showdindan.aspx");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -