Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            errProv.Clear();

            //validate
            List <ValidationMessage> errors = OperationsReadWrite.SaveTask(
                new ValidatableParameter <string> {
                Value = m_proj.Id.ToString(), Source = txtProjName
            },
                new ValidatableParameter <string> {
                Value = Guid.Empty.ToString(), Source = null
            },
                new ValidatableParameter <string> {
                Value = txtTaskName.Text.Trim(), Source = txtTaskName
            },
                new ValidatableParameter <bool> {
                Value = true, Source = null
            });


            if (errors.Count > 0)
            {
                //set up the list of controls that may have errors associated
                List <Control> validatableControls = new List <Control>();
                validatableControls.Add(txtProjName);
                validatableControls.Add(txtTaskName);

                //hook up errors to controls
                foreach (ValidationMessage currError in errors)
                {
                    if (currError.Source != null)
                    {
                        bool found     = false;
                        int  currIndex = 0;
                        while (!found && currIndex < validatableControls.Count)
                        {
                            if (validatableControls[currIndex] == currError.Source)
                            {
                                found = true;
                                errProv.SetError(validatableControls[currIndex], currError.MessageText);
                            }
                            currIndex++;
                        }

                        if (!found)
                        {
                            errProv.SetError(btnSave, currError.MessageText);
                        }
                    }
                    else
                    {
                        errProv.SetError(btnSave, currError.MessageText);
                    }
                }
            }
            else
            {
                this.Close();
            }
        }
Example #2
0
        private void btnDeleteEntry_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to delete this entry?", "Confirm Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK)
            {
                if (m_item.GoalId != Guid.Empty)
                {
                    List <ValidationMessage> errors = OperationsReadWrite.RemoveGoal(new ValidatableParameter <Guid> {
                        Value = m_item.GoalId
                    });

                    if (errors.Count > 0)
                    {
                        throw new ApplicationException(string.Format("Error deleting Goal with Id '{0}': '{1}'", m_item.GoalId, errors[0].MessageText));
                    }
                }

                this.Close();
            }
        }
Example #3
0
        /// <summary>
        /// Saves the current selection
        /// </summary>
        private bool PerformSave()
        {
            errProv.Clear();

            bool savedSuccessfully = false;

            List <ValidatableIntStringPair> exceptionItems = new List <ValidatableIntStringPair>();

            TimeEntry savedItem = null;

            //validate
            List <ValidationMessage> errors = OperationsReadWrite.SaveTimeEntry(
                new ValidatableParameter <Guid> {
                Value = m_lastTimeEntry == null ? Guid.Empty : m_lastTimeEntry.TimeEntryId, Source = null
            },
                new ValidatableParameter <Guid> {
                Value = m_currUser.UserId, Source = null
            },
                new ValidatableParameter <Guid> {
                Value = cbxProjects.SelectedItem == null ? Guid.Empty : ((Project)cbxProjects.SelectedItem).Id, Source = cbxProjects
            },
                new ValidatableParameter <Guid> {
                Value = cbxTasks.SelectedItem == null ? Guid.Empty : ((Task)cbxTasks.SelectedItem).Id, Source = cbxTasks
            },
                new ValidatableParameter <string> {
                Value = txtDetails.Text, Source = txtDetails
            },
                new ValidatableParameter <DateTime?> {
                Value = dtpStart.Value, Source = dtpStart
            },
                new ValidatableParameter <DateTime?> {
                Value = dtpEnd.Value, Source = dtpEnd
            },
                new ValidatableParameter <int> {
                Value = Convert.ToInt32(nudExc1.Value), Source = nudExc1
            },
                new ValidatableParameter <string> {
                Value = txtExc1.Text, Source = txtExc1
            },
                out savedItem);

            if (savedItem != null)
            {
                m_lastTimeEntry = savedItem;
            }

            if (errors.Count > 0)
            {
                //set up the list of controls that may have errors associated
                List <Control> validatableControls = new List <Control>();
                validatableControls.Add(cbxProjects);
                validatableControls.Add(cbxTasks);
                validatableControls.Add(dtpStart);
                validatableControls.Add(dtpEnd);
                validatableControls.Add(nudExc1);
                validatableControls.Add(txtExc1);

                //hook up errors to controls
                foreach (ValidationMessage currError in errors)
                {
                    if (currError.Source != null)
                    {
                        bool found     = false;
                        int  currIndex = 0;
                        while (!found && currIndex < validatableControls.Count)
                        {
                            if (validatableControls[currIndex] == currError.Source)
                            {
                                found = true;
                                errProv.SetError(validatableControls[currIndex], currError.MessageText);
                            }
                            currIndex++;
                        }

                        if (!found)
                        {
                            errProv.SetError(cbxProjects, currError.MessageText);
                        }
                    }
                    else
                    {
                        errProv.SetError(cbxProjects, currError.MessageText);
                    }
                }
            }
            else
            {
                //indicate that save was clicked
                SaveClicked = true;
                SetupGrid();

                //indicate it saved OK
                savedSuccessfully = true;
            }

            return(savedSuccessfully);
        }
