Example #1
0
      /// <summary>
      /// Inserts the time sheet item.
      /// </summary>
      /// <param name="index">The index.</param>
      private void InsertTimeSheetItem(){
        try {
          if (tbcMain.SelectedTab != tbTimeSheet) {
            tbcMain.SelectedTab       = tbTimeSheet;
          }

          if (calTimeSheet.SelectionStart == calTimeSheet.SelectionEnd) {
            if (dgvTimeSheet.SelectedRows.Count == 0) {
              if (dgvTimeSheet.SelectedRows.Count > 1) {
                if (dgvTimeSheet.SelectedRows[0].Index != dgvTimeSheet.Rows.Count - 1) {
                  TimeSheetDay timeSheetDayItem       = (TimeSheetDay)calTimeSheet.Tag;
                  TimeSheet insertPosition            = (TimeSheet)dgvTimeSheet.SelectedRows[0].Tag;
                  TimeSheet timeSheetItem             = new TimeSheet();
                  TimeSheetItemForm frm               = new TimeSheetItemForm(ref timeSheetItem, timeSheetDayItem);
                  DialogResult result                 = frm.ShowDialog();

                  if (timeSheetItem.Task != "") {
                    _timeSheetControl.Insert(timeSheetItem, timeSheetDayItem, insertPosition);
                    PopulateTimeSheetTab(calTimeSheet.SelectionRange);

                    //Set linked Todo item complete
                    if ((timeSheetItem.EndTime != new DateTime()) & (timeSheetItem.TodoTaskGuid != "")) {
                      SetLinkedTodoItemComplete(timeSheetItem.TodoTaskGuid);
                      PopulateTodoTab();
                    }
                  }
                }

              } else {
                MessageBox.Show("Please select only one Time Sheet Item you wish to insert above.", "INSERT",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
              }

            } else {
              MessageBox.Show("Please select the Time Sheet Item to insert above.", "INSERT",
                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

          } else {
            MessageBox.Show("Please select the specific date you wish to insert a Time Sheet Item above.", "INSERT",
                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
          }

        } catch (Exception ex) {
          Utilities.ShowErrorMessage("Error Inserting TimeSheet Item.", ex);
        }
      }
Example #2
0
      /// <summary>
      /// Edits the time sheet item.
      /// </summary>
      /// <param name="index">The index.</param>
      private void EditTimeSheetItem(){
        bool status                             = false;
        try {
          if (tbcMain.SelectedTab != tbTimeSheet) {
            tbcMain.SelectedTab       = tbTimeSheet;
          }

          if (calTimeSheet.SelectionStart == calTimeSheet.SelectionEnd) {
            if ((dgvTimeSheet.SelectedRows.Count > 0) & (dgvTimeSheet.Rows.Count != 1)) {
              if (dgvTimeSheet.SelectedRows.Count == 1) {
                if (dgvTimeSheet.SelectedRows[0].Index != dgvTimeSheet.Rows.Count - 1)
                {
                  TimeSheetDay timeSheetDayItem     = (TimeSheetDay)calTimeSheet.Tag;
                  TimeSheet timeSheetItem           = (TimeSheet)dgvTimeSheet.SelectedRows[0].Tag;
                  TimeSheetItemForm frm             = new TimeSheetItemForm(ref timeSheetItem, timeSheetDayItem);
                  frm.ShowDialog();

                  if (timeSheetItem.GUID != null) {
                    status                          = _timeSheetControl.Edit(timeSheetItem, timeSheetDayItem);
                    PopulateTimeSheetTab(calTimeSheet.SelectionRange);

                    //Set timesheet items linked Todo item complete if End time is set
                    if ((timeSheetItem.EndTime != new DateTime()) & (timeSheetItem.TodoTaskGuid != "")) {
                      SetLinkedTodoItemComplete(timeSheetItem.TodoTaskGuid);
                      PopulateTodoTab();
                    }
                  }
                }

              } else {
                MessageBox.Show("Please select only one Time Sheet Item to edit.", "EDIT",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
              }

            } else {
              MessageBox.Show("Please select the Time Sheet Item you wish to edit.", "EDIT",
                              MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

          } else {
            MessageBox.Show("Please select the specific date you wish to edit a Time Sheet item for.", "EDIT",
                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
          }

        } catch (Exception ex) {
          Utilities.ShowErrorMessage("Error Editing TimeSheet Item.", ex);
        }
      }
Example #3
0
      /// <summary>
      /// Adds the time sheet item.
      /// </summary>
      private void AddTimeSheetItem(){
        try {
          if (tbcMain.SelectedTab != tbTimeSheet) {
            tbcMain.SelectedTab       = tbTimeSheet;
          }

          if (calTimeSheet.SelectionStart == calTimeSheet.SelectionEnd) {
            TimeSheetDay timeSheetDayItem       = (TimeSheetDay)calTimeSheet.Tag;
            TimeSheet timeSheetItem             = new TimeSheet();
            TimeSheetItemForm frm               = new TimeSheetItemForm(ref timeSheetItem, timeSheetDayItem);
            frm.ShowDialog();

            if (timeSheetItem.GUID != "") {
              DateTime result                   = _timeSheetControl.SetLastTimeSheetItemsEndTime(timeSheetItem, timeSheetDayItem);
              _timeSheetControl.Add(timeSheetItem, timeSheetDayItem);
              PopulateTimeSheetTab(calTimeSheet.SelectionRange);

              //Set timesheet items linked Todo item complete if End time is set
              if (result != new DateTime()) {                                                           //previous timesheet item
                int index                       = _timeSheetControl.FindTimeSheetDayIndex(timeSheetDayItem.GUID);
                TimeSheet prevTimeSheetItem     = Persist.Data.TimeSheetDayList[index].TimeSheetList[Persist.Data.TimeSheetDayList[index].TimeSheetList.Count - 2];
                SetLinkedTodoItemComplete(prevTimeSheetItem.TodoTaskGuid);
                PopulateTodoTab();
              }

              if ((timeSheetItem.EndTime != new DateTime()) & (timeSheetItem.TodoTaskGuid != "")) {     //new time sheet item
                SetLinkedTodoItemComplete(timeSheetItem.TodoTaskGuid);
                PopulateTodoTab();
              }
            }

          } else {
            MessageBox.Show("Please select a specific date you wish to add a TimeSheet item to.", "ADD",
                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
          }

        } catch (Exception ex) {
          Utilities.ShowErrorMessage("Error Adding TimeSheet Item.", ex);
        }
      }