Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="frmTimeSheetItem"/> class.
 /// </summary>
 /// <param name="timeSheet">The time sheet.</param>
 public TimeSheetItemForm(ref TimeSheet timeSheet, TimeSheetDay timeSheetDay) {
   InitializeComponent();
   _timeSheetItem            = timeSheet;
   _timeSheetDayItem         = timeSheetDay;
   _categoriesControl        = new CategoriesControl();
   SetUpTimeSheetItemForm();
 }
Ejemplo n.º 2
0
    /// <summary>
    /// Edits the specified time sheet item.
    /// </summary>
    /// <param name="timeSheetItem">The time sheet item.</param>
    /// <param name="day">The day.</param>
    /// <param name="timeSheetItemIndex">Index of the time sheet item.</param>
    public bool Edit(TimeSheet timeSheetItem, TimeSheetDay timeSheetDay) {
      bool status                 = false;
      int timeSheetDayIndex       = FindTimeSheetDayIndex(timeSheetDay.GUID);
      int index                   = FindTimeSheetItemIndex(timeSheetItem.GUID, timeSheetDay.GUID);

      if (index != -1) {
        Persistence.Persist.Data.TimeSheetDayList[timeSheetDayIndex].TimeSheetList[index]       = timeSheetItem;
        Persist();
        status                    = true;
      }

      return status;
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Adds the specified time sheet item.
    /// </summary>
    /// <param name="timeSheetItem">The time sheet item.</param>
    /// <param name="timeSheetDay">The time sheet day.</param>
    public void Add(TimeSheet timeSheetItem, TimeSheetDay timeSheetDay){
      int dayIndex                          = FindTimeSheetDayIndex(timeSheetDay.GUID);

      if (dayIndex != -1) {
        Persistence.Persist.Data.TimeSheetDayList[dayIndex].TimeSheetList.Add(timeSheetItem);
      } else {
        Persistence.Persist.Data.TimeSheetDayList.Add(timeSheetDay);
        Persist();
        dayIndex                            = FindTimeSheetDayIndex(timeSheetDay.GUID);
        Persistence.Persist.Data.TimeSheetDayList[dayIndex].Day      = timeSheetDay.Day;
        Persistence.Persist.Data.TimeSheetDayList[dayIndex].TimeSheetList.Add(timeSheetItem);
      }
      Persist();
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Deletes the specified day.
    /// </summary>
    /// <param name="day">The day.</param>
    /// <param name="timeSheetItemIndex">Index of the time sheet item.</param>
    public void Delete(string guid, TimeSheetDay timeSheetDay) {
      int timeSheetDayIndex       = FindTimeSheetDayIndex(timeSheetDay.GUID);
      int index                   = FindTimeSheetItemIndex(guid, timeSheetDay.GUID);

      Persistence.Persist.Data.TimeSheetDayList[timeSheetDayIndex].TimeSheetList.RemoveAt(index);
      if (Persistence.Persist.Data.TimeSheetDayList[timeSheetDayIndex].TimeSheetList.Count == 0) {
        Persistence.Persist.Data.TimeSheetDayList.RemoveAt(timeSheetDayIndex);
      }
      Persist();
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Sets the last time sheet items end time Or gets the next time sheet items start time. (Subject to Options settings)
    /// </summary>
    /// <param name="timeSheetItem">The time sheet item.</param>
    /// <param name="timeSheetDayItem">The time sheet day item.</param>
    /// <returns></returns>
    public DateTime SetLastTimeSheetItemsEndTime(TimeSheet timeSheetItem, TimeSheetDay timeSheetDayItem){
      int timeSheetDayIndex       = FindTimeSheetDayIndex(timeSheetDayItem.GUID);

      DateTime result             = new DateTime();
      if (timeSheetDayIndex != -1) {
        if (Persistence.Persist.Data.TimeSheetDayList[timeSheetDayIndex].TimeSheetList.Count > 0) {
          DateTime validation     = new DateTime();

          if (Persistence.Persist.Data.TimeSheetDayList[timeSheetDayIndex].TimeSheetList[Persistence.Persist.Data.TimeSheetDayList[timeSheetDayIndex].TimeSheetList.Count - 1].EndTime == validation) {
            if (Properties.Settings.Default.TimeSheet_SetEndTime) {
              Persistence.Persist.Data.TimeSheetDayList[timeSheetDayIndex].TimeSheetList[Persistence.Persist.Data.TimeSheetDayList[timeSheetDayIndex].TimeSheetList.Count - 1].EndTime      = timeSheetItem.StartTime;
              Persistence.Persist.Data.TimeSheetDayList[timeSheetDayIndex].TimeSheetList[Persistence.Persist.Data.TimeSheetDayList[timeSheetDayIndex].TimeSheetList.Count - 1].JobTime      = TimeSheetControl.CalculateJobTime(Persistence.Persist.Data.TimeSheetDayList[timeSheetDayIndex].TimeSheetList[Persistence.Persist.Data.TimeSheetDayList[timeSheetDayIndex].TimeSheetList.Count - 1]);
              result              = Persistence.Persist.Data.TimeSheetDayList[timeSheetDayIndex].TimeSheetList[Persistence.Persist.Data.TimeSheetDayList[timeSheetDayIndex].TimeSheetList.Count - 1].EndTime;
            }
            Persist();
          }
        }
      }
      return result;
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Inserts the specified time sheet item.
    /// </summary>
    /// <param name="timeSheetItem">The time sheet item.</param>
    /// <param name="timeSheetDay">The time sheet day.</param>
    /// <param name="insertPosition">The insert position.</param>
    public void Insert(TimeSheet timeSheetItem, TimeSheetDay timeSheetDay, TimeSheet insertPosition){
      int timeSheetDayIndex       = FindTimeSheetDayIndex(timeSheetDay.GUID);
      int index                   = FindTimeSheetItemIndex(insertPosition.GUID, timeSheetDay.GUID);

      Persistence.Persist.Data.TimeSheetDayList[timeSheetDayIndex].TimeSheetList.Insert(index, timeSheetItem);
      Persist();
    }
Ejemplo n.º 7
0
      /// <summary>
      /// Populates the time sheet tab. (Subject to Options settings)
      /// </summary>
      /// <param name="start">The start.</param>
      /// <param name="end">The end.</param>
      private void PopulateTimeSheetTab(SelectionRange dateRange){
        DateTime[] dates            = Utilities.GetDatesIndexed(dateRange);
        int[] dayIndexes            = _timeSheetControl.GetIndexFromDate(dates);
        dgvTimeSheet.Rows.Clear();

        for (int ct1 = 0; ct1 < dayIndexes.Length; ct1++) {
          if (dayIndexes[ct1] != -1){
            if (Persistence.Persist.Data.TimeSheetDayList[dayIndexes[ct1]].TimeSheetList.Count > 0){
              int rows              = dgvTimeSheet.Rows.Count - 1;
              dgvTimeSheet.Rows.Add(Persistence.Persist.Data.TimeSheetDayList[dayIndexes[ct1]].TimeSheetList.Count);
              calTimeSheet.Tag      = Persistence.Persist.Data.TimeSheetDayList[dayIndexes[ct1]];

              for (int ct2 = 0; ct2 < Persistence.Persist.Data.TimeSheetDayList[dayIndexes[ct1]].TimeSheetList.Count; ct2++) {
                if (Persistence.Persist.Data.TimeSheetDayList[ct1].TimeSheetList[ct2].TodoTaskGuid != "") {
                  dgvTimeSheet.Rows[ct2 + rows].DefaultCellStyle.Font                   = new Font(Font, FontStyle.Bold);
                }
                dgvTimeSheet.Rows[ct2 + rows].Cells["TimeSheetDate"].Value              = Persistence.Persist.Data.TimeSheetDayList[dayIndexes[ct1]].TimeSheetList[ct2].Date.Day + "/" + Persistence.Persist.Data.TimeSheetDayList[dayIndexes[ct1]].TimeSheetList[ct2].Date.Month + "/" + Persistence.Persist.Data.TimeSheetDayList[dayIndexes[ct1]].TimeSheetList[ct2].Date.Year;
                dgvTimeSheet.Rows[ct2 + rows].Cells["TimeSheetTask"].Value              = _timeSheetControl.GetTimeSheetDisplayName(Persistence.Persist.Data.TimeSheetDayList[dayIndexes[ct1]].TimeSheetList[ct2]);
                dgvTimeSheet.Rows[ct2 + rows].Cells["TimeSheetStartTime"].Value         = Persistence.Persist.Data.TimeSheetDayList[dayIndexes[ct1]].TimeSheetList[ct2].StartTime.TimeOfDay.ToString().Substring(0, 8);
                dgvTimeSheet.Rows[ct2 + rows].Cells["TimeSheetEndTime"].Value           = Persistence.Persist.Data.TimeSheetDayList[dayIndexes[ct1]].TimeSheetList[ct2].EndTime.TimeOfDay.ToString().Substring(0, 8);
                dgvTimeSheet.Rows[ct2 + rows].Cells["TimeSheetJobTime"].Value           = Persistence.Persist.Data.TimeSheetDayList[dayIndexes[ct1]].TimeSheetList[ct2].JobTime.Substring(0, 8);
                dgvTimeSheet.Rows[ct2 + rows].Cells["TimeSheetMainCategory"].Value      = CategoriesControl.FindMainCategory(Persistence.Persist.Data.TimeSheetDayList[dayIndexes[ct1]].TimeSheetList[ct2].MainCategoryGuid);
                dgvTimeSheet.Rows[ct2 + rows].Cells["TimeSheetSubCategory"].Value       = CategoriesControl.FindSubCategory(Persistence.Persist.Data.TimeSheetDayList[dayIndexes[ct1]].TimeSheetList[ct2].SubCategoryGuid);
                dgvTimeSheet.Rows[ct2 + rows].Tag                                       = Persistence.Persist.Data.TimeSheetDayList[dayIndexes[ct1]].TimeSheetList[ct2];
              }
            }

          } else {
            TimeSheetDay timeSheetDay       = new TimeSheetDay();
            timeSheetDay.GUID               = Utilities.GetNewGUID();
            timeSheetDay.Day                = calTimeSheet.SelectionStart;
            timeSheetDay.TimeSheetList      = new List<TimeSheet>();
            calTimeSheet.Tag                = timeSheetDay;
          }
        }

        if (Settings.Default.Planner_CalcTotalTime) {
          lblTotal.Text                     = GetTotalTime();

        } else {
          lblTotal.Text                     = "...";
        }

        txtQuickAddTask.Text                = string.Empty;
      }