using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; using System.Globalization; using System.Threading; public partial class SysAdmin_PayDefault : System.Web.UI.Page { static int pageN = 0; static PagedDataSource pds = new PagedDataSource();//静态变量只初始化一次 static string OrderId; static string Cid; string sqlstr; protected void Page_Load(object sender, EventArgs e) { if (Session["Lang"] != null) { if (Session["Lang"].ToString() == "zh-cn") { lblup.Text = "上一页"; lbldown.Text = "下一页"; this.DropDownList1.Items[0].Value = "所有订单"; this.DropDownList1.Items[1].Value = "一个月之内的订单"; this.DropDownList1.Items[2].Value = "一个月之前的订单"; this.DropDownList2.Items[0].Value = "所有状态"; this.DropDownList2.Items[0].Value = "已完成"; this.DropDownList2.Items[0].Value = "未完成"; } else { lblup.Text = "Previous"; lbldown.Text = "Next"; this.DropDownList1.Items[0].Value = "All the Orders"; this.DropDownList1.Items[1].Value = "orders in a month"; this.DropDownList1.Items[2].Value = "orders before a month"; this.DropDownList2.Items[0].Value = "Order Status"; this.DropDownList2.Items[0].Value = "filled orders"; this.DropDownList2.Items[0].Value = "unfilled orders"; } } OrderId = Request.QueryString["OrderId"]; ///订单id try { System.Data.DataTable dt = (DataTable)Session["member"]; Cid = dt.Rows[0]["Cid"].ToString(); } catch { Response.Redirect("default.aspx"); } if (!IsPostBack) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString); // string sqlstr = "select top (" + pagecount + ") * from MyuserTb where ID not in (select top (" + pagec =-ount * (pageN - 1) + ") id from MyuserTb)"; string sqlstr = "select (tab2.amount*(select vip_price_rmb from v3_merchandises where pid = tab2.pid)) as price,(select trade_name_cn from v3_merchandises where pid = tab2.pid) as BookName,* from v3_order as tab1 inner join v3_order_item as tab2 on tab1.oid = tab2.oid and tab2.cid = tab1.cid inner join v3_pic_path as pic on tab2.pid = pic.pid where tab1.cid = '" + Cid + "' and pic.show =1"; SqlDataAdapter sda = new SqlDataAdapter(sqlstr, con); //数据桥接器 作用是把数据读出来 不用执行 一次性读完备用,读完数据库关闭 。 sqldatareader是一条一条的读数据,数据库总是再打开状态 DataTable dt = new DataTable();// 作为临时保存数据的虚拟表 作为数据源 sda.Fill(dt);// 把桥接器里面读出来的数据 放在虚拟表里面 pds.DataSource = dt.DefaultView;//把dataable的值 赋给 pds Bind(0); } } private void Bind(int pageN) { pds.AllowPaging = true; // 是否分页 pds.PageSize = 10; //页面大小 pds.CurrentPageIndex = pageN;// 获取当前页面, 让下面的 显示当前页面 Repeater1.DataSource = pds; Repeater1.DataBind(); } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { sqlstr = "select (tab2.amount*(select vip_price_rmb from v3_merchandises where pid = tab2.pid)) as price,(select trade_name_cn from v3_merchandises where pid = tab2.pid) as BookName,* from v3_order as tab1 inner join v3_order_item as tab2 on tab1.oid = tab2.oid and tab2.cid = tab1.cid inner join v3_pic_path as pic on tab2.pid = pic.pid where tab1.cid = '" + Cid + "' and pic.show =1 "; if (DropDownList1.SelectedIndex == 1) { sqlstr += " and datediff(month,tab2.addtime,getdate())=0 "; } else if (DropDownList1.SelectedIndex == 2) { sqlstr += " and datediff(month,tab2.addtime,getdate())!=0 "; } if (DropDownList2.SelectedIndex == 1) { sqlstr += " and isend =1"; } else if (DropDownList2.SelectedIndex == 2) { sqlstr += " and isend =0"; } sqlstr += " order by tab2.addtime"; pds.DataSource = new common().ExcuteReader(sqlstr).Tables[0].DefaultView; pds.AllowPaging = true; // 是否分页 pds.PageSize = 10; //页面大小 pageN = 0; pds.CurrentPageIndex = pageN;// 获取当前页面, 让下面的 显示当前页面 Repeater1.DataSource = pds; Repeater1.DataBind(); } protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { sqlstr = "select (tab2.amount*(select vip_price_rmb from v3_merchandises where pid = tab2.pid)) as price,(select trade_name_cn from v3_merchandises where pid = tab2.pid) as BookName,* from v3_order as tab1 inner join v3_order_item as tab2 on tab1.oid = tab2.oid and tab2.cid = tab1.cid inner join v3_pic_path as pic on tab2.pid = pic.pid where tab1.cid = '" + Cid + "' and pic.show =1 "; if (DropDownList1.SelectedIndex == 1) { sqlstr += " and datediff(month,tab2.addtime,getdate())=0 "; } else if (DropDownList1.SelectedIndex == 2) { sqlstr += " and datediff(month,tab2.addtime,getdate())!=0 "; } if (DropDownList2.SelectedIndex == 1) { sqlstr += " and isend =1"; } else if (DropDownList2.SelectedIndex == 2) { sqlstr += " and isend =0"; } sqlstr += " order by tab2.addtime"; pds.DataSource = new common().ExcuteReader(sqlstr).Tables[0].DefaultView; pds.AllowPaging = true; // 是否分页 pageN = 0; pds.PageSize = 10; //页面大小 pds.CurrentPageIndex = pageN;// 获取当前页面, 让下面的 显示当前页面 Repeater1.DataSource = pds; Repeater1.DataBind(); } protected void lblup_Click(object sender, EventArgs e) { if (pageN > 0) pageN--; Bind(pageN); } protected void lbldown_Click(object sender, EventArgs e) { if (pageN < pds.PageCount - 1) pageN++; Bind(pageN); } protected override void InitializeCulture() { if (Session["lang"] != null) { string lang = Session["lang"].ToString(); if (!String.IsNullOrEmpty(lang)) { //UICulture - 决定了采用哪一种本地化资源,也就是使用哪种语言 //Culture - 决定各种数据类型是如何组织,如数字与日期 Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang); base.InitializeCulture(); } } } protected void LinkButton2_Click(object sender, EventArgs e) { Session["Lang"] = "en-us"; Response.Redirect(Request.Url.ToString()); } protected void LinkButton1_Click(object sender, EventArgs e) { Session["Lang"] = "zh-cn"; Response.Redirect(Request.Url.ToString()); } }