复杂的个人信息登录界面

aspx中的代码:

<%@ Page Xlanguage="C#" AutoEventWireup="true" CodeFile="PersonalInformation .aspx.cs" Inherits="PersonalInformation_" Debug="true" %>

































个人信息维护
昵称:(发表评论时显示)
性别:

所在部门:
组宣部
学习部
秘书部
文艺部
爱好:
RepeatDirection="Horizontal" Width="257px">
旅游
读书
上网
活动


E-mail:
生日:(yyyy-mm-dd)
个人头像:
个人简介:
Width="277px">

















aspx.cs中的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Text;
using System.Data.SqlClient;

public partial class PersonalInformation_ : System.Web.UI.Page
{
string sqlserverstr = ConfigurationManager.ConnectionStrings["sqlservercon"].ConnectionString;

protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{

SqlConnection conn = new SqlConnection(sqlserverstr);
conn.Open();
SqlCommand sqlcmd = new SqlCommand();
sqlcmd.Connection = conn;
sqlcmd.CommandText = " insert into Person(Nickname,Sex,Hobby,Email,Birthday,HeadPortrait,BriefIntroduction) values(@Nickname,@Sex,@Hobby,@Email,@Birthday,@HeadPortrait,@BriefIntroduction)";

sqlcmd.Parameters.AddWithValue("@Nickname", Nickname.Text);
if (Sex1.Checked)
{
sqlcmd.Parameters.AddWithValue("@Sex", Sex1.Text);
}
else
{
sqlcmd.Parameters.AddWithValue("@Sex", Sex2.Text);
}

string str = "";
foreach (ListItem li in CheckBoxList1.Items)
{
if (li.Selected)
{
str += li.Text+"、";
}
}

sqlcmd.Parameters.AddWithValue("@Hobby", str);



sqlcmd.Parameters.AddWithValue("@Email", Email.Text);
sqlcmd.Parameters.AddWithValue("@Birthday", Birthday.Text);

StringBuilder sb = new StringBuilder();
string filename = this.file1.PostedFile.FileName;
filename = DateTime.Now.Ticks.ToString() + filename.Substring(filename.LastIndexOf("."));
this.file1.PostedFile.SaveAs(Server.MapPath("upload") + "\\" + filename);
sb.Append("");


sqlcmd.Parameters.AddWithValue("@HeadPortrait", sb.ToString());
sqlcmd.Parameters.AddWithValue("@BriefIntroduction", BriefIntroduction.Text);

sqlcmd.ExecuteNonQuery();



SqlConnection conn1 = new SqlConnection(sqlserverstr);
conn1.Open();
SqlCommand sqlcmd1 = new SqlCommand();
sqlcmd1.Connection = conn1;
sqlcmd1.CommandText = " insert into Department(department) values(@department)";
sqlcmd1.Parameters.AddWithValue("@department", department.Text);
sqlcmd1.ExecuteNonQuery();



conn.Close();
conn.Dispose();

}
}

你可能感兴趣的:(复杂的个人信息登录界面)