using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.PreviousPage != null)
{
if (PreviousPage.IsCrossPagePostBack == true)
{
if (((TextBox)Page.PreviousPage.FindControl("textName")).Text != string.Empty &;&; ((TextBox)Page.PreviousPage.FindControl("passwd")).Text != string.Empty)
this.lbname.Text = this.lbname.Text + ((TextBox)Page.PreviousPage.FindControl("textName")).Text;
this.user.Text=this.user.Text + ((TextBox)Page.PreviousPage.FindControl("user")).Text ;
this.psswd.Text = this.psswd.Text + ((TextBox)Page.PreviousPage.FindControl("passwd")).Text;
this.m.Text =this.m.Text + ((TextBox)Page.PreviousPage.FindControl("email")).Text ;
this.q.Text=this.q.Text + ((TextBox)Page.PreviousPage.FindControl("q")).Text;
this.t.Text=this.t.Text + ((TextBox)Page.PreviousPage.FindControl("t")).Text;
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string username = lbname.Text;
string account = user.Text;
string pwd = psswd.Text;
string mail = m.Text;
string question = q.Text;
string answer = t.Text;
using(SqlConnection conn = new SqlConnection("Data Source=(local)\\GSQL,7788;Integrated Security=SSPI;Initial Catalog=student"))
{ System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("insert into sys_user(account,name,pass
word,email,question,answer,memo) values('");
sb.Append(account).Append("','").Append(username).Append("','");
sb.Append(pwd).Append("','").Append(mail).Append("','").Append(question).Append("','").Append(answer).Append("','").Append(" ").Append("')");
conn.Open();
SqlCommand sc = new SqlCommand();
sc.Connection = conn;
sc.CommandText = sb.ToString();
int num=sc.ExecuteNonQuery();
}
Response.Write("
");
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("Default.aspx");
}