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 _organAuthority; public List OrganAuthority { get { if (_organAuthority == null) _organAuthority = new List(); return _organAuthority; } set { _organAuthority = value; } } #endregion #region OrganDelegation : OrganogramDelegation private List _organDelegation; public List OrganDelegation { get { if (_organDelegation == null) _organDelegation = new List(); return _organDelegation; } set { _organDelegation = value; } } #endregion #region OrganJobDesc : OrganogramJobDesc private List _organJobDesc; public List OrganJobDesc { get { if (_organJobDesc == null) _organJobDesc = new List(); return _organJobDesc; } set { _organJobDesc = value; } } #endregion #region OrganResponsibility : OrganogramResponsibility private List _organResponsibility; public List OrganResponsibility { get { if (_organResponsibility == null) _organResponsibility = new List(); return _organResponsibility; } set { _organResponsibility = value; } } #endregion #region OrganSkillLevel : OrganogramSkillLevel private List _organSkillLevel; public List OrganSkillLevel { get { if (_organSkillLevel == null) _organSkillLevel = new List(); 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 _oChilds; public List Childs { get { //if (_oChilds == null) //{ // _oChilds = new List(); // _oChilds = OrganogramBasic.GetByParentId(this.ID,EnumStatus.Regardless); //} return _oChilds; } set { _oChilds = value; } } #endregion #region OrganPosition : OrganogramPosition private List _organPositions; public List 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 GetAthorities(EnumAuthorityType type) //{ // List oobjects = new List(); // 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 _organEmployees; public List OrganEmployees { get { //if (_organEmployees == null && !this.ID.IsUnassigned && this.ID.Integer > 0) // _organEmployees = OrganogramEmployee.Get(this.ID); return _organEmployees; } set { _organEmployees = value; } } #endregion /// /// Return assgined employee, if multiple employee assigned, first employee will be returned. /// /// //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(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 ///// ///// get oranogram node along with node authorities, employees, job-description, ///// skill-lebel, positions ///// ///// Oranogram Node ID ///// //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 Get(EnumStatus nstatus) //{ // #region Cache Header // List organograms = _cache["Get"] as List; // 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 GetbyTier(int fromTier, int toTier) //{ // #region Cache Header // List organograms = _cache["Get"] as List; // 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; //} ///// ///// get organogram node(s) ///// ///// Oranogram Node Id ///// //public static List GetByParentId(int parentID,EnumStatus status) //{ // List items; // #region CacheHeader // items = (List)_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; //} ///// ///// get the organogram node(s), does not have parent (null) ///// ///// //public static List GetTopParents(EnumStatus nstatus) //{ // List items; // try // { // items = OrganogramBasic.Service.GetTopParents(nstatus); // } // catch (ServiceException e) // { // throw new ServiceException(e.Message, e); // } // return items; //} //public static List Get4OrganAuthority(int organAuthorityID) //{ // #region Cache Header // List oOrganAuthority = _cache["Get4OrganAuthority", organAuthorityID] as List; // 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 GetOrganAuthorityByEmp(int EmployeeID) //{ // #region Cache Header // List oOrganAuthority = _cache["GetOrganAuthorityByEmp", EmployeeID] as List; // 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 Get4OrganDelegation(int organDelegationID) //{ // #region Cache Header // List oOrganogramDelegation = _cache["Get4OrganDelegation", organDelegationID] as List; // 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 Get4OrganJobDesc(int organJobDescID) //{ // #region Cache Header // List oOrganogramJobDesc = _cache["Get4OrganJobDesc", organJobDescID] as List; // 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 Get4OrganResponsibility(int organResponsibilityID) //{ // #region Cache Header // List oOrganogramResponsibility = _cache["Get4OrganResponsibility", organResponsibilityID] as List; // 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 Get4OrganSkilLevel(int organSkilLevelID) //{ // #region Cache Header // List oOrganogramSkillLevel = _cache["Get4OrganSkilLevel", organSkilLevelID] as List; // 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 Get4OrganPosition(int organPositionID) //{ // #region Cache Header // List oOrganogramPosition = _cache["Get4OrganPosition", organPositionID] as List; // 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 GetbyPositionTypeid(int positiontypeid) //{ // List 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 oOrganNodes) //{ // try // { // OrganogramBasic.Service.UpdateParentAndTier(oOrganNodes); // } // catch (ServiceException e) // { // throw new ServiceException(e.Message, e); // } //} //#endregion //#endregion //public static List 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 Get( EnumStatus status); List GetByParentID(int parentID,EnumStatus status); int GetMinNodeIdByDept(int deptID); List GetTopParents(EnumStatus status); List Get4OrganAuthority(int NodeID); List Get4OrganDelegation(int NodeID); List Get4OrganJobDesc(int NodeID); List Get4OrganResponsibility(int NodeID); List Get4OrganSkilLevel(int NodeID); List Get4OrganPosition(int NodeID); List GetbyPositionTypeID(int positionTypeid); List GetAllOrganPosition(); List GetOrganAuthorityByEmp(int EmployeeID); DataTable GetManagers(string sEmpIDs); int MaxTier(); List GetbyTier(int fromTier, int toTier); void UpdateParentAndTier(List oNodes); void CreateOrgFromEmployee(int createdBy); int Save(OrganogramBasic item); void Delete(int id); void DeleteAll(); } #endregion }