From b0816412315f8427a430ee3d49db135fe7889a3e Mon Sep 17 00:00:00 2001 From: j502647092 Date: Tue, 23 Jun 2015 16:40:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=86=E9=A1=B5=E9=94=99?= =?UTF-8?q?=E8=AF=AF...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CitySunlight.v12.suo | Bin 128512 -> 128000 bytes CitySunlight/Admin.aspx.cs | 8 ++-- CitySunlight/Basic.Master | 73 +++++++++++++++++++++++++++++++++++ CitySunlight/Basic.Master.cs | 9 +++++ CitySunlight/HttpUtils.cs | 14 +++++++ CitySunlight/Main.aspx.cs | 8 ++-- 6 files changed, 104 insertions(+), 8 deletions(-) diff --git a/CitySunlight.v12.suo b/CitySunlight.v12.suo index 070edc12606e3914bc1bd6a35ebafaa2966825b8..083ccd6b190473e4fc3b0c915ec36ff4175b3f96 100644 GIT binary patch delta 427 zcmX}k-77<390%|{r*n>T^7gcunb(7b@-{_FDdb|cRxFbnbD^YmwrQxtbh%8HqJMYW)_khjplJRW)5&cIVjK% zEGG5X{V3XC6mG!{1$HUTx++n%!wgJ-`BhaZ=Ss=^a*r1D+eP#dDBxxd*=z3EwcME$ zDW9UxBu}(u-r!%(%yhnCJp>=-8Qv%I3kJ17i*DtTRH_wTns~Ad6mgtnzUG@41r;kYo_k`1ZwedTFw8Y&WBGRWN-%Vy} vy_hMidN#k0`uzu91&Eirzlh4>oW^F?bAr2CFaE$~M4#OUZn{$K&k4NGIGF zsw)s7B#-SbVYbFbX{gf|aoyC0Nl_jE54c8lzCiL4UcoH9hBqMp5mzTgX^oeX-tkj4 z&pwD})gR~8grG4!LxOt~uMwHQ6SL#Y^iP>2_F`O~9|z_ineNXSB>WqdFFsAaWxy)f zzGI7fyfQVT$)nA%%I2>paTIBMCR7wQE{XjlCNHYI+F0qNE{tSb(>ZX)r@7FPMg<}1)mFUyM7qmz; xV1#~>=数据库中未找到产品"; else @@ -45,8 +45,8 @@ namespace CitySunlight String delete = "删除"; html += HttpUtils.addTds(ProductManager.NameToUrl(id, name), picurl, price, amount, classname, edit, delete); } - decimal total = ProductManager.SearchProduct(user, "", "", "", "").Rows.Count / peritems; - int totalpages = (int)(Math.Ceiling(total)); + decimal allproduct = ProductManager.SearchProduct(user, "", "", "", "").Rows.Count; + decimal totalpages = Math.Ceiling(allproduct / peritems); String allpage = "
    "; for (int i = 1; i <= totalpages; i++) { diff --git a/CitySunlight/Basic.Master b/CitySunlight/Basic.Master index 64a78ef..68b18e5 100644 --- a/CitySunlight/Basic.Master +++ b/CitySunlight/Basic.Master @@ -55,6 +55,79 @@ + + + + + + + + <%-- + + --%> + + diff --git a/CitySunlight/Basic.Master.cs b/CitySunlight/Basic.Master.cs index b2bf8c6..d036395 100644 --- a/CitySunlight/Basic.Master.cs +++ b/CitySunlight/Basic.Master.cs @@ -9,6 +9,7 @@ namespace CitySunlight { public partial class Basic : System.Web.UI.MasterPage { + public String msg; protected void Page_Load(object sender, EventArgs e) { @@ -17,6 +18,7 @@ namespace CitySunlight { String html = ""; if (Session["username"] == null) + //html = "
  • 登录
  • "; html = "
  • 登录
  • "; else { @@ -27,5 +29,12 @@ namespace CitySunlight } return html; } + public String getAlert(String msg) + { + String html = "
    "; + html += ""; + html += "{1}
    "; + return (msg == null || msg == "") ? "" : String.Format(html, "danger", msg); + } } } \ No newline at end of file diff --git a/CitySunlight/HttpUtils.cs b/CitySunlight/HttpUtils.cs index 25a2603..9091660 100644 --- a/CitySunlight/HttpUtils.cs +++ b/CitySunlight/HttpUtils.cs @@ -132,5 +132,19 @@ namespace CitySunlight } return i; } + /// + /// String尝试转换为double(扩展方法) + /// + /// + /// + public static double Todouble(this string s) + { + double i; + if (!double.TryParse(s, out i)) + { + i = 0; + } + return i; + } } } \ No newline at end of file diff --git a/CitySunlight/Main.aspx.cs b/CitySunlight/Main.aspx.cs index 35da343..9b3a283 100644 --- a/CitySunlight/Main.aspx.cs +++ b/CitySunlight/Main.aspx.cs @@ -15,7 +15,7 @@ namespace CitySunlight public String classid = HttpUtils.getQueryString("classid"); public String search = HttpUtils.getQueryString("search"); public String classoption; - const int peritems = 5; + const decimal peritems = 5; protected void Page_Load(object sender, EventArgs e) { classoption = ProductClassManager.getOptionString("classid", classid); @@ -23,7 +23,7 @@ namespace CitySunlight public String GetProductInfo() { String html = ""; - DataTable items = ProductManager.SearchProduct("", search, classid, "", "", pages, peritems); + DataTable items = ProductManager.SearchProduct("", search, classid, "", "", pages, peritems.ToString().ToInt()); if (items.Rows.Count == 0) return "数据库中未找到产品"; else @@ -42,8 +42,8 @@ namespace CitySunlight html += HttpUtils.addTds(ProductManager.NameToUrl(id, name), picurl, price, amount, classname, user); } - decimal total = ProductManager.SearchProduct("", search, classid, "", "").Rows.Count / peritems; - int totalpages = (int)(Math.Ceiling(total)); + decimal allproduct = ProductManager.SearchProduct("", search, classid, "", "").Rows.Count; + decimal totalpages = Math.Ceiling(allproduct / peritems); String allpage = "
      "; for (int i = 1; i <= totalpages; i++) {