5.1.1欄目部分
增加欄目(addLanMu.aspx):
<html?xmlns="http://www.w3.org/1999/xhtml">
<head?runat="server">
????<title></title>
????<link?rel="stylesheet"?type="text/css"?href="../css/style.css"?/>
????<style?type="text/css">
????body{ background-image:url('backgroundimgs/bg003.jpg');background-size: cover;}
????????#submitLanMu,#backlanmu
????????{
????????????color:White;
????????????width:100px;
????????????height: 35px;
????????outline: none;
????????margin:10px?50px;
????????border: none;
????????
????????line-height: 35px;
????????border-radius: 50px;
????????position: relative;
????????border: rgba(255,255,255,0.2)?2px?solid?;
????????color: var(--color);
????????????-webkit-transition: 0.25s;
????????????transition: 0.25s;
??????????}
????????#submitLanMu:hover,#submitLanMu:focus{box-shadow: inset?0?0?0?2em?var(--hover);}
????????#submitLanMu{--color: #a972cb;--hover: #cb72aa;}
????????#backlanmu:hover,#backlanmu:focus?{box-shadow: inset?-3.5em?0?0?0?var(--hover),?inset?3.5em?0?0?0?var(--hover);}
????????#backlanmu{--color: #ff7f82; --hover: #ffdc7f;}
????</style>
</head>
<body>
????<form?id="form1"?runat="server">
????<div>
?????????<div?id="addLanMuDiv">
????????????<div?style=" text-align:center">增加欄目</div>
????????????<div?class="addUserClass">
????????????????<asp:Label?ID="Label1"?Text="欄目名:"?runat="server"?/>
????????????????<asp:TextBox?ID="addLanMuName"?runat="server"?style="width:150px; ?border:0px"></asp:TextBox>
????????????</div>
????????????<br?/>
????????????<asp:Button?Text="確定"?runat="server"?ID="submitLanMu"?
????????????????οnclick="submitUser_Click"?/>
?????????????<asp:Button?ID="backlanmu"?runat="server"?οnclick="back_Click"?Text="返回"?/>
????????</div>
????</div>
????</form>
</body>
</html>
?
編輯欄目(editLanMu.aspx):
<html?xmlns="http://www.w3.org/1999/xhtml">
<head?runat="server">
????<title></title>
????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>
????<style?type="text/css">
?????????body{ background-image:url('backgroundimgs/bg003.jpg');background-size: cover;}
?????????#submitEditLanMu,#backtolanmu
?????????{
?????????????margin: 30px?20px;
??????????????padding: 15px?20px;
??????????????border-radius: 10px;
??????????????border: 2px?solid;
??????????????font: 16px?'Open Sans',?sans-serif;
??????????????text-transform: uppercase;
??????????????background: none;
??????????????outline: none;
??????????????cursor: pointer;
??????????????-webkit-transition: all?.5s;
??????????????transition: all?.5s;
??????????}
??????????#submitEditLanMu,#backtolanmu?{color: #CEFFF1;border-color: #CEFFF1; overflow: hidden; position: relative;}
??????????#submitEditLanMu:hover,#backtolanmu:hover?{color: #27323A;}
????</style>
</head>
<body>
????<form?id="form1"?runat="server">
????<div>
?????????<div?id="editLanMuDiv"?style=" height:150px; border:0">
????????????<div?style=" text-align:center; color:White">編輯欄目</div>
????????????<div?class="addUserClass">
????????????????<asp:Label?ID="Label1"?Text="欄目名:"?runat="server"?/>
????????????????<asp:TextBox?ID="editLanMu"?runat="server"?style="width:150px; ?border:0px"></asp:TextBox>
????????????</div>
????????????<asp:Button?Text="確定"?runat="server"?ID="submitEditLanMu"?οnclick="submitEditLanMu_Click"?/>
????????????<asp:Button?ID="backtolanmu"?runat="server"?Text="返回"?οnclick="back_Click"?/>
????????</div>
????</div>
????</form>
</body>
</html>
?
欄目管理(lanmuManage.aspx):
<html?xmlns="http://www.w3.org/1999/xhtml">
<head?runat="server">
????<title></title>
????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>
????<style?type="text/css">
????????body{ background-image:url('backgroundimgs/bg003.jpg');background-size: cover;}
????????#addLanMu,#backtomanage
????????{
????????????color:White;
????????????width:100px;
????????????height: 35px;
????????outline: none;
????????margin:10px?50px;
????????border: none;
????????
????????line-height: 35px;
????????border-radius: 50px;
????????position: relative;
????????border: rgba(255,255,255,0.2)?2px?solid?;
????????color: var(--color);
????????????-webkit-transition: 0.25s;
????????????transition: 0.25s;
????????}
????????#addLanMu?{box-shadow: 0.3em?0.3em?0?0?var(--color),?inset?0.3em?0.3em?0?0?var(--color);}
????????#addLanMu:hover, #addLanMu:focus?{box-shadow: 0?0?0?0?var(--hover),?inset?6em?3.5em?0?0?var(--hover);}
????????#addLanMu?{--color: #19bc8b;--hover: #1973bc;}
????????#backtomanage:hover,#backtomanage:focus{box-shadow: inset?0?-3.25em?0?0?var(--hover);}
????????#backtomanage{ ?--color: #000000; ?--hover: #94e458;}
????</style>
</head>
<body>
????<form?id="form1"?runat="server">
????????<div?id="addLanMuHeader"?style=" height:50px; border:0">
????????????<div?style="float:left">
????????????????<asp:Label?ID="bigUser"?runat="server"></asp:Label>
????????????</div>
????????????<div?style="float:right">
????????????????<asp:Button?ID="addLanMu"?runat="server"?Text="添加欄目"?οnclick="addLanMu_Click"?/>
????????????</div>
????????</div>
????????<div?id="showLanMu">
????????????<div>
????????????????<asp:GridView?ID="gvLanMu"?runat="server"?AutoGenerateColumns="False"?
????????????????????Width="500px"?BorderStyle="None">
????????????????????<Columns>
????????????????????????<asp:BoundField?DataField="lanMuId"?HeaderText="欄目ID">
????????????????????????<ItemStyle?HorizontalAlign="Center"?Width="100px"?BorderStyle="None"?/>
????????????????????????</asp:BoundField>
????????????????????????<asp:BoundField?DataField="lanMuName"?HeaderText="欄目名稱">
????????????????????????<ItemStyle?HorizontalAlign="Center"?Width="100px"?BorderStyle="None"?/>
????????????????????????</asp:BoundField>
????????????????????????<asp:TemplateField?HeaderText="修改">
????????????????????????????<ItemTemplate>
????????????????????????????????<asp:LinkButton?ID="editLanMu"?runat="server"?οnclick="editLanMu_Click">編輯欄目</asp:LinkButton>
??????????????????????????????????
????????????????????????????????<asp:LinkButton?ID="delLanMu"?runat="server"?οnclick="delLanMu_Click">刪除</asp:LinkButton>
????????????????????????????</ItemTemplate>
????????????????????????????<ItemStyle?HorizontalAlign="Center"?Width="150px"?BorderStyle="None"?/>
????????????????????????</asp:TemplateField>
????????????????????????<asp:TemplateField?HeaderText="管理">
????????????????????????????<ItemTemplate>
????????????????????????????????<asp:LinkButton?ID="setManage"?runat="server"?οnclick="setManage_Click">設置管理員</asp:LinkButton>
????????????????????????????</ItemTemplate>
????????????????????????????<ItemStyle?HorizontalAlign="Center"?Width="100px"?BorderStyle="None"?/>
????????????????????????</asp:TemplateField>
????????????????????</Columns>
????????????????</asp:GridView>
????????????</div>
????</div>
????????<asp:Button?ID="backtomanage"?runat="server"?οnclick="backtomanage_Click"?Text="返回"?style=" float:right; position:absolute; right:110px"?/>
????</form>
????<div?id="backfooter">
????????<div?>
????????????????版權所有:@ 2018 姚鋒 地址:江蘇省常熟市南三環路99號 <br?/>
????????????????聯系電話:188xxxxxxxx 郵政編碼:215500 <br?/>
????????????[<a?href="yf/index.aspx"?target="_blank">后臺管理</a>]
????????</div>
????</div>
</body>
</html>
5.1.2用戶部分
添加用戶(addUsers.aspx):
<html?xmlns="http://www.w3.org/1999/xhtml">
<head?runat="server">
????<title></title>
????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>
????<style?type="text/css">
???????html,body?{padding:0;margin:0}
???????canvas?{ display:block}
????</style>
</head>
<body>
????<form?id="form1"?runat="server">
????<div>
????????<div?id="addUserDiv">
????????????<div?style=" text-align:center; color:White; ">增加用戶</div>
????????????<div?class="addUserClass">
????????????????<img?src="loginimages/user_icon_copy.png"?/>
????????????????<asp:TextBox?ID="addUserName"?runat="server"?style="width:150px; ?border:0px; color: White;"></asp:TextBox>
????????????</div>
????????????<br?/>
????????????<div?class="addUserClass">
????????????????<img?src="loginimages/lock_icon_copy.png"?/>
?????????????????<asp:TextBox?ID="addUserPwd"?runat="server"?style="width:150px; border:0px; color: White;"></asp:TextBox>
????????????</div>
????????????<div?class="mb2">
????????????????<asp:Button??Text="確定¨"?runat="server"?ID="submitUser"?οnclick="submitUser_Click"?/>
????????????</div>
????????????<div?class="mb2">
????????????????<asp:Button?ID="back"?runat="server"?οnclick="back_Click"?Text="返回"?/>
????????????</div>
????????</div>
????</div>
????</form>
????<canvas></canvas>
????<script?src="loginJavascript/hailang.js"?type="text/javascript"></script>
</body>
</html>
編輯用戶(editUsers.aspx):
<html?xmlns="http://www.w3.org/1999/xhtml">
<head?runat="server">
????<title></title>
????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>
????<style?type="text/css">
?????????body{ background-image:url('backgroundimgs/bg003.jpg');background-size: cover;}
?????????#backto,#submitEditUser
?????????{
??????????????margin: 30px?20px;
??????????????padding: 15px?20px;
??????????????border-radius: 10px;
??????????????border: 2px?solid;
??????????????font: 16px?'Open Sans',?sans-serif;
??????????????text-transform: uppercase;
??????????????background: none;
??????????????outline: none;
??????????????cursor: pointer;
??????????????-webkit-transition: all?.5s;
??????????????transition: all?.5s;
??????????}
??????????#submitEditUser?{
??????????????color: #A3F7BF;
??????????????border-color: #A3F7BF;
??????????????background: -webkit-linear-gradient(left, #a3f7bf, #a3f7bf)?no-repeat;
??????????????background: linear-gradient(to right, #a3f7bf, #a3f7bf)?no-repeat;
??????????????background-size: 0%?100%;
????????????}
??????????#submitEditUser:hover?{background-size: 100%?100%; color: #27323A;}
??????????#backto?{color: #E4F68F;
??????????????border-color: #E4F68F;
??????????????background: -webkit-linear-gradient(left, #e4f68f, #e4f68f)?no-repeat;
??????????????background: linear-gradient(to right, #e4f68f, #e4f68f)?no-repeat;
??????????????background-size: 100%?0%;
????????????}
??????????#backto:hover?{background-size: 100%?100%; color: #27323A;}
????</style>
</head>
<body>
????<form?id="form1"?runat="server">
????<div>
?????????<div?id="editUserDiv">
????????????<div?style=" text-align:center; color:White;">編輯用戶</div>
????????????<div?class="addUserClass">
????????????????<img?src="loginimages/user_icon_copy.png"?/>
????????????????<asp:TextBox?ID="editUserName"?runat="server"?style="width:150px; ?border:0px"></asp:TextBox>
????????????</div>
????????????<br?/>
????????????<div?class="addUserClass">
????????????????<img?src="loginimages/lock_icon_copy.png"?/>
????????????????<asp:TextBox?ID="editUserPwd"?runat="server"?style="width:150px; ?border:0px"></asp:TextBox>
????????????</div>
????????????<asp:Button?Text="確定¨"?runat="server"?ID="submitEditUser"?οnclick="submitEditUser_Click"/>
????????????<asp:Button?ID="backto"?runat="server"?οnclick="back_Click"?Text="返回"?/>
????????</div>
????</div>
????</form>
</body>
</html>
管理用戶(userManage.aspx):
<html?xmlns="http://www.w3.org/1999/xhtml">
<head?runat="server">
????<title>用戶管理系統</title>
????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>
????<style?type="text/css">
????????body{ background-image:url('backgroundimgs/bg003.jpg'); background-size: cover;}
????????#Button1
????????{
???????????color:White;
????????????width:100px;
????????????height: 35px;
????????outline: none;
????????margin:10px?50px;
????????border: none;
????????
????????line-height: 35px;
????????border-radius: 50px;
????????position: relative;
????????border: rgba(255,255,255,0.2)?2px?solid?;
????????color: var(--color);
????????????-webkit-transition: 0.25s;
????????????transition: 0.25s;
????????}
????????#Button1:hover,#Button1:focus?{box-shadow: inset?6.5em?0?0?0?var(--hover);}
????????#Button1?{--color: #8fc866;--hover: #66c887;}
????????#back:hover{ color:Black; ">????</style>
</head>
<body>
????<form?id="form1"?runat="server">
????<div>
????????<div?id="addUserHeader"?style=" height:50px; border:0">
????????????<div?style="float:left">
????????????????<asp:Label?ID="bigUser"?runat="server"?style=" color:White;"></asp:Label>
????????????</div>
????????????<div?style="float:right">
????????????????<asp:Button?ID="Button1"?runat="server"?οnclick="Button1_Click"?Text="添加用戶"?/>
????????????</div>
????????</div>
????</div>
????<div?id="showUser">
????????????<asp:GridView?ID="gvUser"?runat="server"?AutoGenerateColumns="False"?
????????Width="1000px"?BorderStyle="None"??>
????????<Columns>
????????????<asp:BoundField?DataField="uid"?HeaderText="用戶編號">
????????????<ItemStyle?HorizontalAlign="Center"?Width="100px"?BorderStyle="None"?/>
????????????</asp:BoundField>
????????????<asp:HyperLinkField?DataNavigateUrlFields="uid"?DataTextField="userName"?
????????????????HeaderText="用戶姓名">
????????????<ItemStyle?HorizontalAlign="Center"?Width="100px"?BorderStyle="None"?/>
????????????</asp:HyperLinkField>
????????????<asp:BoundField?DataField="passWord"?HeaderText="用戶密碼">
????????????<ItemStyle?HorizontalAlign="Center"?Width="100px"?BorderStyle="None"?/>
????????????</asp:BoundField>
????????????<asp:TemplateField?HeaderText="修改">
????????????????<ItemTemplate>??
????????????????????<asp:LinkButton?ID="editUser"?runat="server"?οnclick="editUser_Click">編輯用戶</asp:LinkButton>
??????????????????????
????????????????????<asp:LinkButton?ID="deleteUser"?runat="server"?οnclick="deleteUser_Click">刪除</asp:LinkButton>
????????????????</ItemTemplate>
????????????????<ItemStyle?Width="200px"?HorizontalAlign="Center"?BorderStyle="None"?/>
????????????</asp:TemplateField>
????????</Columns>
????</asp:GridView>
????</div>
????<asp:Button?ID="back"?runat="server"?οnclick="back_Click"?Text="返回"?style=" position:absolute; right:50px;"/>
????</form>
????<div?id="backfooter">
????????<div?>
????????????????版權所有:@ 2018 姚鋒 地址:江蘇省常熟市南三環路99號 <br?/>
????????????????聯系電話:188xxxxxxxx 郵政編碼:215500 <br?/>
????????????[<a?href="yf/index.aspx"?target="_blank">后臺管理</a>]
????????</div>
????</div>
</body>
</html>
5.1.3新聞部分
添加新聞(addNews.aspx):
<html?xmlns="http://www.w3.org/1999/xhtml">
<head?runat="server">
????<title>發布信息頁面</title>
????<style?type="text/css">
?????????body{ background-image:url('backgroundimgs/bg003.jpg');background-size: cover;}
????</style>
????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>
?????<link?rel="stylesheet"?href="kde/themes/default/default.css"?/>
<link?rel="stylesheet"?href="kde/plugins/code/prettify.css"?/>
<script?charset="utf-8"?src="kde/kindeditor.js"></script>
<script?charset="utf-8"?src="kde/lang/zh_CN.js"></script>
<script?charset="utf-8"?src="kde/plugins/code/prettify.js"></script>
<script>
????KindEditor.ready(function?(K) {
????????var?editor1 = K.create('#content1', {
????????????cssPath: 'kde/plugins/code/prettify.css',
????????????uploadJson: 'kde/upload_json.ashx',
????????????fileManagerJson: 'kde/file_manager_json.ashx',
????????????allowFileManager: true,
????????????afterCreate: function?() {
????????????????var?self = this;
????????????????K.ctrl(document, 13, function?() {
????????????????????self.sync();
????????????????????K('form[name=example]')[0].submit();
????????????????});
????????????????K.ctrl(self.edit.doc, 13, function?() {
????????????????????self.sync();
????????????????????K('form[name=example]')[0].submit();
????????????????});
????????????}
????????});
????????prettyPrint();
????});
</script>
</head>
<body>
????<form?id="example"?runat="server">
????<div?id="box">
????????<div?style="width:1000px;margin:10px 0;border:1px #ccc solid;">標題:<asp:TextBox?
????????????????ID="txtTitle"?runat="server"></asp:TextBox>
????????</div>
????????<div?style="width:1000px;margin:10px 0;border:1px #ccc solid;">欄目:<asp:DropDownList?
????????????????ID="ddlLanMu"?runat="server">
????????????</asp:DropDownList>
??????????主頁圖片:<asp:TextBox?ID="txtImgUrl"?runat="server"?Width="495px"></asp:TextBox>
????????</div>
????????<div?style="width:1000px;margin:10px 0;border:1px #ccc solid;">
????????????<textarea?id="content1"?cols="100"?rows="8"?style="width:1000px;height:500px;visibility:hidden;"?runat="server"></textarea>
????????????<br?/>
????????????<asp:Button?ID="btnBack"?runat="server"?οnclick="btnBack_Click"?Text="返回"?/>
?<asp:Button?ID="btnSubmit"?runat="server"?Text="提交內容"?
????????????????οnclick="btnSubmit_Click"?/>?(提交快捷鍵: Ctrl + Enter)
????????</div>
????</div>
????</form>
</body>
</html>
編輯新聞(editNews.aspx):
<html?xmlns="http://www.w3.org/1999/xhtml">
<head?id="Head1"?runat="server">
????<title>編輯新聞頁面</title>
????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>
?????<link?rel="stylesheet"?href="kde/themes/default/default.css"?/>
<link?rel="stylesheet"?href="kde/plugins/code/prettify.css"?/>
<script?charset="utf-8"?src="kde/kindeditor.js"></script>
<script?charset="utf-8"?src="kde/lang/zh_CN.js"></script>
<script?charset="utf-8"?src="kde/plugins/code/prettify.js"></script>
<script>
????KindEditor.ready(function?(K) {
????????var?editor1 = K.create('#content1', {
????????????cssPath: 'kde/plugins/code/prettify.css',
????????????uploadJson: 'kde/upload_json.ashx',
????????????fileManagerJson: 'kde/file_manager_json.ashx',
????????????allowFileManager: true,
????????????afterCreate: function?() {
????????????????var?self = this;
????????????????K.ctrl(document, 13, function?() {
????????????????????self.sync();
????????????????????K('form[name=example]')[0].submit();
????????????????});
????????????????K.ctrl(self.edit.doc, 13, function?() {
????????????????????self.sync();
????????????????????K('form[name=example]')[0].submit();
????????????????});
????????????}
????????});
????????prettyPrint();
????});
</script>
</head>
<body>
????<form?id="example"?runat="server">
????<div?id="box">
????????<div?style="width:1000px;margin:10px 0;border:1px #ccc solid;">標題:<asp:TextBox?
????????????????ID="txtTitle"?runat="server"></asp:TextBox>
????????</div>
????????<div?style="width:1000px;margin:10px 0;border:1px #ccc solid;">欄目:<asp:DropDownList?
????????????????ID="ddlLanMu"?runat="server">
????????????</asp:DropDownList>
??????????主頁圖片:<asp:TextBox?ID="txtImgUrl"?runat="server"?Width="475px"></asp:TextBox>
????????</div>
????????<div?style="width:1000px;margin:10px 0;border:1px #ccc solid;">
????????????<textarea?id="content1"?cols="100"?rows="8"?style="width:1000px;height:500px;visibility:hidden;"?runat="server"></textarea>
????????????<br?/>
????????????<asp:Button?ID="btnCancel"?runat="server"?οnclick="btnCancel_Click"?Text="返回"?/>
?<asp:Button?ID="btnEdit"?runat="server"?Text="提交內容"?οnclick="btnEdit_Click"?/>?(提交快捷鍵: Ctrl + Enter)
????????</div>
????</div>
????</form>
</body>
</html>
?
給新聞設置管理員:(setManage.aspx)
<html?xmlns="http://www.w3.org/1999/xhtml">
<head?runat="server">
????<title></title>
????<link?href="../css/style.css"?rel="stylesheet"?type="text/css"?/>
????<style?type="text/css">
????????????body{ background-image:url('backgroundimgs/bg003.jpg');}
????????????#setManage,#backTo
????????????{
??????????????margin?: 30px?20px;
??????????????padding: 15px?20px;
??????????????border-radius: 10px;
??????????????border: 2px?solid;
??????????????font: 16px?'Open Sans',?sans-serif;
??????????????text-transform: uppercase;
??????????????background: none;
??????????????outline: none;
??????????????cursor: pointer;
??????????????-webkit-transition: all?.5s;
??????????????transition: all?.5s;}
???????????????#setManage??{color: #A3F7BF;
??????????????border-color: #A3F7BF;
??????????????background: -webkit-linear-gradient(left, #a3f7bf, #a3f7bf)?no-repeat;
??????????????background: linear-gradient(to right, #a3f7bf, #a3f7bf)?no-repeat;
??????????????background-size: 0%?100%;}
?????????????#setManage:hover?{background-size: 100%?100%; color: #27323A;}
?????????????#backTo{color: #E4F68F;
??????????????border-color: #E4F68F;
??????????????background: -webkit-linear-gradient(left, #e4f68f, #e4f68f)?no-repeat;
??????????????background: linear-gradient(to right, #e4f68f, #e4f68f)?no-repeat;
??????????????background-size: 100%?0%;}
?????????????#backTo:hover,#backTo:focus?{background-size: 100%?100%; color: #27323A;} ???????????
????</style>
</head>
<body>
????<form?id="form1"?runat="server">
????<div>
????????<div?id="manageList">
?????????????<div?style=" text-align:center; color:White;">設置管理員</div></br>
?????????????<asp:DropDownList?ID="userList"?runat="server"?style="width:100px; height:30px ">
?????????????</asp:DropDownList>
?????????????</br>
?????????????<asp:Button?ID="setManage"?runat="server"?οnclick="setManage_Click"?Text="確認"?/>
?????????????<asp:Button?ID="backTo"?runat="server"?οnclick="back_Click"?Text="返回"?/>
????????</div>
????</div>
????</form>
????<div?id="backfooter">
????????<div?>
????????????????版權所有:@ 2018 姚鋒 地址:江蘇省常熟市南三環路99號 <br?/>
????????????????聯系電話:188xxxxxxxx 郵政編碼:215500 <br?/>
????????????[<a?href="yf/index.aspx"?target="_blank">后臺管理</a>]
????????</div>
????</div>
</body>
</html>
?
新聞搜索(Search.aspx):
<html?xmlns="http://www.w3.org/1999/xhtml">
<head?runat="server">
????<title></title>
????<link?href="css/style.css"?rel="stylesheet"?type="text/css"?/>
</head>
<body>
????<form?id="form1"?runat="server">
????<div>
????????<div?id="box">
????????<div?id="header"></div>
????????<div?class="splitDiv"></div>
????????<div?id="showLanmu">
?????????????<%=Lanmu.getLanMu()%>
????????</div>
????????<div?class="splitDiv"></div>
????????<div?id="main">
????????????<div?id="left"?style="width:400px;">
????????????????
????????????????<asp:GridView?ID="SearchHotNews"?runat="server"?AutoGenerateColumns="False"?
????????????????????ShowHeader="False"?BorderStyle="None"?CellPadding="0"?GridLines?="None"?
????????????????????Width="400px">
????????????????????<Columns>
????????????????????????<asp:HyperLinkField?
????????????????????????????DataNavigateUrlFormatString="showNews.aspx?id={0}"?DataTextField="title"?
????????????????????????????DataNavigateUrlFields="newid"?Target="_blank">
????????????????????????<ItemStyle?Width="420px"?/>
????????????????????????</asp:HyperLinkField>
????????????????????????<asp:BoundField?DataField="hitCount"?HeaderText="點擊量">
????????????????????????<ItemStyle?HorizontalAlign="Center"?Width="50px"?/>
????????????????????????</asp:BoundField>
????????????????????????<asp:BoundField?DataField="addTime"?DataFormatString="{0:[yy-MM-dd]}"?
????????????????????????????HeaderText="發布時間?">
????????????????????????<ItemStyle?Width="120px"?HorizontalAlign="Center"?/>
????????????????????????</asp:BoundField>
????????????????????</Columns>
????????????????</asp:GridView>
????????????</div>
????????????<div?id="right"?style="width:580px;">
????????????????<asp:GridView?ID="SearchNews"?runat="server"?AutoGenerateColumns="False"?
????????????????????ShowHeader="False"?BorderStyle="None"?CellPadding="0"?GridLines?="None"?
????????????????????Width="580px">
????????????????????<Columns>
????????????????????????<asp:HyperLinkField?
????????????????????????????DataNavigateUrlFormatString="showNews.aspx?id={0}"?DataTextField="title"?
????????????????????????????DataNavigateUrlFields="newid"?Target="_blank">
????????????????????????<ItemStyle?Width="420px"?/>
????????????????????????</asp:HyperLinkField>
????????????????????????<asp:BoundField?DataField="addTime"?DataFormatString="{0:[yy-MM-dd]}">
????????????????????????<ItemStyle?Width="100px"?HorizontalAlign="Center"?/>
????????????????????????</asp:BoundField>
????????????????????</Columns>
????????????????</asp:GridView>
????????????</div>
????????<div?class="splitDiv"></div>
????????<div?id="divLinks">友情鏈接</div>
????????<span?id="QLinks">
??????????????<ul?style=" border:1px solid #ccc; ?margin-top:10px; height:70px">
????????????????<li><a?href='http://rsc.cslg.cn/rsc/'?target='_blank'><img?src="yf/backgroundimgs/rsc.jpg"??border='0'?width='106px'?height='46px'></a></li>
????????????????<li><a?href='http://www.hep.com.cn/service/xuanshu'?target='_blank'><img?src='yf/backgroundimgs/gdjycbs.jpg'?border='0'?width='106px'?height='46px'></a></li>
????????????????<li><a?href='http://kjc.cslg.edu.cn/'?target='_blank'><img?src='yf/backgroundimgs/kxjs.jpg'?border='0'?width='106px'?height='46px'></a></li>
????????????????<li><a?href='http://jwc.cslg.cn/jwc/'?target='_blank'><img?src='yf/backgroundimgs/jwc.jpg'?border='0'?width='106px'?height='46px'></a></li>
????????????????<li><a?href='http://www.icourses.cn/'?target='_blank'><img?src='yf/backgroundimgs/akc.jpg'?border='0'?width='106px'?height='46px'></a></li>
????????????????<li><a?href='http://ctl.nju.edu.cn/yanjiuhui/'?target='_blank'><img?src='yf/backgroundimgs/jsgx.jpg'?border='0'?width='106px'?height='46px'></a></li>
??????????????</ul>
?????????</span>
?????????<div?class="splitDiv"></div>
????????<a?href="#top"><img?src="images/backTop.png"?alt="Alternate Text"?id="backTop"?title="回到頂部"?/></a>
????????<div?id="footer">
????????<div?>
????????????????版權所有:@ 2018 姚鋒 地址:江蘇省常熟市南三環路99號 <br?/>
????????????????聯系電話:188xxxxxxxx 郵政編括碼:215500 <br?/>
????????????[<a?href="yf/index.aspx"?target="_blank">后臺管理</a>]
????????</div>
????</div>
????</form>
</body>
</html>
?
菜單欄目新聞(showlist.aspx):
<html?xmlns="http://www.w3.org/1999/xhtml">
<head?runat="server">
????<title></title>
????<link?href="css/style.css"?rel="stylesheet"?type="text/css"?/>
????<style?type="text/css">
????????#sure{color:White;
????????????width:100px;
????????????height: 43px;
????????outline: none;
????????border: none;
????????line-height: 43px;
????????border-radius: 50px;
????????position: relative;
????????border: rgba(255,255,255,0.2)?2px?solid?;
????????color: var(--color);
????????????-webkit-transition: 0.25s;
????????????transition: 0.25s;
????????????}
????????#sure:hover,#sure:focus?{-webkit-animation: pulse?1s;animation: pulse?1s;box-shadow: 0?0?0?2em?rgba(255, 255, 255, 0);}
????????#sure?{--color: #ef6eae;--hover: #ef8f6e;}
????????@-webkit-keyframes?pulse {0% {box-shadow: 0?0?0?0?var(--hover);}}
????????@keyframes?pulse {0% {box-shadow: 0?0?0?0?var(--hover);}}
??????</style>
</head>
<body>
????<form?id="form1"?runat="server">
????<div>
????????<div?id="box">
????????<div?id="header"></div>
????????<div?class="splitDiv"></div>
????????<div?id="showLanmu">
?????????????<%=Lanmu.getLanMu()%>
?????????????<asp:Button?ID="sure"?runat="server"?Text="搜索"?/>
?????????????<asp:TextBox?ID="Search"?runat="server"??style="width:200px; border:1px solid ?black; border-radius: 50px; text-align:center"></asp:TextBox>
????????</div>
????????<div?class="splitDiv"></div>
????????<div?id="main">
????????????<div?id="left"?style="width:400px; ">
????????????????<asp:GridView?ID="gvHotNews"?runat="server"?AutoGenerateColumns="False"?
????????????????????ShowHeader="False"?BorderStyle="None"?CellPadding="0"?GridLines?="None"?
????????????????????Width="400px">
????????????????????<Columns>
????????????????????????<asp:HyperLinkField?
????????????????????????????DataNavigateUrlFormatString="showNews.aspx?id={0}"?DataTextField="title"?
????????????????????????????DataNavigateUrlFields="newid"?Target="_blank">
????????????????????????<ItemStyle?Width="420px"?/>
????????????????????????</asp:HyperLinkField>
????????????????????????<asp:BoundField?DataField="hitCount"?HeaderText="點擊量">
????????????????????????<ItemStyle?HorizontalAlign="Center"?Width="50px"?/>
????????????????????????</asp:BoundField>
????????????????????????<asp:BoundField?DataField="addTime"?DataFormatString="{0:[yy-MM-dd]}"?
????????????????????????????HeaderText="發布時間?">
????????????????????????<ItemStyle?Width="120px"?HorizontalAlign="Center"?/>
????????????????????????</asp:BoundField>
????????????????????</Columns>
????????????????</asp:GridView>
????????????</div>
????????????<div?id="right"?style="width:580px; ">
????????????????<asp:GridView?ID="gvNews"?runat="server"?AutoGenerateColumns="False"?
????????????????????ShowHeader="False"?BorderStyle="None"?CellPadding="0"?GridLines?="None"?
????????????????????Width="580px">
????????????????????<Columns>
????????????????????????<asp:HyperLinkField?
????????????????????????????DataNavigateUrlFormatString="showNews.aspx?id={0}"?DataTextField="title"?
????????????????????????????DataNavigateUrlFields="newid"?Target="_blank">
????????????????????????<ItemStyle?Width="420px"?/>
????????????????????????</asp:HyperLinkField>
????????????????????????<asp:BoundField?DataField="addTime"?DataFormatString="{0:[yy-MM-dd]}">
????????????????????????<ItemStyle?Width="100px"?HorizontalAlign="Center"?/>
????????????????????????</asp:BoundField>
????????????????????</Columns>
????????????????</asp:GridView>
????????????</div>
????????<div?class="splitDiv"></div>
????????<div?id="divLinks">友情鏈接</div>
????????<span?id="QLinks">
??????????????<ul?style=" border:1px solid #ccc; ?margin-top:10px; height:70px">
????????????????<li><a?href='http://rsc.cslg.cn/rsc/'?target='_blank'><img?src="yf/backgroundimgs/rsc.jpg"??border='0'?width='106px'?height='46px'></a></li>
????????????????<li><a?href='http://www.hep.com.cn/service/xuanshu'?target='_blank'><img?src='yf/backgroundimgs/gdjycbs.jpg'?border='0'?width='106px'?height='46px'></a></li>
????????????????<li><a?href='http://kjc.cslg.edu.cn/'?target='_blank'><img?src='yf/backgroundimgs/kxjs.jpg'?border='0'?width='106px'?height='46px'></a></li>
????????????????<li><a?href='http://jwc.cslg.cn/jwc/'?target='_blank'><img?src='yf/backgroundimgs/jwc.jpg'?border='0'?width='106px'?height='46px'></a></li>
????????????????<li><a?href='http://www.icourses.cn/'?target='_blank'><img?src='yf/backgroundimgs/akc.jpg'?border='0'?width='106px'?height='46px'></a></li>
????????????????<li><a?href='http://ctl.nju.edu.cn/yanjiuhui/'?target='_blank'><img?src='yf/backgroundimgs/jsgx.jpg'?border='0'?width='106px'?height='46px'></a></li>
??????????????</ul>
?????????</span>
?????????<div?class="splitDiv"></div>
???????????
????????<a?href="#top"><img?src="images/backTop.png"?alt="Alternate Text"?id="backTop"?title="回到頂部"?/></a>
????????<div?id="footer">
????????<div?>
????????????????版權所有:@ 2018 姚鋒?地址:江蘇省常熟市南三環路99號 <br?/>
????????????????聯系電話:188xxxxxxxx 郵政編括碼:215500 <br?/>
????????????[<a?href="yf/index.aspx"?target="_blank">后臺管理</a>]
????????</div>
????</div>
????</form>
</body>
</html>
?
單篇新聞(shownews.aspx):
<html?xmlns="http://www.w3.org/1999/xhtml">
<head?runat="server">
????<title>查看新聞頁面</title>
????<link?href="css/style.css"?rel="stylesheet"?type="text/css"?/>
????<style?type="text/css">
????????#shownewssure{color:White;
????????????width:100px;
????????????height: 43px;
????????outline: none;
????????line-height: 43px;
????????border-radius: 50px;
????????border: ?1px?solid?#000;
????????position: relative;
????????border: rgba(255,255,255,0.2)?2px?solid?;
????????color: var(--color);
????????????-webkit-transition: 0.25s;
????????????transition: 0.25s;
????????????}
????????#shownewssure:hover,#shownewssure:focus?{-webkit-animation: pulse?1s;animation: pulse?1s;box-shadow: 0?0?0?2em?rgba(255, 255, 255, 0);}
????????#shownewssure?{--color: #ef6eae;--hover: #ef8f6e;}
????????@-webkit-keyframes?pulse {0% {box-shadow: 0?0?0?0?var(--hover);}}
????????@keyframes?pulse {0% {box-shadow: 0?0?0?0?var(--hover);}}
????</style>
</head>
<body>
????<form?id="form1"?runat="server">
???<div?id="box">
????????<div?id="header"></div>
????????<div?class="splitDiv"></div>
????????<div?id="showLanmu">
????????????<div?id="lanMuList"?>
????????????????<%=Lanmu.getLanMu()%>
????????????????<asp:Button?ID="shownewssure"?runat="server"?Text="搜索"?
????????????????????οnclick="shownewssure_Click"?/>
????????????????<asp:TextBox?ID="shownewsSearch"?runat="server"?style="width:200px; border:1px solid ?black; border-radius: 50px; text-align:center"></asp:TextBox>
?????????????????
????????????</div>
????????</div>
????????<div?class="splitDiv"></div>
?
????????<div?id="main">
????????????<div?id="newsTitle">
????????????????<asp:Label?ID="lblTitle"?runat="server"></asp:Label>
????????????</div>
????????????<div?class="line"></div>
????????????<div?id="newsInfo">
????????????????<asp:Label?ID="lblAddTime"?runat="server"></asp:Label>
????????
????????????????<asp:Label?ID="lblHitCount"?runat="server"></asp:Label>
???????????
????????????????<asp:Label?ID="lblAuthor"?runat="server"></asp:Label>
????????????</div>
????????????<div?id="newsContent">
????????????????<asp:Label?ID="lblContent"?runat="server"></asp:Label>
????????????</div>
????????<div?class="splitDiv"></div>
????????<div?id="divLinks">友情鏈接</div>
????????<span?id="QLinks">
??????????????<ul?style=" border:1px solid #ccc; ?margin-top:10px; height:70px">
????????????????<li><a?href='http://rsc.cslg.cn/rsc/'?target='_blank'><img?src="yf/backgroundimgs/rsc.jpg"??border='0'?width='106px'?height='46px'></a></li>
????????????????<li><a?href='http://www.hep.com.cn/service/xuanshu'?target='_blank'><img?src='yf/backgroundimgs/gdjycbs.jpg'?border='0'?width='106px'?height='46px'></a></li>
????????????????<li><a?href='http://kjc.cslg.edu.cn/'?target='_blank'><img?src='yf/backgroundimgs/kxjs.jpg'?border='0'?width='106px'?height='46px'></a></li>
????????????????<li><a?href='http://jwc.cslg.cn/jwc/'?target='_blank'><img?src='yf/backgroundimgs/jwc.jpg'?border='0'?width='106px'?height='46px'></a></li>
????????????????<li><a?href='http://www.icourses.cn/'?target='_blank'><img?src='yf/backgroundimgs/akc.jpg'?border='0'?width='106px'?height='46px'></a></li>
????????????????<li><a?href='http://ctl.nju.edu.cn/yanjiuhui/'?target='_blank'><img?src='yf/backgroundimgs/jsgx.jpg'?border='0'?width='106px'?height='46px'></a></li>
??????????????</ul>
?????????</span>
?????????<div?class="splitDiv"></div>
????????<a?href="#top"><img?src="images/backTop.png"?alt="Alternate Text"?id="backTop"?title="回到頂部"?/></a>
????????<div?id="footer">
????????<div?>
????????????????版權所有:@ 2018 姚鋒地址:江蘇省常熟市南三環路99號<br?/>
????????????????聯系電話:188xxxxxxxx 郵政編碼:215500 <br?/>
????????????[<a?href="yf/index.aspx"?target="_blank">后臺管理</a>]
????????</div>
????</div>
????</form>
</body>
</html>
5.1.4 主要CSS樣式部分
*,td,li,ul,body?{margin:0;padding:0; }
td,th,table{ border:o;}
#box{width:1000px;margin:0?auto;}
#header{width:1000px;height:170px; background-image:url(../images/toppic.jpg);}
#main{width:1000px;}
#left{float:left;width:490px;height:300px;}
#right{float:right;width:500px;}
.splitDiv{ height:10px; clear:both;}
.line{ width:1000px; height:1px; background:#000; margin:10px?0;}
#divLeft,#divMiddle,#divRight{width:320px;height:200px;float:left;}
#divRight{margin: 10px?10px?10px?0px; ?}
#divMiddle{ margin:10px?10px?10px?0px;}
#divLeft{ margin:10px?10px?10px?0px;}
#divLinks{ width:990px; border:1px?solid?#ccc; padding:5px;}
#footer{ width:1000px; text-align:center; ? font-size:14px; }
#backfooter{ ?width:100%; text-align:center; ?background-color:#20B2AA; font-size:14px; position:fixed; bottom:0px}
.smallTitle{ text-align:center;}
#backTop{ position:fixed; right:20px; bottom:15px;height: 154px;}
#lanMuList{ height:30px; width:1000px; }
#lanMuList?li{ list-style:none; float:left; margin: 0?5px?0px?0px; width:60px; height:40px; line-height:40px; ?text-align:center; }
#lanMuList?a{ text-decoration: none; color:White; font-weight:bold;}
#lanMuList?li:hover{ }
/*下面為showlist界面導航css樣式*/
#showLanmu?a:hover{ color:Red;}
#showLanmu{ height:30px; width:1000px; }
#showLanmu?li{ list-style:none; float:left; margin: 0?5px?0px?0px; width:60px; height:40px; line-height:40px; ?text-align:center; }
#showLanmu?a{ text-decoration: none; color:White; font-weight:bold;}
#showLanmu?li:hover{ }
#showLanmu?a:hover{ color:Red;}
/*下面為搜索框及按鈕css樣式*/
#sure,#shownewssure{ float:right; height:35px; width:50px;}
#Search,#shownewsSearch{ float:right; width:200px; height:30px; }
#QLinks?ul?li{ list-style-type:none;float:left; height:60px; width:157px; margin:8px?0?0?8px; *display:inline; overflow:hidden;}
#QLinks?ul?li?img{ width:149px; height:52px; padding:3px; border:1px?solid?#e6e6e6;}
?/*下面是登陸界面的css樣式表*/
#userlogin{width:150px;height:90px;position:absolute;
?????left:50%;top:50%;
?????border:1px?red?solid;
?????margin-left:-75px;
?????margin-top:-45px;}
?/*下面是查看新聞內容頁面的樣式表*/
#newsTitle{width:1000px;text-align:center;font-size:18pt;}
#newsContent{width:1000px;font-size:12pt;}
#newsInfo{ width:1000px; font-size:12pt; text-align:center; margin-bottom:10px;}
/*下面是管理頁面布局樣式表*/
#adminHeader{ line-height:25px; height:25px; width:1000px; margin-top:5px;}
#adminMenu{line-height:25px;height:25px;width:1000px;}
#adminContent{width:1000px;}
/*下面是用戶管理界面樣式表*/
#showUser{ width:1000px; margin:0?auto;}
/*下面是增加用戶樣式表*/
#addUserDiv?
{width:250px; position:absolute; top:50%;left:50%; ?text-align:center;
?box-shadow: -15px?15px?15px?rgba(6, 17, 47, 0.7);opacity: 1;top: 20px;
?position: relative;width: 300px;height: 400px;position: absolute;
?left: 0;right: 0;margin: auto;top: 0;bottom: 0;padding: 100px?40px?40px?40px;
?background: #35394a;
?/* Old browsers */
?/* FF3.6+ */
?background: -webkit-gradient(linear, left bottom, right top, color-stop(0%, #35394a), color-stop(100%, rgb(0, 0, 0)));
?/* Chrome,Safari4+ */
?background: -webkit-linear-gradient(230deg, rgba(53, 57, 74, 0) 0%, rgb(0, 0, 0) 100%);
?/* Chrome10+,Safari5.1+ */
?/* Opera 11.10+ */
?/* IE10+ */
?background: linear-gradient(230deg, rgba(53, 57, 74, 0) 0%, rgb(0, 0, 0) 100%);
?/* W3C */
?filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='rgba(53, 57, 74, 0)', endColorstr='rgb(0, 0, 0)',GradientType=1 );
?/* IE6-9 fallback on horizontal gradient */}
.addUserClass?
{margin:20px;color:White;height: 46px;outline: none;margin-left: 50px;border: none;line-height: 46px;height: 46px;padding: 0?5px;margin-bottom: 20px;border-radius: 50px;position: relative;border: rgba(255,255,255,0.2)?2px?solid?;}
.mb2?#back,#submitUser{text-decoration: none;outline: none;}
#back,#submitUser?{padding: 15px;margin-left:30px;float:left;display: block;line-height: 20px;text-align: center;font-size: 20px;border-radius: 50px;background: ?rgba(0,0,0,0);border:1px?solid?#75faff;width:100px;color:#75faff;}
#addUserName,#addUserPwd,#editUserName,#editUserPwd,#editLanMu,#addLanMuName,#Search,#shownewsSearch{height: 40px;outline: none;margin-left: 20px;border: none;line-height: 40px;color: black;}
#addUserHeader{line-height:25px; height:25px; width:1000px; margin:5px?auto; border:1px?solid?#ccc;}
/*下面是編輯用戶樣式表*/
#editUserDiv{ width:250px; position:absolute; top:50%;left:50%; margin-left:-155px; margin-top:-200px; text-align:center; background: rgba(41, 39, 39, 0.46);-webkit-box-shadow: 0px?35px?44px?-22px?rgba(0,0,0,0.72);-moz-box-shadow: 0px?35px?44px?-22px?rgba(0,0,0,0.72);box-shadow: 0px?35px?44px?-22px?#1f181b;padding: 60px?40px; }
.addUserClass{ margin:20px;}
#eidtUserHeader{line-height:25px; height:25px; width:1000px; margin:5px?auto; border:1px?solid?#ccc;}
/*下面是欄目管理界面樣式表*/
#showLanMu{ width:1000px; margin:0?auto;}
#addLanMuHeader{line-height:25px; height:25px; width:1000px; margin:5px?auto; border:1px?solid?#ccc;}
#editLanMuDiv,#addLanMuDiv,#manageList{width:300px; position:absolute; top:50%;left:50%; margin-left:-155px; margin-top:-200px;
??????????????text-align:center; background: rgba(41, 39, 39, 0.46);
??????????????-webkit-box-shadow: 0px?35px?44px?-22px?rgba(0,0,0,0.72);-moz-box-shadow: 0px?35px?44px?-22px?rgba(0,0,0,0.72);
??????????????box-shadow: 0px?35px?44px?-22px?#1f181b;
??????????????padding: 60px?40px;}
?
5.2后臺部分主要代碼
5.2.1數據庫部分
Sqlhelper類:
public?class?sqlhelper
{
public?sqlhelper()
{
}
????///?<summary>
????///?函數實現建數據庫連接,并返回該連接
????///?</summary>
????///?<returns>返回建立好的數據庫連接</returns>
????public?static?SqlConnection?createCon()
????{
????????//獲取配置文件中設置好的連接
????????SqlConnection?con = new?SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["myCon"].ConnectionString);
????????return?con;
????}
????public?static?void?excuteSql(string?sqlString)
????{
????????SqlConnection?con = createCon();
????????con.Open();
????????SqlCommand?cmd = new?SqlCommand(sqlString, con);
????????cmd.ExecuteNonQuery();
????????con.Close();
????}
????///?<summary>
????///?數據檢索
????///?</summary>
????///?<param name="sqlString"></param>
????///?<returns></returns>
????public?static?DataSet?excuteDataSet(string?sqlString)
????{
????????SqlConnection?con = createCon();
????????con.Open();
????????SqlDataAdapter?sda = new?SqlDataAdapter(sqlString, con);
????????DataSet?ds = new?DataSet();
????????sda.Fill(ds);
????????con.Close();
????????return?ds;
????}
????public?static?int?excuteInt(string?sqlString)
????{
????????SqlConnection?con = createCon();
????????con.Open();
????????SqlCommand?cmd = new?SqlCommand(sqlString,con);
????????int?count=0;
????????count = Convert.ToInt32(cmd.ExecuteScalar());
????????con.Close();
????????return?count;
????}
????public?static?bool?excuteBool(string?sqlString)
????{
????????SqlConnection?con = createCon();
????????con.Open();
????????SqlCommand?cmd = new?SqlCommand(sqlString, con);
????????bool?result = true;
????????try?
????????{
????????????cmd.ExecuteNonQuery();
????????}
????????catch
????????{
????????????result=false;
????????}
????????con.Close();
????????return?result;
????}
????public?static?SqlDataReader?ExcuteSqlDataReader(string?sql, SqlParameter[] parms)
????{
????????SqlDataReader?result = null;
????????SqlConnection?con = createCon();
????????try
????????{
????????????con.Open();
????????????SqlCommand?cmd = new?SqlCommand(sql, con);
????????????if?(parms != null)
????????????????cmd.Parameters.AddRange(parms);
????????????result = cmd.ExecuteReader(CommandBehavior.CloseConnection);
????????}
????????catch
????????{ }
????????return?result;
????}
}
public?static?News?getNewsById(string?id)//通過新聞id查找新聞????
{
????????News?news = new?News();
????????string?sqlString="select * from t_news where newid="+id;
????????SqlConnection?con = sqlhelper.createCon();
????????con.Open();
????????SqlCommand?cmd = new?SqlCommand(sqlString,con);
????????SqlDataReader?sdr = cmd.ExecuteReader();
????????while?(sdr.Read())
????????{
????????????news.newid = Convert.ToInt32(sdr[0]);
????????????news.title = Convert.ToString(sdr[1]);
????????????news.contents = Convert.ToString(sdr[2]);
????????????news.newid = Convert.ToInt32(sdr[3]);
????????????news.addTime =Convert.ToDateTime(sdr[4]);
????????????news.lanMuId = Convert.ToInt32(sdr[5]);
????????????news.hitCount = Convert.ToInt32(sdr[6]);
????????}
????????con.Close();
????????return?news;
}
News類:
public?class?News
{
public?News()
{
}
????public?int?newid;
????public?string?title;
????public?string?contents;
????public?int?uid;
????public?DateTime?addTime;
????public?int?lanMuId;
????public?int?hitCount;
????public?string?img;
????public?static?void?getPics(ref?string?pics,ref?string?texts,ref?string?links)
????{
????????string?sqlString = "select top 5 newid,title,img from t_news where img<>'' order by addTime DESC";
????????SqlConnection?con = sqlhelper.createCon();
????????con.Open();
????????SqlCommand?cmd = new?SqlCommand(sqlString, con);
????????SqlDataReader?sdr = cmd.ExecuteReader();
????????while?(sdr.Read())
????????{
????????????pics += sdr[2].ToString()+"|";
????????????texts += sdr[1].ToString() + "|";
????????????links += "showNews.aspx?id="?+sdr[0].ToString()+ "|";
????????}
????????pics = pics.Substring(0, pics.Length - 1);
????????texts = texts.Substring(0, texts.Length - 1);
????????links = links.Substring(0, links.Length - 1);
????}
????public?static?News?getNewsByText(string?text)
????{
????????News?news = new?News();
????????string?sqlString = "select * from news where title like ?'%"?+ text + "%' order by addTime DESC";
????????SqlConnection?con = sqlhelper.createCon();
????????con.Open();
????????SqlCommand?cmd = new?SqlCommand(sqlString, con);
????????SqlDataReader?sdr = cmd.ExecuteReader();
????????while?(sdr.Read())
????????{
????????????news.newid = Convert.ToInt32(sdr[0]);
????????????news.title = Convert.ToString(sdr[1]);
????????????news.contents = Convert.ToString(sdr[2]);
????????????news.newid = Convert.ToInt32(sdr[3]);
????????????news.addTime = Convert.ToDateTime(sdr[4]);
????????????news.lanMuId = Convert.ToInt32(sdr[5]);
????????????news.hitCount = Convert.ToInt32(sdr[6]);
????????}
????????con.Close();
????????return?news;
????}
????public?static?News?getNewsById(string?id)
????{
????????News?news = new?News();
????????string?sqlString="select * from t_news where newid="+id;
????????SqlConnection?con = sqlhelper.createCon();
????????con.Open();
????????SqlCommand?cmd = new?SqlCommand(sqlString,con);
????????SqlDataReader?sdr = cmd.ExecuteReader();
????????while?(sdr.Read())
????????{
????????????news.newid = Convert.ToInt32(sdr[0]);
????????????news.title = Convert.ToString(sdr[1]);
????????????news.contents = Convert.ToString(sdr[2]);
????????????news.newid = Convert.ToInt32(sdr[3]);
????????????news.addTime =Convert.ToDateTime(sdr[4]);
????????????news.lanMuId = Convert.ToInt32(sdr[5]);
????????????news.hitCount = Convert.ToInt32(sdr[6]);
????????}
????????con.Close();
????????return?news;
????}
????public?static?void?addHitCount(string?id)
????{
????????string?sqlString = "update t_news set hitCount=hitCount+1 where newid="+id;
????????sqlhelper.excuteSql(sqlString);
????}
????public?static?DataSet?getNewsList()
????{
????????string?sqlString = "select * from View_News order by addTime DESC";
????????return?sqlhelper.excuteDataSet(sqlString);
????}
????public?static?DataSet?getNewsBymanageId(string?id)//管理員管理的頁面顯示相應欄目的新聞
????{
????????string?sqlString = "select * from t_user,t_news,t_lanMu where t_user.manageLanmuid=t_news.lanMuId and t_news.lanMuId=t_lanMu.lanMuId and t_user.uid="+id;
????????return?sqlhelper.excuteDataSet(sqlString);
????}
????public?static?bool?addNews(News?n)
????{
????????string?sqlString = "insert into t_news (title,contents,uid,addTime,lanMuId,hitCount,img) values('"+n.title+"','"+n.contents+"',"+n.uid+",'"+n.addTime+"',"+n.lanMuId+","+n.hitCount+",'"+n.img+"')";
????????return?sqlhelper.excuteBool(sqlString);
????}
????public?static?bool?editNews(News?n)
????{
????????string?sqlString = "update t_news set title='"?+ n.title + "', contents='"?+ n.contents + "', uid="?+ n.uid + ", lanMuId="?+ n.lanMuId+",img='"+n.img+"' where newid="?+n.newid;
????????return?sqlhelper.excuteBool(sqlString);
????}
????public?static?bool?delNews(string?id)
????{
????????string?sqlString = "delete from t_news where newid="?+ id;
????????return?sqlhelper.excuteBool(sqlString);
????}
}
Users類:
public?class?Users
{
public?Users()
{
}
????public?int?uid;
????public?string?userName;
????public?string?passWord;
????public?int?manageLanmuid;
????public?static?Users?getUserById(string?id)
????{
????????Users?users = new?Users();
????????string?sqlString = "select * from t_user where uid="?+ id;
????????SqlConnection?con = sqlhelper.createCon();
????????con.Open();
????????SqlCommand?cmd = new?SqlCommand(sqlString, con);
????????SqlDataReader?sdr = cmd.ExecuteReader();
????????while?(sdr.Read())
????????{
????????????users.uid = Convert.ToInt32(sdr[0]);
????????????users.userName = Convert.ToString(sdr[1]);
????????????users.passWord = Convert.ToString(sdr[2]);
????????}
????????con.Close();
????????return?users;
????}
????public?static?int?getuidByName(string?userName)
????{
????????string?sqlString = "select uid from t_user where userName='"?+ userName + "'";
????????SqlConnection?con = sqlhelper.createCon();
????????con.Open();
????????SqlCommand?cmd = new?SqlCommand(sqlString, con);
????????int?uid = Convert.ToInt32(cmd.ExecuteScalar());
????????con.Close();
????????return?uid;
????}
????public?static?DataSet?getUserList()//獲取用戶列表
????{
????????string?sqlString = "select * from t_user";
????????return?sqlhelper.excuteDataSet(sqlString);
????}
????public?static?bool?delUser(string?id)
????{
????????string?sqlString = "delete from t_user where uid="?+ id;
????????return?sqlhelper.excuteBool(sqlString);
????}
????public?static?bool?addUser(Users?n)
????{
????????string?sqlString = "insert into t_user (userName,passWord) values('"?+ n.userName + "','"?+ n.passWord + "' )";
????????return?sqlhelper.excuteBool(sqlString);
????}
????public?static?bool?editUser(Users?n)
????{
????????string?sqlString = "update t_user set userName ='"?+ n.userName + "', passWord='"?+ n.passWord + "' ?where uid="?+ n.uid;
????????return?sqlhelper.excuteBool(sqlString);
????}
????public?static?bool?giveUseraddlanmu(Users?n)
????{
????????string?sqlString = "update t_user set userName ='"?+ n.userName + "', passWord='"?+ n.passWord + "', manageLanmuid='"?+ n.manageLanmuid + "' ?where uid="?+ n.uid;
????????return?sqlhelper.excuteBool(sqlString);
????}
}
Lanmu類:
public?class?Lanmu
{
public?Lanmu()
{
}
????public?int?lanMuId;
????public?string?lanMuName;
????public?static?DataSet?getLanMuList()//獲取用戶列表
????{
????????string?sqlString = "select * from t_lanMu";
????????return?sqlhelper.excuteDataSet(sqlString);
????}
????public?static?string?getLanMu()//獲取動態欄目
????{
????????string?result = "";
????????string?sql = "select * from t_lanMu";
????????System.Data.SqlClient.SqlDataReader?sdr = sqlhelper.ExcuteSqlDataReader(sql, null);
????????while?(sdr.Read())
????????{
????????????result += "<li><a href='showlist.aspx?id="?+ sdr["lanMuId"] + "'>";
????????????result += sdr["lanMuName"].ToString() + "</a>"?+ "</li>";
????????}
????????sdr.Close();
????????return?result;
????}
????public?static?bool?addLanMu(Lanmu?l)
????{
????????string?sqlString = "insert into t_lanMu (lanMuName) values('"?+ l.lanMuName + "')";
????????return?sqlhelper.excuteBool(sqlString);
????}
????public?static?bool?delLanMu(string?id)
????{
????????string?sqlString = "delete from t_lanMu where lanMuId="?+ id;
????????return?sqlhelper.excuteBool(sqlString);
????}
????public?static?bool?editLanMu(Lanmu?l)
????{
????????string?sqlString = "update t_lanMu set lanMuName='"?+ l.lanMuName + "' ?where lanMuId="?+ l.lanMuId;
????????return?sqlhelper.excuteBool(sqlString);
????}
}
5.2.2欄目部分
增加欄目(addLanMu.aspx.cs):
public?partial?class?yf_addNews?: System.Web.UI.Page
{
????Users?u;
????protected?void?Page_Load(object?sender, EventArgs?e)
????{
????????if?(Session["user"] == null)
????????{
????????????Response.Redirect("index.aspx");
????????}
????????else
????????{
????????????u=(Users)Session["user"];
????????}
????????if?(!IsPostBack)//防止沒有取到下拉菜單值
????????{
????????????ddlLanMu.DataSource = Lanmu.getLanMuList();
????????????ddlLanMu.DataTextField = "lanMuName";
????????????ddlLanMu.DataValueField = "lanMuId";
????????????ddlLanMu.DataBind();
????????????if?(Request.QueryString["id"] != null)
????????????{
????????????????string?id = Request.QueryString["id"].ToString();
????????????????News?n = News.getNewsById(id);
????????????????txtTitle.Text = n.title;
????????????????content1.Value = n.contents;
????????????????foreach?(ListItem?x in?ddlLanMu.Items)
????????????????{
????????????????????if?(x.Value == n.lanMuId.ToString())
????????????????????{
????????????????????????x.Selected = true;
????????????????????}
????????????????}
????????????}
????????}
????}
????protected?void?btnSubmit_Click(object?sender, EventArgs?e)
????{
????????News?n = new?News();
????????n.title = txtTitle.Text;
????????n.contents = content1.Value;
????????n.addTime = DateTime.Now;
????????n.hitCount = 0;
????????n.lanMuId =Convert.ToInt32(ddlLanMu.SelectedValue);
????????n.uid = u.uid;
????????n.img = txtImgUrl.Text;
????????if?(News.addNews(n)== true?)
????????????Response.Write("<script>alert('發布成功!')</script>");
????????else
????????????Response.Write("<script>alert('發布失敗!')</script>");
????}
????protected?void?btnBack_Click(object?sender, EventArgs?e)
????{
????????Response.Redirect("manage.aspx");
????}
}
編輯欄目(editLanMu.aspx.cs):
public?partial?class?yf_editLanMu?: System.Web.UI.Page
{
????protected?void?Page_Load(object?sender, EventArgs?e)
????{
????}
????protected?void?submitEditLanMu_Click(object?sender, EventArgs?e)
????{
????????Lanmu?l = new?Lanmu();
????????l.lanMuName = editLanMu.Text;
????????l.lanMuId = Convert.ToInt32(Request.QueryString["id"].ToString());
????????if?(Lanmu.editLanMu(l) == true)
????????????Response.Write("<script>alert('修改成功!')</script>");
????????else
????????????Response.Write("<script>alert('修改失敗!')</script>");
????}
????protected?void?back_Click(object?sender, EventArgs?e)
????{
????????Response.Redirect("lanmuManage.aspx");
????}
}
欄目管理(lanmuManage.aspx.cs):
public?partial?class?yf_LanMumanage?: System.Web.UI.Page
{
????protected?void?Page_Load(object?sender, EventArgs?e)
????{
????????if?(Session["user"] == null)
????????{
????????????Response.Write("<script>alert('您尚未登錄!')</script>");
????????????Response.Redirect("index.aspx");
????????}
????????else
????????{
????????????Users?u = (Users)Session["user"];
????????????bigUser.Text = "歡迎"?+ u.userName;
????????}
????????showLanMuList();
????}
?
????public?void?showLanMuList()
????{
????????gvLanMu.DataSource = Lanmu.getLanMuList();
????????gvLanMu.DataBind();
????}
????protected?void?delLanMu_Click(object?sender, EventArgs?e)
????{
????????LinkButton?btn = (LinkButton)sender;
????????GridViewRow?gvr = (GridViewRow)btn.NamingContainer;
????????string?id = gvr.Cells[0].Text;
????????if?(Lanmu.delLanMu(id) == true?&& (Convert.ToInt32(id) != 1))
????????{
????????????Response.Write("<script>alert('刪除成功!')</script>");
????????????showLanMuList();
????????}
????????else
????????????Response.Write("<script>alert('刪除失敗!')</script>");
????}
????protected?void?editLanMu_Click(object?sender, EventArgs?e)
????{
????????LinkButton?btn = (LinkButton)sender;
????????GridViewRow?gvr = (GridViewRow)btn.NamingContainer;
????????string?id = gvr.Cells[0].Text;
????????Response.Redirect("editLanMu.aspx?id="?+ id);
????}
????protected?void?addLanMu_Click(object?sender, EventArgs?e)
????{
????????Response.Redirect("addLanMu.aspx");
????}
????protected?void?backtomanage_Click(object?sender, EventArgs?e)
????{
????????Response.Redirect("manage.aspx");
????}
????protected?void?setManage_Click(object?sender, EventArgs?e)
????{
????????LinkButton?btn = (LinkButton)sender;
????????GridViewRow?gvr = (GridViewRow)btn.NamingContainer;
????????string?id = gvr.Cells[0].Text;
????????Response.Redirect("setManage.aspx?id="?+ id);
????}
}
5.2.3用戶部分
添加用戶(addUsers.aspx.cs):
public?partial?class?yf_addUser?: System.Web.UI.Page
{
????protected?void?Page_Load(object?sender, EventArgs?e)
????{
????}
????protected?void?submitUser_Click(object?sender, EventArgs?e)
????{
????????if?(addUserName.Text.Trim() == ""?|| addUserPwd.Text.Trim() == "")
????????{
????????????Response.Write("<script>alert('用戶名和密碼不能為空。');</script>");
????????}
????????else
????????{
????????????Users?n = new?Users();
????????????n.userName = addUserName.Text;
????????????n.passWord = addUserPwd.Text;
????????????if?(Users.addUser(n) == true)
????????????????Response.Write("<script>alert('添加成功')</script>");
????????????else
????????????????Response.Write("<script>alert('添加失敗')</script>");
????????}
????}
????protected?void?back_Click(object?sender, EventArgs?e)
????{
????????Response.Redirect("userManage.aspx");
????}
}
編輯用戶(editUsers.aspx.cs):
public?partial?class?yf_editUser?: System.Web.UI.Page
{
????Users?u;
????protected?void?Page_Load(object?sender, EventArgs?e)
????{
????????if?(Session["user"] == null)
????????????Response.Redirect("index.aspx");
????????else
????????????u = (Users)Session["user"];
????????if?(!IsPostBack)
????????{
????????????if?(Request.QueryString["id"] != null)
????????????{
????????????????string?id = Request.QueryString["id"].ToString();
????????????????Users?n = Users.getUserById(id);
????????????????editUserName.Text = n.userName;
????????????????editUserPwd.Text = n.passWord;
????????????}
????????}
????}
????protected?void?submitEditUser_Click(object?sender, EventArgs?e)
????{
????????Users?n = new?Users();
????????n.userName = editUserName.Text;
????????n.passWord = editUserPwd.Text;
????????n.uid = Convert.ToInt32(Request.QueryString["id"].ToString());
????????if?(Users.editUser(n) == true)
????????????Response.Write("<script>alert('修改成功')</script>");
????????else
????????????Response.Write("<script>alert('修改失敗')</script>");
????}
????protected?void?back_Click(object?sender, EventArgs?e)
????{
????????Response.Redirect("manage.aspx");
????}
}
管理用戶(userManage.aspx.cs):
public?partial?class?yf_userManage?: System.Web.UI.Page
{
????protected?void?Page_Load(object?sender, EventArgs?e)
????{
????????if?(Session["user"] == null)
????????{
????????????Response.Write("<script>alert('您尚未登錄')</script>");
????????????Response.Redirect("index.aspx");
????????}
????????else
????????{
????????????Users?u = (Users)Session["user"];
?????????????bigUser.Text = "歡迎"?+ u.userName;
????????}
????????showUserList();
????}
????public?void?showUserList()
????{
????????gvUser.DataSource = Users.getUserList();
????????gvUser.DataBind();
????}
????protected?void?editUser_Click(object?sender, EventArgs?e)
????{
????????LinkButton?btn = (LinkButton)sender;
????????GridViewRow?gvr = (GridViewRow)btn.NamingContainer;
????????string?id = gvr.Cells[0].Text;
????????Response.Redirect("editUser.aspx?id="?+ id);
????}
????protected?void?deleteUser_Click(object?sender, EventArgs?e)
????{
????????LinkButton?btn = (LinkButton)sender;
????????GridViewRow?gvr = (GridViewRow)btn.NamingContainer;
????????string?id = gvr.Cells[0].Text;
????????if?(Users.delUser(id) == true&&(Convert.ToInt32(id)!=1))
????????{
????????????Response.Write("<script>alert('刪除成功')</script>");
????????????showUserList();
????????}
????????else
????????{
????????????Response.Write("<script>alert('刪除失敗')</script>");
????????}
????}
????protected?void?Button1_Click(object?sender, EventArgs?e)
????{
????????Response.Redirect("addUser.aspx");
????}
????protected?void?back_Click(object?sender, EventArgs?e)
????{
????????Response.Redirect("manage.aspx");
????}
}
5.2.4新聞部分
添加新聞(addNews.aspx.cs):
public?partial?class?yf_addNews?: System.Web.UI.Page
{
????Users?u;
????protected?void?Page_Load(object?sender, EventArgs?e)
????{
????????if?(Session["user"] == null)
????????{
????????????Response.Redirect("index.aspx");
????????}
????????else
????????{
????????????u=(Users)Session["user"];
????????}
????????if?(!IsPostBack)
????????{
????????????ddlLanMu.DataSource = Lanmu.getLanMuList();
????????????ddlLanMu.DataTextField = "lanMuName";
????????????ddlLanMu.DataValueField = "lanMuId";
????????????ddlLanMu.DataBind();
????????????if?(Request.QueryString["id"] != null)
????????????{
????????????????string?id = Request.QueryString["id"].ToString();
????????????????News?n = News.getNewsById(id);
????????????????txtTitle.Text = n.title;
????????????????content1.Value = n.contents;
????????????????foreach?(ListItem?x in?ddlLanMu.Items)
????????????????{
????????????????????if?(x.Value == n.lanMuId.ToString())
????????????????????{
????????????????????????x.Selected = true;
????????????????????}
????????????????}
????????????}
????????}
????}
????protected?void?btnSubmit_Click(object?sender, EventArgs?e)
????{
????????News?n = new?News();
????????n.title = txtTitle.Text;
????????n.contents = content1.Value;
????????n.addTime = DateTime.Now;
????????n.hitCount = 0;
????????n.lanMuId =Convert.ToInt32(ddlLanMu.SelectedValue);
????????n.uid = u.uid;
????????n.img = txtImgUrl.Text;
????????if?(News.addNews(n)== true?)
????????????Response.Write("<script>alert('發布成功')</script>");
????????else
????????????Response.Write("<script>alert('發布失敗')</script>");
????}
????protected?void?btnBack_Click(object?sender, EventArgs?e)
????{
????????Response.Redirect("manage.aspx");
????}
}
編輯新聞(editNews.aspx.cs):
public?partial?class?yf_editeNews?: System.Web.UI.Page
{
????Users?u;
????protected?void?Page_Load(object?sender, EventArgs?e)
????{
????????if?(Session["user"] == null)
????????????Response.Redirect("index.aspx");
????????else
????????????u = (Users)Session["user"];
????????if?(!IsPostBack)
????????{
????????????ddlLanMu.DataSource = Lanmu.getLanMuList();
????????????ddlLanMu.DataTextField = "lanMuName";
????????????ddlLanMu.DataValueField = "lanMuId";
????????????ddlLanMu.DataBind();
????????????if?(Request.QueryString["id"] != null)
????????????{
????????????????string?id = Request.QueryString["id"].ToString();
????????????????News?n = News.getNewsById(id);
????????????????txtTitle.Text = n.title;
????????????????content1.Value = n.contents;
????????????????foreach?(ListItem?x in?ddlLanMu.Items)
????????????????{
????????????????????if?(x.Value == n.lanMuId.ToString())
????????????????????{
????????????????????????x.Selected = true;
????????????????????}
????????????????}
????????????}
????????}
????}
????protected?void?btnEdit_Click(object?sender, EventArgs?e)
????{
????????News?n = new?News();
????????n.title = txtTitle.Text;
????????n.contents = content1.Value;
????????n.uid = u.uid;
????????n.lanMuId =Convert.ToInt32(ddlLanMu.SelectedValue);
????????n.newid = Convert.ToInt32(Request.QueryString["id"].ToString());
????????n.img = txtImgUrl.Text;
????????if?(News.editNews(n)== true)
????????????Response.Write("<script>alert('修改成功')</script>");
????????else
????????????Response.Write("<script>alert('修改失敗')</script>");
????}
????protected?void?btnCancel_Click(object?sender, EventArgs?e)
????{
????????Response.Redirect("manage.aspx");
????}
}
給新聞設置管理員:(setManage.aspx.cs)
public?partial?class?yf_setManage?: System.Web.UI.Page
{
????Users?u;
????protected?void?Page_Load(object?sender, EventArgs?e)
????{
????????if?(Session["user"] == null)
????????{
????????????Response.Redirect("index.aspx");
????????}
????????else
????????{
????????????u = (Users)Session["user"];
????????}
????????if?(!IsPostBack)//防止沒有正確取到下拉菜單里的值
????????{
????????????userList.DataSource = Users.getUserList();
????????????userList.DataTextField = "userName";
????????????userList.DataValueField = "uid";
????????????userList.DataBind();
????????????if?(Request.QueryString["id"] != null)
????????????{
????????????????string?id = Request.QueryString["id"].ToString();
????????????????Users?n = Users.getUserById(id); ??????
????????????????foreach?(ListItem?x in?userList.Items)
????????????????{
????????????????????if?(x.Value == n.manageLanmuid.ToString())
????????????????????{
????????????????????????x.Selected = true;
????????????????????}
????????????????}
????????????}
????????}
????}
????protected?void?setManage_Click(object?sender, EventArgs?e)
????{
????????Users?n = new?Users();
????????n.manageLanmuid = Convert.ToInt32(Request.QueryString["id"].ToString());
????????int?id = Convert.ToInt32(userList.SelectedValue);
????????Users?p = Users.getUserById(id.ToString());//根據欄目id找user
?
????????n.uid = p.uid;
????????n.userName = p.userName;
????????n.passWord = p.passWord;
????????if?(Users.giveUseraddlanmu(n) == true)
????????????Response.Write("<script>alert('設置成功')</script>");
????????else
????????????Response.Write("<script>alert('設置失敗')</script>");
????}
????protected?void?back_Click(object?sender, EventArgs?e)
????{
????????Response.Redirect("lanmuManage.aspx");
????}
}
新聞搜索(Search.aspx.cs):
public?partial?class?Search?: System.Web.UI.Page
{
????protected?void?Page_Load(object?sender, EventArgs?e)
????{
????????if?(Request.QueryString["text"] != null)
????????{
????????????string?search = Request.QueryString["text"];
????????????SearchHotNews.DataSource = sqlhelper.excuteDataSet("select * from t_news where title like ?'%"?+ search + "%' or contents like '%"?+ search + "%' order by hitCount DESC");
????????????SearchHotNews.DataBind();
????????????SearchNews.DataSource = sqlhelper.excuteDataSet("select * from t_news where title like ?'%"?+ search + "%' or contents like '%"?+ search + "%' order by addTime DESC");
????????????SearchNews.DataBind();
????????}
????????else
????????{
????????}
????}
}
菜單欄目新聞(showlist.aspx.cs):
public?partial?class?showlist?: System.Web.UI.Page
{
????protected?void?Page_Load(object?sender, EventArgs?e)
????{
????????if?(Request.QueryString["id"] != null)
????????{
????????????//將欄目id作為參數,根據傳遞的欄目id值顯示
????????????string?id = Request.QueryString["id"].ToString();
????????????SqlConnection?con = sqlhelper.createCon();
????????????con.Open();
????????????string?sql = "select * from t_news where lanMuId=@lanMuId order by hitCount DESC";
????????????SqlCommand?cmd = con.CreateCommand();
????????????cmd.CommandText = sql;
????????????cmd.Parameters.Add(new?SqlParameter("@lanMuId", id));
????????????SqlDataAdapter?sda = new?SqlDataAdapter(cmd);
????????????DataSet?ds = new?DataSet();
????????????sda.Fill(ds);
????????????con.Close();
????????????gvHotNews.DataSource = ds;
????????????gvHotNews.DataBind();
????????????gvNews.DataSource = sqlhelper.excuteDataSet("select * from t_news order by addTime DESC");
????????????gvNews.DataBind();
????????}
????}
}
單篇新聞(shownews.aspx.cs):
public?partial?class?shownews?: System.Web.UI.Page
{
????protected?void?Page_Load(object?sender, EventArgs?e)
????{
????????if(Request.QueryString["id"]!=null)
????????{
????????????string?id=Request.QueryString["id"].ToString();
????????????News.addHitCount(id);
????????????News?n = News.getNewsById(id);
????????????lblTitle.Text = n.title;
????????????lblContent.Text = n.contents;
????????????lblAddTime.Text = "發布時間"+n.addTime.ToString();
????????????lblAuthor.Text ="發布者"+ n.uid.ToString();
????????????lblHitCount.Text ="點擊次數"+ n.hitCount;
????????}
????}
????protected?void?shownewssure_Click(object?sender, EventArgs?e)
????{
????????if?(shownewssure.Text.Trim() == "")
????????{
????????????Response.Write("<script>alert('輸入為空')</script>");
????????}
????????else
????????{
????????????Response.Redirect("Search.aspx?text="?+ shownewsSearch.Text);
????????}
????}
}