public class UserInfo |
{ |
Database Data = new Database(); |
|
//添加会员注册信息 |
public bool Member_Add(UserInfoData userInfoData) |
{ |
SqlParameter[] prm ={ |
Data.MakeOutParam("@Result",SqlDbType.Bit,0), |
Data.MakeInParam("@memberName",SqlDbType.VarChar,18,userInfoData.UserName), |
Data.MakeInParam("@Pwd",SqlDbType.VarChar,16,userInfoData.Pwd), |
Data.MakeInParam("@prePwd",SqlDbType.VarChar,16,userInfoData.PrePwd), |
Data.MakeInParam("@question",SqlDbType.VarChar,50,userInfoData.Question), |
Data.MakeInParam("@answers",SqlDbType.VarChar,30,userInfoData.Answers), |
Data.MakeInParam("@birthDate",SqlDbType.DateTime,8,userInfoData.DateBirth), |
Data.MakeInParam("@gender",SqlDbType.Char,2,userInfoData.Sex), |
Data.MakeInParam("@phone",SqlDbType.VarChar,11,userInfoData.Phone), |
Data.MakeInParam("@trueName",SqlDbType.VarChar,20,userInfoData.TrueName), |
Data.MakeInParam("@mail",SqlDbType.VarChar,50,userInfoData.Mail) |
}; |
bool m_Result = false; |
try |
{ |
Data.RunProc("sp_Member_Add", prm); |
if (Convert.ToBoolean(prm[0].Value)) |
{ |
m_Result = true; |
} |
|
} |
catch(Exception Ex) |
{ |
throw new Exception(Ex.Message); |
} |
finally |
{ |
Data.Close(); |
Data.Dispose(); |
} |
return m_Result; |
} |
} |
|
|
|
|
|
|
protected void Button2_Click(object sender, EventArgs e) |
{ |
|
//实例化UserInfo类 |
UserInfo userInfor = new UserInfo(); |
UserInfoData userInfoData = new UserInfoData(); |
|
userInfoData.UserName = this.text_name.Value.Trim(); |
userInfoData.Pwd = this.txtPwd.Value.Trim(); |
userInfoData.PrePwd = this.txtRePwd.Value.Trim(); |
userInfoData.Question = this.s_Question.Value; |
userInfoData.Answers = this.txtAnswer.Value.Trim(); |
userInfoData.DateBirth = Convert.ToDateTime(this.txtYear.Value.Trim()); |
userInfoData.Sex = this.rblCheck.SelectedValue; |
userInfoData.Phone = this.txtPhone.Text.Trim(); |
userInfoData.TrueName = this.txtName.Text.Trim(); |
userInfoData.Mail = this.txtMail.Text.Trim(); |
|
bool m_Result = false; |
m_Result = userInfor.Member_Add(userInfoData); |
|
if (m_Result) |
{ |
Response.Redirect("Sucess.aspx"); |
} |
|
else |
{ |
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('数据添加失败!')</script>"); |
} |