⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reply.aspx.cs

📁 asp.net 的某物流管理系统 MIS 系统
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class liuyan_Reply : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Showleavewords();
    }
    //显示单条留言
    private void Showleavewords()
    {
        int nResult = -1;
        if (Int32.TryParse(Request.Params["ShowID"].ToString(), out nResult) == false) { return; }
        DataSet ds = Getleavewords(nResult);
        MyGridView.DataSource = ds.Tables["aa"].DefaultView;
        MyGridView.DataBind();

    }
    //取留言按ID
    public DataSet Getleavewords(int nID)
    {
        string myConnectionString = ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING1"].ConnectionString + Server.MapPath("~") + ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING3"].ConnectionString;
        OleDbConnection myConnection = new OleDbConnection(myConnectionString);
        string cmdText = "SELECT * FROM mydata WHERE LeavewordID=" + nID;
        OleDbDataAdapter da = new OleDbDataAdapter(cmdText, myConnection);
        DataSet ds = new DataSet();
        try
        {
            myConnection.Open();
            da.Fill(ds, "aa");
        }
        catch (OleDbException ex)
        {
            throw new Exception(ex.Message, ex);
        }
        finally
        {
            myConnection.Close();
        }
        return ds;
    }
    //回复按ID
    private void Addreply(int nID,string sWords)
    {
        string myConnectionString = ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING1"].ConnectionString + Server.MapPath("~") + ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING3"].ConnectionString;
        OleDbConnection myConnection = new OleDbConnection(myConnectionString);
        string cmdText = "UPDATE mydata SET Reply='" + sWords + "'," +
            "ReplyID=1,Replydate=now() WHERE LeavewordID="+nID;
        OleDbCommand myCommand = new OleDbCommand(cmdText, myConnection);
        try
        {
            myConnection.Open();
            myCommand.ExecuteNonQuery();
        }
        catch (OleDbException ex)
        {
            throw new Exception(ex.Message, ex);
        }
        finally
        {
            myConnection.Close();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        int nResult = -1;
        if (Int32.TryParse(Request.Params["ShowID"].ToString(), out nResult) == false) { return; }
        if (txtReply.Text.Length < 1) return;
        Addreply(nResult, txtReply.Text.ToString());
        Response.Redirect("Viewleavwords.aspx");
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("Viewleavwords.aspx");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -