using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TestDatabaseTableAdapters;
using System.ComponentModel;
/// <summary>
/// Test 的摘要说明
/// </summary>
[DataObject]
public class Test
{
[DataObjectMethod(DataObjectMethodType.Select, true)]
public TestDatabase.TestDataTable GetTest()
{
return Singleton<TestTableAdapter>.Instance.GetTest();
}
[DataObjectMethod(DataObjectMethodType.Select, false)]
public TestDatabase.TestDataTable GetTestById( int id)
{
return Singleton<TestTableAdapter>.Instance.GetTestById(id);
}
[DataObjectMethod(DataObjectMethodType.Insert, true)]
public int?[] InsertTest( int? parentId, string name, DateTime? publishTime, decimal? price, bool? isGood, out int? minId)
{
// 仅为说明如何做错误处理
if (String.IsNullOrEmpty(name))
throw new ArgumentException( "参数不能是空", "name");
int? id = null;
int? count = null;
minId = null;
Singleton<TestTableAdapter>.Instance.InsertTest(parentId, name, publishTime, price, isGood, ref id, ref count, ref minId);
return new int?[] { id, count };
}
[DataObjectMethod(DataObjectMethodType.Delete, true)]
public int? DeleteTest( int id)
{
int? rowAffected;
rowAffected = Singleton<TestTableAdapter>.Instance.DeleteTest(id);
return rowAffected;
}
[DataObjectMethod(DataObjectMethodType.Update, true)]
public int? UpdateTest( int? id, int? parentId, string name, DateTime? publishTime, decimal? price, bool? isGood)
{
int? rowAffected;
rowAffected = Singleton<TestTableAdapter>.Instance.UpdateTest(id, parentId, name, publishTime, price, isGood);
return rowAffected;
}
}