Example #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            errProv.Clear();

            List <ValidatableIntStringPair> exceptionItems = new List <ValidatableIntStringPair>();

            if (m_item == null)
            {
                throw new InvalidOperationException("PopualteScreen not called, invalid operation");
            }

            //validate
            List <ValidationMessage> errors = OperationsReadWrite.SaveGoal(
                new ValidatableParameter <Guid> {
                Value = m_item.GoalId, Source = null
            },
                new ValidatableParameter <Guid> {
                Value = m_item.UserId, Source = null
            },
                new ValidatableParameter <string> {
                Value = txtDescription.Text.Trim(), Source = txtDescription
            },
                new ValidatableParameter <string> {
                Value = txtMeasure.Text.Trim(), Source = txtMeasure
            },
                new ValidatableParameter <DateTime> {
                Value = dtpTarget.Value, Source = dtpTarget
            },
                new ValidatableParameter <bool> {
                Value = chkClosed.Checked, Source = chkClosed
            },
                new ValidatableParameter <string> {
                Value = txtResultMeasure.Text.Trim(), Source = txtResultMeasure
            },
                new ValidatableParameter <int> {
                Value = trkMeasure.Value, Source = trkMeasure
            },
                new ValidatableParameter <DateTime> {
                Value = dtpResultDate.Value, Source = dtpResultDate
            },
                new ValidatableParameter <int> {
                Value = trkTimeliness.Value, Source = trkTimeliness
            },
                new ValidatableParameter <string> {
                Value = txtPositives.Text.Trim(), Source = txtPositives
            },
                new ValidatableParameter <string> {
                Value = txtImprovements.Text.Trim(), Source = txtImprovements
            }
                );

            if (errors.Count > 0)
            {
                //set up the list of controls that may have errors associated
                List <Control> validatableControls = new List <Control>();
                validatableControls.Add(txtDescription);
                validatableControls.Add(txtMeasure);
                validatableControls.Add(dtpTarget);
                validatableControls.Add(chkClosed);
                validatableControls.Add(txtResultMeasure);
                validatableControls.Add(trkMeasure);
                validatableControls.Add(dtpResultDate);
                validatableControls.Add(trkTimeliness);
                validatableControls.Add(txtPositives);
                validatableControls.Add(txtImprovements);

                //hook up errors to controls
                foreach (ValidationMessage currError in errors)
                {
                    if (currError.Source != null)
                    {
                        bool found     = false;
                        int  currIndex = 0;
                        while (!found && currIndex < validatableControls.Count)
                        {
                            if (validatableControls[currIndex] == currError.Source)
                            {
                                found = true;
                                errProv.SetError(validatableControls[currIndex], currError.MessageText);
                            }
                            currIndex++;
                        }

                        if (!found)
                        {
                            errProv.SetError(txtDescription, currError.MessageText);
                        }
                    }
                    else
                    {
                        errProv.SetError(txtDescription, currError.MessageText);
                    }
                }
            }
            else
            {
                //close the form
                this.Close();
            }
        }
Example #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            errProv.Clear();

            List <ValidatableIntStringPair> exceptionItems = new List <ValidatableIntStringPair>();

            TimeEntry savedItem = null;

            //validate
            List <ValidationMessage> errors = OperationsReadWrite.SaveTimeEntry(
                new ValidatableParameter <Guid> {
                Value = m_lastTimeEntry == null ? Guid.Empty : m_lastTimeEntry.TimeEntryId, Source = null
            },
                new ValidatableParameter <Guid> {
                Value = m_currUser.UserId, Source = null
            },
                new ValidatableParameter <Guid> {
                Value = m_lastTimeEntry.ProjectId, Source = lblProjectVal
            },
                new ValidatableParameter <Guid> {
                Value = m_lastTimeEntry.TaskId, Source = lblTaskVal
            },
                new ValidatableParameter <string> {
                Value = txtDetails.Text, Source = txtDetails
            },
                new ValidatableParameter <DateTime?> {
                Value = dtpStart.Value, Source = dtpStart
            },
                new ValidatableParameter <DateTime?> {
                Value = dtpEnd.Value, Source = dtpEnd
            },
                new ValidatableParameter <int> {
                Value = Convert.ToInt32(nudExc1.Value), Source = nudExc1
            },
                new ValidatableParameter <string> {
                Value = txtExc1.Text, Source = txtExc1
            },
                out savedItem);

            if (errors.Count > 0)
            {
                //set up the list of controls that may have errors associated
                List <Control> validatableControls = new List <Control>();
                validatableControls.Add(lblProjectVal);
                validatableControls.Add(lblTaskVal);
                validatableControls.Add(dtpStart);
                validatableControls.Add(dtpEnd);
                validatableControls.Add(nudExc1);
                validatableControls.Add(txtExc1);

                //hook up errors to controls
                foreach (ValidationMessage currError in errors)
                {
                    if (currError.Source != null)
                    {
                        bool found     = false;
                        int  currIndex = 0;
                        while (!found && currIndex < validatableControls.Count)
                        {
                            if (validatableControls[currIndex] == currError.Source)
                            {
                                found = true;
                                errProv.SetError(validatableControls[currIndex], currError.MessageText);
                            }
                            currIndex++;
                        }

                        if (!found)
                        {
                            errProv.SetError(btnSave, currError.MessageText);
                        }
                    }
                    else
                    {
                        errProv.SetError(btnSave, currError.MessageText);
                    }
                }
            }
            else
            {
                SavedEntry   = savedItem;
                WasConfirmed = true;
                this.Close();
            }
        }
Example #6
0
        /// <summary>
        /// Finalisation of form closing procedure
        /// </summary>
        private void FinaliseFormClose()
        {
            if (m_timeForm != null)
            {
                //remember the last saved entry
                m_lastEntry = m_timeForm.LastSavedEntry;

                if (m_timeForm != null)
                {
                    //if we get more properties, might have to retrieve, but for now just construct a new one each time for efficiency
                    LocalSettings settings = new LocalSettings();

                    //if the save button was clicked, update the indicator values
                    if (m_timeForm.LastSavedEntry != null)
                    {
                        m_currProject            = m_timeForm.SelectedProject;
                        m_currTask               = m_timeForm.SelectedTask;
                        m_dfLastStartDate        = m_timeForm.StartTime;
                        settings.LastTimeEntryId = m_timeForm.LastSavedEntry.TimeEntryId;
                    }
                    else
                    {
                        if (m_currProject != null)
                        {
                            //if we were previously working on something, set the last start date to now
                            //so that while the clock is stopped it keeps this time
                            m_dfLastStartDate = DateTime.Now;
                        }
                        m_currProject            = null;
                        m_currTask               = null;
                        settings.LastTimeEntryId = Guid.Empty;
                    }

                    //set the reminder interval
                    settings.LastReminderPeriodInMilliseconds = m_timeForm.ReminderMilliseconds;

                    OperationsReadWrite.SaveLocalSettings(settings);
                }

                //set the reminder milliseconds
                m_reminderMilliseconds = m_timeForm.ReminderMilliseconds;


                //set enabled status on timer
                tmrCheck.Enabled = m_timeForm.AreRemindersOn;


                //update the last reminder time
                m_dtLastReminder = DateTime.Now;

                m_bWasIgnored = false;
                m_dtLastShow  = DateTime.Now;

                //remember the location and size
                if (m_timeForm != null)
                {
                    m_lastLocation = m_timeForm.Location;
                    m_lastSize     = m_timeForm.Size;

                    m_timeForm.Dispose();
                    m_timeForm = null;
                }
            }
        }