1
0
mirror of https://e.coding.net/circlecloud/CitySunlight.git synced 2024-12-04 12:58:46 +00:00

修复分页错误...

This commit is contained in:
j502647092 2015-06-23 16:40:30 +08:00
parent 07eb0fbb12
commit b081641231
6 changed files with 104 additions and 8 deletions

Binary file not shown.

View File

@ -13,7 +13,7 @@ namespace CitySunlight
{ {
int pages = HttpUtils.getQueryString("pages").ToInt(); int pages = HttpUtils.getQueryString("pages").ToInt();
public String user; public String user;
const int peritems = 5; const decimal peritems = 5;
protected void Page_Load(object sender, EventArgs e) protected void Page_Load(object sender, EventArgs e)
{ {
if (Session["username"] == null) if (Session["username"] == null)
@ -26,7 +26,7 @@ namespace CitySunlight
public String GetProductInfo() public String GetProductInfo()
{ {
String html = ""; String html = "";
DataTable items = ProductManager.SearchProduct(user, "", "", "", "", pages, peritems); DataTable items = ProductManager.SearchProduct(user, "", "", "", "", pages, peritems.ToString().ToInt());
if (items.Rows.Count == 0) if (items.Rows.Count == 0)
return "<tr><td>数据库中未找到产品</td></tr>"; return "<tr><td>数据库中未找到产品</td></tr>";
else else
@ -45,8 +45,8 @@ namespace CitySunlight
String delete = "<a href=\"/Product/ProductEdit.aspx?id=" + id + "&type=delete\" >删除</a>"; String delete = "<a href=\"/Product/ProductEdit.aspx?id=" + id + "&type=delete\" >删除</a>";
html += HttpUtils.addTds(ProductManager.NameToUrl(id, name), picurl, price, amount, classname, edit, delete); html += HttpUtils.addTds(ProductManager.NameToUrl(id, name), picurl, price, amount, classname, edit, delete);
} }
decimal total = ProductManager.SearchProduct(user, "", "", "", "").Rows.Count / peritems; decimal allproduct = ProductManager.SearchProduct(user, "", "", "", "").Rows.Count;
int totalpages = (int)(Math.Ceiling(total)); decimal totalpages = Math.Ceiling(allproduct / peritems);
String allpage = "<ul class=\"pagination\">"; String allpage = "<ul class=\"pagination\">";
for (int i = 1; i <= totalpages; i++) for (int i = 1; i <= totalpages; i++)
{ {

View File

@ -55,6 +55,79 @@
</div> </div>
</div> </div>
<!-- /container --> <!-- /container -->
<!-- 模态框Modal -->
<div class="modal fade" id="loginModal" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close"
data-dismiss="modal" aria-hidden="true">
&times;
</button>
<h4 class="modal-title" id="myModalLabel">都市阳光登录
</h4>
</div>
<div class="modal-body">
在这里添加一些文本
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">
关闭
</button>
<button type="button" class="btn btn-primary">
登录
</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
<%-- <!-- 模态框Modal -->
<div class="modal fade" id="loginModal" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close"
data-dismiss="modal" aria-hidden="true">
&times;
</button>
<h4 class="modal-title" id="myModalLabel">都市阳光登录
</h4>
</div>
<div class="modal-body">
<div class="form-control">
<%= getAlert(msg) %>
<label for="UserNameTx" class="col-sm-3"><a class="glyphicon glyphicon-user">用户名</a></label>
<input type="text" id="UserNameTx" name="UserNameTx" class="form-control col-sm-7" placeholder="请输入账号" />
<label for="PassWordTx" class="col-sm-3"><a class="glyphicon glyphicon-th">密 码</a></label>
<input type="password" id="PassWordTx" name="PassWordTx" class="form-control col-sm-7" placeholder="请输入密码" />
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">
关闭
</button>
<button type="button" class="btn btn-primary">
提交更改
</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->--%>
<script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.js"></script> <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.js"></script>
<script src="http://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.js"></script> <script src="http://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.js"></script>
</body> </body>

View File

@ -9,6 +9,7 @@ namespace CitySunlight
{ {
public partial class Basic : System.Web.UI.MasterPage public partial class Basic : System.Web.UI.MasterPage
{ {
public String msg;
protected void Page_Load(object sender, EventArgs e) protected void Page_Load(object sender, EventArgs e)
{ {
@ -17,6 +18,7 @@ namespace CitySunlight
{ {
String html = ""; String html = "";
if (Session["username"] == null) if (Session["username"] == null)
//html = "<li><a href=\"#\" data-toggle=\"modal\" data-target=\"#loginModal\" >登录</a></li>";
html = "<li><a href=\"/Account/Login.aspx\" >登录</a></li>"; html = "<li><a href=\"/Account/Login.aspx\" >登录</a></li>";
else else
{ {
@ -27,5 +29,12 @@ namespace CitySunlight
} }
return html; return html;
} }
public String getAlert(String msg)
{
String html = "<div class=\"alert alert-{0} alert-dismissable\">";
html += "<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>";
html += "{1}</div>";
return (msg == null || msg == "") ? "" : String.Format(html, "danger", msg);
}
} }
} }

View File

@ -132,5 +132,19 @@ namespace CitySunlight
} }
return i; return i;
} }
/// <summary>
/// String尝试转换为double(扩展方法)
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static double Todouble(this string s)
{
double i;
if (!double.TryParse(s, out i))
{
i = 0;
}
return i;
}
} }
} }

View File

@ -15,7 +15,7 @@ namespace CitySunlight
public String classid = HttpUtils.getQueryString("classid"); public String classid = HttpUtils.getQueryString("classid");
public String search = HttpUtils.getQueryString("search"); public String search = HttpUtils.getQueryString("search");
public String classoption; public String classoption;
const int peritems = 5; const decimal peritems = 5;
protected void Page_Load(object sender, EventArgs e) protected void Page_Load(object sender, EventArgs e)
{ {
classoption = ProductClassManager.getOptionString("classid", classid); classoption = ProductClassManager.getOptionString("classid", classid);
@ -23,7 +23,7 @@ namespace CitySunlight
public String GetProductInfo() public String GetProductInfo()
{ {
String html = ""; 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) if (items.Rows.Count == 0)
return "<tr><td style=\"color:red\" colspan=\"8\" align=\"center\">数据库中未找到产品</td></tr>"; return "<tr><td style=\"color:red\" colspan=\"8\" align=\"center\">数据库中未找到产品</td></tr>";
else else
@ -42,8 +42,8 @@ namespace CitySunlight
html += HttpUtils.addTds(ProductManager.NameToUrl(id, name), picurl, price, amount, classname, user); html += HttpUtils.addTds(ProductManager.NameToUrl(id, name), picurl, price, amount, classname, user);
} }
decimal total = ProductManager.SearchProduct("", search, classid, "", "").Rows.Count / peritems; decimal allproduct = ProductManager.SearchProduct("", search, classid, "", "").Rows.Count;
int totalpages = (int)(Math.Ceiling(total)); decimal totalpages = Math.Ceiling(allproduct / peritems);
String allpage = "<ul class=\"pagination\">"; String allpage = "<ul class=\"pagination\">";
for (int i = 1; i <= totalpages; i++) for (int i = 1; i <= totalpages; i++)
{ {