📄 chaxun.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_Chaxun : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
//按编号取货物信息
public OleDbDataReader Gethuobyhao(string sHuohao)
{
string myConnectionString = ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING1"].ConnectionString + Server.MapPath("~") + ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING2"].ConnectionString;
OleDbConnection myConnection = new OleDbConnection(myConnectionString);
string cmdText = "SELECT * FROM Huowu WHERE Huohao='" + sHuohao + "'";
OleDbCommand myCommand = new OleDbCommand(cmdText, myConnection);
OleDbDataReader dr = null;
try
{
myConnection.Open();
dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
}
catch (OleDbException ex)
{
throw new Exception(ex.Message, ex);
}
return dr;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (txtHuohao.Text.Trim().Length < 1)
{
lblError.Text = "请输入货物编号后再查询";
return;
}
OleDbDataReader dr= Gethuobyhao(txtHuohao.Text.ToString().Trim());
if (dr != null)
{
if (dr.Read())
{
txtDaozhan.Text = dr["Daozhan"].ToString();
txtHuoming.Text = dr["Huoming"].ToString();
txtJianshu.Text = dr["Jianshu"].ToString();
txtState.Text = dr["State"].ToString();
txtZhongliang.Text = dr["Zhongliang"].ToString();
lblError.Text = "";
}
else
{
lblError.Text = "对不起,查无此货号,请核对是否输入错误!";
txtDaozhan.Text = "";
txtHuoming.Text = "";
txtJianshu.Text = "";
txtState.Text = "";
txtZhongliang.Text = "";
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -