📄 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 Stock_Sell_search : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Convert.ToString(Session["username"]) == "")
{
Response.Write("<script language=javascript>alert('请登录');location='../login.aspx'</script>");
}
Session["sql"] = "";
this.bind();
this.ED.Text = Convert.ToString(DateTime.Today.ToShortDateString());
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
this.bind();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
Response.Write("<script>window.open('Sell_open.aspx?id=" + id + "','','width=450,height=450')</script>");
Response.Write("<script>location='javascript:history.go(-1)'</script>");
}
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) + "…";
}
}
}
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(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
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();
}
protected void Button2_Click(object sender, EventArgs e)
{
Session["sql"] = "";
this.bind();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -