00004 namespace GentleIDC . Sysbase . Company
00005
{
00006
/// <summary>
00007
/// 功能 : 公司對象操作類
00008
/// 作者 : 樊健漢
00009
/// 編寫日期: 2006-4-24
00010
/// 修改人 :
00011
/// 修改日期
00012
/// </summary>
00013
public class CompanyObj : Gentle . Business . BusinessAdapter
00014
{
00015
public const string Error_Exist ="相同名稱的公司資訊已經存在!" ;
00016
public const string Error_ItemIsNull ="缺少公司資訊對象!" ;
00017
/// <summary>
00018
/// 構造添加公司資訊對象
00019
/// </summary>
00020
public CompanyObj ()
00021
{
00022
}
00023
/// <summary>
00024
/// 構造公司資訊對象
00025
/// 並指定操作的類型(添加|修改)
00026
/// </summary>
00027
/// <param name="isnew">bool</param>
00028
public CompanyObj ( bool isnew )
00029
{
00030
IsNew = isnew ;
00031
}
00032
/// <summary>
00033
/// 是否新增資訊
00034
/// 預設是新增
00035
/// </summary>
00036
public bool IsNew
00037
{
00038
get
00039
{
00040
return mIsNew ;
00041
}
00042
set
00043
{
00044
mIsNew = value ;
00045
}
00046
}
00047
/// <summary>
00048
/// 公司資訊列表
00049
/// </summary>
00050
public GentleIDC . Entitys . tCompany Item
00051
{
00052
get
00053
{
00054
return mItem ;
00055
}
00056
set
00057
{
00058
mItem = value ;
00059
}
00060
}
00061
private bool mIsNew = true ;
00062
private GentleIDC . Entitys . tCompany mItem ;
00063
protected override void OnExecute ()
00064
{
00065
if ( Item == null )
00066
throw ( new Gentle . Business . BusinessException ( Error_ItemIsNull
, null ));
00067
if ( IsNew )
00068
{
00069
System . Collections . IList lst = DataUnit . List ( typeof ( tCompany )
, tCompany . _CompanyName == Item . CompanyName );
00070
if ( lst . Count >0)
00071
{
00072
throw ( new Gentle . Business . BusinessException ( Error_Exist ,
null ));
00073
}
00074
Item . CompanyIndex = GetRecordIndex ( tCompany . TBL . Name );
00075
DataUnit . Save ( Item );
00076
00077
}
00078
else
00079
{
00080
DataUnit . Update ( Item );
00081
}
00082
base . OnExecute ();
00083
}
00084
00085
00086
00087
/// <summary>
00088
/// 擷取相應索引的公司對象
00089
/// </summary>
00090
/// <param name="companyid">公司記錄索引</param>
00091
/// <returns>tCompany</returns>
00092
public static tCompany GetByIndex ( int companyid )
00093
{
00094
using ( IDataSession sessaion = MappingContainer . ConfigContainer .
OpenSession ())
00095
{
00096
sessaion . Open ();
00097
return GetByIndex ( companyid , sessaion );
00098
}
00099
}
00100
00101
/// <summary>
00102
/// 在指定的資料容器中擷取相應索引的公司資訊
00103
/// </summary>
00104
/// <param name="companyid">公司索引值</param>
00105
/// <param name="session">資料容器</param>
00106
/// <returns>公司對象</returns>
00107
public static tCompany GetByIndex ( int companyid , IDataSession session
)
00108
{
00109
return ( tCompany ) session . Load ( typeof ( tCompany ), companyid );
00110
}
00111
/// <summary>
00112
/// 刪除相應索引的公司記錄
00113
/// </summary>
00114
/// <param name="companyid">公司索引</param>
00115
public static void DeleteByIndex ( int companyid )
00116
{
00117
using ( IDataSession session = MappingContainer . ConfigContainer .
OpenSession ())
00118
{
00119
session . Open ();
00120
DeleteByIndex ( companyid , session );
00121
}
00122
}
00123
/// <summary>
00124
/// 在指定資料容器中刪除相應索引的公司記錄
00125
/// </summary>
00126
/// <param name="companyid">公司索引</param>
00127
/// <param name="session">資料容器</param>
00128
public static void DeleteByIndex ( int companyid , IDataSession session )
00129
{
00130
IDelete delte = session . CreateDelete ( tCompany . TBL );
00131
delte . Expreesion = tCompany . _CompanyIndex == companyid ;
00132
delte . Execute ();
00133
}
00134
00135
}
00136