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

📄 note.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 users_note : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            bind();
        }
    }
    void bind()
    {
        SqlConnection con = new SqlConnection("Data source=localhost;uid=sa;pwd=;database=Ebusiness");
        con.Open();
        SqlCommand comm = new SqlCommand("select askid, asktitle ,asktime from service_ask", con);
        DataSet ds = new DataSet();
        SqlDataAdapter sqld = new SqlDataAdapter();
        sqld.SelectCommand = comm;
        sqld.Fill(ds,"tab");
        GridView1.DataSource =ds.Tables["tab"].DefaultView;
        GridView1.DataBind();
        con.Close();
    }

    protected void Button2_Click(object sender, EventArgs e)
    {

        string str = Session["user"].ToString();
        if (str == "")
        {
            ShowMassage("你还没有登陆,不能发表话题");
        }
        else
        {
            SqlConnection con = new SqlConnection("Data source=localhost;uid=sa;pwd=;database=Ebusiness");
            con.Open();
            SqlCommand comm = new SqlCommand("insert into service_ask(asktitle,askcontent,askuser,asktime) values(@asktitle,@askcontent,@askuser,@asktime)", con);
            comm.Parameters.Add("@asktitle", SqlDbType.VarChar, 50).Value = TextBox1.Text;
            comm.Parameters.Add("@askcontent", SqlDbType.VarChar, 8000).Value = TextBox2.Text;
            comm.Parameters.Add("@askuser", SqlDbType.VarChar, 50).Value = str;
            comm.Parameters.Add("@asktime", SqlDbType.DateTime).Value = DateTime.Now.ToString();

            comm.ExecuteNonQuery();
            con.Close();
            ShowMassage("发表成功");
            TextBox1.Text = "";
            TextBox2.Text = "";
        }
        bind();

    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "";
        TextBox2.Text = "";
    }
    public void ShowMassage(string msg)
    {
        Response.Write("<script>window.alert('" + msg + "')</script>");
    }
}

⌨️ 快捷键说明

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