数据库层存数据
1
SqlParameter[]
2
parameters = {
3
new SqlParameter("@EmailAddress", SqlDbType.VarChar, 255),
4
new SqlParameter("@Password", SqlDbType.Binary, 100),
5
new SqlParameter("@FirstName", SqlDbType.VarChar, 30),
6
new SqlParameter("@LastName", SqlDbType.VarChar, 50),
7
new SqlParameter("@Address1", SqlDbType.VarChar, 80),
8
new SqlParameter("@Address2", SqlDbType.VarChar, 80),
9
new SqlParameter("@City", SqlDbType.VarChar, 40),
10
new SqlParameter("@State", SqlDbType.VarChar, 40),
11
new SqlParameter("@ZipCode", SqlDbType.VarChar, 20),
12
new SqlParameter("@HomePhone", SqlDbType.VarChar, 20),
13
new SqlParameter("@Country", SqlDbType.VarChar, 50),
14
new SqlParameter("@UserID", SqlDbType.Int, 4)
15
};
16
17
parameters[0].Value = emailAddress;
18
parameters[1].Value = password;
19
parameters[2].Value = firstName;
20
parameters[3].Value = lastName;
21
parameters[4].Value = address1;
22
//parameters[5].Value = DBNull.Value;
23
parameters[5].Value = address2;
24
parameters[6].Value = city;
25
parameters[7].Value = state;
26
parameters[8].Value = zipCode;
27
parameters[9].Value = homePhone;
28
parameters[10].Value = country;
29
parameters[11].Direction = ParameterDirection.Output;
SqlParameter[] 2
parameters = {3
new SqlParameter("@EmailAddress", SqlDbType.VarChar, 255),4
new SqlParameter("@Password", SqlDbType.Binary, 100),5
new SqlParameter("@FirstName", SqlDbType.VarChar, 30),6
new SqlParameter("@LastName", SqlDbType.VarChar, 50),7
new SqlParameter("@Address1", SqlDbType.VarChar, 80),8
new SqlParameter("@Address2", SqlDbType.VarChar, 80),9
new SqlParameter("@City", SqlDbType.VarChar, 40),10
new SqlParameter("@State", SqlDbType.VarChar, 40), 11
new SqlParameter("@ZipCode", SqlDbType.VarChar, 20),12
new SqlParameter("@HomePhone", SqlDbType.VarChar, 20),13
new SqlParameter("@Country", SqlDbType.VarChar, 50),14
new SqlParameter("@UserID", SqlDbType.Int, 4)15
};16

17
parameters[0].Value = emailAddress;18
parameters[1].Value = password;19
parameters[2].Value = firstName;20
parameters[3].Value = lastName;21
parameters[4].Value = address1;22
//parameters[5].Value = DBNull.Value;23
parameters[5].Value = address2;24
parameters[6].Value = city;25
parameters[7].Value = state;26
parameters[8].Value = zipCode;27
parameters[9].Value = homePhone;28
parameters[10].Value = country;29
parameters[11].Direction = ParameterDirection.Output;上层取值
1
//根据ID获取,回写对象
2
private void LoadFromID()
3
{
4
Data.User dataUser = new Data.User( moduleSettings.ConnectionString );
5
DataRow userRow = dataUser.Retrieve( userID );
6
7
firstName= (string)userRow["FirstName"];
8
lastName = (string)userRow["LastName"];
9
address1 = (string)userRow["Address1"];
10
//address2 = (string)userRow["Address2"];
11
address2 = (userRow["Address2"] == DBNull.Value) ? null : userRow["Address2"].ToString();
12
city = (string)userRow["City"];
13
state = (string)userRow["State"];
14
zipCode = (string)userRow["ZipCode"];
15
homePhone= (string)userRow["HomePhone"];
16
emailAddress = (string)userRow["EmailAddress"];
17
password = (byte[])userRow["Password"];
18
country=(string)userRow["Country"];
19
}
//根据ID获取,回写对象2
private void LoadFromID()3
{4
Data.User dataUser = new Data.User( moduleSettings.ConnectionString );5
DataRow userRow = dataUser.Retrieve( userID );6

7
firstName= (string)userRow["FirstName"];8
lastName = (string)userRow["LastName"];9
address1 = (string)userRow["Address1"];10
//address2 = (string)userRow["Address2"];11
address2 = (userRow["Address2"] == DBNull.Value) ? null : userRow["Address2"].ToString();12
city = (string)userRow["City"];13
state = (string)userRow["State"];14
zipCode = (string)userRow["ZipCode"];15
homePhone= (string)userRow["HomePhone"];16
emailAddress = (string)userRow["EmailAddress"];17
password = (byte[])userRow["Password"];18
country=(string)userRow["Country"];19
}表现层
1
public void BindContent()
2
{
3
FirstName.Text = this.user.FirstName;
4
EmailAddress.Text = this.user.EmailAddress;
5
LastName.Text = this.user.LastName;
6
Address1.Text = this.user.Address1;
7
Address2.Text = this.user.Address2;
8
ZipCode.Text = this.user.ZipCode;
9
City.Text = this.user.City;
10
HomePhone.Text = this.user.HomePhone;
11
State.Text = this.user.State;
12
13
this.BindUserRoles();
14
}
public void BindContent()2
{3
FirstName.Text = this.user.FirstName;4
EmailAddress.Text = this.user.EmailAddress;5
LastName.Text = this.user.LastName;6
Address1.Text = this.user.Address1;7
Address2.Text = this.user.Address2;8
ZipCode.Text = this.user.ZipCode;9
City.Text = this.user.City;10
HomePhone.Text = this.user.HomePhone;11
State.Text = this.user.State;12

13
this.BindUserRoles();14
}
parameters 