609 lines
		
	
	
		
			22 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			609 lines
		
	
	
		
			22 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
using System.Text;
 | 
						|
using Ease.CoreV35.Caching;
 | 
						|
using Ease.CoreV35.DataAccess;
 | 
						|
using Ease.CoreV35.Model;
 | 
						|
using Payroll.BO;
 | 
						|
 | 
						|
namespace Payroll.Service
 | 
						|
{
 | 
						|
    public class FndMngmentWFService : ServiceTemplate, IFndMngmentWFService
 | 
						|
    {
 | 
						|
        #region Cache
 | 
						|
        Cache _cache = new Cache(typeof(FndMngmentWF));
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Map Objects
 | 
						|
 | 
						|
        #region Map Parent
 | 
						|
 | 
						|
        private void MapObject(FndMngmentWF oFndMngment, DataReader oReader)
 | 
						|
        {
 | 
						|
            base.SetObjectID(oFndMngment, oReader.GetID("FndMngmentWFID"));
 | 
						|
            oFndMngment.PurchaseType = oReader.GetString("PurchaseType");
 | 
						|
            oFndMngment.PurchaseAmount = oReader.GetDouble("PurchaseAmount").HasValue ? oReader.GetDouble("PurchaseAmount").Value : 0.0;
 | 
						|
            oFndMngment.Description = oReader.GetString("Description");
 | 
						|
            oFndMngment.EmployeeID = oReader.GetID("EmployeeID");
 | 
						|
            oFndMngment.PFAmount = oReader.GetDouble("PFAmount").HasValue ? oReader.GetDouble("PFAmount").Value : 0.0;
 | 
						|
            oFndMngment.CFAmount = oReader.GetDouble("CFAmount").HasValue ? oReader.GetDouble("CFAmount").Value : 0.0;
 | 
						|
            oFndMngment.PFInterest = oReader.GetDouble("PFInterest").HasValue ? oReader.GetDouble("PFInterest").Value : 0.0;
 | 
						|
            oFndMngment.CFInterest = oReader.GetDouble("CFInterest").HasValue ? oReader.GetDouble("CFInterest").Value : 0.0;
 | 
						|
            oFndMngment.Gratuity = oReader.GetDouble("Gratuity").HasValue ? oReader.GetDouble("Gratuity").Value : 0.0;
 | 
						|
            oFndMngment.Status = (EnumStatus)oReader.GetInt32("Status").Value;
 | 
						|
            oFndMngment.CreatedBy = oReader.GetID("CreatedBy");
 | 
						|
            oFndMngment.ModifiedBy = oReader.GetID("ModifiedBy");
 | 
						|
            oFndMngment.CreatedDate = oReader.GetDateTime("CreationDate").HasValue ? oReader.GetDateTime("CreationDate").Value : DateTime.MinValue;
 | 
						|
            oFndMngment.ModifiedDate = oReader.GetDateTime("ModifiedDate").HasValue ? oReader.GetDateTime("ModifiedDate").Value : DateTime.MinValue;
 | 
						|
            this.SetObjectState(oFndMngment, Ease.CoreV35.ObjectState.Saved);
 | 
						|
        }
 | 
						|
 | 
						|
        protected override T CreateObject<T>(DataReader oReader)
 | 
						|
        {
 | 
						|
            FndMngmentWF oFndMngment = new FndMngmentWF();
 | 
						|
            MapObject(oFndMngment, oReader);
 | 
						|
            return oFndMngment as T;
 | 
						|
        }
 | 
						|
        
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Map FndMngmentEmps
 | 
						|
 | 
						|
        private void MapFndMngmentEmpObject(FndMngmentEmp oFndMngmentEmp, DataReader oReader)
 | 
						|
        {
 | 
						|
            base.SetObjectID(oFndMngmentEmp, oReader.GetID("FndMngmentEmpID"));
 | 
						|
            oFndMngmentEmp.FndMngmentWFID = oReader.GetID("FndMngmentWFID");
 | 
						|
            oFndMngmentEmp.EmployeeID = oReader.GetID("EmployeeID");
 | 
						|
            oFndMngmentEmp.EmployeeNo = oReader.GetString("EmployeeNo");
 | 
						|
            oFndMngmentEmp.EmployeeName = oReader.GetString("EmployeeName");
 | 
						|
            oFndMngmentEmp.DesigName = oReader.GetString("DesigName");
 | 
						|
            oFndMngmentEmp.EmailSent = oReader.GetBoolean("EmailSent").Value;
 | 
						|
            oFndMngmentEmp.WebSent = oReader.GetBoolean("WebSent").Value;
 | 
						|
            oFndMngmentEmp.SentDate = oReader.GetDateTime("SendDate").Value;
 | 
						|
            
 | 
						|
            this.SetObjectState(oFndMngmentEmp, Ease.CoreV35.ObjectState.Saved);
 | 
						|
 | 
						|
        }
 | 
						|
 | 
						|
        private FndMngmentEmp CreateFndMngmentEmp(DataReader oReader)
 | 
						|
        {
 | 
						|
            FndMngmentEmp oFndMngmentEmp = new FndMngmentEmp();
 | 
						|
            MapFndMngmentEmpObject(oFndMngmentEmp, oReader);
 | 
						|
            return oFndMngmentEmp;
 | 
						|
        }
 | 
						|
 | 
						|
        private ObjectsTemplate<FndMngmentEmp> CreateFndMngmentEmps(DataReader oReader)
 | 
						|
        {
 | 
						|
            ObjectsTemplate<FndMngmentEmp> oFndMngmentEmps = new ObjectsTemplate<FndMngmentEmp>();
 | 
						|
            FndMngmentEmp oFndMngmentEmp;
 | 
						|
            
 | 
						|
            while (oReader.Read())
 | 
						|
            {
 | 
						|
                oFndMngmentEmp = new FndMngmentEmp();
 | 
						|
                oFndMngmentEmp = CreateFndMngmentEmp(oReader);
 | 
						|
                oFndMngmentEmps.Add(oFndMngmentEmp);
 | 
						|
            }
 | 
						|
            return oFndMngmentEmps;
 | 
						|
        }
 | 
						|
        
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Map FndMngmentEmpRemarks
 | 
						|
 | 
						|
        private void MapFndMngmentEmpRemarksObject(FndMngmentEmpRemarks oFndMngmentEmpRemarks, DataReader oReader)
 | 
						|
        {
 | 
						|
            base.SetObjectID(oFndMngmentEmpRemarks, oReader.GetID("FndMngmentEmpRemarksID"));
 | 
						|
            oFndMngmentEmpRemarks.FndMngmentEmpID = oReader.GetID("FndMngmentEmpID");
 | 
						|
            oFndMngmentEmpRemarks.FndMngmentWFID = oReader.GetID("FndMngmentWFID");
 | 
						|
            oFndMngmentEmpRemarks.RemarksDateTime = oReader.GetDateTime("RemarksDateTime").Value;
 | 
						|
            oFndMngmentEmpRemarks.Remarks = oReader.GetString("Remarks");
 | 
						|
            oFndMngmentEmpRemarks.IsHR = oReader.GetBoolean("IsHR").Value;
 | 
						|
            this.SetObjectState(oFndMngmentEmpRemarks, Ease.CoreV35.ObjectState.Saved);
 | 
						|
        }
 | 
						|
 | 
						|
        private FndMngmentEmpRemarks CreateFndMngmentEmpRemarks(DataReader oReader)
 | 
						|
        {
 | 
						|
            FndMngmentEmpRemarks oFndMngmentEmpRemarks = new FndMngmentEmpRemarks();
 | 
						|
            MapFndMngmentEmpRemarksObject(oFndMngmentEmpRemarks, oReader);
 | 
						|
            return oFndMngmentEmpRemarks;
 | 
						|
        }
 | 
						|
 | 
						|
        private ObjectsTemplate<FndMngmentEmpRemarks> CreateFndMngmentEmpRemarkses(DataReader oReader)
 | 
						|
        {
 | 
						|
            ObjectsTemplate<FndMngmentEmpRemarks> oFndMngmentEmpRemarkses = new ObjectsTemplate<FndMngmentEmpRemarks>();
 | 
						|
            FndMngmentEmpRemarks oFndMngmentEmpRemarks;
 | 
						|
 | 
						|
            while (oReader.Read())
 | 
						|
            {
 | 
						|
                oFndMngmentEmpRemarks = CreateFndMngmentEmpRemarks(oReader);
 | 
						|
                oFndMngmentEmpRemarkses.Add(oFndMngmentEmpRemarks);
 | 
						|
            }
 | 
						|
 | 
						|
            return oFndMngmentEmpRemarkses;
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region IFndMngmentWFService Members
 | 
						|
 | 
						|
        #region Get Functions
 | 
						|
 | 
						|
        public FndMngmentWF Get(ID id)
 | 
						|
        {
 | 
						|
            FndMngmentWF oFndMngmentWF = null;
 | 
						|
 | 
						|
            #region Cache Header
 | 
						|
            oFndMngmentWF = _cache["Get", id] as FndMngmentWF;
 | 
						|
            if (oFndMngmentWF != null)
 | 
						|
                return oFndMngmentWF;
 | 
						|
            #endregion
 | 
						|
 | 
						|
            TransactionContext tc = null;
 | 
						|
            try
 | 
						|
            {
 | 
						|
                tc = TransactionContext.Begin();
 | 
						|
                DataReader oreader = new DataReader(FndMngmentWFDA.Get(tc, id));
 | 
						|
                if (oreader.Read())
 | 
						|
                {
 | 
						|
                    oFndMngmentWF = CreateObject<FndMngmentWF>(oreader);
 | 
						|
                }
 | 
						|
                oreader.Close();
 | 
						|
 | 
						|
            }
 | 
						|
            catch (Exception e)
 | 
						|
            {
 | 
						|
                #region Handle Exception
 | 
						|
                if (tc != null)
 | 
						|
                    tc.HandleError();
 | 
						|
                ExceptionLog.Write(e);
 | 
						|
                throw new ServiceException(e.Message, e);
 | 
						|
                #endregion
 | 
						|
            }
 | 
						|
            finally
 | 
						|
            {
 | 
						|
                tc.End();
 | 
						|
            }
 | 
						|
 | 
						|
            #region Cache Footer
 | 
						|
            _cache.Add(oFndMngmentWF, "Get", id);
 | 
						|
            #endregion
 | 
						|
 | 
						|
            return oFndMngmentWF;
 | 
						|
        }
 | 
						|
 | 
						|
        public ObjectsTemplate<FndMngmentWF> Get(EnumStatus status)
 | 
						|
        {
 | 
						|
            ObjectsTemplate<FndMngmentWF> oFndMngmentWFs = new ObjectsTemplate<FndMngmentWF>();
 | 
						|
 | 
						|
            #region Cache Header
 | 
						|
            oFndMngmentWFs = _cache["Get"] as ObjectsTemplate<FndMngmentWF>;
 | 
						|
            if (oFndMngmentWFs != null)
 | 
						|
                return oFndMngmentWFs;
 | 
						|
            #endregion
 | 
						|
 | 
						|
            TransactionContext tc = null;
 | 
						|
            try
 | 
						|
            {
 | 
						|
                tc = TransactionContext.Begin();
 | 
						|
                DataReader oreader = new DataReader(FndMngmentWFDA.Get(tc, status));
 | 
						|
                oFndMngmentWFs = CreateObjects<FndMngmentWF>(oreader);
 | 
						|
 | 
						|
                oreader.Close();
 | 
						|
 | 
						|
            }
 | 
						|
            catch (Exception e)
 | 
						|
            {
 | 
						|
                #region Handle Exception
 | 
						|
                if (tc != null)
 | 
						|
                    tc.HandleError();
 | 
						|
                ExceptionLog.Write(e);
 | 
						|
                throw new ServiceException(e.Message, e);
 | 
						|
                #endregion
 | 
						|
            }
 | 
						|
            finally
 | 
						|
            {
 | 
						|
                tc.End();
 | 
						|
            }
 | 
						|
 | 
						|
            #region Cache Footer
 | 
						|
            _cache.Add(oFndMngmentWFs, "Get");
 | 
						|
            #endregion
 | 
						|
 | 
						|
            return oFndMngmentWFs;
 | 
						|
        }
 | 
						|
 | 
						|
        public ObjectsTemplate<FndMngmentEmp> GetFndMngmentEmps(ID FndManagementID)
 | 
						|
        {
 | 
						|
            ObjectsTemplate<FndMngmentEmp> oFndMngmentEmps = new ObjectsTemplate<FndMngmentEmp>();
 | 
						|
 | 
						|
            #region Cache Header
 | 
						|
            oFndMngmentEmps = _cache["Get"] as ObjectsTemplate<FndMngmentEmp>;
 | 
						|
            if (oFndMngmentEmps != null)
 | 
						|
                return oFndMngmentEmps;
 | 
						|
            #endregion
 | 
						|
 | 
						|
            TransactionContext tc = null;
 | 
						|
            try
 | 
						|
            {
 | 
						|
                tc = TransactionContext.Begin();
 | 
						|
                DataReader oreader = new DataReader(FndMngmentWFDA.GetFndMngmntEmps(tc, FndManagementID));
 | 
						|
                oFndMngmentEmps = CreateFndMngmentEmps(oreader);
 | 
						|
 | 
						|
                oreader.Close();
 | 
						|
 | 
						|
            }
 | 
						|
            catch (Exception e)
 | 
						|
            {
 | 
						|
                #region Handle Exception
 | 
						|
                if (tc != null)
 | 
						|
                    tc.HandleError();
 | 
						|
                ExceptionLog.Write(e);
 | 
						|
                throw new ServiceException(e.Message, e);
 | 
						|
                #endregion
 | 
						|
            }
 | 
						|
            finally
 | 
						|
            {
 | 
						|
                tc.End();
 | 
						|
            }
 | 
						|
 | 
						|
            #region Cache Footer
 | 
						|
            _cache.Add(oFndMngmentEmps, "Get");
 | 
						|
            #endregion
 | 
						|
 | 
						|
            return oFndMngmentEmps;
 | 
						|
        }
 | 
						|
 | 
						|
        public ObjectsTemplate<FndMngmentEmpRemarks> GetFndMngmentEmpRemarks(ID FndMngmentEmpID)
 | 
						|
        {
 | 
						|
            ObjectsTemplate<FndMngmentEmpRemarks> oFndMngmentEmpRemarkses = new ObjectsTemplate<FndMngmentEmpRemarks>();
 | 
						|
 | 
						|
            #region Cache Header
 | 
						|
            oFndMngmentEmpRemarkses = _cache["Get"] as ObjectsTemplate<FndMngmentEmpRemarks>;
 | 
						|
            if (oFndMngmentEmpRemarkses != null)
 | 
						|
                return oFndMngmentEmpRemarkses;
 | 
						|
            #endregion
 | 
						|
 | 
						|
            TransactionContext tc = null;
 | 
						|
            try
 | 
						|
            {
 | 
						|
                tc = TransactionContext.Begin();
 | 
						|
                DataReader oreader = new DataReader(FndMngmentWFDA.GetFndMngmntEmpRmrks(tc, FndMngmentEmpID));
 | 
						|
                oFndMngmentEmpRemarkses = CreateFndMngmentEmpRemarkses(oreader);
 | 
						|
 | 
						|
                oreader.Close();
 | 
						|
 | 
						|
            }
 | 
						|
            catch (Exception e)
 | 
						|
            {
 | 
						|
                #region Handle Exception
 | 
						|
                if (tc != null)
 | 
						|
                    tc.HandleError();
 | 
						|
                ExceptionLog.Write(e);
 | 
						|
                throw new ServiceException(e.Message, e);
 | 
						|
                #endregion
 | 
						|
            }
 | 
						|
            finally
 | 
						|
            {
 | 
						|
                tc.End();
 | 
						|
            }
 | 
						|
 | 
						|
            #region Cache Footer
 | 
						|
            _cache.Add(oFndMngmentEmpRemarkses, "Get");
 | 
						|
            #endregion
 | 
						|
 | 
						|
            return oFndMngmentEmpRemarkses;
 | 
						|
        }
 | 
						|
 | 
						|
        public ObjectsTemplate<FndMngmentEmpRemarks> GetAllFndMngmentEmpRemarks(ID FndMngmentWFID)
 | 
						|
        {
 | 
						|
            ObjectsTemplate<FndMngmentEmpRemarks> oFndMngmentEmpRemarkses = new ObjectsTemplate<FndMngmentEmpRemarks>();
 | 
						|
 | 
						|
            #region Cache Header
 | 
						|
            oFndMngmentEmpRemarkses = _cache["Get"] as ObjectsTemplate<FndMngmentEmpRemarks>;
 | 
						|
            if (oFndMngmentEmpRemarkses != null)
 | 
						|
                return oFndMngmentEmpRemarkses;
 | 
						|
            #endregion
 | 
						|
 | 
						|
            TransactionContext tc = null;
 | 
						|
            try
 | 
						|
            {
 | 
						|
                tc = TransactionContext.Begin();
 | 
						|
                DataReader oreader = new DataReader(FndMngmentWFDA.GetAllFndMngmentEmpRemarks(tc, FndMngmentWFID));
 | 
						|
                oFndMngmentEmpRemarkses = CreateFndMngmentEmpRemarkses(oreader);
 | 
						|
                oreader.Close();
 | 
						|
            }
 | 
						|
            catch (Exception e)
 | 
						|
            {
 | 
						|
                #region Handle Exception
 | 
						|
                if (tc != null)
 | 
						|
                    tc.HandleError();
 | 
						|
                ExceptionLog.Write(e);
 | 
						|
                throw new ServiceException(e.Message, e);
 | 
						|
                #endregion
 | 
						|
            }
 | 
						|
            finally
 | 
						|
            {
 | 
						|
                tc.End();
 | 
						|
            }
 | 
						|
 | 
						|
            #region Cache Footer
 | 
						|
            _cache.Add(oFndMngmentEmpRemarkses, "Get");
 | 
						|
            #endregion
 | 
						|
 | 
						|
            return oFndMngmentEmpRemarkses;
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Save Function
 | 
						|
 | 
						|
        public ID Save(FndMngmentWF oFndMngment)
 | 
						|
        {
 | 
						|
            ID id = null;
 | 
						|
            TransactionContext tc = null;
 | 
						|
            try
 | 
						|
            {
 | 
						|
                int startingBatchNo;
 | 
						|
                int previousBatchNo = 0;
 | 
						|
                if (oFndMngment.IsNew)
 | 
						|
                {
 | 
						|
 | 
						|
                    tc = TransactionContext.Begin(true);
 | 
						|
                    id = ID.FromInteger(tc.GenerateID("FndMngmentWF", "FndMngmentWFID"));
 | 
						|
                    base.SetObjectID(oFndMngment,id);
 | 
						|
                    FndMngmentWFDA.Insert(tc, oFndMngment);
 | 
						|
                    
 | 
						|
                    oFndMngment.FndMngmentEmps.ForEach(o => o.FndMngmentWFID = id);
 | 
						|
                    if(oFndMngment.AllFndMngEmpRemarks!=null)
 | 
						|
                    oFndMngment.AllFndMngEmpRemarks.ForEach(o => o.FndMngmentWFID = id); 
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    id = oFndMngment.ID;
 | 
						|
                    oFndMngment.AllFndMngEmpRemarks.ForEach(o => o.FndMngmentWFID = oFndMngment.ID);
 | 
						|
                    foreach (FndMngmentEmp item in oFndMngment.FndMngmentEmps)
 | 
						|
                    {
 | 
						|
                        ObjectsTemplate<FndMngmentEmpRemarks> fndRemarks = new ObjectsTemplate<FndMngmentEmpRemarks>();
 | 
						|
                        oFndMngment.AllFndMngEmpRemarks
 | 
						|
                                    .Where(o => o.FndMngmentEmpID!=null  && !o.FndMngmentEmpID.IsUnassigned && o.FndMngmentEmpID == item.ID)
 | 
						|
                                    .ToList()
 | 
						|
                                    .ForEach(oo=>fndRemarks.Add(oo));
 | 
						|
 | 
						|
 | 
						|
                        item.FndMngmentEmpRmrkses = fndRemarks;              
 | 
						|
 
 | 
						|
                    }
 | 
						|
 | 
						|
                    tc = TransactionContext.Begin(true);
 | 
						|
                    
 | 
						|
                    FndMngmentWFDA.Update(tc, oFndMngment);
 | 
						|
                    FndMngmentWFDA.DeleteFndMngmentEmpRemarkses(tc, id);
 | 
						|
                    FndMngmentWFDA.DeleteFndMngmentEmps(tc, id);
 | 
						|
                    
 | 
						|
                }
 | 
						|
 | 
						|
                foreach (FndMngmentEmp item in oFndMngment.FndMngmentEmps)
 | 
						|
                {
 | 
						|
                    ID fnEmpid = ID.FromInteger(tc.GenerateID("FndMngmentEmp", "FndMngmentEmpID"));
 | 
						|
                    base.SetObjectID(item, fnEmpid);
 | 
						|
                    item.FndMngmentWFID = id;
 | 
						|
                    FndMngmentWFDA.InsertFndMngmentEmp(tc, item);
 | 
						|
                    foreach (FndMngmentEmpRemarks childItem in item.FndMngmentEmpRmrkses)
 | 
						|
                    {
 | 
						|
                        ID fnEmpRemid = ID.FromInteger(tc.GenerateID("FndMngmentEmpRemarks", "FndMngmentEmpRemarksID"));
 | 
						|
                        base.SetObjectID(childItem, fnEmpRemid);
 | 
						|
                        childItem.FndMngmentWFID = id;
 | 
						|
                        childItem.FndMngmentEmpID = fnEmpid;
 | 
						|
 | 
						|
                        FndMngmentWFDA.InsertFndMngmentEmpRemarks(tc,childItem);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
 | 
						|
                foreach (FndMngmentEmpRemarks item in oFndMngment.AllFndMngEmpRemarks.Where(obj=>obj.IsHR))
 | 
						|
                {
 | 
						|
                    ID fnEmpRemid = ID.FromInteger(tc.GenerateID("FndMngmentEmpRemarks", "FndMngmentEmpRemarksID"));
 | 
						|
                    base.SetObjectID(item, fnEmpRemid);
 | 
						|
                    item.FndMngmentWFID = id;
 | 
						|
                    FndMngmentWFDA.InsertFndMngmentEmpRemarks(tc, item);
 | 
						|
                }
 | 
						|
                
 | 
						|
            }
 | 
						|
            catch (Exception e)
 | 
						|
            {
 | 
						|
                #region Handle Exception
 | 
						|
                if (tc != null)
 | 
						|
                    tc.HandleError();
 | 
						|
                ExceptionLog.Write(e);
 | 
						|
                throw new ServiceException(e.Message, e);
 | 
						|
                #endregion
 | 
						|
            }
 | 
						|
            finally
 | 
						|
            {
 | 
						|
                tc.End();
 | 
						|
            }
 | 
						|
 | 
						|
            return oFndMngment.ID;
 | 
						|
        }
 | 
						|
        //public ID Save(FndMngmentWF oFndMngment)
 | 
						|
        //{
 | 
						|
        //    ID id = null;
 | 
						|
        //    TransactionContext tc = null;
 | 
						|
        //    try
 | 
						|
        //    {
 | 
						|
        //        int startingBatchNo;
 | 
						|
        //        int previousBatchNo = 0;
 | 
						|
        //        if (oFndMngment.IsNew)
 | 
						|
        //        {
 | 
						|
 | 
						|
        //            tc = TransactionContext.Begin(true);
 | 
						|
        //            id = ID.FromInteger(tc.GenerateID("FndMngmentWF", "FndMngmentWFID"));
 | 
						|
        //            base.SetObjectID(oFndMngment, id);
 | 
						|
        //            FndMngmentWFDA.Insert(tc, oFndMngment);
 | 
						|
 | 
						|
        //            oFndMngment.FndMngmentEmps.ForEach(o => o.FndMngmentWFID = id);
 | 
						|
        //            if (oFndMngment.AllFndMngEmpRemarks != null)
 | 
						|
        //                oFndMngment.AllFndMngEmpRemarks.ForEach(o => o.FndMngmentWFID = id);
 | 
						|
        //        }
 | 
						|
        //        else
 | 
						|
        //        {
 | 
						|
        //            id = oFndMngment.ID;
 | 
						|
        //            oFndMngment.AllFndMngEmpRemarks.ForEach(o => o.FndMngmentWFID = oFndMngment.ID);
 | 
						|
        //            foreach (FndMngmentEmp item in oFndMngment.FndMngmentEmps)
 | 
						|
        //            {
 | 
						|
        //                ObjectsTemplate<FndMngmentEmpRemarks> fndRemarks = new ObjectsTemplate<FndMngmentEmpRemarks>();
 | 
						|
        //                oFndMngment.AllFndMngEmpRemarks
 | 
						|
        //                            .Where(o => o.FndMngmentEmpID != null && !o.FndMngmentEmpID.IsUnassigned && o.FndMngmentEmpID == item.ID)
 | 
						|
        //                            .ToList()
 | 
						|
        //                            .ForEach(oo => fndRemarks.Add(oo));
 | 
						|
 | 
						|
 | 
						|
        //                item.FndMngmentEmpRmrkses = fndRemarks;
 | 
						|
 | 
						|
        //            }
 | 
						|
 | 
						|
        //            tc = TransactionContext.Begin(true);
 | 
						|
 | 
						|
        //            FndMngmentWFDA.Update(tc, oFndMngment);
 | 
						|
        //            FndMngmentWFDA.DeleteFndMngmentEmpRemarkses(tc, id);
 | 
						|
        //            FndMngmentWFDA.DeleteFndMngmentEmps(tc, id);
 | 
						|
 | 
						|
        //        }
 | 
						|
 | 
						|
        //        foreach (FndMngmentEmp item in oFndMngment.FndMngmentEmps)
 | 
						|
        //        {
 | 
						|
        //            ID fnEmpid = ID.FromInteger(tc.GenerateID("FndMngmentEmp", "FndMngmentEmpID"));
 | 
						|
        //            base.SetObjectID(item, fnEmpid);
 | 
						|
        //            item.FndMngmentWFID = id;
 | 
						|
        //            FndMngmentWFDA.InsertFndMngmentEmp(tc, item);
 | 
						|
        //            foreach (FndMngmentEmpRemarks childItem in item.FndMngmentEmpRmrkses)
 | 
						|
        //            {
 | 
						|
        //                ID fnEmpRemid = ID.FromInteger(tc.GenerateID("FndMngmentEmpRemarks", "FndMngmentEmpRemarksID"));
 | 
						|
        //                base.SetObjectID(childItem, fnEmpRemid);
 | 
						|
        //                childItem.FndMngmentWFID = id;
 | 
						|
        //                childItem.FndMngmentEmpID = fnEmpid;
 | 
						|
 | 
						|
        //                FndMngmentWFDA.InsertFndMngmentEmpRemarks(tc, childItem);
 | 
						|
        //            }
 | 
						|
        //        }
 | 
						|
 | 
						|
        //        foreach (FndMngmentEmpRemarks item in oFndMngment.AllFndMngEmpRemarks.Where(obj => obj.IsHR))
 | 
						|
        //        {
 | 
						|
        //            ID fnEmpRemid = ID.FromInteger(tc.GenerateID("FndMngmentEmpRemarks", "FndMngmentEmpRemarksID"));
 | 
						|
        //            base.SetObjectID(item, fnEmpRemid);
 | 
						|
        //            item.FndMngmentWFID = id;
 | 
						|
        //            FndMngmentWFDA.InsertFndMngmentEmpRemarks(tc, item);
 | 
						|
        //        }
 | 
						|
 | 
						|
        //    }
 | 
						|
        //    catch (Exception e)
 | 
						|
        //    {
 | 
						|
        //        #region Handle Exception
 | 
						|
        //        if (tc != null)
 | 
						|
        //            tc.HandleError();
 | 
						|
        //        ExceptionLog.Write(e);
 | 
						|
        //        throw new ServiceException(e.Message, e);
 | 
						|
        //        #endregion
 | 
						|
        //    }
 | 
						|
        //    finally
 | 
						|
        //    {
 | 
						|
        //        tc.End();
 | 
						|
        //    }
 | 
						|
 | 
						|
        //    return oFndMngment.ID;
 | 
						|
        //}
 | 
						|
 | 
						|
        public void Save(FndMngmentEmpRemarks oFndMngEmpRemarks)
 | 
						|
        {
 | 
						|
            ID id = null;
 | 
						|
            TransactionContext tc = null;
 | 
						|
            try
 | 
						|
            {
 | 
						|
                    tc = TransactionContext.Begin(true);
 | 
						|
                    id = ID.FromInteger(tc.GenerateID("FndMngmentEmpRemarks", "FndMngmentEmpRemarksID"));
 | 
						|
                    base.SetObjectID(oFndMngEmpRemarks, id);
 | 
						|
                    FndMngmentWFDA.InsertFndMngmentEmpRemarks(tc, oFndMngEmpRemarks);
 | 
						|
 | 
						|
            }
 | 
						|
            catch (Exception e)
 | 
						|
            {
 | 
						|
                #region Handle Exception
 | 
						|
                if (tc != null)
 | 
						|
                    tc.HandleError();
 | 
						|
                ExceptionLog.Write(e);
 | 
						|
                throw new ServiceException(e.Message, e);
 | 
						|
                #endregion
 | 
						|
            }
 | 
						|
            finally
 | 
						|
            {
 | 
						|
                tc.End();
 | 
						|
            }
 | 
						|
 | 
						|
           
 | 
						|
        }
 | 
						|
 | 
						|
        public void Deactivate(FndMngmentWF oFndMngment)
 | 
						|
        {
 | 
						|
            TransactionContext tc = null;
 | 
						|
            try
 | 
						|
            {                
 | 
						|
                tc = TransactionContext.Begin(true);
 | 
						|
                oFndMngment.Status = EnumStatus.Inactive;
 | 
						|
                FndMngmentWFDA.Update(tc, oFndMngment);
 | 
						|
            }
 | 
						|
            catch (Exception e)
 | 
						|
            {
 | 
						|
                #region Handle Exception
 | 
						|
                if (tc != null)
 | 
						|
                    tc.HandleError();
 | 
						|
                ExceptionLog.Write(e);
 | 
						|
                throw new ServiceException(e.Message, e);
 | 
						|
                #endregion
 | 
						|
            }
 | 
						|
            finally
 | 
						|
            {
 | 
						|
                tc.End();
 | 
						|
            }
 | 
						|
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region Delete Function
 | 
						|
 | 
						|
        public void Delete(ID id)
 | 
						|
        {
 | 
						|
            TransactionContext tc = null;
 | 
						|
            try
 | 
						|
            {
 | 
						|
                tc = TransactionContext.Begin(true);
 | 
						|
 | 
						|
                FndMngmentWFDA.DeleteFndMngmentEmpRemarkses(tc, id);
 | 
						|
                FndMngmentWFDA.DeleteFndMngmentEmps(tc, id);
 | 
						|
                FndMngmentWFDA.Delete(tc, id);
 | 
						|
 | 
						|
            }
 | 
						|
            catch (Exception e)
 | 
						|
            {
 | 
						|
                #region Handle Exception
 | 
						|
                if (tc != null)
 | 
						|
                    tc.HandleError();
 | 
						|
                ExceptionLog.Write(e);
 | 
						|
                throw new ServiceException(e.Message, e);
 | 
						|
                #endregion
 | 
						|
            }
 | 
						|
            finally
 | 
						|
            {
 | 
						|
                tc.End();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
    }
 | 
						|
}
 |