📄 sell_search.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 Sell_Search : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HeardConfig();
if (!IsPostBack)
{
PersonInfo.Return_SessionPerson();//检测是否登陆
Session["sql"] = "";//初始化SQL语句的保存
this.bind();//执行初始化绑定方法
this.ED.Text = Convert.ToString(DateTime.Today.ToShortDateString());
}
}
#region 页面初始化必需的内容
public void HeardConfig()
{
Header.Title = "销售订单管理系统-销售相关查询";
HeaderTextInfo.GetHeader(this, null);
}
#endregion
//单击翻页时
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
this.bind();
}
//格式化显示的数据 大于6个字的 加省略号
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[4].Text = (Convert.ToDateTime(e.Row.Cells[4].Text)).ToShortDateString();
if ((e.Row.Cells[1].Text).Length > 6)
{
e.Row.Cells[1].Text = (e.Row.Cells[1].Text).Substring(0, 6) + "…";
}
if ((e.Row.Cells[0].Text).Length > 6)
{
e.Row.Cells[0].Text = (e.Row.Cells[0].Text).Substring(0, 6) + "…";
}
if ((e.Row.Cells[2].Text).Length > 6)
{
e.Row.Cells[2].Text = (e.Row.Cells[2].Text).Substring(0, 6) + "…";
}
}
}
//根据选择来执行不同的SQL语句后段
protected void Button1_Click(object sender, EventArgs e)
{
string Sql = " ";
if (CheckBox1.Checked)
{
Sql = Sql + "and CompanyName like '%" + TN.Text + "%' ";
}
if (CheckBox2.Checked)
{
Sql = Sql + "and CommodityName like '%" + PN.Text + "%' ";
}
if (CheckBox3.Checked)
{
Sql = Sql + "and kehu like '%" + MM.Text + "%' ";
}
if (CheckBox4.Checked)
{
Sql = Sql + "and StockDate between '" + SD.Text + "' and '" + ED.Text + "'";
}
Session["sql"] = Sql;
this.bind();
}
//页面初始化绑定数据
public void bind()
{
string strsql, type;
if (Request["type"] == "se")
{
type = "销售信息";
}
else
{
type = "销售退货";
}
Label1.Text = type;
strsql = "select * from sell where type='" + type + "' " + Session["sql"] + " order by id desc";
SqlConnection strcon = new SqlConnection(ConfigurationManager.ConnectionStrings["SellOrder_ConnectionString"].ConnectionString);
strcon.Open();
SqlDataAdapter sda = new SqlDataAdapter(strsql, strcon);
DataSet ds = new DataSet();
sda.Fill(ds, "search");
GridView1.DataSource = ds.Tables["search"];
GridView1.DataKeyNames = new string[] { "id" };
GridView1.DataBind();
}
//清空SQL语句缓存
protected void Button2_Click(object sender, EventArgs e)
{
Session["sql"] = "";
this.bind();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -