using System; using Ease.CoreV35.Caching; using Ease.CoreV35.DataAccess; using Ease.CoreV35.Model; using Payroll.BO; using System.Data; namespace Payroll.Service { #region TrainingSchedule Service [Serializable] class TrainingScheduleService : ServiceTemplate, ITrainingScheduleService { #region Private functions and declaration Cache _cache = new Cache(typeof(TrainingSchedule)); #region base Object Functions private void MapObject(TrainingSchedule oTrainingSchedule, DataReader oReader) { base.SetObjectID(oTrainingSchedule, oReader.GetID("TrainingScheduleID")); oTrainingSchedule.TrainingID = oReader.GetID("TRAININGID"); oTrainingSchedule.TrainingNatureID = oReader.GetID("TrainingNatureID"); oTrainingSchedule.InstituteID = oReader.GetID("InstituteID"); oTrainingSchedule.TrainerDescription = oReader.GetString("TrainerDescription"); oTrainingSchedule.EnrolledEndDate = oReader.GetDateTime("EnrolledEndDate").Value; oTrainingSchedule.EnrolledStartDate = oReader.GetDateTime("EnrolledStartDate").Value; oTrainingSchedule.IsShowInWeb = oReader.GetBoolean("IsShowInWeb").GetValueOrDefault(); oTrainingSchedule.TNAnalysisID = oReader.GetID("TNAnalysisID"); oTrainingSchedule.StartDate = oReader.GetDateTime("StartDate").Value; oTrainingSchedule.EndDate = oReader.GetDateTime("EndDate").Value; oTrainingSchedule.Cost = oReader.GetDouble("Cost").GetValueOrDefault(); oTrainingSchedule.MaxParticipants = oReader.GetInt32("MaxParticipants").GetValueOrDefault(); oTrainingSchedule.EnrolledParticipants = oReader.GetInt32("EnrolledParticipants").GetValueOrDefault(); oTrainingSchedule.CourseOutline = oReader.GetString("CourseOutline"); oTrainingSchedule.ScheduleStatus = oReader.GetBoolean("ScheduleStatus").GetValueOrDefault(); oTrainingSchedule.VenueCost = oReader.GetDouble("VenueCost").GetValueOrDefault(); oTrainingSchedule.RefreshmentCost = oReader.GetDouble("RefreshmentCost").GetValueOrDefault(); oTrainingSchedule.TrainerFees = oReader.GetDouble("TrainerFees").GetValueOrDefault(); oTrainingSchedule.OthesCost = oReader.GetDouble("OthesCost").GetValueOrDefault(); oTrainingSchedule.Venue = oReader.GetString("Venue"); oTrainingSchedule.PayrollTypeID = oReader.GetString("PAYROLLTYPEID") == null ? null : ID.FromInteger(oReader.GetInt32("PAYROLLTYPEID").Value); this.SetObjectState(oTrainingSchedule, Ease.CoreV35.ObjectState.Saved); } protected override T CreateObject(DataReader oReader) { TrainingSchedule oTrainingSchedule = new TrainingSchedule(); MapObject(oTrainingSchedule, oReader); return oTrainingSchedule as T; } #endregion #region Child Object Functions #region TrainingScheduleEmployee Functions private void MapTrainingScheduleEmployeeObject(TrainingScheduleEmployee oTrainingScheduleEmployee, DataReader oReader) { base.SetObjectID(oTrainingScheduleEmployee, oReader.GetID("TrainingScheduleEmployeeID")); oTrainingScheduleEmployee.TrainingScheduleID = oReader.GetID("TrainingScheduleID"); oTrainingScheduleEmployee.EmployeeID = oReader.GetID("EmployeeID"); oTrainingScheduleEmployee.ProposedByID = oReader.GetID("ProposedByID"); oTrainingScheduleEmployee.ProposedDate = oReader.GetDateTime("ProposedDate").GetValueOrDefault(); oTrainingScheduleEmployee.Remarks = oReader.GetString("Remarks"); oTrainingScheduleEmployee.ScheduleEmpStatus = (EnumTSStatus) oReader.GetInt32("ScheduleEmpStatus").GetValueOrDefault(); this.SetObjectState(oTrainingScheduleEmployee, Ease.CoreV35.ObjectState.Saved); } private TrainingScheduleEmployee CreateTrainingScheduleEmployeeObject(DataReader oReader) { TrainingScheduleEmployee oTrainingScheduleEmployee = new TrainingScheduleEmployee(); MapTrainingScheduleEmployeeObject(oTrainingScheduleEmployee, oReader); return oTrainingScheduleEmployee; } private ObjectsTemplate CreateTrainingScheduleEmployeeObjects(DataReader oReader) { ObjectsTemplate trainingScheduleEmployees=new ObjectsTemplate(); while (oReader.Read()) { TrainingScheduleEmployee oTrainingScheduleEmployee = new TrainingScheduleEmployee(); oTrainingScheduleEmployee = CreateTrainingScheduleEmployeeObject(oReader); trainingScheduleEmployees.Add(oTrainingScheduleEmployee); } return trainingScheduleEmployees; } #endregion #region TrainingScheduleDate Functions private void MapTrainingScheduleDateObject(TrainingScheduleDate oTrainingScheduleDate, DataReader oReader) { base.SetObjectID(oTrainingScheduleDate, oReader.GetID("TrainingScheduleDateID")); oTrainingScheduleDate.TrainingScheduleID = oReader.GetID("TrainingScheduleID"); oTrainingScheduleDate.ScheduleDate = oReader.GetDateTime("ScheduleDate").Value; oTrainingScheduleDate.StartTime = oReader.GetDateTime("StartTime").Value; oTrainingScheduleDate.EndTime = oReader.GetDateTime("EndTime").Value; oTrainingScheduleDate.Remarks = oReader.GetString("Remarks"); this.SetObjectState(oTrainingScheduleDate, Ease.CoreV35.ObjectState.Saved); } private TrainingScheduleDate CreateTrainingScheduleDateObject(DataReader oReader) { TrainingScheduleDate oTrainingScheduleDate = new TrainingScheduleDate(); MapTrainingScheduleDateObject(oTrainingScheduleDate, oReader); return oTrainingScheduleDate; } private ObjectsTemplate CreateTrainingScheduleDateObjects(DataReader oReader) { ObjectsTemplate trainingScheduleDates = new ObjectsTemplate(); while (oReader.Read()) { TrainingScheduleDate oTrainingScheduleDate = new TrainingScheduleDate(); oTrainingScheduleDate = CreateTrainingScheduleDateObject(oReader); trainingScheduleDates.Add(oTrainingScheduleDate); } return trainingScheduleDates; } #endregion #endregion #endregion #region Implementation of ITrainingScheduleService #region Get TrainingSchedule public TrainingSchedule Get(ID trainigScheduleID) { TrainingSchedule oTrainingSchedule = null; #region CacheHeader oTrainingSchedule = (TrainingSchedule)_cache["Get", trainigScheduleID]; if (oTrainingSchedule != null) return oTrainingSchedule; #endregion TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); DataReader oreader = new DataReader(TrainingScheduleDA.GetTS(tc, trainigScheduleID.Integer)); if (oreader.Read()) { oTrainingSchedule = CreateObject(oreader); } oreader.Close(); if (oTrainingSchedule != null) { oreader = new DataReader(TrainingScheduleDA.GetTrainingScheduleEmployees(tc, trainigScheduleID)); oTrainingSchedule.EnrolledTrainingEmployees = CreateTrainingScheduleEmployeeObjects(oreader); oreader.Close(); if (oTrainingSchedule.EnrolledTrainingEmployees != null) { foreach (TrainingScheduleEmployee temp in oTrainingSchedule.EnrolledTrainingEmployees) { TrainingSchEmpCostService osvr = new TrainingSchEmpCostService(); temp.TrainingSchEmpCosts = osvr.GetByTrainingScheduleEmpID(tc,temp.EmployeeID, temp.ID); } } oreader = new DataReader(TrainingScheduleDA.GetTrainingScheduleDates(tc, trainigScheduleID.Integer)); oTrainingSchedule.TrainingScheduleDates = CreateTrainingScheduleDateObjects(oreader); oreader.Close(); } tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } #region CacheFooter _cache.Add(oTrainingSchedule, "Get", trainigScheduleID); #endregion return oTrainingSchedule; } #endregion #region Get TrainingSchedules public ObjectsTemplate Get(int payrollTypeID) { ObjectsTemplate oTrainingSchedules; #region CacheHeader oTrainingSchedules = (ObjectsTemplate)_cache["Get"]; if (oTrainingSchedules != null) return oTrainingSchedules; #endregion TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); DataReader oreader = new DataReader(TrainingScheduleDA.Get(tc, payrollTypeID)); oTrainingSchedules = CreateObjects(oreader); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } #region CacheFooter _cache.Add(oTrainingSchedules, "Get"); #endregion return oTrainingSchedules; } public ObjectsTemplate Get(bool active, int payrollTypeID) { ObjectsTemplate oTrainingSchedules; #region CacheHeader oTrainingSchedules = (ObjectsTemplate)_cache["Get"]; if (oTrainingSchedules != null) return oTrainingSchedules; #endregion TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); DataReader oreader = new DataReader(TrainingScheduleDA.Get(tc, active, payrollTypeID)); oTrainingSchedules = CreateObjects(oreader); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } #region CacheFooter _cache.Add(oTrainingSchedules, "Get"); #endregion return oTrainingSchedules; } public ObjectsTemplate Get(DateTime today, int payrollTypeID) { ObjectsTemplate oTrainingSchedules; #region CacheHeader oTrainingSchedules = (ObjectsTemplate)_cache["Get"]; if (oTrainingSchedules != null) return oTrainingSchedules; #endregion TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); DataReader oreader = new DataReader(TrainingScheduleDA.Get(tc, today, payrollTypeID)); oTrainingSchedules = CreateObjects(oreader); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } #region CacheFooter _cache.Add(oTrainingSchedules, "Get"); #endregion return oTrainingSchedules; } public ObjectsTemplate Get(DateTime fromDate, DateTime toDate, int training, int payrollTypeID) { ObjectsTemplate oTrainingSchedules; #region CacheHeader oTrainingSchedules = (ObjectsTemplate)_cache["Get"]; if (oTrainingSchedules != null) return oTrainingSchedules; #endregion TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); DataReader oreader = new DataReader(TrainingScheduleDA.Get(tc, fromDate, toDate, training, payrollTypeID)); oTrainingSchedules = CreateObjects(oreader); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } #region CacheFooter _cache.Add(oTrainingSchedules, "Get"); #endregion return oTrainingSchedules; } public ObjectsTemplate Get(DateTime fromDate, DateTime toDate, int training, bool active, int payrollTypeID) { ObjectsTemplate oTrainingSchedules; #region CacheHeader oTrainingSchedules = (ObjectsTemplate)_cache["Get"]; if (oTrainingSchedules != null) return oTrainingSchedules; #endregion TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); DataReader oreader = new DataReader(TrainingScheduleDA.Get(tc, fromDate, toDate, training, active, payrollTypeID)); oTrainingSchedules = CreateObjects(oreader); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } #region CacheFooter _cache.Add(oTrainingSchedules, "Get"); #endregion return oTrainingSchedules; } public ObjectsTemplate Get(int training, int TNAID, bool active, int payrollTypeID) { ObjectsTemplate oTrainingSchedules; #region CacheHeader oTrainingSchedules = (ObjectsTemplate)_cache["Get"]; if (oTrainingSchedules != null) return oTrainingSchedules; #endregion TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); DataReader oreader = new DataReader(TrainingScheduleDA.Get(tc, training, TNAID, active, payrollTypeID)); oTrainingSchedules = CreateObjects(oreader); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } #region CacheFooter _cache.Add(oTrainingSchedules, "Get"); #endregion return oTrainingSchedules; } public ObjectsTemplate Get(int training, int TNAID, int payrollTypeID) { ObjectsTemplate oTrainingSchedules; #region CacheHeader oTrainingSchedules = (ObjectsTemplate)_cache["Get"]; if (oTrainingSchedules != null) return oTrainingSchedules; #endregion TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); DataReader oreader = new DataReader(TrainingScheduleDA.Get(tc, training, TNAID, payrollTypeID)); oTrainingSchedules = CreateObjects(oreader); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } #region CacheFooter _cache.Add(oTrainingSchedules, "Get"); #endregion return oTrainingSchedules; } public ObjectsTemplate Get(DateTime fromDate, DateTime toDate, bool active, int payrollTypeID) { ObjectsTemplate oTrainingSchedules; #region CacheHeader oTrainingSchedules = (ObjectsTemplate)_cache["Get"]; if (oTrainingSchedules != null) return oTrainingSchedules; #endregion TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); DataReader oreader = new DataReader(TrainingScheduleDA.Get(tc, fromDate, toDate, active, payrollTypeID)); oTrainingSchedules = CreateObjects(oreader); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } #region CacheFooter _cache.Add(oTrainingSchedules, "Get"); #endregion return oTrainingSchedules; } public ObjectsTemplate GetbyStatus(int status, int payrollTypeID) { ObjectsTemplate oTrainingSchedules; #region CacheHeader oTrainingSchedules = (ObjectsTemplate)_cache["Get"]; if (oTrainingSchedules != null) return oTrainingSchedules; #endregion TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); DataReader oreader = new DataReader(TrainingScheduleDA.GetbyStatus(tc, status, payrollTypeID)); oTrainingSchedules = CreateObjects(oreader); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } #region CacheFooter _cache.Add(oTrainingSchedules, "Get"); #endregion return oTrainingSchedules; } public ObjectsTemplate Get(DateTime today, int EmpID, int status, int payrollTypeID) { ObjectsTemplate oTrainingSchedules; #region CacheHeader oTrainingSchedules = (ObjectsTemplate)_cache["Get"]; if (oTrainingSchedules != null) return oTrainingSchedules; #endregion TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); DataReader oreader = new DataReader(TrainingScheduleDA.Get(tc, today, EmpID, status, payrollTypeID)); oTrainingSchedules = CreateObjects(oreader); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } #region CacheFooter _cache.Add(oTrainingSchedules, "Get"); #endregion return oTrainingSchedules; } public ObjectsTemplate Get(DateTime fromDate, DateTime toDate, int payrollTypeID) { ObjectsTemplate oTrainingSchedules; #region CacheHeader oTrainingSchedules = (ObjectsTemplate)_cache["Get"]; if (oTrainingSchedules != null) return oTrainingSchedules; #endregion TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); DataReader oreader = new DataReader(TrainingScheduleDA.Get(tc, fromDate, toDate, payrollTypeID)); oTrainingSchedules = CreateObjects(oreader); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } #region CacheFooter _cache.Add(oTrainingSchedules, "Get"); #endregion return oTrainingSchedules; } public TrainingScheduleEmployee getScheduleEmp(ID SEmpID) { TrainingScheduleEmployee oTrainingScheduleEmp=null; TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); DataReader dtReader = new DataReader(TrainingScheduleDA.getScheduleEmp(tc, SEmpID)); if(dtReader.Read()) oTrainingScheduleEmp = CreateTrainingScheduleEmployeeObject(dtReader); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } return oTrainingScheduleEmp; } public DataSet Get(string query) { TransactionContext tc = null; DataSet ds = new DataSet(); try { tc = TransactionContext.Begin(); ds = TrainingScheduleDA.Get(tc, query); tc.End(); return ds; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } #endregion #region Save TrainingSchedule public ID Save(TrainingSchedule oTrainingSchedule) { try { TransactionContext tc = null; try { #region Saving data tc = TransactionContext.Begin(true); if (oTrainingSchedule.IsNew) { #region New Schedule Insert int newID = tc.GenerateID("TrainingSchedule", "TrainingScheduleID"); base.SetObjectID(oTrainingSchedule, ID.FromInteger(newID)); TrainingScheduleDA.Insert(tc, oTrainingSchedule); #endregion } else { #region Old Schedule Update TrainingScheduleDA.Update(tc, oTrainingSchedule); //ObjectsTemplate tempatt= oTrainingSchedule.TrainingScheduleAttns; TrainingScheduleDA.DeleteScheduleDetail(tc,oTrainingSchedule.ID.Integer); #region Old Code //foreach (TrainingScheduleEmployee enrolledTrainingEmployee in oTrainingSchedule.EnrolledTrainingEmployees) //{ // enrolledTrainingEmployee.TrainingScheduleID = oTrainingSchedule.ID; // base.SetObjectID(enrolledTrainingEmployee, ID.FromInteger(tc.GenerateID("TrainingScheduleEmployee", "TrainingScheduleEmployeeID"))); // TrainingScheduleDA.InsertTrainingEmployee(tc, enrolledTrainingEmployee); //} //DataReader oreader = new DataReader(TrainingScheduleDA.GetTrainingScheduleDates(tc, oTrainingSchedule.ID.Integer)); //ObjectsTemplate oTempTrainingScheduleDates = CreateTrainingScheduleDateObjects(oreader); //oreader.Close(); //foreach (TrainingScheduleDate tempTrainingScheduleDate in oTempTrainingScheduleDates) //{ // bool isExist = false; // foreach (TrainingScheduleDate trainingSchDate in oTrainingSchedule.TrainingScheduleDates) // { // if(tempTrainingScheduleDate.ScheduleDate==trainingSchDate.ScheduleDate) // { // isExist = true; // break; // } // } // if (!isExist) // TrainingScheduleDA.DeleteTrainingScheduleDate(tc, tempTrainingScheduleDate.ID.Integer); //} //foreach (TrainingScheduleDate trainingSchDate in oTrainingSchedule.TrainingScheduleDates) //{ // if(trainingSchDate.IsNew) // { // trainingSchDate.TrainingScheduleID = oTrainingSchedule.ID; // base.SetObjectID(trainingSchDate, ID.FromInteger(tc.GenerateID("TrainingScheduleDate", "TrainingScheduleDateID"))); // TrainingScheduleDA.InsertTrainingScheduleDate(tc,trainingSchDate); // } //} #endregion Old Code #endregion } foreach (TrainingScheduleEmployee enrolledTrainingEmployee in oTrainingSchedule.EnrolledTrainingEmployees) { enrolledTrainingEmployee.TrainingScheduleID = oTrainingSchedule.ID; base.SetObjectID(enrolledTrainingEmployee, ID.FromInteger(tc.GenerateID("TrainingScheduleEmployee", "TrainingScheduleEmployeeID"))); TrainingScheduleDA.InsertTrainingEmployee(tc, enrolledTrainingEmployee); foreach (TrainingSchEmpCost hcost in enrolledTrainingEmployee.TrainingSchEmpCosts) { hcost.TrainSchEmpID = enrolledTrainingEmployee.ID.Integer; base.SetObjectID(hcost, ID.FromInteger(tc.GenerateID("TrainingSchEmpCost", "TrainingSchEmpCostID"))); hcost.CreatedBy = User.CurrentUser.ID; hcost.CreatedDate = DateTime.Today; TrainingSchEmpCostDA.Insert(tc, hcost); } } foreach (TrainingScheduleDate scheduleDate in oTrainingSchedule.TrainingScheduleDates) { scheduleDate.TrainingScheduleID = oTrainingSchedule.ID; base.SetObjectID(scheduleDate, ID.FromInteger(tc.GenerateID("TrainingScheduleDate", "TrainingScheduleDateID"))); TrainingScheduleDA.InsertTrainingScheduleDate(tc, scheduleDate); } tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } } catch (Exception e) { throw new Exception(e.Message, e); } return oTrainingSchedule.ID; } public ID SaveAttnStatus(TrainingSchedule oTrainingSchedule) { try { TransactionContext tc = null; try { #region Saving data tc = TransactionContext.Begin(true); //TrainingScheduleDA.DeleteTrainingEmployees(tc, oTrainingSchedule.ID.Integer); foreach (TrainingScheduleEmployee enrolledTrainingEmployee in oTrainingSchedule.EnrolledTrainingEmployees) { //enrolledTrainingEmployee.TrainingScheduleID = oTrainingSchedule.ID; //base.SetObjectID(enrolledTrainingEmployee, ID.FromInteger(tc.GenerateID("TrainingScheduleEmployee", "TrainingScheduleEmployeeID"))); //TrainingScheduleDA.InsertTrainingEmployee(tc, enrolledTrainingEmployee); TrainingScheduleDA.updateScheduleEmp(tc, enrolledTrainingEmployee.ID.Integer, (int)enrolledTrainingEmployee.ScheduleEmpStatus); } TrainingScheduleDA.DeleteTrainingScheduleAttn(tc, oTrainingSchedule.ID.Integer); foreach (TrainingScheduleDate scheduleDate in oTrainingSchedule.TrainingScheduleDates) { foreach (TrainingScheduleAttn attn in scheduleDate.TrainingScheduleAttns) { base.SetObjectID(attn, ID.FromInteger(tc.GenerateID("TrainingScheduleAttn", "TSAttnID"))); TrainingScheduleDA.InsertTrainingScheduleAttn(tc,attn); } } tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } } catch (Exception e) { throw new Exception(e.Message, e); } return oTrainingSchedule.ID; } public ID SaveTrainingEmp(TrainingScheduleEmployee tEmp) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); if (tEmp.IsNew) { base.SetObjectID(tEmp, ID.FromInteger(tc.GenerateID("TrainingScheduleEmployee", "TrainingScheduleEmployeeID"))); TrainingScheduleDA.InsertTrainingEmployee(tc, tEmp); } else { TrainingScheduleDA.updateScheduleEmp(tc, tEmp); } tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } return tEmp.ID; } #endregion #region Delete Training Schedule public void Delete(ID trainingScheduleID) { try { TransactionContext tc = null; try { #region Deleting data tc = TransactionContext.Begin(true); TrainingScheduleAttnDA.DeletebyTrainingScheduleID(tc,trainingScheduleID.Integer); TrainingScheduleDA.DeleteTrainingScheduleDates(tc, trainingScheduleID.Integer); TrainingScheduleDA.DeleteTrainingEmployees(tc,trainingScheduleID.Integer); TrainingScheduleDA.Delete(tc,trainingScheduleID.Integer); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } } catch (Exception e) { throw new Exception(e.Message, e); } } #endregion #region Child Delete Function public void DeleteNominatedEmp(ID SEmpID) { try { TransactionContext tc = null; try { #region Deleting data tc = TransactionContext.Begin(true); TrainingScheduleDA.DeleteNominatedEmp(tc, SEmpID.Integer); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } } catch (Exception e) { throw new Exception(e.Message, e); } } public void updateScheduleEmp(ID SEmpID, int status) { try { TransactionContext tc = null; try { #region Update data tc = TransactionContext.Begin(true); TrainingScheduleDA.updateScheduleEmp(tc, SEmpID.Integer,status); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } } catch (Exception e) { throw new Exception(e.Message, e); } } #endregion #region Childs Get Functions public ObjectsTemplate GetTrainingScheduleDates(ID trainingScheduleID) { ObjectsTemplate oTrainingScheduleDates; #region CacheHeader oTrainingScheduleDates = (ObjectsTemplate)_cache["Get"]; if (oTrainingScheduleDates != null) return oTrainingScheduleDates; #endregion TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); DataReader oreader = new DataReader(TrainingScheduleDA.GetTrainingScheduleDates(tc,trainingScheduleID.Integer)); oTrainingScheduleDates = CreateTrainingScheduleDateObjects(oreader); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } #region CacheFooter _cache.Add(oTrainingScheduleDates, "Get"); #endregion return oTrainingScheduleDates; } public ObjectsTemplate GetTrainingScheduleEmployees(ID trainingScheduleID) { ObjectsTemplate oTrainingScheduleEmployees; #region CacheHeader oTrainingScheduleEmployees = (ObjectsTemplate)_cache["Get"]; if (oTrainingScheduleEmployees != null) return oTrainingScheduleEmployees; #endregion TransactionContext tc = null; try { #region Retrieving data tc = TransactionContext.Begin(); DataReader oreader = new DataReader(TrainingScheduleDA.GetTrainingScheduleEmployees(tc,trainingScheduleID)); oTrainingScheduleEmployees = CreateTrainingScheduleEmployeeObjects(oreader); tc.End(); #endregion } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); throw new ServiceException(e.Message, e); #endregion } #region CacheFooter _cache.Add(oTrainingScheduleEmployees, "Get"); #endregion return oTrainingScheduleEmployees; } #endregion #endregion } #endregion }