using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
///////////////////////////////////////////////////////////////////////////////////////////////////
//creation date:17/12/31 01:41:46 م
//author:
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace Demo
{
//\////////////////////////////////////////////////////////////////////////////////////////////
[Serializable]
public partial class Entity_Employee
{
#region properties
private Int64? ID;
public Int64? _ID
{
set
{
ID=value;
}
get
{
return ID;
}
}
//-----------------------------------------------------------------------------------------
private String First_Name;
public String _First_Name
{
set
{
First_Name=value;
}
get
{
return string.IsNullOrEmpty(First_Name) ? null : First_Name;
}
}
//-----------------------------------------------------------------------------------------
private String Last_Name;
public String _Last_Name
{
set
{
Last_Name=value;
}
get
{
return string.IsNullOrEmpty(Last_Name) ? null : Last_Name;
}
}
//-----------------------------------------------------------------------------------------
private float? Salary;
public float? _Salary
{
set
{
Salary=value;
}
get
{
return Salary;
}
}
//-----------------------------------------------------------------------------------------
private Int64? Dept_ID;
public Int64? _Dept_ID
{
set
{
Dept_ID=value;
}
get
{
return Dept_ID;
}
}
//-----------------------------------------------------------------------------------------
private Int64? Gender_ID;
public Int64? _Gender_ID
{
set
{
Gender_ID=value;
}
get
{
return Gender_ID;
}
}
//-----------------------------------------------------------------------------------------
#endregion
//-----------------------------------------------------------------------------------------
public Entity_Employee()
{
}
//-----------------------------------------------------------------------------------------
public Entity_Employee(Int64 _ID)
{
//get the record
DataTable DT_Employee=BLL_Employee.SelectByPK((Int64) _ID);
//check if exists
if(DT_Employee.Rows.Count==1)
{
AssignPropertyFromDataRow(DT_Employee.Rows[0]);
}
}
//-----------------------------------------------------------------------------------------
public Entity_Employee(Int64 _ID,bool LoadObjectFromDB)
{
//assign the PK value
this._ID =_ID;
//if true then load object from DB
if(LoadObjectFromDB)
{
//get the record
DataTable DT_Employee=BLL_Employee.SelectByPK((Int64) _ID);
//check if exists
if(DT_Employee.Rows.Count==1)
{
AssignPropertyFromDataRow(DT_Employee.Rows[0]);
}
}
}
//-----------------------------------------------------------------------------------------
public Entity_Employee(DataRow DataRow_Employee)
{
AssignPropertyFromDataRow(DataRow_Employee);
}
//-----------------------------------------------------------------------------------------
protected void AssignPropertyFromDataRow(DataRow DataRow_Employee)
{
//ID
_ID=DataRow_Employee["ID"]is DBNull?(Int64?)null:Convert.ToInt64(DataRow_Employee["ID"]);
//First_Name
_First_Name=DataRow_Employee["First_Name"]is DBNull?(String)null:Convert.ToString(DataRow_Employee["First_Name"]);
//Last_Name
_Last_Name=DataRow_Employee["Last_Name"]is DBNull?(String)null:Convert.ToString(DataRow_Employee["Last_Name"]);
//Salary
_Salary=DataRow_Employee["Salary"]is DBNull?(float?)null:Convert.ToSingle(DataRow_Employee["Salary"]);
//Dept_ID
_Dept_ID=DataRow_Employee["Dept_ID"]is DBNull?(Int64?)null:Convert.ToInt64(DataRow_Employee["Dept_ID"]);
//Gender_ID
_Gender_ID=DataRow_Employee["Gender_ID"]is DBNull?(Int64?)null:Convert.ToInt64(DataRow_Employee["Gender_ID"]);
}
//-----------------------------------------------------------------------------------------
///
/// this function returns the new ID of the inserted Employee table
///
public object Insert()
{
return DAL_Employee.Insert(this);
}
//-----------------------------------------------------------------------------------------
///
/// this function returns the number of effteced rows
///
public int Update()
{
return DAL_Employee.Update(this);
}
//-----------------------------------------------------------------------------------------
///
/// this function returns the number of affected rows it should be 1 or 0
///
public int Delete()
{
return DAL_Employee.Delete(this);
}
//-----------------------------------------------------------------------------------------
///
///delete data by foreign key column [Dept_ID]
///
public int DeletetByFK_Dept_ID()
{
return DAL_Employee.DeleteByFK_Dept_ID((Int64)this._Dept_ID);
}
//-----------------------------------------------------------------------------------------
///
///delete data by foreign key column [Gender_ID]
///
public int DeletetByFK_Gender_ID()
{
return DAL_Employee.DeleteByFK_Gender_ID((Int64)this._Gender_ID);
}
//-----------------------------------------------------------------------------------------
///
/// this function returns the number of effteced rows
///
public int DeleteAll()
{
return DAL_Employee.DeleteAll();
}
//-----------------------------------------------------------------------------------------
///
/// this function returns all Employee row(s)
///
public DataTable Select()
{
return DAL_Employee.Select();
}
//-----------------------------------------------------------------------------------------
///
/// this function returns all Employee row(s) include relational table(s) data
///
public DataTable SelectIncludeRT()
{
return DAL_Employee.SelectIncludeRT();
}
//-----------------------------------------------------------------------------------------
///
/// this function returns data table object according to primary key
///
public DataTable SelectByPK()
{
return DAL_Employee.SelectByPK((Int64) _ID);
}
//-----------------------------------------------------------------------------------------
///
/// this function returns data table object according to primary key
///
public DataTable SelectIncludeRTByPK()
{
return DAL_Employee.SelectIncludeRTByPK((Int64) _ID);
}
//-----------------------------------------------------------------------------------------
///
/// this function returns all Employee row(s)
///
public DataTable SelectByAnyOr()
{
return DAL_Employee.SelectByAnyOr(this);
}
//-----------------------------------------------------------------------------------------
///
/// this function returns all Employee row(s)
///
public DataTable SelectIncludeRTByAnyOr()
{
return DAL_Employee.SelectIncludeRTByAnyOr(this);
}
//-----------------------------------------------------------------------------------------
///
/// this function returns all Employee row(s)
///
public DataTable SelectByAnyAnd()
{
return DAL_Employee.SelectByAnyAnd(this);
}
//-----------------------------------------------------------------------------------------
///
/// this function returns all Employee row(s)
///
public DataTable SelectIncludeRTByAnyAnd()
{
return DAL_Employee.SelectIncludeRTByAnyAnd(this);
}
//-----------------------------------------------------------------------------------------
///
/// this function returns all Employee row(s)
///
public DataTable FindByAnyOr()
{
return DAL_Employee.FindByAnyOr(this);
}
//-----------------------------------------------------------------------------------------
///
/// this function returns all Employee row(s)
///
public DataTable FindByAnyAnd()
{
return DAL_Employee.FindByAnyAnd(this);
}
//-----------------------------------------------------------------------------------------
///
/// this function returns all Employee row(s)
///
public DataTable FindIncludeRTByAnyOr()
{
return DAL_Employee.FindIncludeRTByAnyOr(this);
}
//-----------------------------------------------------------------------------------------
///
/// this function returns all Employee row(s)
///
public DataTable FindIncludeRTByAnyAnd()
{
return DAL_Employee.FindIncludeRTByAnyAnd(this);
}
//-----------------------------------------------------------------------------------------
///
///select data by foreign key column [Dept_ID]
///
public DataTable SelectByFK_Dept_ID()
{
return DAL_Employee.SelectByFK_Dept_ID((Int64)this._Dept_ID);
}
//-----------------------------------------------------------------------------------------
///
///select data by foreign key column [Dept_ID]
///
public DataTable SelectIncludeRTByFK_Dept_ID()
{
return DAL_Employee.SelectIncludeRTByFK_Dept_ID((Int64)this._Dept_ID);
}
//-----------------------------------------------------------------------------------------
///
///select data by foreign key column [Gender_ID]
///
public DataTable SelectByFK_Gender_ID()
{
return DAL_Employee.SelectByFK_Gender_ID((Int64)this._Gender_ID);
}
//-----------------------------------------------------------------------------------------
///
///select data by foreign key column [Gender_ID]
///
public DataTable SelectIncludeRTByFK_Gender_ID()
{
return DAL_Employee.SelectIncludeRTByFK_Gender_ID((Int64)this._Gender_ID);
}
//-----------------------------------------------------------------------------------------
///
/// this function delete all records in the Employee table and reset identity seed to
/// the passed value
///
public int Truncate()
{
return DAL_Employee.Truncate();
}
//-----------------------------------------------------------------------------------------
///
/// this function counts number of rows according to the object
///
public Int64 Count()
{
return DAL_Employee.Count(this);
}
//-----------------------------------------------------------------------------------------
}
//\////////////////////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////////////////////////