/// <summary> /// Deprecated Method for adding a new object to the NonChargeables EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToNonChargeables(NonChargeable nonChargeable) { base.AddObject("NonChargeables", nonChargeable); }
/// <summary> /// copy nonchargeable record to manager nonchargeable record /// </summary> /// <param name="n"></param> public void copyToManagerNonChargeable(NonChargeable n) { using (var context = new PetoEntities()) { try { ManagerNonChargeable mNCh = new ManagerNonChargeable(); mNCh.Hours = n.Hours; mNCh.Accomodations = n.Accomodation; mNCh.Misc = n.Misc; mNCh.Distance = n.Distance; mNCh.Remarks = n.Remarks; mNCh.TimeSheetId = n.TimeSheetId; mNCh.TypeHours = n.TypeHours; mNCh.TypeExpense = n.TypeExpense; mNCh.Day = n.Day; context.ManagerNonChargeables.AddObject(mNCh); context.SaveChanges(); } catch (Exception) { throw; } } }
/// <summary> /// Create a new NonChargeable object. /// </summary> /// <param name="nonChargeId">Initial value of the NonChargeId property.</param> /// <param name="timeSheetId">Initial value of the TimeSheetId property.</param> /// <param name="hours">Initial value of the Hours property.</param> /// <param name="day">Initial value of the Day property.</param> public static NonChargeable CreateNonChargeable(global::System.Int32 nonChargeId, global::System.Int32 timeSheetId, global::System.Decimal hours, global::System.String day) { NonChargeable nonChargeable = new NonChargeable(); nonChargeable.NonChargeId = nonChargeId; nonChargeable.TimeSheetId = timeSheetId; nonChargeable.Hours = hours; nonChargeable.Day = day; return nonChargeable; }
/// <summary> /// create a NonChargeable Record /// </summary> /// <param name="n"></param> public string createNonChargeable(string hours, string accom, string distance, string misc, string day, string expense, string hourType, int timesheetID, string remarks, ref decimal hoursLBL, ref int distLBL, ref decimal expenseLBL) { using (var context = new PetoEntities()) { try { // to ensure only not null values are saved if (timesheetID > 0 && (hours != "0" && hours != string.Empty) || (accom != "0" && accom != string.Empty) || (distance != "0" && distance != string.Empty) || (misc != "0" && misc != string.Empty)) { NonChargeable nonCh = new NonChargeable(); if (hours != "0" && hours != string.Empty) { nonCh.Hours = Convert.ToDecimal(hours); // assign type of hour if (hourType != "Select") { nonCh.TypeHours = hourType; } hoursLBL += nonCh.Hours; } if (accom != "0" && accom != string.Empty) { nonCh.Accomodation = Convert.ToDecimal(accom); expenseLBL += Convert.ToDecimal(accom); } if (distance != "0" && distance != string.Empty) { nonCh.Distance = Convert.ToInt32(distance); distLBL += Convert.ToInt32(distance); } if (remarks != string.Empty) { nonCh.Remarks = remarks; } if (misc != "0" && misc != string.Empty) { nonCh.Misc = Convert.ToDecimal(misc); expenseLBL += Convert.ToDecimal(misc); } // assign expenses if ((misc != "0" && misc != string.Empty) || (distance != "0" && distance != string.Empty) || (accom != "0" && accom != string.Empty)) { if (expense != "Select") { nonCh.TypeExpense = expense; } } if (misc != "0" && misc != string.Empty || distance != "0" && distance != string.Empty || accom != "0" && accom != string.Empty || hours != "0" && hours != string.Empty) { nonCh.TimeSheetId = timesheetID; } nonCh.Day = day; // one of these must be selected in order to save if (expense != "Select" || hours != "Select") { context.NonChargeables.AddObject(nonCh); context.SaveChanges(); } } return "Data Saved Successfully"; } catch (Exception ex) { return "Data was not saved due to: " + ex.Message; } } }