基于visual studio .NET和sql server 的三层架构 购物网站的实现 代码解读(二)管理员权限(main主页)

这部分页面基本没啥代码,我把我设计页的源码分享出来。

这里用的是frameset上古框架,在大学可以用,外面似乎用iframe+div的比较多。

页面分三个部分,篇幅最大的一块用来显示内容,顶部是top.aspx,左边的侧边栏是菜单menu.aspx

1.main

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="main.aspx.cs" Inherits="admin_main" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>BQ购物网后台管理</title>
</head>
<frameset rows="100,*" cols="*" frameborder="no" border="0" framespacing="0">
  <frame src="top.aspx" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" />
  <frameset cols="200,*" frameborder="no" border="0" framespacing="0">
    <frame src="menu.aspx" name="leftFrame" scrolling="No" noresize="noresize" id="leftFrame" />
    <frame src="" name="College" id="mainFrame" />
  </frameset>
</frameset>
<noframes>
</noframes>
</html>

2.top

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="top.aspx.cs" Inherits="admin_top" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>BQ购物网后台</title>
    <link href="css/web.css" rel="stylesheet" type="text/css" />
</head>
<body style="background:#dbe7a1;">
    <form id="form1" runat="server">
    <div>
      <table width="100%" height="100" border="0" cellspacing="1" cellpadding="1">
  <tr>
    <td><img src="images/logo.jpg" width="500" height="100" /></td>
    <td align="right" style="padding:0 50px 0 0; color:#FFFFFF;">欢迎 <asp:Label 
            ID="username" runat="server" Text="Label"></asp:Label>
         登录 | <a href="../user/index.aspx" target="_blank" style="color:#FFFFFF;">返回首页</a> | <a href="exit.aspx" style="color:#FFFFFF;">退出</a></td>
    </tr>
</table>  
    </div>
    </form>
</body>
</html>

3.menu

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="menu.aspx.cs" Inherits="admin_menu" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>BQ购物网后台管理</title>
    <link href="css/web.css" rel="stylesheet" type="text/css" />
</head>
<body style="background:#dbe7a1;">
    <form id="form1" runat="server">

    <%
        BQ.Entity.admin admin = new BQ.Entity.admin();
        admin = (BQ.Entity.admin)BQ.SessionHelper.GetSession("admin");
         %>

    
    <% if (admin.State == 8) //管理员拥有的权限
       {%>

    <table width="90%" border="0" align="center" cellpadding="0" cellspacing="1">
    <tr>
        <td height="28" align="center"><a href="user.aspx" target="College" style="color:#FFFFFF;">会员管理</a></td>
    </tr>
    <tr>
        <td height="28" align="center"><a href="Mall.aspx" target="College" style="color:#FFFFFF;">商家管理</a></td>
    </tr>
    <tr>
        <td height="28" align="center"><a href="menulist.aspx" target="College" style="color:#FFFFFF;">分类管理</a></td>
    </tr>
    <tr>
        <td height="28" align="center"><a href="menulist_add.aspx" target="College" style="color:#FFFFFF;">新增分类</a></td>
    </tr>
    <tr>
        <td height="28" align="center"><a href="goods.aspx" target="College" style="color:#FFFFFF;">商品管理</a></td>
    </tr>
    <tr>
        <td height="28" align="center"><a href="order.aspx" target="College" style="color:#FFFFFF;">订单管理</a></td>
    </tr>
    <tr>
        <td height="28" align="center"><a href="message.aspx" target="College" style="color:#FFFFFF;">评论管理</a></td>
    </tr>
    <tr>
        <td height="28" align="center"><a href="password.aspx" target="College" style="color:#FFFFFF;">密码设置</a></td>
    </tr>
    <tr>
        <td height="28" align="center"><a href="exit.aspx" target="College" style="color:#FFFFFF;">退出系统</a></td>
    </tr>
    </table>

    <%}
       else //商家拥有的权限
       { %>

    <table width="90%" border="0" align="center" cellpadding="0" cellspacing="1">
    <tr>
        <td height="28" align="center"><a href="goods.aspx" target="College" style="color:#FFFFFF;">商品管理</a></td>
    </tr>
    <tr>
        <td height="28" align="center"><a href="goods_add.aspx" target="College" style="color:#FFFFFF;">新增商品</a></td>
    </tr>
    <tr>
        <td height="28" align="center"><a href="order.aspx" target="College" style="color:#FFFFFF;">订单管理</a></td>
    </tr>
    <tr>
        <td height="28" align="center"><a href="admin_edit.aspx" target="College" style="color:#FFFFFF;">商家信息</a></td>
    </tr>
    <tr>
        <td height="28" align="center"><a href="password.aspx" target="College" style="color:#FFFFFF;">密码设置</a></td>
    </tr>
    <tr>
        <td height="28" align="center"><a href="exit.aspx" target="College" style="color:#FFFFFF;">退出系统</a></td>
    </tr>
    </table>

    <%} %>

    </form>
</body>
</html>

基本没啥难度,都是用a href进行的页面跳转

Visual Studio中,可以使用Console.ReadLine()方法来读取控制台应用程序中的用户输入。如果您想要在控制台应用程序中执行SQL语句并从用户那里获取输入,您可以按照以下步骤操作: 1. 添加System.Data.SqlClient和System.Configuration引用。 2. 在App.config文件中添加连接字符串。例如: ``` <connectionStrings> <add name="MyConnectionString" connectionString="Data Source=MyServer;Initial Catalog=MyDatabase;Integrated Security=True"/> </connectionStrings> ``` 3. 在C#代码中,使用以下代码来连接到数据库并执行SQL查询: ``` using System; using System.Data.SqlClient; using System.Configuration; namespace ConsoleApp1 { class Program { static void Main(string[] args) { string connectionString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString; SqlConnection conn = new SqlConnection(connectionString); conn.Open(); Console.Write("Enter your SQL query: "); string sql = Console.ReadLine(); SqlCommand cmd = new SqlCommand(sql, conn); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Console.WriteLine(reader[0]); } reader.Close(); conn.Close(); Console.ReadLine(); } } } ``` 在上面的示例中,我们首先从App.config文件中读取连接字符串,然后使用SqlConnection类连接到数据库。接下来,我们使用Console.ReadLine()方法获取用户输入的SQL查询,并使用SqlCommand类执行查询并获取SqlDataReader类的结果。最后,我们使用Console.WriteLine()方法将结果输出到控制台。请注意,这是一个基本示例,并且需要添加错误处理和其他功能来确保应用程序的正确性和安全性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值