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" %>
<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-heading">
@ -11,52 +11,19 @@
<div class="form-group">
<%= getAlert(msg) %>
</div>
<div class="form-group">
<button type="button" class="btn btn-primary btn-lg" style="text-shadow: black 5px 3px 3px;">
<span class="glyphicon glyphicon-user"></span>用户名
</button>
<input type="text" id="UserNameTx" name="UserNameTx" class="form-control" placeholder="请输入账号" />
<div>
<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="请输入账号" />
</div>
<div class="form-group">
<button type="button" class="btn btn-primary btn-lg" style="text-shadow: black 5px 3px 3px;"><span class="glyphicon glyphicon-th"></span>密 码</button>
<input type="password" id="PassWordTx" name="PassWordTx" class="form-control" placeholder="请输入密码" />
<div>
<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 class="form-group">
<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="login" Text="登录" Width="140" OnClick="login_Click" class="btn btn-lg btn-success" />
<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" CssClass="btn btn-lg btn-primary" />
<asp:Button runat="server" ID="login" Text="登录" Width="140" OnClick="login_Click" CssClass="btn btn-lg btn-success" />
</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>
</asp:Content>

View File

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

View File

@ -51,6 +51,13 @@ namespace CitySunlight
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">
<form id="formmain" runat="server">
<table class="table table-condensed">
<table class="table text-center">
<%= GetProductInfo() %>
</table>
</form>

View File

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

View File

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

View File

@ -20,7 +20,7 @@ namespace CitySunlight
html = "<li><a href=\"/Account/Login.aspx\" >登录</a></li>";
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=\"/Product/ProductEdit.aspx?type=create\" >发布</a></li>";
html += "<li><a href=\"/Admin.aspx\" >管理</a></li>";

View File

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

View File

@ -7,7 +7,7 @@
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<StartPageUrl>Account/Login.aspx</StartPageUrl>
<StartPageUrl>Main.aspx</StartPageUrl>
<StartAction>SpecificPage</StartAction>
<AspNetDebugging>True</AspNetDebugging>
<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>";
}
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>
/// 添加Td(带内容)
/// </summary>

View File

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

View File

@ -27,16 +27,8 @@ namespace CitySunlight
if (items.Rows.Count == 0)
return "<tr><td style=\"color:red\" colspan=\"8\" align=\"center\">数据库中未找到产品</td></tr>";
else
html += String.Format("<tr>{0}</tr>",
HttpUtils.addTd() +
HttpUtils.addTd("商品名称") +
HttpUtils.addTd("商品图片") +
HttpUtils.addTd("商品价格") +
HttpUtils.addTd("商品数量") +
HttpUtils.addTd("商品分类") +
HttpUtils.addTd("所属卖家") +
HttpUtils.addTd());
html += HttpUtils.addThs("商品名称", "商品图片", "商品价格", "商品库存", "商品分类", "所属卖家");
html += "<tbody class=\"text-center\">";
foreach (DataRow item in items.Rows)
{
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 classname = ProductClassManager.getClassName(int.Parse(ProductManager.GetProductInfo(item, ProductManager.Info.Class)));
html += String.Format("<tr>{0}</tr>",
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(""));
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));
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++)
{
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 += "</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;
}

View File

@ -1,74 +1,56 @@
<%@ Page Language="C#" MasterPageFile="~/Basic.Master" AutoEventWireup="true" CodeBehind="ProductClassEdit.aspx.cs" Inherits="CitySunlight.ProductClassEdit" %>
<asp:Content ContentPlaceHolderID="body" ID="body" runat="server">
<form id="productclasseditform" 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>
<form id="productclasseditform" class="form-horizontal" runat="server">
</tr>
</table>
<div class="panel panel-info">
<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>
</asp:Content>

View File

@ -71,5 +71,13 @@ namespace CitySunlight
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";
//<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>
/// 获得分类列表的Html代码,默认选择第一个
/// </summary>
@ -32,7 +48,7 @@ namespace CitySunlight
/// <returns>分类列表的Html代码</returns>
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>";
DataTable option = sql.ExecuteDataTable("select * from " + tbname, CommandType.Text);
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" %>
<asp:Content runat="server" ID="body" ContentPlaceHolderID="body">
<form id="productedit" runat="server" enctype="multipart/form-data">
<table class="table table-condensed">
<tr>
<td>
<span style="color: red"><%= msg %></span>
</tr>
</table>
<%= CreateEditForm() %>
<table class="table table-condensed">
<tr>
<td>
<asp:Button ID="submit" runat="server" Text="提交" OnClick="submit_Click"/></td>
</tr>
</table>
<form id="productedit" class="form-horizontal" runat="server" enctype="multipart/form-data">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">都市阳光销售平台 - 商品编辑</h3>
</div>
<div class="panel-body">
<div class="form-group">
<%= getAlert(msg) %>
</div>
<%= CreateEditForm() %>
<div class="form-group text-center">
<asp:Button ID="submit" runat="server" Text="提交" OnClick="submit_Click" CssClass="btn btn-lg btn-success" />
</div>
</div>
</div>
</form>
</asp:Content>

View File

@ -71,7 +71,7 @@ namespace CitySunlight.Product
{
String name = "";
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 amount = "";
String classid = "";
@ -79,7 +79,7 @@ namespace CitySunlight.Product
{
name = ProductManager.GetProductInfo(id, ProductManager.Info.ItemName);
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);
amount = ProductManager.GetProductInfo(id, ProductManager.Info.Amount);
classid = ProductManager.GetProductInfo(id, ProductManager.Info.Class);
@ -92,44 +92,40 @@ namespace CitySunlight.Product
}
String html = "";
html += "<table align=\"center\">";
html += "<tr>" + addTdc("<h1>商品编辑</h1>", 3) + "</tr>";
html += "<tr>" + addTd("商品名称") + addTdc(addText("Name", name), 2) + addTd("<input type=\"hidden\" name=\"iid\" value=\"" + id + "\"/>") + "</tr>";
html += "<tr>" + addTd("商品分类") + addTd(ProductClassManager.getOptionString("Class", classid)) + addTd(addA("编辑", "ProductClassEdit.aspx")) + "</tr>";
html += "<tr>" + addTdr("商品图片", 2) + addTdc(picurl, 2) + "</tr>";
html += "<tr>" + addTdc(addFile("Picture"), 2) + "</tr>";
html += "<tr>" + addTd("商品价格") + addTdc(addText("Price", price), 2) + "</tr>";
html += "<tr>" + addTd("库存数量") + addTdc(addText("Amount", amount), 2) + "</tr>";
html += "</table>";
html += addFormGroup("商品名称", addDiv(addText("Name", name), "8"));
html += addFormGroup("商品分类", addDiv(ProductClassManager.getOptionString("Class", classid), "8") + addDiv(addA("编辑", "ProductClassEdit.aspx"), "2"));
html += addFormGroup("商品图片", addDiv(picurl, "8"));
html += addFormGroup("上产图片", addDiv(addFile("Picture"), "8"));
html += addFormGroup("商品价格", addDiv(addText("Price", price), "8"));
html += addFormGroup("库存数量", addDiv(addText("Amount", amount), "8"));
return html;
}
protected String addA(String Text, String Url)
{
return String.Format("<a href=\"{0}\">{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);
return String.Format("<a href=\"{0}\" Class=\"btn btn-sm btn-success\">{1}</a>", Url, Text);
}
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)
{
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)
{
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)
{
@ -159,7 +155,7 @@ namespace CitySunlight.Product
HttpPostedFile file = HttpUtils.getFilebyName("Picture");
decimal price = HttpUtils.getElementsbyName("Price").Todecimal();
int amount = HttpUtils.getElementsbyName("Amount").ToInt();
int classid = int.Parse(HttpUtils.getElementsbyName("Class"));
int classid = HttpUtils.getElementsbyName("Class").ToInt();
//检查名称
if (name.Length == 0)
{
@ -225,10 +221,15 @@ namespace CitySunlight.Product
msg = "产品发布失败!";
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()
{

View File

@ -1,5 +1,32 @@
<%@ Page Language="C#" MasterPageFile="~/Basic.Master" AutoEventWireup="true" CodeBehind="ProductShow.aspx.cs" Inherits="CitySunlight.Product.ProductShow" %>
<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>

View File

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

View File

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