ACM官网开发

目录

一.介绍

二.实现功能

 三.数据库E-R图

四.数据库设计

 五.每个页面的设计(附主要代码及效果图)

1.主页

(1)

(2)

2.用户登录页面

 (1)

(2)

(3)

3.用户注册界面

(1)

(2)

(3)

4.用户编辑资料页面

(1)

(2)

(3)

 5.管理员登录界面

 (1)

(2)

(3)

 6.功能选择界面

 (1)

(2)

(3)

7.用户管理界面

(1)

(2)

(3)

 8.博文管理页面

(1)

(2)

(3)

9.用户反馈界面

(1)

 (2)

 六.小结


一.介绍

本系统设计并实现了基于.net的ACM官网开发。该官网的功能包括主页设计、博文管理,用户管理,登录界面,管理员界面,对用户资料进行编辑等,实现了简易的网站架构,有了基础的网站模式。本系统使用ASP.NET及html+css技术,后台使用SQL数据。

二.实现功能

 

 三.数据库E-R图

 

四.数据库设计

CREATE TABLE [dbo].[AdminInfo] (
    [Id]    INT          NOT NULL,
    [UName] VARCHAR (50) NULL,
    [Pwd]   VARCHAR (50) NULL,
    [Sex]   VARCHAR (50) NULL,
    [RName] VARCHAR (50) NULL,
    PRIMARY KEY CLUSTERED ([Id] ASC)
);

CREATE TABLE [dbo].[ArticleInfo] (
    [Id]          INT          IDENTITY (1, 1) NOT NULL,
    [ArticleId]   VARCHAR (50) NOT NULL,
    [ArticleName] VARCHAR (50) NULL,
    [Author]      VARCHAR (50) NULL,
    [InData]      DATETIME     NULL
);

CREATE TABLE [dbo].[User_In] (
    [Id]        INT            IDENTITY (1, 1) NOT NULL,
    [User_Name] NVARCHAR (MAX) NOT NULL,
    [Sex]       VARCHAR (50)   NOT NULL,
    [Name]      VARCHAR (50)   NOT NULL,
    [PassWord]  VARCHAR (50)   NOT NULL,
    [EntryDate] DATETIME       NOT NULL,
    CONSTRAINT [PK_User_In] PRIMARY KEY CLUSTERED ([Id] ASC)
);

 五.每个页面的设计(附主要代码及效果图)

1.主页

(1)

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

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>欢迎</title>
    <style type="text/css">
        .auto-style1 {
            width: 100%;
            height: 630px;
        }
        .auto-style2 {
            height: 24px;
            text-align: center;
        }
        .auto-style3 {
            height: 31px;
        }
        .auto-style4 {
            height: 20px;
        }
        .auto-style5 {
            height: 20px;
            text-align: center;
        }
        </style>
</head>
<body style ="background-image:url(http://localhost:59344/图片/backiee-124618.jpg); background-attachment: fixed; background-repeat: no-repeat; background-size: cover;">
    <form id="form1" runat="server">
    <div style="height: 773px">
    
        <table class="auto-style1">
            <tr>
                <td style="text-align: right; font-size: 20px; font-family: 微软雅黑;" class="auto-style3"><a href ="LoginForm.aspx" style ="color:aqua; font-size: 35px;">登录</a>&nbsp; &nbsp;&nbsp;&nbsp; <a href ="RegisterForm.aspx" style ="color:aqua; font-size: 35px;">注册</a>&nbsp;&nbsp;&nbsp; <a href ="AdminLoginForm.aspx" style ="color:aqua; font-size: 35px;">管理员登录</a>&nbsp;&nbsp; </td>
            </tr>
            <tr style="font-family: 楷体; font-size: 70px;">
                <td class="auto-style2"><strong style="color: #FFFF00"> 欢迎来到ACM</strong></td>
            </tr>
            <tr>
                <td style="font-family: 华文隶书; font-size: 45px; color: #FFFFFF;">
                    <br />
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    业精于勤荒于嬉,行成于思毁于随。<br />
                    <br />
                    <span>&nbsp;&nbsp;&nbsp;&nbsp; 不积跬步,无以至千里;不积小流,无以成江海。<br />
                    &nbsp;<br />
                    &nbsp;&nbsp;&nbsp;&nbsp; 用0和1去描述和创造这个世界的点点滴滴。<br />
                        <br />
                         &nbsp;&nbsp;&nbsp;&nbsp; 希望大家能够在这里学习到一些有用的知识,欢迎大家前来交流学习。<br />
                    </span></td>
            </tr>
            <tr>
                <td style="font-family: 幼圆; font-size: 40px; text-align: right; color: #66FF33;">
                    <br />
                    请先<a href ="LoginForm.aspx" style="color: #00FFFF"><strong>登录用户</strong> </a>,如果第一次请先<a href ="RegisterForm.aspx" style="color: #00FFFF"><strong>注册</strong></a></td>
            </tr>
            <tr>
                <td style="font-family: 幼圆; font-size: 30px; text-align: right; color: #00FFFF;" class="auto-style4">
                    <br />
                    如果有任何问题请及时<a href =" Feedback.html" style="color: #FFFF00">联系我们</a> </td>
            </tr>
            <tr>
                <td >
                    <br />
                    <hr style="border-style: none; border-width: 50px; border-color: inherit; height: 10px; width: 98%; color: #6600FF;" noshade="noshade" /> </td>
            </tr>
            <tr>
                <td style="font-family: 幼圆; font-size: 40px; color: #66FF33;" class="auto-style5">
                    <strong style="color: #FFFFFF; font-size: 20px; font-family: 黑体">Copyright 2021 浙江师范大学 版权所有</strong></td>
            </tr>
    
        </table>
    
    </div>
    </form>
</body>
</html>

(2)

2.用户登录页面

 (1)

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>用户登录界面</title>
    <style type="text/css">
        .auto-style1 {
            width: 99%;
            height: 344px;
        }
        .auto-style2 {
            width: 236px;
            text-align: center;
        }
        .auto-style3 {
            height: 24px;
            text-align: center;
        }
        .auto-style4 {
        }
        .auto-style5 {
            width: 236px;
            text-align: center;
            height: 46px;
        }
        .auto-style6 {
            height: 46px;
            width: 169px;
        }
        .auto-style7 {
            width: 169px;
        }

 

        .auto-style8 {
            width: 249px;
            height: 10px;
        }
        
        .auto-style9 {
            height: 24px;
            text-align: center;
            width: 297px;
        }
        .auto-style10 {
            width: 297px;
            height: 10px;
        }
        .auto-style11 {
            height: 10px;
            width: 169px;
        }
        .auto-style12 {
            width: 236px;
            text-align: center;
            height: 10px;
        }
        
    </style>
</head>
<body style ="background-image: url(http://localhost:59344/图片/backiee-124618.jpg); background-attachment: fixed; background-repeat: no-repeat; background-size: cover;">
    
    <div style="margin: auto; width: 949px">
    <form id="form1" runat="server">
        <table class="auto-style1">
            <tr>
                <td class="auto-style3" colspan="4" style="color: #CCFF66; font-size: xx-large; font-family: 黑体;">
    
                    <strong style="font-size: 45px">用户登录</strong> </td>
            </tr>
            <tr>
                <td class="auto-style3" colspan="4" style="color: #CCFF66; font-size: xx-large; font-family: 黑体;">
    
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style6">
    
        <asp:Label ID="lblUser" runat="server" Text="用户名:" ForeColor="#CCCCFF" Font-Bold="True" Font-Names="幼圆" Font-Size="37px" Font-Overline="False"></asp:Label>
                </td>
                <td class="auto-style5">
        <asp:TextBox ID="txtUserName" runat="server" Height="36px" style="margin-left: 0px" Width="244px"></asp:TextBox>
                </td>
                <td class="auto-style4" rowspan="6" colspan="2">
        <asp:Label ID="lbMessg" runat="server" Font-Names="华文细黑" ForeColor="Yellow" Font-Size="30px"></asp:Label>
    
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
    
                    &nbsp;</td>
                <td class="auto-style2">
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style7">
        <asp:Label ID="lblPwd" runat="server" Text="密码:" ForeColor="#CCCCFF" Font-Bold="True" Font-Names="幼圆" Font-Size="37px" ></asp:Label>
                </td>
                <td class="auto-style2"><asp:TextBox ID="txtPwd" runat="server" Height="35px" Width="244px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7">
                    &nbsp;</td>
                <td class="auto-style2">&nbsp;</td>
            </tr>
            <tr>
                <td style="color: #00FFFF" class="auto-style7">&nbsp;</td>
                <td class="auto-style2">
                    &nbsp;</td>
            </tr>
            <tr>
                <td style="color: #00FFFF" class="auto-style7"></td>
                <td class="auto-style2"></td>
            </tr>
            <tr>
                <td class="auto-style11">
        <asp:Button ID="btnOk" runat="server" Text="登录" OnClick="btnOk_Click" Font-Names="华文新魏" Font-Size="35px" Height="49px" Width="103px" />
                </td>
                <td class="auto-style12">
        &nbsp;&nbsp;
        <asp:Button ID="btnRe" runat="server" Text="注册" OnClick="btnRe_Click" Font-Names="华文新魏" Font-Size="35px" Height="49px" style="margin-left: 0px" Width="98px" />
    
                </td>
                <td class="auto-style8">
        &nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="btnCancle" runat="server" Text="取消" OnClick="btnCancle_Click" Font-Names="华文新魏" Font-Size="35px" Height="49px" style="margin-left: 0px" Width="98px" />
    
                </td>
                <td class="auto-style10">
        &nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="btnClear" runat="server" Text="重置" OnClick="btnClear_Click" Font-Names="华文新魏" Font-Size="35px" Height="49px" style="margin-left: 0px" Width="98px" />
    
                </td>
            </tr>
        </table>
    </form>
    </div>

</body>
</html>

(2)

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class LoginForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

```
}
```

```asp
protected void btnOk_Click(object sender, EventArgs e)
{
    string user = txtUserName.Text;
    string pwd = txtPwd.Text;
    //建立数据库连接,从ConfigurationManager中获取连接数据库的字符串
    string strcon =
    ConfigurationManager.ConnectionStrings["data"].ConnectionString;
    //查询字符串
    string strsql = "select PassWord from User_In where User_Name = @user";
    SqlConnection conn = new SqlConnection(strcon);
    SqlCommand com = new SqlCommand(strsql, conn);
    com.Parameters.AddWithValue("@user", user);
    //建立sqlDataReader用于读取数据
    SqlDataReader reader = null;
    conn.Open();
    reader = com.ExecuteReader();
    if (reader.Read()) //判断是否有下一条记录
    {
        if (reader["PassWord"].ToString() == pwd)
        {
            
            Response.Redirect("SuccessLoginForm.aspx?name=" + txtUserName.Text + "&admin="+"");
        }
        else
        {
            lbMessg.Text = "<font fontsize=4 color=red >密码出错,请重试</font>";
        }
    }
    else
    {
        lbMessg.Text = "<font fontsize=4 >用户名不存在,请先注册!</font>";
    }
    conn.Close();
}

protected void btnRe_Click(object sender, EventArgs e)
{
    Response.Redirect("RegisterForm.aspx");
}

protected void btnCancle_Click(object sender, EventArgs e)
{
    Response.Redirect("StartForm.aspx");
}

protected void btnClear_Click(object sender, EventArgs e)
{
    txtUserName.Text = "";
    txtPwd.Text = "";
}
```
}

(3)

 

3.用户注册界面

(1)

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>用户注册</title>
    <style type="text/css">
        .auto-style1 {
            width: 103%;
        }
        .auto-style2 {
            height: 24px;
        }
        .auto-style5 {
        }
        .auto-style6 {
            height: 24px;
            width: 239px;
        }
        .auto-style7 {
            height: 11px;
        }
        .auto-style8 {
            width: 239px;
        }
        .auto-style9 {
            width: 250px;
        }
        .auto-style10 {
            height: 24px;
            width: 250px;
        }
        .auto-style11 {
            width: 232px;
        }
        .auto-style12 {
            height: 24px;
            width: 232px;
        }
        .auto-style13 {
            width: 239px;
            height: 90px;
        }
        .auto-style14 {
            width: 250px;
            height: 90px;
        }
        .auto-style15 {
            width: 232px;
            height: 90px;
        }
        .auto-style16 {
            height: 90px;
        }
    </style>
</head>
<body style ="background-image: url(http://localhost:59344/图片/backiee-124618.jpg); background-attachment: fixed; background-repeat: no-repeat; background-size: cover;">
    <form id="form1" runat="server">
    <div style="margin: auto; width: 1138px; height: 672px;">
    
        <table class="auto-style1">
            <tr>
                <td class="auto-style5" colspan="3" style="color: #99FF99; font-family: 华文琥珀; font-size: 60px; text-align: center;">
    
                    注册</td>
                <td class="auto-style5" style="color: #99FF99; font-family: 华文琥珀; font-size: 60px; text-align: center;">
    
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style7" colspan="3">
    
                </td>
                <td class="auto-style7">
    
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style8">
    
        <asp:Label ID="Label1" runat="server" Text="用户名" ForeColor="#CCCCFF" Font-Bold="True" Font-Names="幼圆" Font-Size="37px" ></asp:Label>
                    <br />
                    <br />
                </td>
                <td class="auto-style9">
        <asp:TextBox ID="txtUserName" runat="server" Height="34px" Width="224px"></asp:TextBox>
                </td>
                <td class="auto-style11">&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style8">
        <asp:Label ID="Label2" runat="server" Text="密码" ForeColor="#CCCCFF" Font-Bold="True" Font-Names="幼圆" Font-Size="37px" ></asp:Label>
                    <br />
                    <br />
                </td>
                <td class="auto-style9">
        <asp:TextBox ID="txtPassword" runat="server" Height="33px" Width="223px"></asp:TextBox>
                </td>
                <td class="auto-style11">&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style8">
        <asp:Label ID="Label4" runat="server" Text="再次输入密码" ForeColor="#CCCCFF" Font-Bold="True" Font-Names="幼圆" Font-Size="37px" ></asp:Label>
                    <br />
                    <br />
                </td>
                <td class="auto-style9">
        <asp:TextBox ID="txtAgPwd" runat="server" Height="34px" Width="222px"></asp:TextBox>
        &nbsp; </td>
                <td class="auto-style11">
        <asp:Label ID="lbMessage1" runat="server" ForeColor="Yellow" Font-Names="隶书" Font-Size="25px"></asp:Label>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style8">
        <asp:Label ID="Label3" runat="server" Text="姓名" ForeColor="#CCCCFF" Font-Bold="True" Font-Names="幼圆" Font-Size="37px" ></asp:Label>
                    <br />
                    <br />
                </td>
                <td class="auto-style9">
        <asp:TextBox ID="txtName" runat="server" Height="33px" Width="222px"></asp:TextBox>
                </td>
                <td class="auto-style11">&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style13" style="font-size: 37px; font-family: 幼圆"><span style="color: #CCCCFF" ><strong>性别</strong> </span>  
        </td>
                <td class="auto-style14">
        <asp:RadioButtonList ID="rblSex" runat="server" Font-Names="微軟正黑體" Font-Size="30px" ForeColor="Yellow" Width="219px">
            <asp:ListItem>男</asp:ListItem>
            <asp:ListItem>女</asp:ListItem>
        </asp:RadioButtonList>
                </td>
                <td class="auto-style15"></td>
                <td class="auto-style16"></td>
            </tr>
            <tr>
                <td class="auto-style6"></td>
                <td class="auto-style10"></td>
                <td class="auto-style12">&nbsp;</td>
                <td class="auto-style2">&nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style6">
                    <br />
        <asp:Button ID="btnRe" runat="server" Text="注册" OnClick="btnRe_Click" Font-Names="华文新魏" Font-Size="35px" ForeColor="#0066FF" />
                </td>
                <td class="auto-style10">
                    <br />
&nbsp;&nbsp;&nbsp;
        <asp:Button ID="btnCancle" runat="server" Text="重置" OnClick="btnCancle_Click"  Font-Names="华文新魏" Font-Size="35px" ForeColor="#0066FF"/>
        &nbsp; </td>
                <td class="auto-style12">
        <asp:Label ID="lbMessage" runat="server" Font-Names="隶书" Font-Size="25px" ForeColor="Yellow"></asp:Label>
                </td>
                <td class="auto-style2">
        <asp:Button ID="btnBack" runat="server" Text="返回上一界面" OnClick="btnBack_Click"  Font-Names="华文新魏" Font-Size="35px" ForeColor="#0066FF" Height="58px" Width="232px"/>
                </td>
            </tr>
            <tr>
                <td class="auto-style6">
                    &nbsp;</td>
                <td class="auto-style10">
                    <br />
                </td>
                <td class="auto-style12">
                    &nbsp;</td>
                <td class="auto-style2">
                    &nbsp;</td>
            </tr>
        </table>
        <br />
    
    </div>
    </form>
</body>
</html>

(2)

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class RegisterForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    
    protected void btnRe_Click(object sender, EventArgs e)
    {
        string user;
        string pswd;
        string sex;
        string realname;
        user = Request.Form["txtUserName"];
        pswd = Request.Form["txtPassword"];
        sex = Request.Form["rblSex"];
        realname = Request.Form["txtName"];
    
        string constr =
ConfigurationManager.ConnectionStrings["data"].ConnectionString;
        string strsql = string.Format("select count(*) from User_In where User_Name = '{0}'", user);
        SqlConnection conn = new SqlConnection(constr);
        SqlCommand com1 = new SqlCommand(strsql, conn);
        conn.Open();
        int flag = (int)com1.ExecuteScalar();//执行查询后返回结果
        conn.Close();
        if (flag == 0) //如果结果为空,说明用户名不存在
                       //向数据库添加用户注册信息
        {
            string strinsert = string.Format("insert into User_In (User_Name,Sex,Name,PassWord,EntryDate) values('{0}','{1}','{2}','{3}','{4}' )", user, sex, realname, pswd,DateTime.Now);
            SqlCommand com2 = new SqlCommand(strinsert, conn);
            conn.Open();
            com2.ExecuteNonQuery();
            conn.Close();
            if (txtAgPwd.Text != txtPassword.Text)
            {
                lbMessage1.Text = "两次密码输入不正确";
             }
            else
            {
                Response.Write("<a href =\"LoginForm.aspx\" style =\"color: aqua;\"> 注册成功!点击返回登录</a> <p></p>");
                lbMessage.Text = "";
            }
        }
        else
        {
            lbMessage.Text = "对不起该用户名已经存在,请选择其他用户!";
            txtName.Text = "";
            txtUserName.Text = "";
            txtAgPwd.Text = "";
            txtPassword.Text = "";

        }
    }
    
    protected void btnCancle_Click(object sender, EventArgs e)
    {
        txtName.Text = "";
        txtUserName.Text = "";
        txtAgPwd.Text = "";
        txtPassword.Text = "";
    }

    protected void btnBack_Click(object sender, EventArgs e)
    {
        Response.Redirect("LoginForm.aspx");
    }
}

(3)

 

4.用户编辑资料页面

(1)

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>个人中心</title>
    <style type="text/css">
        .auto-style1 {
            width: 1203px;
        }
        .auto-style3 {
        }
        .auto-style9 {
            height: 24px;
            width: 50px;
            text-align: left;
        }
        .auto-style10 {
            height: 24px;
            width: 245px;
        }
        .auto-style12 {
            height: 24px;
            width: 42px;
        }
        .auto-style13 {
            width: 127px;
            height: 64px;
        }
        .auto-style14 {
            height: 24px;
            width: 127px;
        }
        .auto-style15 {
        }
        .auto-style16 {
            height: 64px;
            width: 50px;
        }
        .auto-style17 {
            height: 24px;
            width: 86px;
        }
    </style>
</head>
<body style ="background-image: url(http://localhost:59344/图片/backiee-124618.jpg); background-attachment: fixed; background-repeat: no-repeat; background-size: cover; ">
    
    <div style="margin: auto; width: 1216px" >
    <form id="form1" runat="server">
        <table class="auto-style1">
            <tr>
                <td class="auto-style3" style="font-size: 30px; color: #00FFFF; text-align: right; font-family: 华文新魏;" colspan="4"> <asp:Label ID="lblMessage" runat="server" Font-Size="30px"></asp:Label>
                    欢迎您,<a href ="StartForm.aspx" style ="color:aqua; font-size: 25px; text-align: right; position: relative;">退出登录</a></td>
            </tr>
            <tr>
                <td class="auto-style3" style="font-size: 30px; color: #C0C0C0; text-align: center;" colspan="4"><strong style="font-family: 幼圆; font-size: 55px; color: #FFFF00">用户中心<br />
                    </strong></td>
            </tr>
            <tr>
                <td class="auto-style13" style="font-size: 30px; color: #C0C0C0"><strong>用户名:<br />
                    </strong> </td>
                <td class="auto-style16">
                    <asp:TextBox ID="txtUser" runat="server" AutoPostBack="True" Height="32px" Width="269px"></asp:TextBox>
                </td>
                <td class="auto-style15" colspan="2" rowspan="5"></td>
            </tr>
            <tr>
                <td class="auto-style14" style="font-size: 30px; color: #C0C0C0"><strong>姓名:<br />
                    </strong></td>
                <td class="auto-style9">
                    <asp:TextBox ID="txtName" runat="server" AutoPostBack="True" Height="32px" Width="268px" style="text-align: left"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style14" style="font-size: 30px; color: #C0C0C0"><strong>性别:<br />
                    </strong></td>
                <td class="auto-style9">
                    <asp:TextBox ID="txtSex" runat="server" AutoPostBack="True" Height="32px" Width="267px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style14" style="font-size: 30px; color: #C0C0C0"><strong>密码:<br />
                    </strong></td>
                <td class="auto-style9">
                    <asp:TextBox ID="txtPwd" runat="server" AutoPostBack="True" Height="32px" Width="268px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style14" style="font-size: 30px; color: #C0C0C0">&nbsp;</td>
                <td class="auto-style9">
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style14">
                    <asp:Button ID="btnUpdate" runat="server" OnClick="btnUpdate_Click" Text="修改资料" Font-Size="27px" Height="58px" Width="123px" Font-Bold="True" ForeColor="Blue" />
                </td>
                <td class="auto-style9">
                    <asp:Button ID="btnOk" runat="server" OnClick="btnOk_Click" Text="保存" Font-Size="29px" Height="56px" Width="111px" Font-Bold="True" ForeColor="Blue" style="text-align: center" />
                </td>
                <td class="auto-style17">
                    <asp:Button ID="btnCancle" runat="server" Text="取消" Font-Size="28px" Height="55px" Width="98px" Font-Bold="True" ForeColor="Blue" OnClick="btnCancle_Click" />
                </td>
                <td class="auto-style12">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btnBack" runat="server" Text="返回上一界面" Font-Size="28px" Height="55px" Width="185px" Font-Bold="True" ForeColor="Blue" OnClick="btnBack_Click" />
                </td>
            </tr>
        </table>
    </form>
    </div>

</body>
</html>

(2)

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserInfoForm : System.Web.UI.Page
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        lblMessage.Text = Request.QueryString["user"].ToString();
        if (!IsPostBack)
        {
            txtName.ReadOnly = true;
            txtUser.ReadOnly = true;
            txtSex.ReadOnly = true;
            txtPwd.ReadOnly = true;
            btnOk.Visible = false;
            btnCancle.Visible = false;
    
            string username = Request.QueryString["user"].ToString();
    
            string strcon =
            ConfigurationManager.ConnectionStrings["data"].ConnectionString;
    
            string strsql = "select * from User_In where User_Name = @user";
            SqlConnection conn = new SqlConnection(strcon);
            SqlCommand com = new SqlCommand(strsql, conn);
            com.Parameters.AddWithValue("@user", username);
    
            SqlDataReader reader = null;
            conn.Open();
            reader = com.ExecuteReader();
            while (reader.Read())
            {
                txtUser.Text = reader["User_Name"].ToString();
                txtName.Text = reader["Name"].ToString();
                txtPwd.Text = reader["PassWord"].ToString();
                txtSex.Text = reader["Sex"].ToString();
            }
            conn.Close();
        }


    }

    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        txtName.ReadOnly = false;
        txtUser.ReadOnly = false;
        txtSex.ReadOnly = false;
        txtPwd.ReadOnly = false;
        btnUpdate.Visible = false;
        btnOk.Visible = true;
        btnCancle.Visible = true;

    }
    
    protected void btnOk_Click(object sender, EventArgs e)
    {
        string username = Request.QueryString["user"].ToString();
        string a = txtPwd.Text;
    
        if (this.txtName.Text == "" || this.txtPwd.Text == "" || this.txtSex.Text == "" || this.txtUser.Text == "")
        {
            Response.Write("<script language=javascript> alert('修改信息不能为空')</script>");
        }
        else
        {
            string strcon =
             ConfigurationManager.ConnectionStrings["data"].ConnectionString;


​            
​           
​            
​                
​            string strcom = string.Format("update User_In set User_Name = '{0}',Sex = '{1}',Name = '{2}',PassWord = '{3}' where User_Name = '{4}'", txtUser.Text, txtSex.Text, txtName.Text,txtPwd.Text, username);
​              
​            SqlConnection mycon = new SqlConnection(strcon);
​            SqlCommand mycom = new SqlCommand(strcom, mycon);
​            mycon.Open();
​            if (mycom.ExecuteNonQuery() > 0)
​            {
​                Response.Write("<script language=javascript> alert('修改成功')</script>");
​            }
​    
            mycon.Close();


​      
​           
​        }
​    
​    }
​    
    protected void btnCancle_Click(object sender, EventArgs e)
    {
        txtName.ReadOnly = true;
        txtUser.ReadOnly = true;
        txtSex.ReadOnly = true;
        txtPwd.ReadOnly = true;
        btnOk.Visible = false;
        btnCancle.Visible = false;
        btnUpdate.Visible = true;
    
    }
    
    protected void btnBack_Click(object sender, EventArgs e)
    {
        Response.Redirect("SuccessLoginForm.aspx?name="+lblMessage.Text);
    }
}

(3)

 5.管理员登录界面

 (1)

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>登录界面</title>
    <style type="text/css">
        .auto-style1 {
            width: 100%;
        }
        .auto-style2 {
            width: 236px;
            text-align: center;
        }
        .auto-style3 {
            height: 24px;
            text-align: center;
        }
        .auto-style4 {
            width: 249px;
        }
        .auto-style5 {
            width: 236px;
            text-align: center;
            height: 46px;
        }
        .auto-style6 {
            height: 46px;
            width: 169px;
        }
        .auto-style7 {
            width: 169px;
        }

        .auto-style8 {
            width: 249px;
        }
        
        .auto-style9 {
            height: 25px;
            text-align: center;
        }
        
        .auto-style10 {
            width: 169px;
            height: 45px;
        }
        .auto-style11 {
            width: 236px;
            text-align: center;
            height: 45px;
        }
        
    </style>
</head>
<body style ="background-image:url(http://localhost:59344/图片/backiee-124618.jpg); background-attachment: fixed; background-repeat: no-repeat; background-size: cover;">
    
    <div style="margin: auto; width: 972px">
    <form id="form1" runat="server">
        <table class="auto-style1">
            <tr>
                <td class="auto-style9" colspan="3" style="color: #CCFF66; font-size: 55px; font-family: 方正姚体;">
    
                    <strong style="font-size: 55px; color: #CCFF66; font-family: 方正姚体;">管理员登录</strong> </td>
            </tr>
            <tr>
                <td class="auto-style3" colspan="3">
    
                    &nbsp;</td>
            </tr>
            
            <tr>
                <td class="auto-style6" style="border-top-style: solid; border-width: inherit; border-color: #FFFF00; border-left-style: solid;">
    
        <asp:Label ID="lblUser" runat="server" Text="用户名:" ForeColor="#CCCCFF" Font-Bold="True" Font-Names="幼圆" Font-Size="37px" Font-Overline="False"></asp:Label>
                </td>
                <td class="auto-style5" style="border-top-style: solid; border-width: inherit; border-color: #FFFF00">
        <asp:TextBox ID="txtUserName" runat="server" Height="36px" style="margin-left: 0px" Width="244px"></asp:TextBox>
                </td>
                <td class="auto-style4" rowspan="6" style="border-top-style: solid; border-width: medium; border-color: #FFFF00; border-right-style: solid;">
        <asp:Label ID="lbMessg" runat="server" Font-Names="华文细黑" ForeColor="Yellow" Font-Size="30px"></asp:Label>
    
                </td>
            </tr>
            <tr>
                <td class="auto-style7" style="border-left-style: solid; border-color: #FFFF00">
    
                    &nbsp;</td>
                <td class="auto-style2">
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style10" style="border-left-style: solid; border-color: #FFFF00">
        <asp:Label ID="lblPwd" runat="server" Text="密码:" ForeColor="#CCCCFF" Font-Bold="True" Font-Names="幼圆" Font-Size="37px" ></asp:Label>
                </td>
                <td class="auto-style11"><asp:TextBox ID="txtPwd" runat="server" Height="35px" Width="244px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style7" style="border-left-style: solid; border-color: #FFFF00">
                    &nbsp;</td>
                <td class="auto-style2">&nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style7" style="border-left-style: solid; border-color: #FFFF00">&nbsp;</td>
                <td class="auto-style2">
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style7" style="border-left-style: solid; border-color: #FFFF00">&nbsp;</td>
                <td class="auto-style2">&nbsp;</td>
            </tr>
            <tr style="border-width: thick; border-bottom-style: solid; border-color: #FFFF00">
                <td class="auto-style7" style="border-left-style: solid; border-color: #FFFF00; border-bottom-style: solid;">
        <asp:Button ID="btnOk" runat="server" Text="登录" OnClick="btnOk_Click" Font-Names="华文新魏" Font-Size="35px" Height="49px" Width="103px" />
                </td>
                <td class="auto-style2" style="border-bottom-style: solid; border-color: #FFFF00">
        &nbsp;&nbsp;
        <asp:Button ID="btnClear" runat="server" Text="重置" OnClick="btnClear_Click" Font-Names="华文新魏" Font-Size="35px" Height="49px" Width="103px" />
    
                </td>
                <td class="auto-style8" style="border-top-style: none; border-width: medium; border-color: #FFFF00; border-right-style: solid; border-bottom-style: solid;">
        <asp:Button ID="btnCancle" runat="server" Text="取消" OnClick="btnCancle_Click" Font-Names="华文新魏" Font-Size="35px" Height="49px" style="margin-left: 0px" Width="98px" />
    
                </td>
            </tr>
        </table>
    </form>
    </div>

</body>
</html>

(2)

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class AdminLoginForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    
    protected void btnCancle_Click(object sender, EventArgs e)
    {
        Response.Redirect("StartForm.aspx");
    }
    
    protected void btnOk_Click(object sender, EventArgs e)
    {
        string user = txtUserName.Text;
        string pwd = txtPwd.Text;
        //建立数据库连接,从ConfigurationManager中获取连接数据库的字符串
        string strcon =
        ConfigurationManager.ConnectionStrings["data"].ConnectionString;
        //查询字符串
        string strsql = "select Pwd from AdminInfo where UName = @user";
        SqlConnection conn = new SqlConnection(strcon);
        SqlCommand com = new SqlCommand(strsql, conn);
        com.Parameters.AddWithValue("@user", user);
        //建立sqlDataReader用于读取数据
        SqlDataReader reader = null;
        conn.Open();
        reader = com.ExecuteReader();
        if (reader.Read()) //判断是否有下一条记录
        {
            if (reader["Pwd"].ToString() == pwd)
            {
    
                Response.Redirect("SuccessLoginForm.aspx?admin=" + txtUserName.Text+"&name="+"");
              
            }
            else
            {
                lbMessg.Text = "<font fontsize=4 color=red >密码出错,请重试</font>";
            }
        }
        else
        {
            lbMessg.Text = "<font fontsize=4 >用户名不存在!</font>";
        }
        conn.Close();
    }

    protected void btnClear_Click(object sender, EventArgs e)
    {
        txtPwd.Text = "";
        txtUserName.Text = "";
    }
}

(3)

 

 6.功能选择界面

 (1)

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>主界面</title>
    <style type="text/css">
        .auto-style1 {
            width: 100%;
        }
        .auto-style2 {
            height: 24px;
            text-align: center;
        }
        .auto-style3 {
            height: 31px;
        }
        .auto-style4 {
            text-align: center;
        }
    </style>
</head>
<body style ="background-image:url(http://localhost:59344/图片/backiee-124618.jpg); background-attachment: fixed; background-repeat: no-repeat; background-size: cover;">
    
    <div style="height: 803px; width: 1265px;"><form id="form1" runat="server">
    
        &nbsp;<table class="auto-style1">
            <tr>
                <td style="text-align: right; font-size: 30px; font-family: 微软雅黑; color: #FFFFFF;" class="auto-style3">
                    &nbsp;<asp:Label ID="lblMessage" runat="server" Font-Size="30px"></asp:Label>
                    欢迎您,<a href ="StartForm.aspx" style ="color:aqua; font-size: 25px;">退出登录</a></td>
            </tr>
            <tr style="font-family: 楷体; font-size: 70px;">
                <td class="auto-style2"><strong style="color: #FFFF00">欢迎来到ACM</strong> </td>
            </tr>
            <tr>
                <td style="font-family: 华文隶书; font-size: 45px; color: #FFFFFF;">
                    <br />
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    业精于勤荒于嬉,行成于思毁于随。<br />
                    <br />
                    <span>&nbsp;&nbsp;&nbsp;&nbsp; 不积跬步,无以至千里;不积小流,无以成江海。<br />
                    &nbsp;<br />
                    &nbsp;&nbsp;&nbsp;&nbsp; 用0和1去描述和创造这个世界的点点滴滴。<br />
                        <br />
                         &nbsp;&nbsp;&nbsp;&nbsp; 希望大家能够在这里学习到一些有用的知识,欢迎大家前来交流学习。<br />
                    </span></td>
            </tr>
            <tr>
                <td style="font-family: 幼圆; font-size: 45px; text-align: center;" aria-busy="False">
                    <br />
                    <asp:Button ID="btnBookMan" runat="server" Height="59px" Text="博文管理" Width="168px" OnClick="btnBookMan_Click" Font-Names="华文细黑" Font-Size="35px" />
                    &nbsp;&nbsp;&nbsp;&nbsp;<asp:Button ID="btnUserMan" runat="server" Height="59px" Text="用户管理" Width="168px" Font-Names="华文细黑" Font-Size="35px" Visible="False" OnClick="btnUserMan_Click" />
                    &nbsp;&nbsp; &nbsp;<asp:Button ID="btnPerson" runat="server" Height="59px" Text="个人中心" Width="168px" OnClick="btnPerson_Click" Font-Names="华文细黑" Font-Size="35px" />
&nbsp;&nbsp;&nbsp;&nbsp;
                    <br />
                    </td>
            </tr>
            <tr>
                <td style="font-family: 幼圆; font-size: 30px; text-align: right; color: #00FFFF;" class="auto-style4">
                    <br />
                    如果有任何问题请及时<a href =" Feedback.html" style="color: #FFFF00">联系我们</a> </td>
            </tr>
             <tr>
                <td >
                    <br />
                    <hr style="border-style: none; border-width: 50px; border-color: inherit; height: 10px; width: 98%; color: #6600FF;" noshade="noshade"/> </td>
            </tr>
            <tr>
                <td style="font-family: 幼圆; font-size: 40px; color: #66FF33;" class="auto-style4">
                    <strong style="color: #FFFFFF; font-size: 20px; font-family: 黑体">Copyright 2021 浙江师范大学 版权所有</strong></td>
            </tr>
            </table>
    
    
    </form></div>
</body>
</html>

(2)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class SuccessLoginForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["name"].ToString() == string.Empty)
            {
                btnUserMan.Visible = true;
                btnPerson.Visible = false;
                lblMessage.Text = Request.QueryString["admin"].ToString();
            }
            else
            {
                lblMessage.Text = Request.QueryString["name"].ToString();
            }
            
        }
        
    }
    
    protected void btnBookMan_Click(object sender, EventArgs e)
    {
        Response.Redirect("management.aspx?user=" + lblMessage.Text);
    }
    
    protected void btnPerson_Click(object sender, EventArgs e)
    {
        Response.Redirect("UserInfoForm.aspx?user=" + lblMessage.Text);
    }
    
    protected void btnUserMan_Click(object sender, EventArgs e)
    {
        Response.Redirect("UserManagerForm.aspx?user=" + lblMessage.Text);
    }
}

(3)

##### 普通用户登录

##### 管理员登录

 

 

7.用户管理界面

(1)

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>用户管理</title>
    <style type="text/css">
        .auto-style1 {
            width: 1168px;
        }
        .auto-style2 {
            height: 49px;
        }
        .auto-style3 {
            text-align: right;
        }
        .auto-style15 {
            text-align: left;
        }
        .auto-style16 {
            height: 24px;
        }
        .auto-style17 {
            height: 24px;
        }
    </style>
</head>
<body style ="background-image: url(http://localhost:59344/图片/backiee-124618.jpg); background-attachment: fixed; background-repeat: no-repeat; background-size: cover; ">
    
    <div style="margin: auto">
    <form id="form1" runat="server">
        <table class="auto-style1">
            <tr>
                <td class="auto-style3" colspan="4" style="font-family: 华文细黑; font-size: 30px; color: #00FFFF;">
                   <asp:Label ID="lblMessage" runat="server" Font-Size="30px"></asp:Label>
                    欢迎您,<a href ="StartForm.aspx" style ="color:aqua; font-size: 25px;">退出登录</a></td>
            </tr>
            <tr>
                <td class="auto-style2" colspan="4" style="font-family: 华康海报体W12(P); font-size: 45px; color: #00FFFF; text-align: center;">
                   <strong style="text-align: right"> 用户管理</strong>&nbsp;&nbsp; </td>
            </tr>
            <tr>
                <td class="auto-style16" colspan="3">
                </td>
                <td class="auto-style17">
                    </td>
            </tr>
            <tr>
                <td class="auto-style17">
                    <asp:Label ID="Label1" runat="server" Text="用户名:" Font-Bold="True" Font-Names="微软雅黑" Font-Size="25px" ForeColor="#FF9933"></asp:Label>
                </td>
                <td class="auto-style16">
                    <asp:TextBox ID="txtUserName" runat="server" Width="428px" Height="30px"></asp:TextBox>
                </td>
                <td class="auto-style13" rowspan="4">
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:RadioButtonList ID="rdla" runat="server" Width="368px" Font-Bold="True" Font-Italic="False" Font-Names="方正姚体" Font-Size="30px" ForeColor="Yellow">
                        <asp:ListItem>按用户名修改/删除/查找</asp:ListItem>
                        <asp:ListItem>按姓名修改/删除/查找</asp:ListItem>
                        <asp:ListItem>按性别修改/删除/查找</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
                <td class="auto-style2" rowspan="4">
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style5">
                    <asp:Label ID="Label2" runat="server" Text="密码:" Font-Bold="True" Font-Names="微软雅黑" Font-Size="25px" ForeColor="#FF9933"></asp:Label>
                </td>
                <td class="auto-style16">
                    <asp:TextBox ID="txtpwd" runat="server" Width="429px" Height="30px" style="text-align: left"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style6">
                    <asp:Label ID="Label3" runat="server" Text="姓名:" Font-Bold="True" Font-Names="微软雅黑" Font-Size="25px" ForeColor="#FF9933"></asp:Label>
                </td>
                <td class="auto-style15">
                    <asp:TextBox ID="txtName" runat="server" Width="428px" Height="30px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style6">
                    <asp:Label ID="Label4" runat="server" Text="性别:" Font-Bold="True" Font-Names="微软雅黑" Font-Size="25px" ForeColor="#FF9933"></asp:Label>
                </td>
                <td class="auto-style15">
                    <asp:RadioButtonList ID="rblSex" runat="server" Font-Bold="True" Font-Names="华文行楷" Font-Overline="False" Font-Size="30px" ForeColor="#FFCCCC">
                        <asp:ListItem>男</asp:ListItem>
                        <asp:ListItem>女</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <asp:Button ID="btadd" runat="server" OnClick="btadd_Click" Text="增加" Font-Names="幼圆" Font-Size="20px" ForeColor="Blue" Height="45px" Width="87px" />
&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btupdate" runat="server" OnClick="btupdate_Click"  Text="修改" Font-Names="幼圆" Font-Size="20px" ForeColor="Blue" Height="46px" Width="100px" />
&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btdelete" runat="server" OnClick="btdelete_Click" Text="删除" Font-Names="幼圆" Font-Size="20px" ForeColor="Blue" Height="45px" Width="98px" />
&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btfind" runat="server" OnClick="btfind_Click" Text="查询" Font-Names="幼圆" Font-Size="20px" ForeColor="Blue" Height="46px" Width="99px" />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btnBack" runat="server" OnClick="btnBack_Click" Text="返回上一界面" Font-Names="幼圆" Font-Size="20px" ForeColor="Blue" Height="38px" Width="206px" />
                    &nbsp;<br />
                    <br />
                    <asp:GridView ID="gridv1" runat="server" Width="1088px" Height="234px" BorderColor="#6666FF" Font-Size="20px" ForeColor="#66CCFF">
                    </asp:GridView>
                </td>
                <td class="auto-style2">
                    &nbsp;</td>
            </tr>
</table>
    </form>
    </div>
    
</body>
</html>

(2)

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserManager : System.Web.UI.Page
{
    public void FillGridView()
    {
        //从Web.Config文件中读出数据的连接字符串
        string strcon =
        ConfigurationManager.ConnectionStrings["data"].ConnectionString;
        //建立数据库连接
        SqlConnection conn = new SqlConnection(strcon);
        string strcom = "select User_Name as 用户名,Sex as 性别,Name as 姓名,PassWord as 密码,EntryDate As 注册时间 from User_In";
        SqlCommand sqlcom = new SqlCommand(strcom, conn);
        SqlDataAdapter sda = new SqlDataAdapter(sqlcom);
        conn.Open();
        DataSet ds = new DataSet();
        sda.Fill(ds, "BookInfo");
        conn.Close();
        this.gridv1.DataSource = ds;
        this.gridv1.DataBind();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        lblMessage.Text = Request.QueryString["user"].ToString();
        this.FillGridView();
    }
    
    protected void btadd_Click(object sender, EventArgs e)
    {
        string strcon =
ConfigurationManager.ConnectionStrings["data"].ConnectionString;
        string strcom = "insert into User_In(User_Name,Sex,Name,PassWord,EntryDate) values('" + txtUserName.Text + "','"  + rblSex.SelectedValue.ToString()+"','"  + txtName.Text + "','" +  txtpwd.Text +  "','" + DateTime.Now + "')";
        SqlConnection mycon = new SqlConnection(strcon);
        SqlCommand mycom = new SqlCommand(strcom, mycon);
        mycon.Open();
        mycom.ExecuteNonQuery();
        mycon.Close();
        this.FillGridView();
    }

    protected void btupdate_Click(object sender, EventArgs e)
    {
        if (this.txtUserName.Text == "" || this.txtpwd.Text == "" || this.txtName.Text == "")
        {
            Response.Write("<script language=javascript> alert('修改信息不能为空')</script>");
        }
        else
        {
            string strcon =
             ConfigurationManager.ConnectionStrings["data"].ConnectionString;
    
            string strcom = "";
            switch (rdla.SelectedIndex)
            {
                case 0:
                    strcom = string.Format("update User_In set Name = '{0}',Sex = '{1}',PassWord = '{2}' where User_Name = '{3}'", txtName.Text, rblSex.Text,txtpwd.Text, txtUserName.Text);
                    break;
                case 1:
                    strcom = string.Format("update User_In set User_Name = '{0}',Sex = '{1}',PassWord = '{2}' where Name = '{3}'", txtUserName.Text, rblSex.Text, txtpwd.Text, txtName.Text);
                    break;
                case 2:
                    strcom = string.Format("update User_In set Name = '{0}',User_Name = '{1}' ,PassWord = '{2}'where Sex = '{3}'", txtName.Text, txtUserName.Text, txtpwd.Text,rblSex.Text);
                    break;
            }
            if (rdla.SelectedValue != string.Empty)
            {
                SqlConnection mycon = new SqlConnection(strcon);
                SqlCommand mycom = new SqlCommand(strcom, mycon);
                mycon.Open();
                if (mycom.ExecuteNonQuery() > 0)
                {
                    Response.Write("<script language=javascript> alert('修改成功')</script>");
                }
                mycon.Close();
                this.FillGridView();
            }
            else
            {
                Response.Write("<script language=javascript> alert('请选择你的修改方式!')</script>");
            }
    
        }
    }
    
    protected void btdelete_Click(object sender, EventArgs e)
    {   
        string strcon =
        ConfigurationManager.ConnectionStrings["data"].ConnectionString;
        string strcom = "";
        switch (rdla.SelectedIndex)
       {
           case 0:
                strcom = string.Format("delete from User_In  where User_Name = '{0}'", txtUserName.Text);
                break;
           case 1:
                strcom = string.Format("delete from User_In  where Name = '{0}'", txtName.Text);
                break;
           case 2:
                strcom = string.Format("delete from User_In  where Sex = '{0}'", rblSex.Text);
                break;
       }
        if (rdla.SelectedValue != string.Empty)
        {
            SqlConnection mycon = new SqlConnection(strcon);
            SqlCommand mycom = new SqlCommand(strcom, mycon);
            mycon.Open();
            if (mycom.ExecuteNonQuery() > 0)
            {
                Response.Write("<script language=javascript> alert('删除成功')</script>");
            }
            else
            {
                Response.Write("<script language=javascript> alert('未能找到相关信息')</script>");
            }
    
            mycon.Close();
            this.FillGridView();
        }
        else
        {
            Response.Write("<script language=javascript> alert('请选择你的删除方式!')</script>");
        }    
        
    }
    
    protected void btfind_Click(object sender, EventArgs e)
    {
        string strcon =
ConfigurationManager.ConnectionStrings["data"].ConnectionString;
        SqlConnection con = new SqlConnection(strcon);
        con.Open();
        string strcom = "";
        switch (rdla.SelectedIndex)
        {//根据单选按钮组选项的ID来确定用户的选择
            case 0:
                strcom = "select  Id as 用户编号,User_Name as 用户名,PassWord as 密码,Sex As 性别,Name as 姓名,EntryDate As 注册时间 from User_In where User_Name like'%" + txtUserName.Text + "%'";
                break;
            case 1:
                strcom = "select  Id as 用户编号,User_Name as 用户名,PassWord as 密码,Sex As 性别,Name as 姓名,EntryDate As 注册时间 from User_In where Name like'%" + txtName.Text + "%'";
                break;
            case 2:
                strcom = "select  Id as 用户编号,User_Name as 用户名,PassWord as 密码,Sex As 性别,Name as 姓名,EntryDate As 注册时间 from User_In where Sex like'%" + rblSex.Text + "%'";
                break;
        }
        if (rdla.SelectedValue != string.Empty)
        {
            SqlCommand cmd = new SqlCommand(strcom, con);
            DataSet ds = new DataSet();
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            con.Close();
            sda.Fill(ds, "User_In");
                
            this.gridv1.DataSource = ds;
            this.gridv1.DataBind();


​          
​                

        }
        else
        {
            Response.Write("<script language=javascript> alert('请选择你的查询方式!')</script>");
        }
    }


    protected void btnBack_Click(object sender, EventArgs e)
    {
        Response.Redirect("SuccessLoginForm.aspx?name=" + lblMessage.Text);
    }
}

(3)

 8.博文管理页面

(1)

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>博文管理界面</title>
    <style type="text/css">
        .auto-style1 {
            width: 100%;
            height: 545px;
        }
        .auto-style2 {
            width: 105px;
        }
        .auto-style3 {
            text-align: center;
        }
        .auto-style6 {
            height: 28px;
            width: 120px;
        }
        .auto-style9 {
            text-align: center;
            width: 105px;
        }
        .auto-style11 {
            text-align: right;
            height: 53px;
        }
        .auto-style13 {
            width: 409px;
        }
        .auto-style15 {
            height: 28px;
            width: 294px;
        }
        .auto-style16 {
            width: 294px;
        }
        .auto-style18 {
            text-align: center;
            height: 53px;
        }
        .auto-style19 {
            width: 120px;
        }
    </style>
</head>
<body style ="background-image:url(http://localhost:59344/图片/backiee-124618.jpg); background-attachment: fixed; background-repeat: no-repeat; background-size: cover;">
    <form id="form1" runat="server">
    <div style="margin: auto; width: 1201px; height: 615px;">
    
        <table class="auto-style1">
            <tr>
                <td class="auto-style11" colspan="4" style="font-family: 华文细黑; font-size: 30px; color: #00FFFF;">
                   <asp:Label ID="lblMessage" runat="server" Font-Size="30px"></asp:Label>
                    欢迎您,<a href ="StartForm.aspx" style ="color:aqua; font-size: 25px;">退出登录</a></td>
            </tr>
            <tr>
                <td class="auto-style18" colspan="4" style="font-family: 华文琥珀; font-size: 57px; color: #00FFFF;">
                    博文管理 </td>
            </tr>
            <tr>
                <td class="auto-style3" colspan="3">
                </td>
                <td class="auto-style9">
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style19">
                    <asp:Label ID="Label1" runat="server" Text="编号:" Font-Bold="True" Font-Names="微软雅黑" Font-Size="25px" ForeColor="#FF9933"></asp:Label>
                </td>
                <td class="auto-style16">
                    <asp:TextBox ID="txtNum" runat="server" Width="428px" Height="30px"></asp:TextBox>
                </td>
                <td class="auto-style13" rowspan="3">
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:RadioButtonList ID="rdla" runat="server" Width="399px" Font-Bold="True" Font-Italic="False" Font-Names="方正姚体" Font-Size="30px" ForeColor="Yellow" >
                        <asp:ListItem>按编号修改/删除/查找</asp:ListItem>
                        <asp:ListItem>按博文名称修改/删除/查找</asp:ListItem>
                        <asp:ListItem>按作者修改/删除/查找</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
                <td class="auto-style2" rowspan="3">
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="auto-style19">
                    <asp:Label ID="Label2" runat="server" Text="博文名称:" Font-Bold="True" Font-Names="微软雅黑" Font-Size="25px" ForeColor="#FF9933"></asp:Label>
                </td>
                <td class="auto-style16">
                    <asp:TextBox ID="txtName" runat="server" Width="429px" Height="30px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="auto-style6">
                    <asp:Label ID="Label3" runat="server" Text="作者:" Font-Bold="True" Font-Names="微软雅黑" Font-Size="25px" ForeColor="#FF9933"></asp:Label>
                </td>
                <td class="auto-style15">
                    <asp:TextBox ID="txtAuthor" runat="server" Width="428px" Height="30px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <asp:Button ID="btadd" runat="server" OnClick="btadd_Click" Text="增加" Font-Names="幼圆" Font-Size="20px" ForeColor="Blue" />
&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btupdate" runat="server" OnClick="btupdate_Click"  Text="修改" Font-Names="幼圆" Font-Size="20px" ForeColor="Blue" />
&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btdelete" runat="server" OnClick="btdelete_Click" Text="删除" Font-Names="幼圆" Font-Size="20px" ForeColor="Blue" />
&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btfind" runat="server" OnClick="btfind_Click" Text="查询" Font-Names="幼圆" Font-Size="20px" ForeColor="Blue" />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btfind0" runat="server" OnClick="btfind0_Click" Text="返回上一界面" Font-Names="幼圆" Font-Size="20px" ForeColor="Blue" />
                    &nbsp;<br />
                    <br />
                    <asp:GridView ID="gridv1" runat="server" Width="845px" Height="234px" BorderColor="#6666FF" Font-Size="20px" ForeColor="#66CCFF">
                    </asp:GridView>
                </td>
                <td class="auto-style2">
                    &nbsp;</td>
            </tr>
        </table>
    
    </div>
    </form>
</body>
</html>

(2)

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class management : System.Web.UI.Page
{

    public void FillGridView()
    {
        //从Web.Config文件中读出数据的连接字符串
        string strcon =
        ConfigurationManager.ConnectionStrings["data"].ConnectionString;
        //建立数据库连接
        SqlConnection conn = new SqlConnection(strcon);
        string strcom = "select ArticleId as 博文编号,ArticleName as 博文标题,Author as 作者,InData As 入库时间 from ArticleInfo";
        SqlCommand sqlcom = new SqlCommand(strcom, conn);
        SqlDataAdapter sda = new SqlDataAdapter(sqlcom);
        conn.Open();
        DataSet ds = new DataSet();
        sda.Fill(ds, "BookInfo");
        conn.Close();
        this.gridv1.DataSource = ds;
        this.gridv1.DataBind();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        lblMessage.Text = Request.QueryString["user"].ToString();
        this.FillGridView();
    }
    
    protected void btadd_Click(object sender, EventArgs e)
    {
        string strcon =
        ConfigurationManager.ConnectionStrings["data"].ConnectionString;
        string strcom = "insert into ArticleInfo(ArticleId,ArticleName,Author,InData) values('" + txtNum.Text + "','" + txtName.Text + "','" + txtAuthor.Text + "','"+DateTime.Now + "')";
        SqlConnection mycon = new SqlConnection(strcon);
        SqlCommand mycom = new SqlCommand(strcom, mycon);
        mycon.Open();
        mycom.ExecuteNonQuery();
        mycon.Close();
        this.FillGridView();
    }
    
    protected void btupdate_Click(object sender, EventArgs e)
    {
    
        if (this.txtNum.Text == "" || this.txtName.Text == "" || this.txtAuthor.Text == "")
        {
            Response.Write("<script language=javascript> alert('修改信息不能为空')</script>");
        }
        else
        {
            string strcon =
             ConfigurationManager.ConnectionStrings["data"].ConnectionString;
    
            string strcom = "";
            switch (rdla.SelectedIndex)
            {
                case 0:
                    strcom = string.Format("update ArticleInfo set ArticleName = '{0}',Author = '{1}' where ArticleId = '{2}'", txtName.Text,txtAuthor.Text,txtNum.Text);
                    break;
                case 1:
                    strcom = string.Format("update ArticleInfo set ArticleId = '{0}',Author = '{1}' where ArticleName = '{2}'", txtNum.Text, txtAuthor.Text, txtName.Text);
                    break;
                case 2:
                    strcom = string.Format("update ArticleInfo set ArticleId = '{0}',ArticleName = '{1}' where Author = '{2}'", txtNum.Text, txtName.Text, txtAuthor.Text);
                    break;
            }
            if (rdla.SelectedValue != string.Empty)
            {
                SqlConnection mycon = new SqlConnection(strcon);
                SqlCommand mycom = new SqlCommand(strcom, mycon);
                mycon.Open();
                if (mycom.ExecuteNonQuery() > 0)
                {
                    Response.Write("<script language=javascript> alert('修改成功')</script>");
                }
                else
                {
                    Response.Write("<script language=javascript> alert('未能找到相关信息')</script>");
                }
                mycon.Close();
                this.FillGridView();
            }
            else
            {
                Response.Write("<script language=javascript> alert('请选择你修改的方式!')</script>");
            }
                
        }
    }
    
    protected void btdelete_Click(object sender, EventArgs e)
    {
        
            string strcon =
            ConfigurationManager.ConnectionStrings["data"].ConnectionString;
            string strcom = "";
            switch (rdla.SelectedIndex)
            {
                case 0:
                    strcom = string.Format("delete from ArticleInfo  where ArticleId = '{0}'",  txtNum.Text);
                    break;
                case 1:
                    strcom = string.Format("delete from ArticleInfo  where ArticleName = '{0}'",  txtName.Text);
                    break;
                case 2:
                    strcom = string.Format("delete from ArticleInfo  where Author = '{0}'",  txtAuthor.Text);
                    break;
            }
            if (rdla.SelectedValue != string.Empty)
            {
                SqlConnection mycon = new SqlConnection(strcon);
                SqlCommand mycom = new SqlCommand(strcom, mycon);
                mycon.Open();
                if (mycom.ExecuteNonQuery() > 0)
                {
                    Response.Write("<script language=javascript> alert('删除成功')</script>");
                }
                else
                {
                    Response.Write("<script language=javascript> alert('未能找到相关信息')</script>");
                }
                mycon.Close();
                this.FillGridView();
            }
            else
            {
                Response.Write("<script language=javascript> alert('请选择你的删除的方式!')</script>");
            }


​        
​    }
​    
​    protected void btfind_Click(object sender, EventArgs e)
​    {
​        string strcon =
ConfigurationManager.ConnectionStrings["data"].ConnectionString;
​        SqlConnection con = new SqlConnection(strcon);
​        con.Open();
​        string strcom = "";
​        switch (rdla.SelectedIndex)
​        {//根据单选按钮组选项的ID来确定用户的选择
​            case 0: //选择了“按编号查询”
​                strcom = "select  ArticleId as 博文编号,ArticleName as 博文标题,Author as 作者,InData As 入库时间 from ArticleInfo where ArticleId like'%" + txtNum.Text + "%'";
​                break;
​            case 1://选择了“按姓名查询”
​                strcom = "select  ArticleId as 博文编号,ArticleName as 博文标题,Author as 作者,InData As 入库时间 from ArticleInfo where ArticleName like'%" + txtName.Text + "%'";
​                break;
​            case 2:
​                strcom = "select  ArticleId as 博文编号,ArticleName as 博文标题,Author as 作者,InData As 入库时间 from ArticleInfo where Author like'%" + txtAuthor.Text + "%'";
​                break;
​        }
​        if (rdla.SelectedValue != string.Empty)
​        {
​            SqlCommand cmd = new SqlCommand(strcom, con);
​            DataSet ds = new DataSet();
​            SqlDataAdapter sda = new SqlDataAdapter(cmd);
​            sda.Fill(ds, "student");
​            

            con.Close();
            this.gridv1.DataSource = ds;
            this.gridv1.DataBind();


​            
​            
​                
​            
​                


        }
        else
        {
            Response.Write("<script language=javascript> alert('请选择你的查询方式!')</script>");
        }
       
    }
    
    protected void btfind0_Click(object sender, EventArgs e)
    {
        Response.Redirect("SuccessLoginForm.aspx?name=" + lblMessage.Text);
    }
}

(3)

9.用户反馈界面

(1)

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户反馈</title>

    <script src="JavaScript.js"></script>

</head>

<body background="图片/backiee-194354.jpg" style="background-size: cover">
<div>
  <table width="700" border="1" align="center" >
    <tr>
      <td align="center" style="color: yellow;font-size:25px"><h1>用户反馈</h1></td>
    </tr>
    <tr>
      <td ><marquee scrollamount="8" style="color: #14E85C; font-size:15px"><h2>欢迎提出宝贵意见</h2></marquee></td>
    </tr>
    <tr>
      <td><div id="box" style="height:400px; color: aliceblue;font-size: 25px"></div></td>
    </tr>

    <tr>
      <td><div id="left" >
      <textarea id="msg"  name="message" rows="4" cols="30" style="color: #F2FB0A; background-color: transparent; font-size: 30px"></textarea> </div>
      <div id="right" width:50px>
      <input type="button" id="btn"  style="font-size:18px" value="确定" />  
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   
      <input type="button"  id="calc" style="font-size:18px" value="取消"  οnclick="calc()"/>
          <p></p>
          <dr/>
    </div>
          <div><input type="text"  id="txt"   readonly style="background-color: transparent;  color: yellow;font-size: 24px;font-family:宋体;" ></div>
          <input type="button" style="font-size:18px" value="显示时间" onClick="showtime()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input type="button" style="font-size:18px" value="暂停时间" onClick="stopCount()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <a href="StartForm.aspx"> <input type="button" style="font-size:18px" value="返回" /></a>
      </td>
    </tr>
  </table>
</div>

</body>
    
<head>

    <script src="JavaScript.js"></script>
</head>
</html>

 (2)

 六.小结

通过这次的学习研究,我知道了如何去开发一个好的网页,以及网站的运行机制,包括如何去管理一个网站,管理员及用户的登录和注册页面等。我发现了自己在Asp.NET设计中的不足,对数据库的调用还不够熟悉,经常遇到许多的问题,经常会犯一些致命的错误。在今后的学习中我要做到一丝不苟,坚持努力,多去练习降低出错率。利用该项技术去创造出更多有用美观的网页。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值