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

📄 addnews.aspx.cs

📁 前台首页:users/index.aspx 后台首页:login.aspx 这是一个有关宠物的电子商务网站 注:后台的“售后服务” 和“数据统计”这两块由于时间原因暂时 没完成。由于技术问
💻 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 addnews : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Session["user"] = "Admin";
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection("data source=localhost;uid=sa;pwd=;database=Ebusiness");
        con.Open();
        SqlCommand comm = new SqlCommand();
        comm.CommandText = "insert into petnews1(title,content,Auth,[date]) values(@title,@content,@Auth,@date)";
        comm.Connection = con;
        comm.Parameters.Add("@title", SqlDbType.Char, 100).Value = TextBox1.Text;
        comm.Parameters.Add("@content", SqlDbType.VarChar, 8000).Value = TextBox2.Text;
        comm.Parameters.Add("@Auth", SqlDbType.Char, 100).Value = Session["user"].ToString();
        comm.Parameters.Add("@date", SqlDbType.DateTime).Value = DateTime.Now.ToString();
        comm.ExecuteNonQuery();
        con.Close();
        ShowMassage("提交成功");
        TextBox1.Text = "";
        TextBox2.Text = "";
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "";
        TextBox2.Text = "";
    }
    private void ShowMassage(string msg)
    {
        Response.Write("<script>window.alert('" + msg + "')</script>");
    }
}

⌨️ 快捷键说明

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