一、数据库Test,
表:
二、配置文件web.config
三、业务实体
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
5
namespace com.Model
6
2
3
4
5
6
四、数据访问层
类:SqlHelper
1
//===============================================================================
2
// .NET数据访问通用程序,来自Microsoft公司
3
// 更多信息参见
4
// http://msdn.microsoft.com/library/en-us/dnbda/html/daab-rm.asp
5
//===============================================================================
6
7
using System;
8
using System.Configuration;
9
using System.Data;
10
using System.Data.SqlClient;
11
using System.Collections;
12
13
namespace com.DataAccess
14
2
3
4
5
6
7
8
9
10
11
12
13
14
类:Customer
1
using System;
2
using System.Data.SqlClient;
3
using System.Data;
4
using System.Text;
5
using System.Collections.Generic;
6
using com.Model;
7
8
namespace com.DataAccess
9
}
2
3
4
5
6
7
8
9
五、业务逻辑层
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
using com.DataAccess;
5
using com.Model;
6
using com.BusinessRule;
7
8
namespace com.BusinessLogic
9
2
3
4
5
6
7
8
9
六、业务规则层
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
using com.DataAccess;
5
using com.Model;
6
7
namespace com.BusinessRule
8
2
3
4
5
6
7
8
七、业务外观层
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
using System.Web.UI.WebControls;
5
using com.BusinessLogic;
6
using com.Model;
7
8
namespace com.BusinessFacade
9
2
3
4
5
6
7
8
9
八、界面层
1
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
2
3
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5
<html xmlns="http://www.w3.org/1999/xhtml" >
6
<head runat="server">
7
<title>无标题页</title>
8
</head>
9
<body>
10
<form id="form1" runat="server">
11
<div>
12
</div>
13
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
14
InsertMethod="InsertCustomer" SelectMethod="GetCustomersByAll" TypeName="com.BusinessLogic.CustomerLogic" DeleteMethod="DeleteCustomerByID" UpdateMethod="UpdateCustomer">
15
<DeleteParameters>
16
<asp:ControlParameter ControlID="FormView1" PropertyName="SelectedValue" Name="custId" Type="Int32" />
17
</DeleteParameters>
18
<UpdateParameters>
19
<asp:Parameter Name="custId" Type="Int32" />
20
<asp:Parameter Name="custName" Type="String" />
21
<asp:Parameter Name="address" Type="String" />
22
<asp:Parameter Name="linkman" Type="String" />
23
</UpdateParameters>
24
<InsertParameters>
25
<asp:Parameter Name="custName" Type="String" />
26
<asp:Parameter Name="address" Type="String" />
27
<asp:Parameter Name="linkman" Type="String" />
28
</InsertParameters>
29
</asp:ObjectDataSource>
30
<asp:FormView ID="FormView1" runat="server" DataSourceID="ObjectDataSource1" AllowPaging="True" DataKeyNames="custId">
31
<EditItemTemplate>
32
CustName:
33
<asp:TextBox ID="CustNameTextBox" runat="server" Text='<%# Bind("CustName") %>'></asp:TextBox><br />
34
Address:
35
<asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>'></asp:TextBox><br />
36
Linkman:
37
<asp:TextBox ID="LinkmanTextBox" runat="server" Text='<%# Bind("Linkman") %>'></asp:TextBox><br />
38
CustId:
39
<asp:TextBox ID="CustIdTextBox" runat="server" BorderStyle="None" Enabled="False"
40
Text='<%# Bind("CustId") %>'></asp:TextBox><br />
41
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
42
Text="更新"></asp:LinkButton>
43
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
44
Text="取消"></asp:LinkButton>
45
</EditItemTemplate>
46
<InsertItemTemplate>
47
CustName:
48
<asp:TextBox ID="CustNameTextBox" runat="server" Text='<%# Bind("CustName") %>'></asp:TextBox><br />
49
Address:
50
<asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>'></asp:TextBox><br />
51
Linkman:
52
<asp:TextBox ID="LinkmanTextBox" runat="server" Text='<%# Bind("Linkman") %>'></asp:TextBox><br />
53
CustId:
54
<asp:TextBox ID="CustIdTextBox" runat="server" Text='0' Enabled="False"></asp:TextBox><br />
55
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
56
Text="插入"></asp:LinkButton>
57
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
58
Text="取消"></asp:LinkButton>
59
</InsertItemTemplate>
60
<ItemTemplate>
61
CustName:
62
<asp:Label ID="CustNameLabel" runat="server" Text='<%# Bind("CustName") %>'></asp:Label><br />
63
Address:
64
<asp:Label ID="AddressLabel" runat="server" Text='<%# Bind("Address") %>'></asp:Label><br />
65
Linkman:
66
<asp:Label ID="LinkmanLabel" runat="server" Text='<%# Bind("Linkman") %>'></asp:Label><br />
67
CustId:
68
<asp:Label ID="CustIdLabel" runat="server" Enabled="False" Text='<%# Bind("CustId") %>'></asp:Label><br />
69
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
70
Text="编辑"></asp:LinkButton>
71
<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
72
Text="删除" ></asp:LinkButton>
73
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
74
Text="新建"></asp:LinkButton>
75
</ItemTemplate>
76
</asp:FormView>
77
<asp:Table ID="Table1" runat="server">
78
</asp:Table>
79
80
</form>
81
</body>
82
</html>
83
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83