Example #1
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            SqlData_1 da = new SqlData_1();

            /*SqlConnection sqlcon;
             * SqlCommand sqlcom;
             * SqlDataAdapter sqldata;
             * sqlcon = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
             * sqlcon.Open();   //打开链接
             */
            string P_str_Com = "update tb_Admin set UserName='******',PassWord='******'"
                               + ",Sex='" + this.ddlSex.SelectedValue + "',ReallyName='" + this.txtRealName.Text + "'"
                               + ",Birthday='" + this.txtBirthday.Text + "',Email='" + this.txtEmail.Text + "',HomePhone='" + this.txtHphone.Text + "'"
                               + ",MobilePhone='" + this.txtMphone.Text + "',PostCode='" + this.txtPostCode.Text + "',QQ='" + this.txtQQ.Text + "'"
                               + ",ICQ='" + this.txtICQ.Text + "',Address='" + this.txtAddress.Text + "',Answer='" + this.txtAns.Text + "',Question='" + this.txtQues.Text + "',SuperAdmin='" + this.DropDownList1.SelectedValue + "'"
                               + " where ID='" + Request["ID"] + "'";
            bool add = da.ExceSQL(P_str_Com);
            if (add == true)
            {
                Response.Write("<script language=javascript>alert('修改信息成功!');location='AdminManage.aspx'</script>");
            }
            else
            {
                Response.Write("<script language=javascript>alert('修改信息失败!');location='javascript:history.go(-1)'</script>");
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
Example #2
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string        ID;
        SqlConnection mycon = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);

        mycon.Open();
        DataSet        mydataset     = new DataSet();
        SqlDataAdapter mydataadapter = new SqlDataAdapter("select * from tb_Blog where UserName='******'", mycon);

        mydataadapter.Fill(mydataset, "tb_Blog");
        DataRowView rowview = mydataset.Tables["tb_Blog"].DefaultView[0];

        ID = rowview["BlogID"].ToString();
        string    com = "Insert into tb_Article(Subject,Author,Content,Time,BlogID) values('" + this.txtSubject.Text + "','" + Session["UserName"].ToString() + "','" + this.txtContent.Text + "','" + DateTime.Now.ToString() + "','" + ID + "')";
        SqlData_1 da  = new SqlData_1();
        bool      add = da.ExceSQL(com);

        if (add)
        {
            Response.Write("<script language=javascript>alert('文章添加成功!');location='ArticleManage.aspx'</script>");
        }
        else
        {
            Response.Write("<script language=javascript>alert('文章添加失败!');location='javascript:history.go(-1)'</script>");
        }
    }
Example #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlData_1 da = new SqlData_1();
        DataSet   ds = da.ExceDS("select top 10 * from tb_Href");

        this.DataList1.DataSource = ds;
        this.DataList1.DataBind();
    }