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

📄 dp_dianpugonggao.aspx.cs

📁 基于VS05和SQL05做的一个电子商务网站
💻 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.SqlClient;

public partial class DP_DianPuGongGao : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["username"] == null)
            {
                Response.Write("<script language='JavaScript'>");
                Response.Write("alert('请先登录!')");
                Response.Write("</script>");
                Response.End();
                return;
            }

            string userName = Session["username"].ToString();
            string sql = "select DianPuGongGao from DianPuDetail where DianPuUser='" + userName + "'";
            SqlConnection connections = new SqlConnection(ConfigurationManager.AppSettings["ConnStr"]);
            SqlCommand commands = new SqlCommand(sql, connections);
            connections.Open();
            SqlDataReader dr = commands.ExecuteReader();
            if (dr.Read())
            {
                string txtValue = dr["DianPuGongGao"].ToString();
                TEXTAREA1.Value = txtValue;
            }
            dr.Close();
            connections.Close();
        }
    }
    protected void Submit1_ServerClick(object sender, EventArgs e)
    {
        string gonggao = TEXTAREA1.Value.ToString();
        string userName = Session["username"].ToString();
        if (userName == null) userName = "游客";
        if (userName == "游客")
        {
            Response.Write("<script	language='JavaScript'>");
            Response.Write("alert('请登陆')");
            Response.Write("</script>");
        }
        else if (gonggao == "")
        {
            Response.Write("<script language='javaScript'>");
            Response.Write("alert('公告内容为空!!!')");
            Response.Write("</script>");
        }
        else
        {
            string sql = "update DianPuDetail set DianPuGongGao='" + gonggao + "' where DianPuUser='" + userName + "'";
            SqlConnection connections = new SqlConnection(ConfigurationManager.AppSettings["ConnStr"]);
            SqlCommand commands = new SqlCommand(sql, connections);
            connections.Open();
            commands.ExecuteNonQuery();
            connections.Close();
        }
    }
}

⌨️ 快捷键说明

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