1 using System;
2 using System.IO;
3 using System.Data;
4 using System.Web.UI;
5 using System.Web.UI.WebControls;
6 using System.Collections.Generic;
7 using System.Threading;
8 using System.Text;
9
10 using SigilSoft.Data.SqlClient;
11
12 using Sigil.Common;
13 using Sigil.Template;
14
15 namespace Sigil.Ste37
16 {
17
18 public partial class ProductList : PageList
19 {
20 // private static readonly string SortString = "productName";
21
22 //声明控件
23 protected TextBox SearchName = new TextBox();
24 protected DropDownList Dlb = new DropDownList();
25 protected Label tx = new Label();
26
27
28 protected void Page_Load(object sender, EventArgs e)
29 {
30 if (!IsPostBack)
31 {
32 if (SearchName.Text == null)
33 Paging(BuildInfo(), true);
34 else
35 Paging(GetInfo(), true);
36 //绑定DropList
37 //ListHelper.Bind(Dlb, DropListBrand(), "brandname", "brandid");
38 }
39 }
40 #region 获取数据
41 // 搜索
42 protected void Search_Click(object sender, EventArgs e)
43 {
44 Paging(GetInfo(), true);
45 }
46
47 //排序
48 protected void Sort_Changed(object sender, CommandEventArgs e)
49 {
50 Paging(GetInfo(), e, false);
51 }
52
53 //翻页
54 protected void Page_Changed(object sender, EventArgs e)
55 {
56 Paging(GetInfo(), true);
57 }
58
59 // 读取产品数据
60 private DataTable GetInfo()
61 {
62 DataTable dt = new DataTable();
63 string sql = "select productname, productcode from product where productname like '%{0}%' ";
64 sql = string.Format(sql, SearchName.Text);
65 Trace.Warn(sql);
66 dt = new Gladiator().GetDataTable(sql, SqlStringFrom.Program);
67 if (dt.Rows.Count > 0)
68 {
69 tx.Visible = false;
70 }
71 else
72 {
73 tx.Visible = true;
74 }
75 return dt;
76 }
77 private DataTable BuildInfo()
78 {
79 DataTable dt = new DataTable();
80
81 string sql = "select productname, productcode from product";
82 Trace.Warn(sql);
83 dt = new Gladiator().GetDataTable(sql, SqlStringFrom.Program);
84 return dt;
85 }
86 //读取DropList控件
87 private DataTable DropListBrand()
88 {
89 DataTable dt = new DataTable();
90 string sql = "selcet brandId,brandname from brand";
91 Trace.Warn(sql);
92 dt = new Gladiator().GetDataTable(sql, SqlStringFrom.Program);
93 return dt;
94 }
95 # endregion
96 }
97 }