using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.Sql; using System.Data.SqlClient; using System.Data; using System.Collections;public partial class Select : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { TextBoxSelect.Text = "请输入货单号码"; } } protected void ButtonSelect_Click(object sender, EventArgs e) { string connectionString = "Data Source=192.168.1.50;Initial Catalog=HFCS20;Persist Security Info=True;User ID=sa;Password=sa123456#"; SqlConnection conn = new SqlConnection(connectionString); string s = TextBoxSelect.Text.Trim(); try { if (s.Length == 18) { string s1 = s.Substring(0, 1); if (s1 == "2") { string strSql1 = "SELECT [BottleCode] as [瓶码],[BoxCode] as [盒码],[TrayCode] as [堆码],[ProduceDate] as [生产日期],[CustomerName] as" + "[客户名称],[ProductName] as [产品名称],[ProductCode] as [产品编码],[fwCode] as [防伪码] FROM [FWTobottle_Code],[Prd_Product],[Stock_Product],[Cust_Customer] where [Cust_CustomerID]" + "in (select [Cust_CustomerID] from [Order_SaleOrder] where [Order_SaleOrderID] in (select [Order_SaleOrderID] from [Stock_Product]" + "where [BottleCode] = (select [bottCode] from [FWTobottle_Code] where [fwCode]='" + s1 + "'))) and [BottleCode] = (select [bottCode] " + "from [FWTobottle_Code] where [fwCode]='" + s1 + "');"; conn.Open(); SqlDataAdapter adapter = new SqlDataAdapter(strSql1, conn); DataSet ds1 = new DataSet(); adapter.Fill(ds1); GridView1.DataSource = ds1; GridView1.DataBind(); } else if (s1 == "4") { string strSql2 = "SELECT [BottleCode] as [瓶码],[BoxCode] as [盒码],[TrayCode] as [堆码],[ProduceDate] as [生产日期],[CustomerName] as" + "[客户名称],[ProductName] as [产品名称],[ProductCode] as [产品编码] FROM [Prd_Product],[Stock_Product],[Cust_Customer] where [Cust_CustomerID]" + "in (select [Cust_CustomerID] from [Order_SaleOrder] where [Order_SaleOrderID] in (select [Order_SaleOrderID] from [Stock_Product]" + "where [BottleCode] = (select [bottCode] from [FWTobottle_Code] where [fwCode] in (select [fwCode] from [Fwcode_Relation] where [fwCode1] = '" + s1 + "'))))" + "and [BottleCode] = (select [bottCode] from [FWTobottle_Code]where [fwCode]in (select [fwCode] from [Fwcode_Relation] where [fwCode1] = '" + s1 + "'));"; conn.Open(); SqlDataAdapter adapter = new SqlDataAdapter(strSql2, conn); DataSet ds2 = new DataSet(); adapter.Fill(ds2); GridView1.DataSource = ds2; GridView1.DataBind(); } } else { string sql = "SELECT [BottleCode] as [瓶码],[BoxCode] as [盒码],[TrayCode] as [堆码],[ProduceDate] as [生产日期],[CustomerName] as " + "[客户名称],[ProductName] as [产品名称],[ProductCode] as [产品编码] FROM [Prd_Product],[Stock_Product],[Cust_Customer] where [Cust_CustomerID] " + "in (select [Cust_CustomerID] from [Order_SaleOrder] where [Order_SaleOrderID] in (select [Order_SaleOrderID] from [Stock_Product]" + "where [BottleCode] = '" + s + "')) and [BottleCode]='" + s + "';"; conn.Open(); SqlDataAdapter adapter = new SqlDataAdapter(sql, conn); DataSet ds = new DataSet(); adapter.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); conn.Close(); } } catch(Exception e1) { Response.Write(e1.Message); } } protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView gvw = (GridView)sender; if (e.NewPageIndex < 0) { TextBox pageNum = (TextBox)gvw.BottomPagerRow.FindControl("tbPage"); int Pa = int.Parse(pageNum.Text); if (Pa <= 0) { gvw.PageIndex = 0; } else { gvw.PageIndex = Pa - 1; } } else { gvw.PageIndex = e.NewPageIndex; } string s = TextBoxSelect.Text.Trim(); if (s.Length == 18) { string str1 = s.Substring(0, 1); if (str1 == "2") { string connectionString = "Data Source=192.168.1.50;Initial Catalog=HFCS20;Persist Security Info=True;User ID=sa;Password=sa123456#"; SqlConnection conn = new SqlConnection(connectionString); string strSql1 = "SELECT [BottleCode] as [瓶码],[BoxCode] as [盒码],[TrayCode] as [堆码],[ProduceDate] as [生产日期],[CustomerName] as" + "[客户名称],[ProductName] as [产品名称],[ProductCode] as [产品编码],[fwCode] as [防伪码] FROM [FWTobottle_Code],[Prd_Product],[Stock_Product],[Cust_Customer] where [Cust_CustomerID]" + "in (select [Cust_CustomerID] from [Order_SaleOrder] where [Order_SaleOrderID] in (select [Order_SaleOrderID] from [Stock_Product]" + "where [BottleCode] = (select [bottCode] from [FWTobottle_Code] where [fwCode]='" + s + "'))) and [BottleCode] = (select [bottCode] " + "from [FWTobottle_Code] where [fwCode]='" + s + "');"; conn.Open(); SqlDataAdapter adapter = new SqlDataAdapter(strSql1, conn); DataSet ds1 = new DataSet(); adapter.Fill(ds1); GridView1.DataSource = ds1; GridView1.DataBind(); } else if (str1 == "4") { string connectionString = "Data Source=192.168.1.50;Initial Catalog=HFCS20;Persist Security Info=True;User ID=sa;Password=sa123456#"; SqlConnection conn = new SqlConnection(connectionString); string strSql2 = "SELECT [BottleCode] as [瓶码],[BoxCode] as [盒码],[TrayCode] as [堆码],[ProduceDate] as [生产日期],[CustomerName] as" + "[客户名称],[ProductName] as [产品名称],[ProductCode] as [产品编码] FROM [Prd_Product],[Stock_Product],[Cust_Customer] where [Cust_CustomerID]" + "in (select [Cust_CustomerID] from [Order_SaleOrder] where [Order_SaleOrderID] in (select [Order_SaleOrderID] from [Stock_Product]" + "where [BottleCode] = (select [bottCode] from [FWTobottle_Code] where [fwCode] in (select [fwCode] from [Fwcode_Relation] where [fwCode1] = '" + s + "'))))" + "and [BottleCode] = (select [bottCode] from [FWTobottle_Code]where [fwCode]in (select [fwCode] from [Fwcode_Relation] where [fwCode1] = '" + s + "'));"; conn.Open(); SqlDataAdapter adapter = new SqlDataAdapter(strSql2, conn); DataSet ds2 = new DataSet(); adapter.Fill(ds2); GridView1.DataSource = ds2; GridView1.DataBind(); } } else { string connectionString = "Data Source=192.168.1.50;Initial Catalog=HFCS20;Persist Security Info=True;User ID=sa;Password=sa123456#"; SqlConnection conn = new SqlConnection(connectionString); string sql = "SELECT [BottleCode] as [瓶码],[BoxCode] as [盒码],[TrayCode] as [堆码],[ProduceDate] as [生产日期],[CustomerName] as " + "[客户名称],[ProductName] as [产品名称],[ProductCode] as [产品编码] FROM [Prd_Product],[Stock_Product],[Cust_Customer] where [Cust_CustomerID] " + "in (select [Cust_CustomerID] from [Order_SaleOrder] where [Order_SaleOrderID] in (select [Order_SaleOrderID] from [Stock_Product]" + "where [BottleCode] = '" + s + "')) and [BottleCode]='" + s + "';"; conn.Open(); SqlDataAdapter adapter = new SqlDataAdapter(sql, conn); DataSet ds = new DataSet(); adapter.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); } } }
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data;
using System.Collections;public partial class Select : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TextBoxSelect.Text = "请输入货单号码";
}
}
protected void ButtonSelect_Click(object sender, EventArgs e)
{
string connectionString = "Data Source=192.168.1.50;Initial Catalog=HFCS20;Persist Security Info=True;User ID=sa;Password=sa123456#";
SqlConnection conn = new SqlConnection(connectionString);
string s = TextBoxSelect.Text.Trim();
try
{
if (s.Length == 18)
{
string s1 = s.Substring(0, 1);
if (s1 == "2")
{
string strSql1 = "SELECT [BottleCode] as [瓶码],[BoxCode] as [盒码],[TrayCode] as [堆码],[ProduceDate] as [生产日期],[CustomerName] as" +
"[客户名称],[ProductName] as [产品名称],[ProductCode] as [产品编码],[fwCode] as [防伪码] FROM [FWTobottle_Code],[Prd_Product],[Stock_Product],[Cust_Customer] where [Cust_CustomerID]" +
"in (select [Cust_CustomerID] from [Order_SaleOrder] where [Order_SaleOrderID] in (select [Order_SaleOrderID] from [Stock_Product]" +
"where [BottleCode] = (select [bottCode] from [FWTobottle_Code] where [fwCode]='" + s1 + "'))) and [BottleCode] = (select [bottCode] " +
"from [FWTobottle_Code] where [fwCode]='" + s1 + "');";
conn.Open();
SqlDataAdapter adapter = new SqlDataAdapter(strSql1, conn);
DataSet ds1 = new DataSet();
adapter.Fill(ds1);
GridView1.DataSource = ds1;
GridView1.DataBind();
}
else if (s1 == "4")
{
string strSql2 = "SELECT [BottleCode] as [瓶码],[BoxCode] as [盒码],[TrayCode] as [堆码],[ProduceDate] as [生产日期],[CustomerName] as" +
"[客户名称],[ProductName] as [产品名称],[ProductCode] as [产品编码] FROM [Prd_Product],[Stock_Product],[Cust_Customer] where [Cust_CustomerID]" +
"in (select [Cust_CustomerID] from [Order_SaleOrder] where [Order_SaleOrderID] in (select [Order_SaleOrderID] from [Stock_Product]" +
"where [BottleCode] = (select [bottCode] from [FWTobottle_Code] where [fwCode] in (select [fwCode] from [Fwcode_Relation] where [fwCode1] = '" + s1 + "'))))" +
"and [BottleCode] = (select [bottCode] from [FWTobottle_Code]where [fwCode]in (select [fwCode] from [Fwcode_Relation] where [fwCode1] = '" + s1 + "'));";
conn.Open();
SqlDataAdapter adapter = new SqlDataAdapter(strSql2, conn);
DataSet ds2 = new DataSet();
adapter.Fill(ds2);
GridView1.DataSource = ds2;
GridView1.DataBind();
}
}
else
{
string sql = "SELECT [BottleCode] as [瓶码],[BoxCode] as [盒码],[TrayCode] as [堆码],[ProduceDate] as [生产日期],[CustomerName] as " +
"[客户名称],[ProductName] as [产品名称],[ProductCode] as [产品编码] FROM [Prd_Product],[Stock_Product],[Cust_Customer] where [Cust_CustomerID] " +
"in (select [Cust_CustomerID] from [Order_SaleOrder] where [Order_SaleOrderID] in (select [Order_SaleOrderID] from [Stock_Product]" +
"where [BottleCode] = '" + s + "')) and [BottleCode]='" + s + "';";
conn.Open();
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
conn.Close();
}
}
catch(Exception e1)
{
Response.Write(e1.Message);
}
} protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView gvw = (GridView)sender; if (e.NewPageIndex < 0)
{
TextBox pageNum = (TextBox)gvw.BottomPagerRow.FindControl("tbPage"); int Pa = int.Parse(pageNum.Text);
if (Pa <= 0)
{
gvw.PageIndex = 0;
}
else
{
gvw.PageIndex = Pa - 1;
}
}
else
{
gvw.PageIndex = e.NewPageIndex;
}
string s = TextBoxSelect.Text.Trim();
if (s.Length == 18)
{
string str1 = s.Substring(0, 1);
if (str1 == "2")
{
string connectionString = "Data Source=192.168.1.50;Initial Catalog=HFCS20;Persist Security Info=True;User ID=sa;Password=sa123456#";
SqlConnection conn = new SqlConnection(connectionString);
string strSql1 = "SELECT [BottleCode] as [瓶码],[BoxCode] as [盒码],[TrayCode] as [堆码],[ProduceDate] as [生产日期],[CustomerName] as" +
"[客户名称],[ProductName] as [产品名称],[ProductCode] as [产品编码],[fwCode] as [防伪码] FROM [FWTobottle_Code],[Prd_Product],[Stock_Product],[Cust_Customer] where [Cust_CustomerID]" +
"in (select [Cust_CustomerID] from [Order_SaleOrder] where [Order_SaleOrderID] in (select [Order_SaleOrderID] from [Stock_Product]" +
"where [BottleCode] = (select [bottCode] from [FWTobottle_Code] where [fwCode]='" + s + "'))) and [BottleCode] = (select [bottCode] " +
"from [FWTobottle_Code] where [fwCode]='" + s + "');";
conn.Open();
SqlDataAdapter adapter = new SqlDataAdapter(strSql1, conn);
DataSet ds1 = new DataSet();
adapter.Fill(ds1);
GridView1.DataSource = ds1;
GridView1.DataBind();
}
else if (str1 == "4")
{
string connectionString = "Data Source=192.168.1.50;Initial Catalog=HFCS20;Persist Security Info=True;User ID=sa;Password=sa123456#";
SqlConnection conn = new SqlConnection(connectionString);
string strSql2 = "SELECT [BottleCode] as [瓶码],[BoxCode] as [盒码],[TrayCode] as [堆码],[ProduceDate] as [生产日期],[CustomerName] as" +
"[客户名称],[ProductName] as [产品名称],[ProductCode] as [产品编码] FROM [Prd_Product],[Stock_Product],[Cust_Customer] where [Cust_CustomerID]" +
"in (select [Cust_CustomerID] from [Order_SaleOrder] where [Order_SaleOrderID] in (select [Order_SaleOrderID] from [Stock_Product]" +
"where [BottleCode] = (select [bottCode] from [FWTobottle_Code] where [fwCode] in (select [fwCode] from [Fwcode_Relation] where [fwCode1] = '" + s + "'))))" +
"and [BottleCode] = (select [bottCode] from [FWTobottle_Code]where [fwCode]in (select [fwCode] from [Fwcode_Relation] where [fwCode1] = '" + s + "'));";
conn.Open();
SqlDataAdapter adapter = new SqlDataAdapter(strSql2, conn);
DataSet ds2 = new DataSet();
adapter.Fill(ds2);
GridView1.DataSource = ds2;
GridView1.DataBind();
}
}
else
{
string connectionString = "Data Source=192.168.1.50;Initial Catalog=HFCS20;Persist Security Info=True;User ID=sa;Password=sa123456#";
SqlConnection conn = new SqlConnection(connectionString);
string sql = "SELECT [BottleCode] as [瓶码],[BoxCode] as [盒码],[TrayCode] as [堆码],[ProduceDate] as [生产日期],[CustomerName] as " +
"[客户名称],[ProductName] as [产品名称],[ProductCode] as [产品编码] FROM [Prd_Product],[Stock_Product],[Cust_Customer] where [Cust_CustomerID] " +
"in (select [Cust_CustomerID] from [Order_SaleOrder] where [Order_SaleOrderID] in (select [Order_SaleOrderID] from [Stock_Product]" +
"where [BottleCode] = '" + s + "')) and [BottleCode]='" + s + "';";
conn.Open();
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
}