温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:VS2005典型实例源码大全(C#)
当前文件:
VS2005Helper/Web/App_Code/Test.cs,打开代码结构图
VS2005Helper/Web/App_Code/Test.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Web; 5
using System.Web.Security; 6
using System.Web.UI; 7
using System.Web.UI.WebControls; 8
using System.Web.UI.WebControls.WebParts; 9
using System.Web.UI.HtmlControls; 10
11
using TestDatabaseTableAdapters; 12
using System.ComponentModel; 13
14
/// <summary> 15
/// Test 的摘要说明 16
/// </summary> 17
[DataObject] 18
public class Test 19
{ 20
[DataObjectMethod(DataObjectMethodType.Select, true)] 21
public TestDatabase.TestDataTable GetTest() 22
{ 23
return Singleton<TestTableAdapter>.Instance.GetTest(); 24
} 25
26
[DataObjectMethod(DataObjectMethodType.Select, false)] 27
public TestDatabase.TestDataTable GetTestById(int id) 28
{ 29
return Singleton<TestTableAdapter>.Instance.GetTestById(id); 30
} 31
32
[DataObjectMethod(DataObjectMethodType.Insert, true)] 33
public int?[] InsertTest(int? parentId, string name, DateTime? publishTime, decimal? price, bool? isGood, out int? minId) 34
{ 35
// 仅为说明如何做错误处理 36
if (String.IsNullOrEmpty(name)) 37
throw new ArgumentException("参数不能是空", "name"); 38
39
int? id = null; 40
int? count = null; 41
minId = null; 42
43
Singleton<TestTableAdapter>.Instance.InsertTest(parentId, name, publishTime, price, isGood, ref id, ref count, ref minId); 44
return new int?[] { id, count }; 45
} 46
47
[DataObjectMethod(DataObjectMethodType.Delete, true)] 48
public int? DeleteTest(int id) 49
{ 50
int? rowAffected; 51
52
rowAffected = Singleton<TestTableAdapter>.Instance.DeleteTest(id); 53
return rowAffected; 54
} 55
56
[DataObjectMethod(DataObjectMethodType.Update, true)] 57
public int? UpdateTest(int? id, int? parentId, string name, DateTime? publishTime, decimal? price, bool? isGood) 58
{ 59
int? rowAffected; 60
61
rowAffected = Singleton<TestTableAdapter>.Instance.UpdateTest(id, parentId, name, publishTime, price, isGood); 62
return rowAffected; 63
} 64
} 65







}