コード例 #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ManagerNonChargeables EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToManagerNonChargeables(ManagerNonChargeable managerNonChargeable)
 {
     base.AddObject("ManagerNonChargeables", managerNonChargeable);
 }
コード例 #2
0
    /// <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;
            }
        }
    }
コード例 #3
0
 /// <summary>
 /// Create a new ManagerNonChargeable object.
 /// </summary>
 /// <param name="managerNonChargeableId">Initial value of the ManagerNonChargeableId property.</param>
 /// <param name="timeSheetId">Initial value of the TimeSheetId property.</param>
 public static ManagerNonChargeable CreateManagerNonChargeable(global::System.Int32 managerNonChargeableId, global::System.Int32 timeSheetId)
 {
     ManagerNonChargeable managerNonChargeable = new ManagerNonChargeable();
     managerNonChargeable.ManagerNonChargeableId = managerNonChargeableId;
     managerNonChargeable.TimeSheetId = timeSheetId;
     return managerNonChargeable;
 }
コード例 #4
0
    /// <summary>
    /// create a Manager NonChargeable Record
    /// </summary>
    /// <param name="n"></param>
    public string createManagerNonChargeable(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)
                {
                    ManagerNonChargeable nonCh = new ManagerNonChargeable();
                    if (hours != "0" && hours != string.Empty)
                    {
                        nonCh.Hours = Convert.ToDecimal(hours);
                        if (hourType != "Select")
                        {
                            nonCh.TypeHours = hourType;
                        }
                        if (nonCh.Hours.HasValue)
                        {
                            hoursLBL += nonCh.Hours.Value;
                        }
                    }
                    if (accom != "0" && accom != string.Empty)
                    {
                        nonCh.Accomodations = 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);
                    }

                    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.ManagerNonChargeables.AddObject(nonCh);
                        context.SaveChanges();
                    }
                }

                return "Data Saved Successfully";
            }
            catch (Exception ex)
            {
                return "Data was not saved due to: " + ex.Message;
            }
        }
    }