using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Data.SqlClient;
public partial class Insertshow : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
             if (FileUpload1.HasFile)
            {
                //将图像保存到程序所在的文件夹中
                FileUpload1.SaveAs(Server.MapPath(FileUpload1.FileName));
                Session["imagename"] = FileUpload1.FileName;
            }
           try
           {
            string ConStr = "server=(local);user id=myzf;pwd=123456;database=SQL_Data";
            SqlConnection con = new SqlConnection(ConStr);
            con.Open();
            string sqlinsert = "insert into 会员信息(姓名,性别,电话,邮件,照片) values ( '" + TextBox1 .Text  + "','" + TextBox2 .Text  + "','" + TextBox3 .Text  + "','" + TextBox4.Text + "','" + Session["imagename"].ToString() + "')";
            SqlCommand com = new SqlCommand(sqlinsert, con);
            com.ExecuteNonQuery();
            Response.Write("<script language=javascript>alert('成功插入新记录信息！')</script>");
            con.Close();
           }
           catch 
            {
               Response.Write("<script language=javascript>alert('插入新记录信息失败！')</script>");
            }     
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "";
        TextBox2.Text = "";
        TextBox3.Text = "";
        TextBox4.Text = "";
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }
}
