using System; using System.Collections.Generic; using System.Data; using System.Linq; namespace HRM.BO { #region AssetInventory public class AssetInventory : BasicBaseObject { #region Constructor public AssetInventory() { _assetID = 0; _receiveEmployeeID = 0; _assignedDate = DateTime.Now; _assignRemarks = string.Empty; _assignUserID = 0; _isEmpConfirmed = false; _empConfirmDate = DateTime.Now; _empConfirmRemarks = string.Empty; _retainUserID = 0; _retainDate = DateTime.Now; _retainRemarks = string.Empty; _isempRetained = false; _amount = 0; } #endregion #region Properties #region AssetID : ID private int _assetID; public int AssetID { get { return _assetID; } set { _assetID = value; } } #endregion #region AssignedUserID : ID private int _receiveEmployeeID; public int ReceiveEmployeeID { get { return _receiveEmployeeID; } set { _receiveEmployeeID = value; } } #endregion #region AssignedDate : DateTime private DateTime _assignedDate; public DateTime AssignedDate { get { return _assignedDate; } set { _assignedDate = value; } } #endregion #region AssignedRemarks : string private string _assignRemarks; public string AssignedRemarks { get { return _assignRemarks; } set { _assignRemarks = value; } } #endregion #region AssignUserID : ID private int _assignUserID; public int AssignUserID { get { return _assignUserID; } set { _assignUserID = value; } } #endregion #region IsEmpConfirmed : Boolean private bool _isEmpConfirmed; public bool IsEmpConfirmed { get { return _isEmpConfirmed; } set { _isEmpConfirmed = value; } } #endregion #region empConfirmDate : DateTime private DateTime _empConfirmDate; public DateTime empConfirmDate { get { return _empConfirmDate; } set { _empConfirmDate = value; } } #endregion #region EmpConfirmRemarks : string private string _empConfirmRemarks; public string EmpConfirmRemarks { get { return _empConfirmRemarks; } set { _empConfirmRemarks = value; } } #endregion #region RetainUserID : ID private int _retainUserID; public int RetainUserID { get { return _retainUserID; } set { _retainUserID = value; } } #endregion #region RetainDate : DateTime private DateTime _retainDate; public DateTime RetainDate { get { return _retainDate; } set { _retainDate = value; } } #endregion #region RetainRemarks : string private string _retainRemarks; public string RetainRemarks { get { return _retainRemarks; } set { _retainRemarks = value; } } #endregion #region IsEmpRetained : Boolean private bool _isempRetained; public bool IsEmpRetained { get { return _isempRetained; } set { _isempRetained = value; } } public Asset Asset { get; set; } //private Asset _asset; //public Asset Asset //{ // get // { // if (_asset == null) // _asset = Asset.Get(_assetID); // return _asset; // } // set // { // _asset = value; // } //} #endregion #region Amount : double private double _amount; public double Amount { get { return _amount; } set { _amount = value; } } #endregion #endregion //#region Service Factory IAssetInventoryService : IAssetInventoryService //internal static IAssetInventoryService Service //{ // get { return Services.Factory.CreateService(typeof(IAssetInventoryService)); } //} //#endregion //#region Functions //public string GetStatus() //{ // string sCurrstatus = ""; // if (this.IsEmpConfirmed == false) // { // sCurrstatus = "Employee Confirmation Pending"; // } // else // sCurrstatus = "Employee Received"; // if (this.IsEmpRetained == true) // { // sCurrstatus = "Employee Returned"; // } // if (this.ID.IsUnassigned == true && this.Asset.AssetType == EnumAssetInventoryType.FixedItem) // sCurrstatus = "Exit Clearance Item"; // return sCurrstatus; //} //public static AssetInventory Get(int nID) //{ // AssetInventory assetInventory = null; // #region Cache Header // assetInventory = (AssetInventory)_cache["Get", nID]; // if (assetInventory != null) // return assetInventory; // #endregion // assetInventory = AssetInventory.Service.Get(nID); // #region Cache Footer // _cache.Add(assetInventory, "Get", nID); // #endregion // return assetInventory; //} //public static List Get() //{ // #region Cache Header // List assetInventorys = _cache["Get"] as List; // if (assetInventorys != null) // return assetInventorys; // #endregion // try // { // assetInventorys = Service.Get(); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(assetInventorys, "Get"); // #endregion // return assetInventorys; //} //public static List ReceivableItems(int ReceiveEmpid, int assignByEmpid) //{ // List Items = new List(); // Items = AssetInventory.GetAllAsset(ReceiveEmpid, assignByEmpid); // //OrganogramBasic oBasic = OrganogramBasic.GetbyEmployeeid(ID.FromInteger(ReceiveEmpid)); // //if (oBasic != null && oBasic.Parent != null && oBasic.Parent.EmployeeAssigned == true // // && oBasic.Parent.GetAssignedEmployee().ID.Integer == assignByEmpid) // //{ // // List LineMngAssets = Asset.GetLineManagerItem(); // // if (Items == null) Items = new List(); // // foreach (Asset item in LineMngAssets) // // { // // AssetInventory containItem = Items.Find(delegate(AssetInventory param) { return param.AssetID.Integer == item.ID.Integer; }); // // if (containItem == null) // // { // // AssetInventory newITem = new AssetInventory(); // // newITem.AssetID = item.ID; // // newITem.AssignedDate = DateTime.Today; // // newITem.ReceiveEmployeeID = ID.FromInteger(ReceiveEmpid); // // newITem.AssignUserID = oBasic.Parent.GetAssignedEmployee().ID; // // newITem.RetainDate = DateTime.Today; // // newITem.RetainUserID = ID.FromInteger(assignByEmpid); // // newITem.IsEmpConfirmed = true; // // newITem.IsEmpRetained = false; // // newITem.Asset = item; // // Items.Add(newITem); // // } // // } // //} // //Employee oEmp = Employee.Get(ID.FromInteger(assignByEmpid)); // //List papersItems = Asset.Get(oEmp, EnumAssetInventoryType.OtherItem); // //foreach (Asset item in papersItems) // //{ // // if (item.IsLinemanager == true) continue; // // AssetInventory containItem = Items.Find(delegate(AssetInventory param) { return param.AssetID.Integer == item.ID.Integer; }); // // if (containItem == null) // // { // // AssetInventory newITem = new AssetInventory(); // // newITem.AssetID = item.ID; // // newITem.AssignedDate = DateTime.Today; // // newITem.ReceiveEmployeeID = ID.FromInteger(ReceiveEmpid); // // newITem.AssignUserID = ID.FromInteger(assignByEmpid); // // newITem.RetainDate = DateTime.Today; // // newITem.RetainUserID = ID.FromInteger(assignByEmpid); // // newITem.IsEmpConfirmed = true; // // newITem.IsEmpRetained = false; // // newITem.Asset = item; // // Items.Add(newITem); // // } // //} // // List oList = Items.FindAll(x => x.IsEmpRetained == true); // List notRetainItems = new List(); // foreach (AssetInventory item in Items) // { // if (item.IsEmpRetained == false) // notRetainItems.Add(item); // } // Items = notRetainItems; // return Items; //} //public static List MyReturnableItems(int employeeID) //{ // List Items = new List(); // Items = AssetInventory.GetReceivedItems(employeeID); // List assets = Asset.Get(); // List DefaultAsset = assets.Where(obj => obj.DefaultItem).ToList(); // // Return to Line manager Items // List ReturnsItems = new List(); // ReturnsItems = AssetInventory.GetReturnedAssets(employeeID); // OrganogramBasic oBasic = OrganogramBasic.GetbyEmployeeid(ID.FromInteger(employeeID)); // if (oBasic != null && oBasic.Parent != null && oBasic.Parent.EmployeeAssigned == true) // { // List LineMngAssets = DefaultAsset.Where(obj => obj.IsLinemanager).ToList(); // if (Items == null) Items = new List(); // foreach (Asset item in LineMngAssets) // { // AssetInventory containItem = Items.Find(delegate(AssetInventory param) { return param.AssetID.Integer == item.ID.Integer; }); // AssetInventory returnitm = ReturnsItems.Find(delegate(AssetInventory param) { return param.AssetID.Integer == item.ID.Integer; }); // if (containItem == null && returnitm == null) // { // AssetInventory newITem = new AssetInventory(); // newITem.AssetID = item.ID; // newITem.AssignedDate = DateTime.Today; // newITem.ReceiveEmployeeID = ID.FromInteger(employeeID); // newITem.AssignUserID = oBasic.Parent.GetAssignedEmployee().ID; // newITem.RetainDate = DateTime.Today; // newITem.RetainUserID = ID.FromInteger(employeeID); // newITem.IsEmpConfirmed = true; // newITem.IsEmpRetained = false; // newITem.Asset = item; // Items.Add(newITem); // } // } // } // //List papersItems = Asset.Get(EnumAssetInventoryType.OtherItem); // //foreach (Asset item in papersItems) // //{ // // if (item.IsLinemanager == true) continue; // // AssetInventory containItem = Items.Find(delegate(AssetInventory param) { return param.AssetID.Integer == item.ID.Integer; }); // // AssetInventory returnitm = ReturnsItems.Find(delegate(AssetInventory param) { return param.AssetID.Integer == item.ID.Integer; }); // // if (containItem == null && returnitm ==null) // // { // // Employee oEmp = Employee.Get(item.AssignUserNo1); // // if(oEmp==null) // // oEmp = Employee.Get(item.AssignUserNo2); // // if (oEmp == null) continue; // // AssetInventory newITem = new AssetInventory(); // // newITem.AssetID = item.ID; // // newITem.AssignedDate = DateTime.Today; // // newITem.ReceiveEmployeeID = ID.FromInteger(employeeID); // // newITem.AssignUserID = oEmp.ID; // // newITem.RetainDate = DateTime.Today; // // newITem.RetainUserID = oEmp.ID; // // newITem.IsEmpConfirmed = true; // // newITem.IsEmpRetained = false; // // newITem.Asset = item; // // Items.Add(newITem); // // } // //} // // List oList = Items.FindAll(x => x.IsEmpRetained == true); // foreach (Asset item in DefaultAsset) // { // if (item.IsLinemanager == true) continue; // AssetInventory containItem = Items.Find(delegate(AssetInventory param) { return param.AssetID.Integer == item.ID.Integer; }); // AssetInventory returnitm = ReturnsItems.Find(delegate(AssetInventory param) { return param.AssetID.Integer == item.ID.Integer; }); // if (containItem == null && returnitm == null) // { // Employee oEmp = Employee.Get(item.AssignUserNo1); // if (oEmp == null) // oEmp = Employee.Get(item.AssignUserNo2); // if (oEmp == null) continue; // AssetInventory newITem = new AssetInventory(); // newITem.AssetID = item.ID; // newITem.AssignedDate = DateTime.Today; // newITem.ReceiveEmployeeID = ID.FromInteger(employeeID); // newITem.AssignUserID = oEmp.ID; // newITem.RetainDate = DateTime.Today; // newITem.RetainUserID = oEmp.ID; // newITem.IsEmpConfirmed = true; // newITem.IsEmpRetained = false; // newITem.Asset = item; // Items.Add(newITem); // } // } // List notRetainItems = new List(); // foreach (AssetInventory item in Items) // { // if (item.IsEmpRetained == false) // notRetainItems.Add(item); // } // Items = notRetainItems; // return Items; //} //public static List GetAllAsset(int ReceiveEmployeeID, int assignUserID) //{ // #region Cache Header // List assetInventorys = _cache["GetAllAsset"] as List; // if (assetInventorys != null) // return assetInventorys; // #endregion // try // { // assetInventorys = Service.GetAllAsset(ReceiveEmployeeID, assignUserID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(assetInventorys, "GetAllAsset"); // #endregion // return assetInventorys; //} //public static List GetAllAssets(int assignedUserID) //{ // #region Cache Header // List assetInventorys = _cache["GetAllAssets"] as List; // if (assetInventorys != null) // return assetInventorys; // #endregion // try // { // assetInventorys = Service.GetAllAssets(assignedUserID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(assetInventorys, "GetAllAssets"); // #endregion // return assetInventorys; //} //public static List GetAssets(int assignedUserID, bool isEmpConfirmed, int assignUserID) //{ // #region Cache Header // List assetInventorys = _cache["GetAssets"] as List; // if (assetInventorys != null) // return assetInventorys; // #endregion // try // { // assetInventorys = Service.GetAssets(assignedUserID, isEmpConfirmed, assignUserID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(assetInventorys, "GetAssets"); // #endregion // return assetInventorys; //} //public int Save() //{ // base.SetAuditTrailProperties(); // return AssetInventory.Service.Save(this); //} //public void Delete() //{ // AssetInventory.Service.Delete(ID); //} //public static void Save(List inventories) //{ // // base.SetAuditTrailProperties(); // foreach (var item in inventories) // { // item.SetAuditTrailProperties(); // } // AssetInventory.Service.Save(inventories); //} //public int UpdateEmpConfirm() //{ // base.SetAuditTrailProperties(); // return AssetInventory.Service.UpdateEmpConfirm(this); //} //public int UpdateRetainAsset() //{ // base.SetAuditTrailProperties(); // return AssetInventory.Service.UpdateRetainAsset(this); //} //#endregion //public void Delete(int nID) //{ // AssetInventory.Service.Delete(nID); //} //public static List GetReceivedItems(int receiveEmployeeID) //{ // #region Cache Header // List assetInventorys = _cache["GetAllAssignedAsset"] as List; // if (assetInventorys != null) // return assetInventorys; // #endregion // try // { // assetInventorys = Service.GetReceivedItems(receiveEmployeeID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(assetInventorys, "GetAllAssignedAsset"); // #endregion // return assetInventorys; //} //public static List GetAllAsset(int AssID) //{ // #region Cache Header // List assetInventorys = _cache["GetAllAsset"] as List; // if (assetInventorys != null) // return assetInventorys; // #endregion // try // { // assetInventorys = Service.GetAllAsset(AssID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(assetInventorys, "GetAllAsset"); // #endregion // return assetInventorys; //} //public static List GetReturnedAssets(int assignUserID) //{ // #region Cache Header // List assetInventorys = _cache["GetReturnedAssets"] as List; // if (assetInventorys != null) // return assetInventorys; // #endregion // try // { // assetInventorys = Service.GetReturnedItems(assignUserID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // #region Cache Footer // _cache.Add(assetInventorys, "GetReturnedAssets"); // #endregion // return assetInventorys; //} //public static List GetEmpAssignedNotReceiveConfirm(int receiveEmployeeID) //{ // List assetInventorys = null; // try // { // assetInventorys = Service.GetEmpAssignedNotReceiveConfirm(receiveEmployeeID); // } // catch (ServiceException e) // { // throw new Exception(e.Message, e); // } // return assetInventorys; //} //public static DataSet GetAssetsClearance(int receivedEmpID) //{ // DataSet ds = null; // try // { // ds = Service.GetAssetsClearance(receivedEmpID); // } // catch (Exception e) // { // throw new Exception(e.Message, e); // } // return ds; //} } #endregion #region IAssetInventoryService public interface IAssetInventoryService { AssetInventory Get(int id); List Get(); List GetAllAsset(int assignedUserID, int assignUserID); List GetAllAssets(int assignedUserID); List GetAssets(int assignedUserID, bool isEmpConfirmed, int assignUserID); int Save(AssetInventory item); void Save(List inventories); void Delete(int id); int UpdateEmpConfirm(AssetInventory item); int UpdateRetainAsset(AssetInventory item); //delete with id //void Delete(int nID); List GetAllAsset(int AssID); List GetEmpAssignedNotReceiveConfirm(int receiveEmpID); List GetReceivedItems(int receiveEmployeeID); List GetReturnedItems(int receiveEmployeeID); DataSet GetAssetsClearance(int receivedEmpID); } #endregion }