EchoTex_Payroll/HRM.BO/Organogram/OrganogramBasic.cs

868 lines
25 KiB
C#
Raw Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
namespace HRM.BO
{
#region Organogram
public class OrganogramBasic : BasicBaseObject
{
#region Constructor
public OrganogramBasic()
{
_positionName = string.Empty;
_parentID = 0;
_tier = 0;
_uniqueId = 0;
//_positionTypeID = null;
_positionNo = string.Empty;
_companyID = 0;
_departmentID = 0;
_functionID = 0;
_gradeID = 0;
_designationID = 0;
_locationID = 0;
//_reportingNodeID = null;
//_employeeID = null;
_parent = null;
_oChilds = null;
//_positionNo = string.Empty;
_jdNo = string.Empty;
_revisionNo = string.Empty;
_revisionDate = DateTime.MinValue;
_parentID = null;
}
#endregion
#region Properties
#region positionName : string
private string _positionName;
public string PositionName
{
get { return _positionName; }
set
{
_positionName = value;
}
}
#endregion
#region parentID : ID
private int? _parentID;
public int? ParentID
{
get { return _parentID; }
set
{
_parentID = value;
}
}
#endregion
#region tier : int
private int _tier;
public int Tier
{
get { return _tier; }
set
{
_tier = value;
}
}
#endregion
#region uniqueId : int
private int _uniqueId;
public int UniqueId
{
get { return _uniqueId; }
set
{
_uniqueId = value;
}
}
#endregion
#region positionNo : string
private string _positionNo;
public string PositionNo
{
get { return _positionNo; }
set
{
_positionNo = value;
}
}
#endregion
public string EmployeeNoView {get;set;}
public string EmployeeNameView { get; set; }
#region companyID : ID
private int _companyID;
public int CompanyID
{
get { return _companyID; }
set
{
_companyID = value;
}
}
#endregion
#region departmentID : ID
private int _departmentID;
public int DepartmentID
{
get { return _departmentID; }
set
{
_departmentID = value;
}
}
#endregion
#region functionID : ID
private int _functionID;
public int FunctionID
{
get { return _functionID; }
set
{
_functionID = value;
}
}
#endregion
#region gradeID : ID
private int? _gradeID;
public int? GradeID
{
get { return _gradeID; }
set
{
_gradeID = value;
}
}
#endregion
#region designationID : ID
private int _designationID;
public int DesignationID
{
get { return _designationID; }
set
{
_designationID = value;
}
}
#endregion
#region locationID : ID
private int _locationID;
public int LocationID
{
get { return _locationID; }
set
{
_locationID = value;
}
}
#endregion
#region JDNo : string
private string _jdNo;
public string JDNo
{
get { return _jdNo; }
set
{
_jdNo = value;
}
}
#endregion
#region RevisionNo
private string _revisionNo;
public string RevisionNo
{
get { return _revisionNo; }
set
{
_revisionNo = value;
}
}
#endregion
#region RevisionDate
private DateTime _revisionDate;
public DateTime RevisionDate
{
get { return _revisionDate; }
set
{
_revisionDate = value;
}
}
#endregion
#region OrganAuthority : OrganogramAuthority
private List<OrganogramAuthority> _organAuthority;
public List<OrganogramAuthority> OrganAuthority
{
get
{
if (_organAuthority == null) _organAuthority = new List<OrganogramAuthority>();
return _organAuthority;
}
set
{
_organAuthority = value;
}
}
#endregion
#region OrganDelegation : OrganogramDelegation
private List<OrganogramDelegation> _organDelegation;
public List<OrganogramDelegation> OrganDelegation
{
get
{
if (_organDelegation == null) _organDelegation = new List<OrganogramDelegation>();
return _organDelegation;
}
set
{
_organDelegation = value;
}
}
#endregion
#region OrganJobDesc : OrganogramJobDesc
private List<OrganogramJobDesc> _organJobDesc;
public List<OrganogramJobDesc> OrganJobDesc
{
get
{
if (_organJobDesc == null) _organJobDesc = new List<OrganogramJobDesc>();
return _organJobDesc;
}
set
{
_organJobDesc = value;
}
}
#endregion
#region OrganResponsibility : OrganogramResponsibility
private List<OrganogramResponsibility> _organResponsibility;
public List<OrganogramResponsibility> OrganResponsibility
{
get
{
if (_organResponsibility == null) _organResponsibility = new List<OrganogramResponsibility>();
return _organResponsibility;
}
set
{
_organResponsibility = value;
}
}
#endregion
#region OrganSkillLevel : OrganogramSkillLevel
private List<OrganogramSkillLevel> _organSkillLevel;
public List<OrganogramSkillLevel> OrganSkillLevel
{
get
{
if (_organSkillLevel == null) _organSkillLevel = new List<OrganogramSkillLevel>();
return _organSkillLevel;
}
set
{
_organSkillLevel = value;
}
}
#endregion
#region OrganPosition : OrganogramPosition
private OrganogramBasic _parent;
public OrganogramBasic Parent
{
get
{
//if (_parent == null )
//{
// if (_parentID!=null &&!_parentID.IsUnassigned) _parent = OrganogramBasic.Get(_parentID);
// else return null;
//}
return _parent;
}
set
{
_parent = value;
}
}
#endregion
#region ChildNodes
private List<OrganogramBasic> _oChilds;
public List<OrganogramBasic> Childs
{
get
{
//if (_oChilds == null)
//{
// _oChilds = new List<OrganogramBasic>();
// _oChilds = OrganogramBasic.GetByParentId(this.ID,EnumStatus.Regardless);
//}
return _oChilds;
}
set { _oChilds = value; }
}
#endregion
#region OrganPosition : OrganogramPosition
private List<OrganogramPosition> _organPositions;
public List<OrganogramPosition> OrganPositions
{
get
{
//if (_organPositions == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
//{
// _organPositions = OrganogramBasic.Get4OrganPosition(this.ID);
//}
return this._organPositions;
}
set
{
_organPositions = value;
}
}
#endregion
//public List<OrganogramBasic> GetAthorities(EnumAuthorityType type)
//{
// List<OrganogramBasic> oobjects = new List<OrganogramBasic>();
// foreach (OrganogramAuthority oitem in this.OrganAuthority)
// {
// if (oitem.AuthorityType == type)
// {
// OrganogramBasic organogram = OrganogramBasic.Get(oitem.ChildNodeID);
// oobjects.Add(organogram);
// }
// }
// return oobjects;
//}
#region OrganEmployee : OrganEmployees
private List<OrganogramEmployee> _organEmployees;
public List<OrganogramEmployee> OrganEmployees
{
get
{
//if (_organEmployees == null && !this.ID.IsUnassigned && this.ID.Integer > 0)
// _organEmployees = OrganogramEmployee.Get(this.ID);
return _organEmployees;
}
set
{
_organEmployees = value;
}
}
#endregion
/// <summary>
/// Return assgined employee, if multiple employee assigned, first employee will be returned.
/// </summary>
/// <returns></returns>
//public Employee GetAssignedEmployee()
//{
// Employee oEmp = null;
// if (EmployeeAssigned==false)
// throw new Exception("Employee not yet assigned in this position");
// oEmp = _organEmployees[0].Employee;
// return oEmp;
//}
//public bool EmployeeAssigned
//{
// get
// {
// if (this.OrganEmployees != null && this.OrganEmployees.Count > 0)
// return true;
// else
// return false;
// }
//}
//#region Service Factory IOrganogramService : IOrganogramService
//internal static IOrganogramService Service
//{
// get { return Services.Factory.CreateService<IOrganogramService>(typeof(IOrganogramService)); }
//}
//#endregion
#endregion
//#region Functions
//#region Save
//public int Save()
//{
// this.SetAuditTrailProperties();
// return OrganogramBasic.Service.Save(this);
//}
//#endregion
//#region Delete
//public void Delete(int id)
//{
// OrganogramBasic.Service.Delete(id);
//}
//public void DeleteAll()
//{
// OrganogramBasic.Service.DeleteAll();
//}
//#endregion
//#region Get
///// <summary>
///// get oranogram node along with node authorities, employees, job-description,
///// skill-lebel, positions
///// </summary>
///// <param name="nID">Oranogram Node ID</param>
///// <returns></returns>
//public static OrganogramBasic Get(int nodeID)
//{
// OrganogramBasic oOrganogram = null;
// #region Cache Header
// oOrganogram = (OrganogramBasic)_cache["Get", nodeID];
// if (oOrganogram != null)
// return oOrganogram;
// #endregion
// oOrganogram = OrganogramBasic.Service.Get(nodeID);
// #region Cache Footer
// _cache.Add(oOrganogram, "Get", nodeID);
// #endregion
// return oOrganogram;
//}
//public static OrganogramBasic GetbyEmployeeid(int employeeid)
//{
// OrganogramBasic oOrganogram = null;
// oOrganogram = OrganogramBasic.Service.GetbyEmployeeid(employeeid);
// return oOrganogram;
//}
//public static List<OrganogramBasic> Get(EnumStatus nstatus)
//{
// #region Cache Header
// List<OrganogramBasic> organograms = _cache["Get"] as List<OrganogramBasic>;
// if (organograms != null)
// return organograms;
// #endregion
// try
// {
// organograms = Service.Get(nstatus);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(organograms, "Get");
// #endregion
// return organograms;
//}
//public static List<OrganogramBasic> GetbyTier(int fromTier, int toTier)
//{
// #region Cache Header
// List<OrganogramBasic> organograms = _cache["Get"] as List<OrganogramBasic>;
// if (organograms != null)
// return organograms;
// #endregion
// try
// {
// organograms = Service.GetbyTier(fromTier, toTier);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(organograms, "Get");
// #endregion
// return organograms;
//}
///// <summary>
///// get organogram node(s)
///// </summary>
///// <param name="parentID">Oranogram Node Id</param>
///// <returns></returns>
//public static List<OrganogramBasic> GetByParentId(int parentID,EnumStatus status)
//{
// List<OrganogramBasic> items;
// #region CacheHeader
// items = (List<OrganogramBasic>)_cache["GetByParentId"];
// if (items != null)
// return items;
// #endregion
// try
// {
// items = OrganogramBasic.Service.GetByParentID(parentID,status);
// }
// catch (ServiceException e)
// {
// throw new ServiceException(e.Message, e);
// }
// #region CacheFooter
// _cache.Add(items, "GetByParentId");
// #endregion
// return items;
//}
///// <summary>
///// get the organogram node(s), does not have parent (null)
///// </summary>
///// <returns></returns>
//public static List<OrganogramBasic> GetTopParents(EnumStatus nstatus)
//{
// List<OrganogramBasic> items;
// try
// {
// items = OrganogramBasic.Service.GetTopParents(nstatus);
// }
// catch (ServiceException e)
// {
// throw new ServiceException(e.Message, e);
// }
// return items;
//}
//public static List<OrganogramAuthority> Get4OrganAuthority(int organAuthorityID)
//{
// #region Cache Header
// List<OrganogramAuthority> oOrganAuthority = _cache["Get4OrganAuthority", organAuthorityID] as List<OrganogramAuthority>;
// if (oOrganAuthority != null)
// return oOrganAuthority;
// #endregion
// try
// {
// oOrganAuthority = Service.Get4OrganAuthority(organAuthorityID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(oOrganAuthority, "Get4OrganAuthority", organAuthorityID);
// #endregion
// return oOrganAuthority;
//}
//public static List<OrganogramAuthority> GetOrganAuthorityByEmp(int EmployeeID)
//{
// #region Cache Header
// List<OrganogramAuthority> oOrganAuthority = _cache["GetOrganAuthorityByEmp", EmployeeID] as List<OrganogramAuthority>;
// if (oOrganAuthority != null)
// return oOrganAuthority;
// #endregion
// try
// {
// oOrganAuthority = Service.GetOrganAuthorityByEmp(EmployeeID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(oOrganAuthority, "GetOrganAuthorityByEmp", EmployeeID);
// #endregion
// return oOrganAuthority;
//}
//public static List<OrganogramDelegation> Get4OrganDelegation(int organDelegationID)
//{
// #region Cache Header
// List<OrganogramDelegation> oOrganogramDelegation = _cache["Get4OrganDelegation", organDelegationID] as List<OrganogramDelegation>;
// if (oOrganogramDelegation != null)
// return oOrganogramDelegation;
// #endregion
// try
// {
// oOrganogramDelegation = Service.Get4OrganDelegation(organDelegationID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(oOrganogramDelegation, "Get4OrganDelegation", organDelegationID);
// #endregion
// return oOrganogramDelegation;
//}
//public static List<OrganogramJobDesc> Get4OrganJobDesc(int organJobDescID)
//{
// #region Cache Header
// List<OrganogramJobDesc> oOrganogramJobDesc = _cache["Get4OrganJobDesc", organJobDescID] as List<OrganogramJobDesc>;
// if (oOrganogramJobDesc != null)
// return oOrganogramJobDesc;
// #endregion
// try
// {
// oOrganogramJobDesc = Service.Get4OrganJobDesc(organJobDescID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(oOrganogramJobDesc, "Get4OrganJobDesc", organJobDescID);
// #endregion
// return oOrganogramJobDesc;
//}
//public static List<OrganogramResponsibility> Get4OrganResponsibility(int organResponsibilityID)
//{
// #region Cache Header
// List<OrganogramResponsibility> oOrganogramResponsibility = _cache["Get4OrganResponsibility", organResponsibilityID] as List<OrganogramResponsibility>;
// if (oOrganogramResponsibility != null)
// return oOrganogramResponsibility;
// #endregion
// try
// {
// oOrganogramResponsibility = Service.Get4OrganResponsibility(organResponsibilityID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(oOrganogramResponsibility, "Get4OrganResponsibility", organResponsibilityID);
// #endregion
// return oOrganogramResponsibility;
//}
//public static List<OrganogramSkillLevel> Get4OrganSkilLevel(int organSkilLevelID)
//{
// #region Cache Header
// List<OrganogramSkillLevel> oOrganogramSkillLevel = _cache["Get4OrganSkilLevel", organSkilLevelID] as List<OrganogramSkillLevel>;
// if (oOrganogramSkillLevel != null)
// return oOrganogramSkillLevel;
// #endregion
// try
// {
// oOrganogramSkillLevel = Service.Get4OrganSkilLevel(organSkilLevelID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(oOrganogramSkillLevel, "Get4OrganSkilLevel", organSkilLevelID);
// #endregion
// return oOrganogramSkillLevel;
//}
//public static List<OrganogramPosition> Get4OrganPosition(int organPositionID)
//{
// #region Cache Header
// List<OrganogramPosition> oOrganogramPosition = _cache["Get4OrganPosition", organPositionID] as List<OrganogramPosition>;
// if (oOrganogramPosition != null)
// return oOrganogramPosition;
// #endregion
// try
// {
// oOrganogramPosition = Service.Get4OrganPosition(organPositionID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// #region Cache Footer
// _cache.Add(oOrganogramPosition, "Get4OrganPosition", organPositionID);
// #endregion
// return oOrganogramPosition;
//}
//public static List<OrganogramBasic> GetbyPositionTypeid(int positiontypeid)
//{
// List<OrganogramBasic> oOrganogramPosition = null;
// try
// {
// oOrganogramPosition = Service.GetbyPositionTypeID(positiontypeid);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// return oOrganogramPosition;
//}
//public static int GetMinNodeIdByDept(int deptID)
//{
// int nNodeID = null;
// nNodeID = OrganogramBasic.Service.GetMinNodeIdByDept(deptID);
// return nNodeID;
//}
//public void UpdateParentAndTier(List<OrganogramBasic> oOrganNodes)
//{
// try
// {
// OrganogramBasic.Service.UpdateParentAndTier(oOrganNodes);
// }
// catch (ServiceException e)
// {
// throw new ServiceException(e.Message, e);
// }
//}
//#endregion
//#endregion
//public static List<OrganogramPosition> GetAllOrganPosition()
//{
// return Service.GetAllOrganPosition();
//}
//public static DataTable GetManagers(string sEmpIDs)
//{
// return Service.GetManagers(sEmpIDs);
//}
//public static int MaxTier()
//{
// return Service.MaxTier();
//}
}
#endregion
public class OrganogramBasicTemp : BasicBaseObject
{
public int OrganogramID { get; set; }
public int? EmployeeID { get; set; }
public int ParentID { get; set; }
public int Tier { get; set; }
public string PositionName { get; set; }
public string EmployeeNo { get; set; }
public string EmployeeName { get; set; }
public int PositionTypeID { get; set; }
public EnumOGPositionType positionType { get; set; }
public EmpLifeCycle LifeCycle { get; set; }
}
#region IOrganogram Service
public interface IOrganogramService
{
OrganogramBasic Get(int id);
OrganogramBasic GetbyEmployeeid(int EmployeeID);
List<OrganogramBasic> Get( EnumStatus status);
List<OrganogramBasic> GetByParentID(int parentID,EnumStatus status);
int GetMinNodeIdByDept(int deptID);
List<OrganogramBasic> GetTopParents(EnumStatus status);
List<OrganogramAuthority> Get4OrganAuthority(int NodeID);
List<OrganogramDelegation> Get4OrganDelegation(int NodeID);
List<OrganogramJobDesc> Get4OrganJobDesc(int NodeID);
List<OrganogramResponsibility> Get4OrganResponsibility(int NodeID);
List<OrganogramSkillLevel> Get4OrganSkilLevel(int NodeID);
List<OrganogramPosition> Get4OrganPosition(int NodeID);
List<OrganogramBasic> GetbyPositionTypeID(int positionTypeid);
List<OrganogramPosition> GetAllOrganPosition();
List<OrganogramAuthority> GetOrganAuthorityByEmp(int EmployeeID);
DataTable GetManagers(string sEmpIDs);
int MaxTier();
List<OrganogramBasic> GetbyTier(int fromTier, int toTier);
void UpdateParentAndTier(List<OrganogramBasic> oNodes);
void CreateOrgFromEmployee(int createdBy);
int Save(OrganogramBasic item);
void Delete(int id);
void DeleteAll();
}
#endregion
}