📄 shenbao.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 nicholasbjj
{
/// <summary>
/// Summary description for shenbao.
/// </summary>
public class shenbao : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList timesellect;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.HyperLink HyperLink1;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.TextBox TextBox69;
protected System.Web.UI.WebControls.TextBox TextBox87;
protected System.Web.UI.WebControls.TextBox TextBox88;
protected System.Web.UI.WebControls.TextBox TextBox79;
protected System.Web.UI.WebControls.TextBox TextBox75;
protected System.Web.UI.WebControls.TextBox TextBox71;
protected System.Web.UI.WebControls.Image Image1;
protected System.Web.UI.WebControls.Label Label1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!Page.IsPostBack)
{
string sql="select * from [szb]";
string strConn="Server=(local);User ID=sa;Database=bjj;PassWord=temo456";
SqlConnection conn=new SqlConnection(strConn);
SqlCommand cmd=new SqlCommand();
SqlDataReader reader;
cmd.Connection=conn;
cmd.CommandText=sql;
conn.Open();
reader=cmd.ExecuteReader();
DropDownList1.DataSource=reader;
DropDownList1.DataTextField="szbname";
DropDownList1.DataValueField="szbid";
DropDownList1.DataBind();
reader.Close();
conn.Close();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
string ins="insert into [szbsj] (szbid,comid,sjz,zhsp,yjh,ysj,njh,nlj,[time]) values (";
ins+="'"+DropDownList1.SelectedValue+"',";
ins+="'"+this.GetComID(Session["usercom"].ToString())+"',";//
ins+="'"+this.TextBox69.Text+"',";
ins+="'"+this.TextBox71.Text+"',";
ins+="'"+this.TextBox75.Text+"',";
ins+="'"+this.TextBox79.Text+"',";
ins+="'"+this.TextBox87.Text+"',";
ins+="'"+this.TextBox88.Text+"',";
ins+="'"+this.timesellect.SelectedValue+"')";
try
{
string strConn="Server=(local);User ID=sa;Database=bjj;PassWord=temo456";
SqlConnection conn=new SqlConnection(strConn);
SqlCommand cmd=new SqlCommand();
cmd.Connection=conn;
cmd.CommandText=ins;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Response.Write("申报成功!");
//Response.Write("<script>alert('注册成功!');window.location='denglu.aspx';<script>");
}
catch
{
Response.Write("申报失败,请稍后再试");
}
}
private string GetComID(string comname)
{
string strConn="Server=(local);User ID=sa;Database=bjj;PassWord=temo456";
string sql="select comid from company where comname='"+comname+"'";
string res="";
SqlConnection conn=new SqlConnection(strConn);
SqlCommand cmd=new SqlCommand();
SqlDataReader reader;
cmd.Connection=conn;
cmd.CommandText=sql;
conn.Open();
reader=cmd.ExecuteReader();
if(reader.Read())
res=reader["comid"].ToString();
reader.Close();
cmd.Dispose();
conn.Close();
return res;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -