📄 inputche.aspx.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 System.Data.OleDb;
public partial class include_Che : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Session["Leaveword"].ToString() != "pass")
{
Response.Redirect("../Default.aspx");
}
}
catch
{
Response.Redirect("../Default.aspx");
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Write("<Script>window.close();</Script>");
}
protected void Button1_Click(object sender, EventArgs e)
{
string chehao = txtChehao.Text.ToString().Trim();
string chicun = txtChicun.Text.ToString().Trim();
string zaizhong = txtZaizhong.Text.ToString().Trim();
string suodi = txtSuodi.Text.ToString().Trim();
string xingming = txtXingming.Text.ToString().Trim();
string shouji = txtShouji.Text.ToString().Trim();
string zaidian = txtZaidian.Text.ToString().Trim();
string beizhu = txtBeizhu.Text.ToString().Trim();
int usenum = 0;
Saveche(chehao, chicun, zaizhong, suodi, xingming, shouji, zaidian, beizhu, usenum);
Response.Write("<Script>alert('输入成功!')</Script>");
Cleartstr();
}
//保存车辆到数据库
private void Saveche(string sChehao, string sChicun, string sZaizhong,string sSuodi, string sXingming, string sShouji,
string sZaidian, string sBeizhu, int nUsenum)
{
string myConnectionString = ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING1"].ConnectionString + Server.MapPath("~") + ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING2"].ConnectionString;
OleDbConnection myConnection = new OleDbConnection(myConnectionString);
string cmdText = "INSERT INTO Che(Chehao,Chicun,Zaizhong,Suodi,Xingming,Shouji,Zaidian,Beizhu,Usenum,Createdate)VALUES(" +
"'" + sChehao + "'," +
"'" + sChicun + "'," +
"'" + sZaizhong + "'," +
"'" + sSuodi + "'," +
"'" + sXingming + "'," +
"'" + sShouji + "'," +
"'" + sZaidian + "'," +
"'" + sBeizhu + "'," +
nUsenum + ",now())";
OleDbCommand myCommand = new OleDbCommand(cmdText, myConnection);
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
}
catch (OleDbException ex)
{
throw new Exception(ex.Message, ex);
}
finally
{
myConnection.Close();
}
}
//清空输入
private void Cleartstr()
{
txtBeizhu.Text = "";
txtChehao.Text = "";
txtChicun.Text = "";
txtShouji.Text = "";
txtSuodi.Text = "";
txtXingming.Text = "";
txtZaidian.Text = "";
txtZaizhong.Text = "";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -