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 15:28:58 +08:00
parent d6728fb119
commit ffa408a7a3
22 changed files with 266 additions and 354 deletions

Binary file not shown.

View File

@ -1,7 +1,7 @@
<%@ Page Language="C#" MasterPageFile="~/Basic.Master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="CitySunlight.Default" ValidateRequest="false" %> <%@ Page Language="C#" MasterPageFile="~/Basic.Master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="CitySunlight.Default" ValidateRequest="false" %>
<asp:Content ID="body" ContentPlaceHolderID="body" runat="server"> <asp:Content ID="body" ContentPlaceHolderID="body" runat="server">
<form id="loginform" runat="server"> <form id="loginform" runat="server" class="form-horizontal col-sm-10">
<div class="panel panel-info"> <div class="panel panel-info">
<div class="panel-heading"> <div class="panel-heading">
@ -11,52 +11,19 @@
<div class="form-group"> <div class="form-group">
<%= getAlert(msg) %> <%= getAlert(msg) %>
</div> </div>
<div class="form-group"> <div>
<button type="button" class="btn btn-primary btn-lg" style="text-shadow: black 5px 3px 3px;"> <label for="UserNameTx" class="col-sm-3"><a class="glyphicon glyphicon-user">用户名</a></label>
<span class="glyphicon glyphicon-user"></span>用户名 <input type="text" id="UserNameTx" name="UserNameTx" class="form-control col-sm-7" placeholder="请输入账号" />
</button>
<input type="text" id="UserNameTx" name="UserNameTx" class="form-control" placeholder="请输入账号" />
</div> </div>
<div class="form-group"> <div>
<button type="button" class="btn btn-primary btn-lg" style="text-shadow: black 5px 3px 3px;"><span class="glyphicon glyphicon-th"></span>密 码</button> <label for="PassWordTx" class="col-sm-3"><a class="glyphicon glyphicon-th">密 码</a></label>
<input type="password" id="PassWordTx" name="PassWordTx" class="form-control" placeholder="请输入密码" /> <input type="password" id="PassWordTx" name="PassWordTx" class="form-control col-sm-7" placeholder="请输入密码" />
</div> </div>
<div class="form-group"> <div class="form-group col-sm-8 text-center">
<asp:Button runat="server" ID="register" Text="注册" Height="45" Width="70" OnClick="register_Click" UseSubmitBehavior="False" class="btn btn-lg btn-primary" /> <asp:Button runat="server" ID="register" Text="注册" Height="45" Width="70" OnClick="register_Click" UseSubmitBehavior="False" CssClass="btn btn-lg btn-primary" />
<asp:Button runat="server" ID="login" Text="登录" Width="140" OnClick="login_Click" class="btn btn-lg btn-success" /> <asp:Button runat="server" ID="login" Text="登录" Width="140" OnClick="login_Click" CssClass="btn btn-lg btn-success" />
</div> </div>
</div> </div>
</div> </div>
<%-- <table id="tb" class="table table-condensed">
<tr>
<td colspan="2" id="head">
<h1>都市阳光销售平台</h1>
</td>
</tr>
<tr>
<td>
<%= getAlert(msg) %>
</td>
</tr>
<tr>
<td>
<label>用 户 名:</label>
<input type="text" id="UserNameTx" name="UserNameTx" />
</td>
</tr>
<tr>
<td>
<label>密&nbsp;&nbsp;码:</label>
<input type="password" id="PassWordTx" name="PassWordTx" />
</td>
</tr>
<tr>
<td></td>
</tr>
</table>--%>
</form> </form>
</asp:Content> </asp:Content>

View File

@ -1,44 +1,35 @@
<%@ Page Language="C#" MasterPageFile="~/Basic.Master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="CitySunlight.register" %> <%@ Page Language="C#" MasterPageFile="~/Basic.Master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="CitySunlight.register" %>
<asp:Content ID="body" ContentPlaceHolderID="body" runat="server"> <asp:Content ID="body" ContentPlaceHolderID="body" runat="server">
<form id="registerform" runat="server">
<table id="tb" class="table table-bordered"> <form id="registerform" runat="server" class="form-horizontal col-sm-10">
<tr>
<td colspan="2" id="head"> <div class="panel panel-info">
<h1>都市阳光注册系统</h1> <div class="panel-heading">
</td> <h3 class="panel-title">都市阳光销售平台</h3>
</tr> </div>
<tr>
<td colspan="2"> <div class="panel-body">
<span style="color: red"><%= msg %></span> <div class="form-group">
</td> <%= getAlert(msg) %>
</tr> </div>
<tr> <div>
<td> <label for="UserNameTx" class="col-sm-3"><a class="glyphicon glyphicon-user">用 户 名</a></label>
<label>用 户 名: </label> <input type="text" id="UserNameTx" name="UserNameTx" class="form-control" placeholder="请输入账号" />
</td> </div>
<td> <div>
<input name="usernameTx" type="text" /> <label for="PassWordTx" class="col-sm-3"><a class="glyphicon glyphicon-th">密 码</a></label>
</tr> <input type="password" id="PassWordTx" name="PassWordTx" class="form-control" placeholder="请输入密码" />
<tr> </div>
<td> <div>
<label>密&nbsp;&nbsp;码: </label> <label for="confirmTx" class="col-sm-3"><a class="glyphicon glyphicon-th">确认密码</a></label>
</td> <input type="password" id="confirmTx" name="confirmTx" class="form-control" placeholder="请再次输入密码" />
<td> </div>
<input name="passwordTx" type="password" /> <div class="form-group text-center">
</tr> <asp:Button runat="server" Text="注册" ID="submit" OnClick="submit_Click" CssClass="btn btn-lg btn-success" />
<tr> </div>
<td> </div>
<label>确认密码: </label> </div>
</td>
<td>
<input name="confirmTx" type="password" />
</tr>
<tr>
<td colspan="2">
<asp:Button runat="server" Text="注册" ID="submit" OnClick="submit_Click" />
</tr>
</table>
</form> </form>
</asp:Content> </asp:Content>

View File

@ -51,6 +51,13 @@ namespace CitySunlight
msg = "注册失败,请联系管理员!"; msg = "注册失败,请联系管理员!";
} }
} }
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

@ -2,7 +2,7 @@
<asp:Content ID="body" ContentPlaceHolderID="body" runat="server"> <asp:Content ID="body" ContentPlaceHolderID="body" runat="server">
<form id="formmain" runat="server"> <form id="formmain" runat="server">
<table class="table table-condensed"> <table class="table text-center">
<%= GetProductInfo() %> <%= GetProductInfo() %>
</table> </table>
</form> </form>

View File

@ -30,15 +30,8 @@ namespace CitySunlight
if (items.Rows.Count == 0) if (items.Rows.Count == 0)
return "<tr><td>数据库中未找到产品</td></tr>"; return "<tr><td>数据库中未找到产品</td></tr>";
else else
html += String.Format("<tr>{0}</tr>", html += html += HttpUtils.addThs("商品名称", "商品图片", "商品价格", "商品数量", "商品分类", "编辑", "删除");
HttpUtils.addTd("") + html += "<tbody class=\"text-center\">";
HttpUtils.addTd("商品名称") +
HttpUtils.addTd("商品图片") +
HttpUtils.addTd("商品价格") +
HttpUtils.addTd("商品数量") +
HttpUtils.addTd("商品分类") +
HttpUtils.addTd("编辑") +
HttpUtils.addTd("删除"));
foreach (DataRow item in items.Rows) foreach (DataRow item in items.Rows)
{ {
int id = int.Parse(ProductManager.GetProductInfo(item, ProductManager.Info.ID)); int id = int.Parse(ProductManager.GetProductInfo(item, ProductManager.Info.ID));
@ -50,16 +43,7 @@ namespace CitySunlight
String edit = "<a href=\"/Product/ProductEdit.aspx?id=" + id + "&type=edit\" >编辑</a>"; String edit = "<a href=\"/Product/ProductEdit.aspx?id=" + id + "&type=edit\" >编辑</a>";
String classname = ProductClassManager.getClassName(int.Parse(ProductManager.GetProductInfo(item, ProductManager.Info.Class))); String classname = ProductClassManager.getClassName(int.Parse(ProductManager.GetProductInfo(item, ProductManager.Info.Class)));
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 += "<tr>"; html += HttpUtils.addTds(ProductManager.NameToUrl(id, name), picurl, price, amount, classname, edit, delete);
html += HttpUtils.addTd();
html += HttpUtils.addTd(ProductManager.NameToUrl(id, name));
html += HttpUtils.addTd(picurl);
html += HttpUtils.addTd(price);
html += HttpUtils.addTd(amount);
html += HttpUtils.addTd(classname);
html += HttpUtils.addTd(edit);
html += HttpUtils.addTd(delete);
html += "</tr>";
} }
decimal total = ProductManager.SearchProduct(user, "", "", "", "").Rows.Count / peritems; decimal total = ProductManager.SearchProduct(user, "", "", "", "").Rows.Count / peritems;
int totalpages = (int)(Math.Ceiling(total)); int totalpages = (int)(Math.Ceiling(total));
@ -72,6 +56,7 @@ namespace CitySunlight
allpage += String.Format("<li><a href=\"#\">共{0}页</a><li>", totalpages); allpage += String.Format("<li><a href=\"#\">共{0}页</a><li>", totalpages);
allpage += "</ul>"; allpage += "</ul>";
html += String.Format("<tr><td colspan=\"6\" align=\"right\"></td><td colspan=\"2\">{0}</td></tr>", allpage); html += String.Format("<tr><td colspan=\"6\" align=\"right\"></td><td colspan=\"2\">{0}</td></tr>", allpage);
html += "</tbody>";
return html; return html;
} }
} }

View File

@ -46,10 +46,12 @@
<div class="container theme-showcase" role="main"> <div class="container theme-showcase" role="main">
<div class="page-header"> <div class="page-header">
</div> </div>
<div class="row"> <div class="container">
<div class="col-md-6"> <div class="row">
<asp:ContentPlaceHolder ID="body" runat="server"> <div class="col-sm-3 col-md-6 col-lg-8">
</asp:ContentPlaceHolder> <asp:ContentPlaceHolder ID="body" runat="server">
</asp:ContentPlaceHolder>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -20,7 +20,7 @@ namespace CitySunlight
html = "<li><a href=\"/Account/Login.aspx\" >登录</a></li>"; html = "<li><a href=\"/Account/Login.aspx\" >登录</a></li>";
else else
{ {
html = String.Format("<li>欢迎您 {0} </li>", Session["username"].ToString()); html = String.Format("<li><a href=\"#\" >欢迎您 {0} </a></li>", Session["username"].ToString());
html += "<li><a href=\"/Account/LogOut.aspx\" >注销</a></li>"; html += "<li><a href=\"/Account/LogOut.aspx\" >注销</a></li>";
html += "<li><a href=\"/Product/ProductEdit.aspx?type=create\" >发布</a></li>"; html += "<li><a href=\"/Product/ProductEdit.aspx?type=create\" >发布</a></li>";
html += "<li><a href=\"/Admin.aspx\" >管理</a></li>"; html += "<li><a href=\"/Admin.aspx\" >管理</a></li>";

View File

@ -58,7 +58,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Account\LogOut.aspx" /> <Content Include="Account\LogOut.aspx" />
<Content Include="CssStyle\CityStyle.css" />
<Content Include="Account\Login.aspx" /> <Content Include="Account\Login.aspx" />
<Content Include="Admin.aspx" /> <Content Include="Admin.aspx" />
<Content Include="Main.aspx" /> <Content Include="Main.aspx" />

View File

@ -7,7 +7,7 @@
<VisualStudio> <VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties> <WebProjectProperties>
<StartPageUrl>Account/Login.aspx</StartPageUrl> <StartPageUrl>Main.aspx</StartPageUrl>
<StartAction>SpecificPage</StartAction> <StartAction>SpecificPage</StartAction>
<AspNetDebugging>True</AspNetDebugging> <AspNetDebugging>True</AspNetDebugging>
<SilverlightDebugging>False</SilverlightDebugging> <SilverlightDebugging>False</SilverlightDebugging>

View File

@ -1,53 +0,0 @@
body {
align-content: center;
}
table {
align-content: center;
}
label {
width: 80px;
display: inline-block;
align-content: center;
}
input {
margin-left: 0px;
margin-right: 2px;
margin-top: 2px;
margin-bottom: 2px;
}
table td {
align-content: center;
}
table tr {
align-content: center;
}
#tb {
color: #333333;
border-width: 0px;
border-collapse: collapse;
background-color: #333333;
}
#tb th {
border-width: 0px;
padding: 8px;
align-content: center;
background-color: #dedede;
}
#tb td {
border-width: 0px;
padding: 8px;
align-content: center;
background-color: #ffffff;
}
#errmsg {
align-content: center;
}

View File

@ -63,6 +63,24 @@ namespace CitySunlight
{ {
return "<td></td>"; return "<td></td>";
} }
public static String addThs(params String[] head)
{
String ths = "";
foreach (String th in head)
{
ths += "<th class=\"text-center\">" + th + "</th>";
}
return String.Format("<thead class=\"text-center\"><tr>{0}</tr></thead>", ths);
}
public static String addTds(params String[] head)
{
String ths = "";
foreach (String th in head)
{
ths += "<th class=\"text-center\">" + th + "</th>";
}
return String.Format("<tr class=\"text-center\">{0}</tr>", ths);
}
/// <summary> /// <summary>
/// 添加Td(带内容) /// 添加Td(带内容)
/// </summary> /// </summary>

View File

@ -1,19 +1,19 @@
<%@ Page Language="C#" MasterPageFile="~/Basic.Master" AutoEventWireup="true" CodeBehind="Main.aspx.cs" Inherits="CitySunlight.Main" %> <%@ Page Language="C#" MasterPageFile="~/Basic.Master" AutoEventWireup="true" CodeBehind="Main.aspx.cs" Inherits="CitySunlight.Main" %>
<%@ Import Namespace="CitySunlight" %> <%@ Import Namespace="CitySunlight" %>
<asp:Content ID="body" ContentPlaceHolderID="body" runat="server"> <asp:Content ID="body" ContentPlaceHolderID="body" runat="server">
<form id="formmain" runat="server"> <form id="formmain" class="form-horizontal" runat="server">
<table class="table table-striped table-bordered"> <div class="form-group">
<tr> <label class="col-sm-2 control-label">商品名称</label>
<td></td> <div class="col-sm-4">
<td><span>商品名称: </span></td> <input class="form-control" name="search" type="text" placeholder="请输入商品名称查找...">
<td colspan="2"> </div>
<input name="search" type="text" value="<%= search %>" /></td> <div class="col-sm-2"><%= classoption %></div>
<td>产品分类: </td> <div class="col-sm-2">
<td><%= classoption %></td> <asp:Button ID="searchB" runat="server" Text="搜索" OnClick="searchB_Click" CssClass="btn btn-default" />
<td> </div>
<asp:Button ID="searchB" runat="server" Text="搜索" OnClick="searchB_Click"/></td> </div>
<td>&nbsp;</td> <table class="table text-center">
</tr>
<%= GetProductInfo() %> <%= GetProductInfo() %>
</table> </table>
</form> </form>

View File

@ -27,16 +27,8 @@ namespace CitySunlight
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
html += String.Format("<tr>{0}</tr>", html += HttpUtils.addThs("商品名称", "商品图片", "商品价格", "商品库存", "商品分类", "所属卖家");
HttpUtils.addTd() + html += "<tbody class=\"text-center\">";
HttpUtils.addTd("商品名称") +
HttpUtils.addTd("商品图片") +
HttpUtils.addTd("商品价格") +
HttpUtils.addTd("商品数量") +
HttpUtils.addTd("商品分类") +
HttpUtils.addTd("所属卖家") +
HttpUtils.addTd());
foreach (DataRow item in items.Rows) foreach (DataRow item in items.Rows)
{ {
int id = int.Parse(ProductManager.GetProductInfo(item, ProductManager.Info.ID)); int id = int.Parse(ProductManager.GetProductInfo(item, ProductManager.Info.ID));
@ -48,28 +40,11 @@ namespace CitySunlight
String user = ProductManager.GetProductInfo(item, ProductManager.Info.UserName); String user = ProductManager.GetProductInfo(item, ProductManager.Info.UserName);
String classname = ProductClassManager.getClassName(int.Parse(ProductManager.GetProductInfo(item, ProductManager.Info.Class))); String classname = ProductClassManager.getClassName(int.Parse(ProductManager.GetProductInfo(item, ProductManager.Info.Class)));
html += String.Format("<tr>{0}</tr>", html += HttpUtils.addTds(ProductManager.NameToUrl(id, name), picurl, price, amount, classname, user);
HttpUtils.addTd("") +
HttpUtils.addTd(ProductManager.NameToUrl(id, name)) +
HttpUtils.addTd(picurl) +
HttpUtils.addTd(price) +
HttpUtils.addTd(amount) +
HttpUtils.addTd(classname) +
HttpUtils.addTd(user) +
HttpUtils.addTd(""));
} }
decimal total = ProductManager.SearchProduct("", search, classid, "", "").Rows.Count / peritems; decimal total = ProductManager.SearchProduct("", search, classid, "", "").Rows.Count / peritems;
int totalpages = (int)(Math.Ceiling(total)); int totalpages = (int)(Math.Ceiling(total));
String allpage = "<ul class=\"pagination\">"; String allpage = "<ul class=\"pagination\">";
// <ul class="pagination">
// <li><a href="#">&laquo;</a></li>
// <li><a href="#">1</a></li>
// <li><a href="#">2</a></li>
// <li><a href="#">3</a></li>
// <li><a href="#">4</a></li>
// <li><a href="#">5</a></li>
// <li><a href="#">&raquo;</a></li>
//</ul>
for (int i = 1; i <= totalpages; i++) for (int i = 1; i <= totalpages; i++)
{ {
String page = String.Format("<li><a href=\"/Main.aspx?search={0}&classid={1}&pages={2}\">{3}</a></li>", search, classid, i, i); String page = String.Format("<li><a href=\"/Main.aspx?search={0}&classid={1}&pages={2}\">{3}</a></li>", search, classid, i, i);
@ -77,7 +52,8 @@ namespace CitySunlight
} }
allpage += String.Format("<li><a href=\"#\">共{0}页</a><li>", totalpages); allpage += String.Format("<li><a href=\"#\">共{0}页</a><li>", totalpages);
allpage += "</ul>"; allpage += "</ul>";
html += String.Format("<tr><td colspan=\"8\" align=\"right\">{0}</td></tr>", allpage); html += String.Format("<tr><td colspan=\"6\" align=\"right\">{0}</td></tr>", allpage);
html += "</tbody>";
return html; return html;
} }

View File

@ -1,74 +1,56 @@
<%@ Page Language="C#" MasterPageFile="~/Basic.Master" AutoEventWireup="true" CodeBehind="ProductClassEdit.aspx.cs" Inherits="CitySunlight.ProductClassEdit" %> <%@ Page Language="C#" MasterPageFile="~/Basic.Master" AutoEventWireup="true" CodeBehind="ProductClassEdit.aspx.cs" Inherits="CitySunlight.ProductClassEdit" %>
<asp:Content ContentPlaceHolderID="body" ID="body" runat="server"> <asp:Content ContentPlaceHolderID="body" ID="body" runat="server">
<form id="productclasseditform" runat="server"> <form id="productclasseditform" class="form-horizontal" runat="server">
<table class="table table-bordered">
<tr>
<td colspan="2">
<h3>自定义分类管理</h3>
</td>
</tr>
<!-- 消息提示 -->
<tr>
<td colspan="2">
<%= msg %>
</td>
</tr>
<!-- 添加分类 -->
<tr>
<td colspan="2">
<h4>添加分类</h4>
</td>
</tr>
<tr>
<td>
<a>新增类名: </a>
<input type="text" name="customclass" />
</td>
<td rowspan="2">
<asp:Button runat="server" ID="add" Text="添加" Width="45px" OnClick="add_Click" /></td>
</tr>
<tr>
<td>
<a>上级分类: </a>
<%= GetOption("addclassfather") %>
</td>
</tr>
<!-- 删除分类 -->
<tr>
<td colspan="2">
<h4>删除分类</h4>
</td>
</tr>
<tr>
<td>
<a>当前分类: </a>
<%= GetOption("deleteclass") %>
</td>
<td>
<asp:Button runat="server" ID="remove" Text="删除" Width="45px" OnClick="remove_Click" /></td>
</tr>
<!-- 修改分类 -->
<tr>
<td colspan="2">
<h4>修改分类</h4>
</td>
</tr>
<tr>
<td>
<a>选择分类: </a>
<%= GetOption("editclassid") %>
</td>
<td rowspan="2">
<asp:Button runat="server" ID="Edit" Text="修改" Width="45px" OnClick="edit_Click" /></td>
</tr>
<tr>
<td>
<a>修改类名: </a>
<input type="text" name="editclassname" />
</td>
</tr> <div class="panel panel-info">
</table> <div class="panel-heading">
<h3 class="panel-title">都市阳光销售平台 - 自定义分类管理</h3>
</div>
<div class="panel-body">
<div class="form-group">
<%= getAlert(msg) %>
</div>
<div class="form-group">
<h3 class="label-success">添加分类</h3>
<div class="text-center">
<label>新增类名: </label>
<input type="text" name="customclass" class="form-control" />
</div>
<div class="text-center">
<label>选择父类: </label>
<%= GetOption("addclassfather") %>
<asp:Button runat="server" ID="add" Text="添加" Width="60px" OnClick="add_Click" CssClass="btn btn-sm btn-success text-center" />
</div>
</div>
<div class="form-group">
<h3 class="label-danger">删除分类</h3>
<div class="text-center">
<label>当前分类: </label>
<%= GetOption("deleteclass") %>
<asp:Button runat="server" ID="remove" Text="删除" Width="60px" OnClick="remove_Click" CssClass="btn btn-sm btn-danger text-center" />
</div>
</div>
<div class="form-group">
<h3 class="label-primary">修改分类</h3>
<div class="text-center">
<label>选择分类: </label>
<%= GetOption("editclassid") %>
</div>
<div class="text-center">
<label>修改类名: </label>
<input type="text" name="editclassname" class="form-control" />
<asp:Button runat="server" ID="Edit" Text="修改" Width="60px" OnClick="edit_Click" CssClass="btn btn-sm btn-primary text-center" />
</div>
</div>
</div>
</div>
</form> </form>
</asp:Content> </asp:Content>

View File

@ -71,5 +71,13 @@ namespace CitySunlight
return; return;
} }
} }
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

@ -15,6 +15,22 @@ namespace CitySunlight
//分类表名 //分类表名
public const String tbname = "tb_proclass"; public const String tbname = "tb_proclass";
//<div class="btn-group">
// <a class="btn btn-info" href="#">Info</a>
// <a class="btn btn-info dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret"></span></a>
// <ul class="dropdown-menu">
// <li><a href="#">Action</a></li>
// <li><a href="#">Another action</a></li>
// <li><a href="#">Something else here</a></li>
// <li class="divider"></li>
// <li><a href="#">Separated link</a></li>
// </ul>
//</div><!-- /btn-group -->
/// <summary> /// <summary>
/// 获得分类列表的Html代码,默认选择第一个 /// 获得分类列表的Html代码,默认选择第一个
/// </summary> /// </summary>
@ -32,7 +48,7 @@ namespace CitySunlight
/// <returns>分类列表的Html代码</returns> /// <returns>分类列表的Html代码</returns>
public static String getOptionString(String name, String df) public static String getOptionString(String name, String df)
{ {
String html = "<select style=\"width: 120px\" Name=\"" + name + "\">"; String html = "<select class=\"form-control\" Name=\"" + name + "\">";
html += "<option value=\"0\">请选择分类</option>"; html += "<option value=\"0\">请选择分类</option>";
DataTable option = sql.ExecuteDataTable("select * from " + tbname, CommandType.Text); DataTable option = sql.ExecuteDataTable("select * from " + tbname, CommandType.Text);
foreach (DataRow item in option.Rows) foreach (DataRow item in option.Rows)

View File

@ -1,19 +1,20 @@
<%@ Page Language="C#" MasterPageFile="~/Basic.Master" AutoEventWireup="true" CodeBehind="ProductEdit.aspx.cs" Inherits="CitySunlight.Product.ProductEdit" %> <%@ Page Language="C#" MasterPageFile="~/Basic.Master" AutoEventWireup="true" CodeBehind="ProductEdit.aspx.cs" Inherits="CitySunlight.Product.ProductEdit" %>
<asp:Content runat="server" ID="body" ContentPlaceHolderID="body"> <asp:Content runat="server" ID="body" ContentPlaceHolderID="body">
<form id="productedit" runat="server" enctype="multipart/form-data"> <form id="productedit" class="form-horizontal" runat="server" enctype="multipart/form-data">
<table class="table table-condensed"> <div class="panel panel-info">
<tr> <div class="panel-heading">
<td> <h3 class="panel-title">都市阳光销售平台 - 商品编辑</h3>
<span style="color: red"><%= msg %></span> </div>
</tr> <div class="panel-body">
</table> <div class="form-group">
<%= CreateEditForm() %> <%= getAlert(msg) %>
<table class="table table-condensed"> </div>
<tr> <%= CreateEditForm() %>
<td> <div class="form-group text-center">
<asp:Button ID="submit" runat="server" Text="提交" OnClick="submit_Click"/></td> <asp:Button ID="submit" runat="server" Text="提交" OnClick="submit_Click" CssClass="btn btn-lg btn-success" />
</tr> </div>
</table> </div>
</div>
</form> </form>
</asp:Content> </asp:Content>

View File

@ -71,7 +71,7 @@ namespace CitySunlight.Product
{ {
String name = ""; String name = "";
String url = "empty.jpg"; String url = "empty.jpg";
String picurl = String.Format("<img src=\"../Picture/{0}\"alt=\"\" width=\"64\" height=\"64\"/>", url); String picurl = addImg(url);
String price = ""; String price = "";
String amount = ""; String amount = "";
String classid = ""; String classid = "";
@ -79,7 +79,7 @@ namespace CitySunlight.Product
{ {
name = ProductManager.GetProductInfo(id, ProductManager.Info.ItemName); name = ProductManager.GetProductInfo(id, ProductManager.Info.ItemName);
url = ProductManager.GetProductInfo(id, ProductManager.Info.PicUrl); url = ProductManager.GetProductInfo(id, ProductManager.Info.PicUrl);
picurl = String.Format("<img src=\"../Picture/{0}\"alt=\"\" width=\"64\" height=\"64\"/>", url); picurl = addImg(url);
price = ProductManager.GetProductInfo(id, ProductManager.Info.Price); price = ProductManager.GetProductInfo(id, ProductManager.Info.Price);
amount = ProductManager.GetProductInfo(id, ProductManager.Info.Amount); amount = ProductManager.GetProductInfo(id, ProductManager.Info.Amount);
classid = ProductManager.GetProductInfo(id, ProductManager.Info.Class); classid = ProductManager.GetProductInfo(id, ProductManager.Info.Class);
@ -92,44 +92,40 @@ namespace CitySunlight.Product
} }
String html = ""; String html = "";
html += "<table align=\"center\">"; html += addFormGroup("商品名称", addDiv(addText("Name", name), "8"));
html += "<tr>" + addTdc("<h1>商品编辑</h1>", 3) + "</tr>"; html += addFormGroup("商品分类", addDiv(ProductClassManager.getOptionString("Class", classid), "8") + addDiv(addA("编辑", "ProductClassEdit.aspx"), "2"));
html += "<tr>" + addTd("商品名称") + addTdc(addText("Name", name), 2) + addTd("<input type=\"hidden\" name=\"iid\" value=\"" + id + "\"/>") + "</tr>"; html += addFormGroup("商品图片", addDiv(picurl, "8"));
html += "<tr>" + addTd("商品分类") + addTd(ProductClassManager.getOptionString("Class", classid)) + addTd(addA("编辑", "ProductClassEdit.aspx")) + "</tr>"; html += addFormGroup("上产图片", addDiv(addFile("Picture"), "8"));
html += "<tr>" + addTdr("商品图片", 2) + addTdc(picurl, 2) + "</tr>"; html += addFormGroup("商品价格", addDiv(addText("Price", price), "8"));
html += "<tr>" + addTdc(addFile("Picture"), 2) + "</tr>"; html += addFormGroup("库存数量", addDiv(addText("Amount", amount), "8"));
html += "<tr>" + addTd("商品价格") + addTdc(addText("Price", price), 2) + "</tr>";
html += "<tr>" + addTd("库存数量") + addTdc(addText("Amount", amount), 2) + "</tr>";
html += "</table>";
return html; return html;
} }
protected String addA(String Text, String Url) protected String addA(String Text, String Url)
{ {
return String.Format("<a href=\"{0}\">{1}</a>", Url, Text); return String.Format("<a href=\"{0}\" Class=\"btn btn-sm btn-success\">{1}</a>", Url, Text);
}
protected String addTd(String value)
{
return String.Format("<td align=\"center\">{0}</td>", value);
}
protected String addTdc(String value, int colspan)
{
return String.Format("<td colspan=\"{0}\" align=\"center\">{1}</td>", colspan, value);
}
protected String addTdr(String value, int rowspan)
{
return String.Format("<td rowspan=\"{0}\" align=\"center\">{1}</td>", rowspan, value);
} }
protected String addText(String name, String value) protected String addText(String name, String value)
{ {
return String.Format("<input type=\"text\" name=\"{0}\" value=\"{1}\" />", name, value); return String.Format("<input class=\"form-control\" type=\"text\" name=\"{0}\" value=\"{1}\" />", name, value);
} }
protected String addImg(String picname) protected String addImg(String picname)
{ {
return String.Format("<img alt=\"\" src=\"../Picture/{0}\" />", picname); return String.Format("<img src=\"../Picture/{0}\"alt=\"\" width=\"300\" height=\"300\"/>", picname);
} }
protected String addFile(String name) protected String addFile(String name)
{ {
return String.Format("<input type=\"file\" name=\"{0}\" style=\"width:150px\" value=\"请选择文件...\" />", name); return String.Format("<input type=\"file\" name=\"{0}\" class=\"form-control\" value=\"请选择文件...\" />", name);
}
protected String addDiv(String label, String value)
{
return String.Format("<div class=\"col-sm-" + value + "\">{0}</div>", label);
}
protected String addFormGroup(String label, String value)
{
String html = String.Format("<label class=\"col-sm-2 control-label\">{0}</label>", label);
html += String.Format("<div class=\"col-sm-10\">{0}</div>", value);
return html;
} }
protected void submit_Click(object sender, EventArgs e) protected void submit_Click(object sender, EventArgs e)
{ {
@ -159,7 +155,7 @@ namespace CitySunlight.Product
HttpPostedFile file = HttpUtils.getFilebyName("Picture"); HttpPostedFile file = HttpUtils.getFilebyName("Picture");
decimal price = HttpUtils.getElementsbyName("Price").Todecimal(); decimal price = HttpUtils.getElementsbyName("Price").Todecimal();
int amount = HttpUtils.getElementsbyName("Amount").ToInt(); int amount = HttpUtils.getElementsbyName("Amount").ToInt();
int classid = int.Parse(HttpUtils.getElementsbyName("Class")); int classid = HttpUtils.getElementsbyName("Class").ToInt();
//检查名称 //检查名称
if (name.Length == 0) if (name.Length == 0)
{ {
@ -225,10 +221,15 @@ namespace CitySunlight.Product
msg = "产品发布失败!"; msg = "产品发布失败!";
GoBack(); GoBack();
} }
} }
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, type.Equals("success") ? type : "danger", msg);
}
public void GoBack() public void GoBack()
{ {

View File

@ -1,5 +1,32 @@
<%@ Page Language="C#" MasterPageFile="~/Basic.Master" AutoEventWireup="true" CodeBehind="ProductShow.aspx.cs" Inherits="CitySunlight.Product.ProductShow" %> <%@ Page Language="C#" MasterPageFile="~/Basic.Master" AutoEventWireup="true" CodeBehind="ProductShow.aspx.cs" Inherits="CitySunlight.Product.ProductShow" %>
<asp:Content ContentPlaceHolderID="body" runat="server" ID="body"> <asp:Content ContentPlaceHolderID="body" runat="server" ID="body">
<%= ShowProduct() %> <div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">都市阳光销售平台 - 商品浏览</h3>
</div>
<div class="panel-body text-center">
<div class="text-center">
<div>
<div class="thumbnail">
<img src='<%="../Picture/"+ picurl %>'
alt="<%= name %>" width="300" height="300">
</div>
<div class="caption">
<h2><%= name %></h2>
<p>价格: <%= price %></p>
<p>库存: <%= amount %></p>
<p>分类: <%= classname %></p>
<p>
<a href="#" class="btn btn-primary" role="button">购买
</a>
<a href="#" class="btn btn-default" role="button">加入购物车
</a>
</p>
</div>
</div>
</div>
</div>
</div>
</asp:Content> </asp:Content>

View File

@ -9,54 +9,39 @@ namespace CitySunlight.Product
{ {
public partial class ProductShow : System.Web.UI.Page public partial class ProductShow : System.Web.UI.Page
{ {
public String type; public String type;
public String username; public String username;
public String name;
public String url;
public String picurl;
public String price;
public String amount;
public String user;
public String edit;
public String classname;
protected void Page_Load(object sender, EventArgs e) protected void Page_Load(object sender, EventArgs e)
{ {
if (Session["username"] != null) if (Session["username"] != null)
{ {
username = Session["username"].ToString(); username = Session["username"].ToString();
} }
}
protected String ShowProduct()
{
String html = "";
int id = HttpUtils.getQueryString("id").ToInt(); int id = HttpUtils.getQueryString("id").ToInt();
if (ProductManager.isExist(id)) GetProductInfo(id);
html = GetProductInfo(id);
else
html = "<span style=\"color:red\">当前ID的产品不存在或已被删除!</span>";
return html;
} }
private string GetProductInfo(int id) private void GetProductInfo(int id)
{ {
String html = ""; name = ProductManager.GetProductInfo(id, ProductManager.Info.ItemName);
String name = ProductManager.GetProductInfo(id, ProductManager.Info.ItemName); picurl = ProductManager.GetProductInfo(id, ProductManager.Info.PicUrl);
String url = ProductManager.GetProductInfo(id, ProductManager.Info.PicUrl); price = ProductManager.GetProductInfo(id, ProductManager.Info.Price);
String picurl = String.Format("<img src=\"../Picture/{0}\"alt=\"\" width=\"256\" height=\"256\"/>", url); amount = ProductManager.GetProductInfo(id, ProductManager.Info.Amount);
String price = ProductManager.GetProductInfo(id, ProductManager.Info.Price); user = ProductManager.GetProductInfo(id, ProductManager.Info.UserName);
String amount = ProductManager.GetProductInfo(id, ProductManager.Info.Amount); edit = "<a href=\"/Product/ProductEdit.aspx?id=" + id + "&type=edit\" >编辑</a>";
String user = ProductManager.GetProductInfo(id, ProductManager.Info.UserName); classname = ProductClassManager.getClassName(int.Parse(ProductManager.GetProductInfo(id, ProductManager.Info.Class)));
String edit = "<a href=\"/Product/ProductEdit.aspx?id=" + id + "&type=edit\" >编辑</a>";
String classname = ProductClassManager.getClassName(int.Parse(ProductManager.GetProductInfo(id, ProductManager.Info.Class)));
html += "<table align=\"center\">";
html += "<tr>";
html += HttpUtils.addTd(picurl, 3, 3);
html += HttpUtils.addTd(String.Format("名称: {0}", name));
html += user == username ? HttpUtils.addTd(edit) : "";
html += "<tr>";
html += HttpUtils.addTd(String.Format("分类: {0}", classname));
html += "</tr><tr>";
html += HttpUtils.addTd(String.Format("库存: {0}", amount));
html += "</tr><tr>";
html += HttpUtils.addTd();
html += HttpUtils.addTd(String.Format("价格: {0}", price));
html += HttpUtils.addTd();
html += HttpUtils.addTd("<a href=\"#\">购买</a>");
html += "</tr>";
html += "</table>";
return html;
} }
} }

View File

@ -10,7 +10,7 @@
</configSections> </configSections>
<system.web> <system.web>
<compilation debug="true" targetFramework="4.5" /> <compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" /> <httpRuntime targetFramework="4.5" executionTimeout="240" maxRequestLength="8192000" />
</system.web> </system.web>
<entityFramework> <entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">