📄 querypartaddform.aspx.cs
字号:
//文件名:QueryPartAddForm.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.SqlClient;
public partial class QueryManage_QueryPartAddForm : System.Web.UI.Page
{
private static DataTable MyTable = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
string MyForbidString = Session["MyForbid"].ToString();
if (MyForbidString.IndexOf("D2") > 1)
{
Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
}
}
protected void Button1_Click(object sender, EventArgs e)
{//查询配件入库信息
MyTable.Rows.Clear();
string MySQL = "SELECT dbo.配件入库.自动编号, dbo.配件入库.入库编号, dbo.配件入库.配件编号, dbo.配件入库.配件名称, dbo.配件入库.规格型号, dbo.配件入库.入库日期, dbo.配件入库.入库数量, dbo.配件入库.计量单位, dbo.配件入库.购买单价, dbo.配件入库.购买金额, dbo.配件入库.生产厂家, dbo.配件入库.供货商家, dbo.员工信息.员工姓名 AS 库管人员 FROM dbo.配件入库 INNER JOIN dbo.员工信息 ON dbo.配件入库.库管人员 = dbo.员工信息.员工编号 WHERE (dbo.配件入库.入库编号 LIKE '%" + this.TextBox1.Text + "%')";
MySQL += "AND (dbo.配件入库.配件编号 LIKE '%" + this.TextBox2.Text + "%')";
MySQL += "AND (dbo.配件入库.配件名称 LIKE '%" + this.TextBox3.Text + "%')";
MySQL += "AND (dbo.配件入库.规格型号 LIKE '%" + this.TextBox4.Text + "%')";
MySQL += "AND (dbo.配件入库.生产厂家 LIKE '%" + this.TextBox5.Text + "%')";
MySQL += "AND (dbo.配件入库.供货商家 LIKE '%" + this.TextBox6.Text + "%')";
MySQL += "AND (dbo.配件入库.入库日期 BETWEEN '" + this.TextBox7.Text + "' AND '" + this.TextBox8.Text + "') ";
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyServiceDBConnectionString"].ConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
SqlDataAdapter MyAdatper = new SqlDataAdapter(MySQL, MyConnection);
MyAdatper.Fill(MyTable);
this.GridView1.DataSource = MyTable;
this.GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{//在GridView控件单元格中设置短日期显示格式
if (e.Row.RowType == DataControlRowType.DataRow)
{
DateTime MyDate = DateTime.Parse(e.Row.Cells[5].Text);
e.Row.Cells[5].Text = MyDate.ToShortDateString();
}
}
protected void Button2_Click(object sender, EventArgs e)
{//打印配件入库信息
Server.Transfer("~/QueryManage/QueryPartAddPrint.aspx");
}
public DataTable MyQueryTable
{//设置要传递到打印页的数据
get
{
return MyTable;
}
}
public String MyPrintDate
{//设置要传递到打印页的数据
get
{
string MyDate = "打印日期:" + DateTime.Now.ToShortDateString();
return MyDate;
}
}
public String MyPrintTitle
{//设置要传递到打印页的数据
get
{
return Session["MyServiceName"].ToString() + "配件入库信息查询结果表";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -