吃饱了撑着的系列-家用留言网站

博主利用ASP.NET开发了一个留言板系统,客人可通过扫描二维码留言,主人则可查看及管理留言。系统包括客人留言界面、主人登录及留言管理功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天突发奇想的一个东西,做出来感觉挺不错

虽然基本没有考虑网络攻击啊网络安全什么的情况,而且用的时候连防火墙都得关了

不过我觉得创意还是不错滴~

 

先简单描述一下我的需求:

一个客人准备登门拜访我,但我不在家,家里也没人,肿么办呢?

一般情况下,客人随身带便利贴而且还愿意给你留言登门来意的情况很少,有什么东西可以解决这一情况呢?

如果我在门口贴一个二维码,客人扫描手机登录一个网站不就可以留言了么?

我寻思了一两分钟,发现其实技术实现并不难,而且需求也很少:

1、客人写留言的界面,留言内容要能保存到数据库

2、主人能查看留言并管理留言

别的需求差不多没了,有以上这两点就已经很实用了

 

如何实现呢?

用ASP.NET开发吧,我也熟悉,在IIS服务器上部署也简单,正好电脑上齐备了VS2013、MySQL、Dreamweaver

要是我在家有一台闲置的或者专门管理智能家居的服务器电脑,那就正好用来当部署机了,不过现阶段的防火墙得关这是个隐患

 

码代码中(4个小时的功夫)……

 

写了个大概,先玩玩吧:

这是部署好了以后在电脑的浏览器上尝试的

给主人家留个言,约波麻将

主人家回来了,登录上去看看

看看出去这一趟都谁来过(在家的时候无人问津,一出门就各种人上门拜访)

(上面这些按钮的操作可是都没问题的哦)

要是有的留言太长,表格显示不完,那就点进去看看

OK,PC上没问题了,把防火墙关了,试试手机上

首先,把WLAN打开,连到电脑,记住DHCP分配给电脑的IP地址,比如是192.168.1.3,IIS上部署的端口是3450

网上随便找一个网站,把http://192.168.1.3:3450生成一个二维码,打印个告示出来附上二维码,贴在门口

“请连接到Johan_home(密码:88888888),扫码留言”

然后,装作家里没人,把自己锁外面……拿出手机,连到WLAN,浏览器扫码

好吧我承认在手机上看着字有点小……无伤大雅,无伤大雅

留个言,约一波踢球

然后假装刚从外面回来,连上WiFi,进入网站看看有什么未处理的留言,还真不少

 

emmmmmmmm,成就感满满,感觉非常好就像是刚逛了超市回来买了很多东西那种满足

上源码吧,GitHub登不上去奇了怪了:

【Default.aspx】默认页面

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

<!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>
</head>
<body>
    <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="Image/headImage.png" width="1000" height="150"></td>
      </tr>
      <tr>
        <td><table width="800" border="0" align="center" cellpadding="0" cellspacing="20">
          <tr>
            <td><a href="WriteMessage.aspx"><img src="Image/note.png" width="370" height="200" border="0"></a></td>
            <td><a href="login.aspx"><img src="Image/read.png" width="370" height="200" border="0"></a></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><img src="Image/tailImage.png" width="1000" height="200"></td>
      </tr>
    </table>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>

【Default.aspx.cs】

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

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

    }
}

【WriteMessage.aspx】客人写留言的页面

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

<!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 {
            height: 16px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="Image/writeHeadImage.png" width="1000" height="150"></td>
      </tr>
      <tr>
        <td><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td class="auto-style1">
                <asp:Label ID="Label1" runat="server" Text="姓名:"></asp:Label>
              </td>
          </tr>
            <tr>
            <td>
                <asp:TextBox ID="TextBoxName" runat="server" Width="200px"></asp:TextBox>
              </td>
          </tr>
            <tr>
            <td>
                <asp:Label ID="Label4" runat="server" Text="留言:"></asp:Label>
              </td>
          </tr>
          <tr>
            <td>
                <asp:TextBox ID="TextBoxMessage" runat="server" Height="200px" Width="600px" TextMode="MultiLine"></asp:TextBox>
              </td>
          </tr>
            <tr>
            <td>
                
                <asp:Label ID="Label5" runat="server" Text="(提交后主人会及时查阅并回话,谢谢)"></asp:Label>
                
              </td>
          </tr>
          <tr>
            <td>
                <asp:Button ID="ButtonSubmit" runat="server" Text="提交" Width="200px" OnClick="ButtonSubmit_Click" />
              </td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><img src="Image/tailImage.png" width="1000" height="200"></td>
      </tr>
    </table>
    <div>
    
    </div>
    </form>
</body>
</html>

【WriteMessage.aspx.cs】

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

using MySql.Data;
using MySql.Data.MySqlClient;
using System.Collections;
using System.Configuration;

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

    }

    /*
     * 函数名:ButtonSubmit_Click
     * 作用:点击“提交”响应事件
     * 参数:object sender, EventArgs e
     * 返回:void
     */
    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
        // 获取输入的参数
        string name = TextBoxName.Text.ToString();
        string message = TextBoxMessage.Text.ToString();

        // 保存
        if (saveMessage(name, message))
        {
            Response.Write("<script>alert('留言已保存,主人会尽快回复!');</script>");
        }
        else
        {
            Response.Write("<script>alert('留言保存失败!');</script>");
        }
        Response.Redirect("Default.aspx");
    }

    /*
     * 函数名:saveMessage
     * 作用:保存留言
     * 参数:string name, string message
     * 返回:bool
     */
    private bool saveMessage(string name, string message)
    {
        // 获取提交时的日期
        string Date = "";
        DateTime cur = new DateTime();
        cur = System.DateTime.Now;
        Date += cur.Year + "/";
        Date += cur.Month + "/";
        Date += cur.Day + " ";
        Date += cur.Hour + ":";
        Date += cur.Minute + ":";
        Date += cur.Second;

        // 连接数据库
        string constr = "server=localhost;User Id=root;password=123456;Database=evmm";
        MySqlConnection mycon = new MySqlConnection(constr);
        mycon.Open();

        // 执行插入操作
        string sql = string.Format("insert into home_messages values('{0}','{1}','{2}','{3}')", name, Date, message, "未查看");
        MySqlCommand mycmd = new MySqlCommand(sql, mycon);
        bool flag;
        if (mycmd.ExecuteNonQuery() > 0)
        {
            flag = true;
        }
        else
        {
            flag = false;
        }

        // 关闭数据库
        mycon.Close();
        return flag;
    }
}

【login.aspx】主人登录页面

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

<!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 {
            height: 41px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="Image/loginHeadImage.png" width="1000" height="150"></td>
      </tr>
      <tr>
        <td><table width="800" border="0" align="center" cellpadding="0" cellspacing="20">
          <tr>
            <td class="auto-style1"><div align="center">
                <asp:Label ID="Label1" runat="server" Text="账号"></asp:Label>
                <asp:TextBox ID="TextBoxAccount" runat="server" Width="200px"></asp:TextBox>
                </div></td>
          </tr>
          <tr>
            <td><div align="center">
                <asp:Label ID="Label2" runat="server" Text="密码"></asp:Label>
                <asp:TextBox ID="TextBoxPwd" runat="server" Width="200px"></asp:TextBox>
                </div></td>
          </tr>
          <tr>
            <td><div align="center">
                <asp:Button ID="ButtonLogin" runat="server" OnClick="ButtonLogin_Click" Text="登录" Width="100px" />
                </div></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><img src="Image/tailImage.png" width="1000" height="200"></td>
      </tr>
    </table>
    <div>
    
    </div>
    </form>
</body>
</html>

【login.aspx.cs】

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

using MySql.Data;
using MySql.Data.MySqlClient;
using System.Collections;
using System.Configuration;

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

    }

    /*
     * 函数名:ButtonLogin_Click
     * 作用:验证登录
     * 参数:object sender, EventArgs e
     * 返回:void
     */
    protected void ButtonLogin_Click(object sender, EventArgs e)
    {
        // 获取输入的参数
        string acc = TextBoxAccount.Text.ToString();
        string pwd = TextBoxPwd.Text.ToString();

        // 验证成功
        if (success(acc, pwd))
        {
            Response.Redirect("admin.aspx");
        }

        // 验证失败
        else
        {
            Response.Write("<script>alert('账号或密码错误!');</script>");
        }
    }

    /*
     * 函数名:success
     * 作用:从数据库验证登录
     * 参数:string acc, string pwd
     * 返回:bool
     */
    private bool success(string acc, string pwd)
    {
        // 连接数据库
        string constr = "server=localhost;User Id=root;password=123456;Database=evmm";
        MySqlConnection mycon = new MySqlConnection(constr);
        mycon.Open();

        // 查询操作
        string sql = string.Format("select password from home_admins where account={0}", acc);
        MySqlCommand mycmd = new MySqlCommand(sql, mycon);
        MySqlDataReader reader = null;
        reader = mycmd.ExecuteReader();
        string pwdGet = "";

        // 验证密码
        while (reader.Read())
        {
            pwdGet = reader[0].ToString();
        }

        // 关闭数据库
        reader.Close();
        mycon.Close();

        // 对比
        if (pwd == pwdGet)
        {
            return true;   // 验证通过
        }
        else
        {
            return false;  // 验证失败
        }
    }
}

【admin.aspx】主人页面

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

<!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>
</head>
<body>
    <form id="form1" runat="server">
    <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="Image/adminHeadImage.png" width="1000" height="150"></td>
      </tr>
      <tr>
        <td><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td>
                <asp:Button ID="ButtonAllRead" runat="server" OnClick="ButtonAllRead_Click" Text="全部标记为已读" Width="150px" />
                <asp:Button ID="ButtonClear" runat="server" OnClick="ButtonClear_Click" Text="全部删除" Width="150px" />
                <asp:Button ID="ButtonClearSelected" runat="server" OnClick="ButtonClearSelected_Click" Text="删除已选" Width="150px" />
                <asp:Button ID="ButtonReadSelected" runat="server" OnClick="ButtonReadSelected_Click" Text="标记已选已读" Width="150px" />
              </td>
          </tr>
          <tr>
            <td>
                <asp:Table ID="Table1" runat="server">
                </asp:Table>
              </td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><img src="Image/tailImage.png" width="1000" height="200"></td>
      </tr>
    </table>
    <div>
    
    </div>
    </form>
</body>
</html>

【admin.aspx.cs】

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

using MySql.Data;
using MySql.Data.MySqlClient;
using System.Collections;
using System.Configuration;

public partial class admin : System.Web.UI.Page
{
    // 参数
    private int MN;           // 留言数量
    private CheckBox[] check; // 可选框
    private Label[] dateLabel;// 日期标签

    /*
     * 函数名:Page_Load
     * 作用:页面加载
     * 参数:object sender, EventArgs e
     * 返回:void
     */
    protected void Page_Load(object sender, EventArgs e)
    {
        // 加载留言数据
        MN = getMessages();
        check = new CheckBox[MN];
        dateLabel = new Label[MN];
        readFromDatabase();
    }

    /*
     * 函数名:readFromDatabase
     * 作用:从数据库加载留言数据
     * 参数:void
     * 返回:void
     */
    private void readFromDatabase()
    {
        // 创建数组
        HomeMessage [] HM = new HomeMessage[MN];
        for(int i = 0;i < MN;i++)
        {
            HM[i] = new HomeMessage();
        }

        // 从数据库读取到数组
        string constr = "server=localhost;User Id=root;password=123456;Database=evmm";
        MySqlConnection mycon = new MySqlConnection(constr);
        mycon.Open();
        string sql = string.Format("select * from home_messages");
        MySqlCommand mycmd = new MySqlCommand(sql, mycon);
        MySqlDataReader reader = null;
        reader = mycmd.ExecuteReader();
        int index = 0;
        while (reader.Read())
        {
            HM[index].setName(reader[0].ToString());
            HM[index].setDate(reader[1].ToString());
            HM[index].setMessage(reader[2].ToString());
            HM[index].setStatus(reader[3].ToString());
            index++;
        }
        reader.Close();
        mycon.Close();

        // 显示到表格控件
        TableRow row;
        TableCell cell;
        LinkButton linkBut;
        Label label;
        for(int i = 0;i < MN; i++)
        {
            // 每次循环是添加一行的内容
            // 可选框
            row = new TableRow();
            cell = new TableCell();
            check[i] = new CheckBox();
            cell.Controls.Add(check[i]);
            row.Cells.Add(cell);

            // 姓名
            cell = new TableCell();
            label = new Label();
            label.Text = HM[i].getName();
            cell.Controls.Add(label);
            row.Cells.Add(cell);

            // 日期
            cell = new TableCell();
            dateLabel[i] = new Label();
            dateLabel[i].Text = HM[i].getDate();
            cell.Controls.Add(dateLabel[i]);
            row.Cells.Add(cell);

            // 留言
            cell = new TableCell();
            linkBut = new LinkButton();
            linkBut.Text = HM[i].getMessage();
            linkBut.PostBackUrl = "MessageDetail.aspx?date=" + HM[i].getDate();
            cell.Controls.Add(linkBut);
            row.Cells.Add(cell);

            // 阅读状态
            cell = new TableCell();
            label = new Label();
            label.Text = HM[i].getStatus();
            if (label.Text.ToString() == "未查看")
            {
                label.BackColor = System.Drawing.Color.Red;
            }
            cell.Controls.Add(label);
            row.Cells.Add(cell);

            // 加到表格
            Table1.Rows.Add(row);
        }
    }

    /*
     * 函数名:getMessages
     * 作用:查看留言记录总数量
     * 参数:void
     * 返回:int
     */
    private int getMessages()
    {
        int n = 0;

        // 连接数据库
        string constr = "server=localhost;User Id=root;password=123456;Database=evmm";
        MySqlConnection mycon = new MySqlConnection(constr);
        mycon.Open();

        // 查询操作
        string sql = string.Format("select count(*) from home_messages");
        MySqlCommand mycmd = new MySqlCommand(sql, mycon);
        MySqlDataReader reader = null;
        reader = mycmd.ExecuteReader();

        // 读取
        while (reader.Read())
        {
            n = int.Parse(reader[0].ToString());
        }

        // 关闭数据库
        reader.Close();
        mycon.Close();

        return n;
    }

    /*
     * 函数名:ButtonAllRead_Click
     * 作用:全部标记已读
     * 参数:object sender, EventArgs e
     * 返回:void
     */
    protected void ButtonAllRead_Click(object sender, EventArgs e)
    {
        // 连接数据库
        string constr = "server=localhost;User Id=root;password=123456;Database=evmm";
        MySqlConnection mycon = new MySqlConnection(constr);
        mycon.Open();

        // 执行插入操作
        string sql = string.Format("update home_messages set status='已查看'");
        MySqlCommand mycmd = new MySqlCommand(sql, mycon);
        if (mycmd.ExecuteNonQuery() > 0)
        {
            Response.Redirect("admin.aspx");
        }
        else
        {
            Response.Write("<script>alert('标记过程出错!');</script>");
        }

        // 关闭数据库
        mycon.Close();
    }

    /*
     * 函数名:ButtonAllClear_Click
     * 作用:全部删除
     * 参数:object sender, EventArgs e
     * 返回:void
     */
    protected void ButtonClear_Click(object sender, EventArgs e)
    {
        // 连接数据库
        string constr = "server=localhost;User Id=root;password=123456;Database=evmm";
        MySqlConnection mycon = new MySqlConnection(constr);
        mycon.Open();

        // 执行插入操作
        string sql = string.Format("delete from home_messages");
        MySqlCommand mycmd = new MySqlCommand(sql, mycon);
        if (mycmd.ExecuteNonQuery() > 0)
        {
            Response.Write("<script>alert('删除完成!');</script>");
            Response.Redirect("admin.aspx");
        }
        else
        {
            Response.Write("<script>alert('删除过程出错!');</script>");
            Response.Redirect("admin.aspx");
        }

        // 关闭数据库
        mycon.Close();
    }

    /*
     * 函数名:ButtonClearSelected_Click
     * 作用:删除已选
     * 参数:object sender, EventArgs e
     * 返回:void
     */
    protected void ButtonClearSelected_Click(object sender, EventArgs e)
    {
        // 筛选已选项,标记角标,定向删除
        for (int i = 0;i < MN;i++)
        {
            if (check[i].Checked == true)
            {
                // 连接数据库
                string constr = "server=localhost;User Id=root;password=123456;Database=evmm";
                MySqlConnection mycon = new MySqlConnection(constr);
                mycon.Open();

                // 执行删除操作
                string sql = string.Format("delete from home_messages where Date='{0}'", dateLabel[i].Text.ToString());
                MySqlCommand mycmd = new MySqlCommand(sql, mycon);
                mycmd.ExecuteNonQuery();
                
                // 关闭数据库
                mycon.Close();
            }
            else
            {
                continue;
            }
        }
        Response.Redirect("admin.aspx");
    }

    /*
     * 函数名:ButtonReadSelected_Click
     * 作用:标记已选已读
     * 参数:object sender, EventArgs e
     * 返回:void
     */
    protected void ButtonReadSelected_Click(object sender, EventArgs e)
    {
        // 筛选已选项,标记角标,定向删除
        for (int i = 0; i < MN; i++)
        {
            if (check[i].Checked == true)
            {
                // 连接数据库
                string constr = "server=localhost;User Id=root;password=123456;Database=evmm";
                MySqlConnection mycon = new MySqlConnection(constr);
                mycon.Open();

                // 执行修改操作
                string sql = string.Format("update home_messages set status='已查看' where Date='{0}'", dateLabel[i].Text.ToString());
                MySqlCommand mycmd = new MySqlCommand(sql, mycon);
                mycmd.ExecuteNonQuery();

                // 关闭数据库
                mycon.Close();
            }
            else
            {
                continue;
            }
        }
        Response.Redirect("admin.aspx");
    }
}

【MessageDetail.aspx】留言详细页面

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

<!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 {
            height: 36px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="Image/adminHeadImage.png" width="1000" height="150"></td>
      </tr>
      <tr>
        <td><table width="800" border="0" align="center" cellpadding="0" cellspacing="20">
          <tr>
            <td class="auto-style1">
                <asp:Label ID="LabelName" runat="server" Text="姓名:"></asp:Label>
              </td>
          </tr>
          <tr>
            <td class="auto-style1">
                <asp:Label ID="LabelContent" runat="server" Text="内容:"></asp:Label>
              </td>
          </tr>
          <tr>
            <td>
                <asp:Button ID="ButtonDelete" runat="server" OnClick="ButtonDelete_Click" Text="删除" Width="200px" />
                <asp:Button ID="ButtonReturn" runat="server" OnClick="ButtonReturn_Click" Text="返回" Width="200px" />
              </td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><img src="Image/tailImage.png" width="1000" height="200"></td>
      </tr>
    </table>
    <div>
    
    </div>
    </form>
</body>
</html>

【MessageDetail.aspx.cs】

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

using MySql.Data;
using MySql.Data.MySqlClient;
using System.Collections;
using System.Configuration;

public partial class MessageDetail : System.Web.UI.Page
{
    // 参数
    private string date;   // 留言日期

    /*
     * 函数名:Page_Load
     * 作用:页面加载
     * 参数:object sender, EventArgs e
     * 返回:void
     */
    protected void Page_Load(object sender, EventArgs e)
    {
        date = Request.QueryString["date"];
        readData();
        signedRead();
    }

    /*
     * 函数名:readData
     * 作用:加载内容
     * 参数:void
     * 返回:void
     */
    private void readData()
    {
        // 从数据库读取到数组
        string constr = "server=localhost;User Id=root;password=123456;Database=evmm";
        MySqlConnection mycon = new MySqlConnection(constr);
        mycon.Open();
        string sql = string.Format("select Name, Message from home_messages where Date='{0}'", date);
        MySqlCommand mycmd = new MySqlCommand(sql, mycon);
        MySqlDataReader reader = null;
        reader = mycmd.ExecuteReader();
        string name = "";
        string content = "";
        while (reader.Read())
        {
            name = reader[0].ToString();
            content = reader[1].ToString();
        }
        reader.Close();
        mycon.Close();

        // 显示
        LabelName.Text = "姓名:" + name;
        LabelContent.Text = "内容:" + content;
    }

    /*
     * 函数名:ButtonDelete_Click
     * 作用:删除该留言
     * 参数:object sender, EventArgs e
     * 返回:void
     */
    protected void ButtonDelete_Click(object sender, EventArgs e)
    {
        // 连接数据库
        string constr = "server=localhost;User Id=root;password=123456;Database=evmm";
        MySqlConnection mycon = new MySqlConnection(constr);
        mycon.Open();

        // 执行删除操作
        string sql = string.Format("delete from home_messages where Date='{0}'", date);
        MySqlCommand mycmd = new MySqlCommand(sql, mycon);
        if (mycmd.ExecuteNonQuery() > 0)
        {
            Response.Write("<script>alert('删除完成!');</script>");
            Response.Redirect("admin.aspx");
        }
        else
        {
            Response.Write("<script>alert('删除过程出错!');</script>");
            Response.Redirect("admin.aspx");
        }

        // 关闭数据库
        mycon.Close();
    }

    /*
     * 函数名:signedRead
     * 作用:标记为已读
     * 参数:void
     * 返回:void
     */
    private void signedRead()
    {
        // 连接数据库
        string constr = "server=localhost;User Id=root;password=123456;Database=evmm";
        MySqlConnection mycon = new MySqlConnection(constr);
        mycon.Open();

        // 执行删除操作
        string sql = string.Format("update home_messages set status='已查看' where Date='{0}'", date);
        MySqlCommand mycmd = new MySqlCommand(sql, mycon);
        mycmd.ExecuteNonQuery();

        // 关闭数据库
        mycon.Close();
    }

    /*
     * 函数名:ButtonReturn_Click
     * 作用:返回
     * 参数:object sender, EventArgs e
     * 返回:void
     */
    protected void ButtonReturn_Click(object sender, EventArgs e)
    {
        Response.Redirect("admin.aspx");
    }
}

【HomeMessage.cs】留言条类

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

public class HomeMessage
{
    private string name;
    private string date;
    private string message;
    private string status;

    // set方法
    public void setName(string name) { this.name = name; }
    public void setDate(string date) { this.date = date; }
    public void setMessage(string message) { this.message = message; }
    public void setStatus(string status) { this.status = status; }

    // get方法
    public string getName() { return this.name; }
    public string getDate() { return this.date; }
    public string getMessage() { return this.message; }
    public string getStatus() { return this.status; }
}

歇了歇了……

 

=============================== 更新分割线 ================================

晚上,跑到妹子面前得意洋洋地吹了一波后

我以为能像卖个好创意那样炫耀一波给自己加分+10240

结果,妹子把我狂笑了一顿……

“你不在家我不知道给你发微信啊?”

“有道理吼……”

 

果然还是应了标题的前缀

 

 

=================== 2020年2月14追更=====================

emmmmmm今天是居家躲疫中的情人节,偶然看到这篇文章,望着窗外成双的乌鸦有感在此跟各位兄弟兜个底

接着上述故事

网站嘛,没有使用,一般也没客人来,来客人也走运营商流程解决了

我嘛,还是那个一个人的我,默默在优快云寻求慰藉

妹子嘛,已经成了抹不去的回忆,我们走完了onepiece前的所有旅途

所以去找她吧,我把一切都留在那了

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值