public void PopulateScreen(Goal item, User currUser) { m_item = item; if (item == null) { m_item = new Goal(); m_item.GoalId = Guid.Empty; m_item.UserId = currUser.UserId; m_item.ActualCompletionDate = OperationsReadOnly.RoundToMinute(DateTime.Now); m_item.TargetCompletionDate = OperationsReadOnly.RoundToMinute(DateTime.Now); } txtDescription.Text = m_item.Description; txtMeasure.Text = m_item.TargetMeasure; dtpTarget.Value = m_item.TargetCompletionDate; chkClosed.Checked = m_item.Completed; txtResultMeasure.Text = m_item.ResultMeasure; trkMeasure.Value = m_item.ResultMeasureRating; dtpResultDate.Value = m_item.ActualCompletionDate; trkTimeliness.Value = m_item.ResultTimelinessRating; txtPositives.Text = m_item.Positives; txtImprovements.Text = m_item.Improvements; SetupCompleted(); }
private bool ChangeEntry(bool isProjectWork, bool isTaskChange) { //show popup and ask for date frmConfirmEndTime tmEdit = new frmConfirmEndTime(); m_lastTimeEntry.EndDateTime = OperationsReadOnly.RoundToMinute(DateTime.Now); tmEdit.PopulateScreen(m_lastTimeEntry, m_currUser); tmEdit.StartPosition = FormStartPosition.CenterParent; tmEdit.BringToFront(); tmEdit.ShowDialog(this); if (tmEdit.WasConfirmed) { //change status if (isProjectWork) { //reset the screen with the newly selected project and task if possible PopulateScreen(m_currUser, new TimeEntry { StartDateTime = tmEdit.SavedEntry.EndDateTime, EndDateTime = OperationsReadOnly.RoundToMinute(DateTime.Now), ProjectId = cbxProjects.SelectedItem == null ? Guid.Empty : ((Project)cbxProjects.SelectedItem).Id, TaskId = cbxTasks.SelectedItem == null ? Guid.Empty : ((Task)cbxTasks.SelectedItem).Id }, AreRemindersOn, m_reminderMilliseconds); } else { //set up the screen for a new entry PopulateScreen(m_currUser, null, AreRemindersOn, m_reminderMilliseconds); } return(true); } else { return(false); } }
public void PopulateScreen(Project proj, Task tsk) { m_proj = proj; m_task = tsk; txtProjName.Text = m_proj.Description; txtTaskName.Text = m_task.Description; cbxUsers.DataSource = OperationsReadOnly.GetAllUsers(); }
private void SetupTasks() { if (dgProjects.SelectedRows.Count > 0) { Project currItem = (Project)dgProjects.SelectedRows[0].DataBoundItem; m_tasks = OperationsReadOnly.GetAllTasksForProject(currItem.Id); m_tasksRetrieved = DateTime.Now; dgTasks.DataSource = m_tasks; } }
private void SetupUserAccess() { if (dgTasks.SelectedRows.Count > 0) { Task currItem = (Task)dgTasks.SelectedRows[0].DataBoundItem; m_users = OperationsReadOnly.GetAllUsersForTask(currItem.ProjectId, currItem.Id); m_usersRetrieved = DateTime.Now; dgUsers.DataSource = m_users; } }
private void SetupGrid() { if (ucTimes == null) { ucTimes = new UserControls.TimeEditGrid(); ucTimes.Dock = DockStyle.Fill; ucTimes.EditFormClosing += new FormClosingEventHandler(ucTimes_EditFormClosing); pnlGrid.Controls.Add(ucTimes); } ucTimes.SetupGrid(OperationsReadOnly.GetTimeEntryForDate(dtpFilterDate.Value, m_currUser), m_currUser); }
private void SetupGoals() { if (lnkShowGoals.Text == cstrGridFilterTextCompleted) { gvGoals.DataSource = OperationsReadOnly.GetAllGoals(false); } else { gvGoals.DataSource = OperationsReadOnly.GetAllGoals(true); } SetupGoalContext(); }
private void SetupProjectAndTasks(Project currProject, Task currTask) { cbxProjects.Items.Clear(); List <Project> projs = OperationsReadOnly.GetProjectsForUser(m_currUser.UserId, true); cbxProjects.Items.AddRange(projs.ToArray()); if (currProject != null) { bool found = false; int currIndex = 0; while (!found && currIndex < projs.Count) { if (projs[currIndex].Id == currProject.Id) { found = true; cbxProjects.SelectedIndex = currIndex; } currIndex++; } } cbxTasks.Items.Clear(); List <Task> tsks = OperationsReadOnly.GetTasksForProjectAndUser(currProject == null ? Guid.Empty : currProject.Id, m_currUser == null ? Guid.Empty : m_currUser.UserId, true); cbxTasks.Items.AddRange(tsks.ToArray()); if (currTask != null) { bool found = false; int currIndex = 0; while (!found && currIndex < tsks.Count) { if (tsks[currIndex].Id == currTask.Id) { found = true; cbxTasks.SelectedIndex = currIndex; } currIndex++; } } //detault to first task if there is one and one is not selected if (cbxTasks.Items.Count > 0 && cbxTasks.SelectedIndex < 0) { //default to first task as per issue 2884 cbxTasks.SelectedIndex = 0; } }
private void cbxProjects_SelectedIndexChanged(object sender, EventArgs e) { Project SelectedProject = cbxProjects.SelectedItem == null ? null : (Project)cbxProjects.SelectedItem; cbxTasks.Items.Clear(); cbxTasks.SelectedItem = null; if (SelectedProject != null) { List <Task> tsks = OperationsReadOnly.GetTasksForProjectAndUser(SelectedProject.Id, m_currUser.UserId, true); cbxTasks.Items.AddRange(tsks.ToArray()); } //detault to first task if there is one and one is not selected if (cbxTasks.Items.Count > 0 && cbxTasks.SelectedIndex < 0) { //default to first task as per issue 2884 cbxTasks.SelectedIndex = 0; } }
/// <summary> /// Populate the times grid /// </summary> private void SetupGrid() { if (dgHistory == null) { dgHistory = new UserControls.TimeEditGrid(); //dgHistory.Anchor = ( (AnchorStyles)AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top ); dgHistory.Dock = DockStyle.Fill; dgHistory.EditFormClosing += new FormClosingEventHandler(tmEdit_FormClosing); tabPage1.Controls.Add(dgHistory); } if (showAllForDay) { dgHistory.SetupGrid(OperationsReadOnly.GetTimeEntryForDate(OperationsReadOnly.RoundToMinute(DateTime.Now), m_currUser), m_currUser); } else { dgHistory.SetupGrid(OperationsReadOnly.GetRecentTimeEntry(5, m_currUser), m_currUser); } }
private void cbxProjects_SelectedIndexChanged(object sender, EventArgs e) { bool performChange = false; if (m_isInSetupMode) { performChange = true; } else { //check if we were updating a different one, if we confirmed performChange = m_lastTimeEntry == null || m_lastTimeEntry.TimeEntryId == Guid.Empty || ChangeEntry(true, false); } if (performChange) { cbxTasks.Items.Clear(); cbxTasks.SelectedItem = null; if (SelectedProject != null) { List <Task> tsks = OperationsReadOnly.GetTasksForProjectAndUser(SelectedProject.Id, m_currUser.UserId, true); cbxTasks.Items.AddRange(tsks.ToArray()); } //detault to first task if there is one and one is not selected if (cbxTasks.Items.Count > 0 && cbxTasks.SelectedIndex < 0) { //default to first task as per issue 2884 cbxTasks.SelectedIndex = 0; } } else { //put the project and task back to how they were m_isInSetupMode = true; Project currProj = m_lastTimeEntry == null || m_lastTimeEntry.TimeEntryId == Guid.Empty ? null : OperationsReadOnly.GetProjectForUser(m_lastTimeEntry.ProjectId, m_currUser.UserId); Task currTask = m_lastTimeEntry == null || m_lastTimeEntry.TimeEntryId == Guid.Empty ? null : OperationsReadOnly.GetTaskById(m_lastTimeEntry.TaskId, m_lastTimeEntry.ProjectId, m_currUser.UserId); SetupProjectAndTasks(currProj, currTask); m_isInSetupMode = false; } }
private void StartClock(bool createNewEntry) { startNewEntryToolStripMenuItem.Enabled = false; startAndContinuePreviousEntryToolStripMenuItem.Enabled = false; //set up the screen for a new entry if (createNewEntry) { PopulateScreen(m_currUser, new TimeEntry { StartDateTime = OperationsReadOnly.RoundToMinute(DateTime.Now), EndDateTime = OperationsReadOnly.RoundToMinute(DateTime.Now) }, AreRemindersOn, m_reminderMilliseconds); } else { m_isInSetupMode = true; PopulateScreen(m_currUser, OperationsReadOnly.GetLatestTimeEntry(m_currUser), AreRemindersOn, m_reminderMilliseconds); m_isInSetupMode = false; } chkNothing.Text = "Stop the Clock "; chkNothing.Image = global::TRec.Windows.UI.Properties.Resources.stopwatch_off; }
private void cbxTasks_SelectedIndexChanged(object sender, EventArgs e) { bool performChange = false; if (m_isInSetupMode) { performChange = true; } else { //check if we were updating a different one, if we confirmed performChange = m_lastTimeEntry == null || m_lastTimeEntry.TimeEntryId == Guid.Empty || ChangeEntry(true, true); } if (!performChange) { //put the project and task back to how they were m_isInSetupMode = true; Project currProj = m_lastTimeEntry == null || m_lastTimeEntry.TimeEntryId == Guid.Empty ? null : OperationsReadOnly.GetProjectForUser(m_lastTimeEntry.ProjectId, m_currUser.UserId); Task currTask = m_lastTimeEntry == null || m_lastTimeEntry.TimeEntryId == Guid.Empty ? null : OperationsReadOnly.GetTaskById(m_lastTimeEntry.TaskId, m_lastTimeEntry.ProjectId, m_currUser.UserId); SetupProjectAndTasks(currProj, currTask); m_isInSetupMode = false; } }
/// <summary> /// Constructor /// </summary> public frmMain() { InitializeComponent(); Process currentProc = Process.GetCurrentProcess(); bool continueProcessing = true; Process[] existingProcesses = Process.GetProcessesByName(currentProc.ProcessName, currentProc.MachineName); if (existingProcesses.Count() > 0) { Process sameProc = null; int currIndex = 0; while (sameProc == null && currIndex < existingProcesses.Count()) { if (existingProcesses[currIndex].Id != currentProc.Id && string.Equals(existingProcesses[currIndex].StartInfo.FileName, currentProc.StartInfo.FileName, StringComparison.CurrentCultureIgnoreCase)) { sameProc = existingProcesses[currIndex]; } currIndex++; } if (sameProc != null) { MessageBox.Show(string.Format("Error: The file {0} is already running, you cannot run it more than once. If you cannot see it, kill the process in task manager (ctrl+alt+del). Process Id = {1} Process Name = {2}", sameProc.StartInfo.FileName, sameProc.Id.ToString(), sameProc.ProcessName), "Error - Program already running", MessageBoxButtons.OK, MessageBoxIcon.Error); continueProcessing = false; Application.Exit(); this.Close(); this.Dispose(); } } if (continueProcessing) { //todo: popup a window and ask for either windows identity or login with username and password m_currUser = OperationsReadOnly.CreateOrGetUser(System.Security.Principal.WindowsIdentity.GetCurrent()); //Turn this on for initialising one project and task on entry //OperationsReadWrite.TempInit(); this.ShowInTaskbar = false; this.WindowState = FormWindowState.Minimized; //set the last reminder so that it will show straight away the first time m_dtLastReminder = DateTime.Now.AddMilliseconds(-m_reminderMilliseconds); //set the last entry initially - taken out as it can be annoying when days apart, need to think about this //m_lastEntry = OperationsReadOnly.GetLatestTimeEntry( m_currUser ); //instead, get from settings LocalSettings settings = OperationsReadOnly.GetLocalSettings(); if (settings != null) { if (settings.LastTimeEntryId != Guid.Empty) { m_lastEntry = OperationsReadOnly.GetTimeEntryById(settings.LastTimeEntryId, m_currUser); } if (settings.LastReminderPeriodInMilliseconds > 0) { m_reminderMilliseconds = settings.LastReminderPeriodInMilliseconds; } } } }
private void bgwGenerate_DoWork(object sender, DoWorkEventArgs e) { if (isTimeReport) { //doing time entry report List <string> fnames = new List <string>(); foreach (string fileName in lstFiles.Items) { fnames.Add(fileName); } List <ReportingItemSummary> reportItems = OperationsReadOnly.GetReportingItems(dtpStart.Value, dtpEnd.Value, fnames); if (selectedReportType == cstrCSVDataExtract) { StringBuilder stb = new StringBuilder(); stb.Append("Time Entry Id"); stb.Append(cstrSeparator); stb.Append("User Id"); stb.Append(cstrSeparator); stb.Append("User Display Name"); stb.Append(cstrSeparator); stb.Append("Project Id"); stb.Append(cstrSeparator); stb.Append("Project Name"); stb.Append(cstrSeparator); stb.Append("Task Id"); stb.Append(cstrSeparator); stb.Append("Task Name"); stb.Append(cstrSeparator); stb.Append("Start DateTime"); stb.Append(cstrSeparator); stb.Append("End DateTime"); stb.Append(cstrSeparator); stb.Append("Exception Minutes"); stb.Append(cstrSeparator); stb.Append("Total TimeMinutes"); stb.Append(cstrSeparator); stb.Append("Details"); stb.Append(cstrSeparator); stb.Append("Exception Details"); stb.Append(Environment.NewLine); foreach (ReportingItemSummary currItem in reportItems) { stb.Append(FormatResult(currItem.TimeEntryId)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.UserId)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.UserDisplayName)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.ProjectId)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.ProjectName)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.TaskId)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.TaskName)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.StartDateTime)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.EndDateTime)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.ExceptionMinutes)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.TotalMinutes)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.Details)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.ExceptionDetails)); stb.Append(cstrSeparator); stb.Append(Environment.NewLine); } e.Result = stb.ToString(); } else { e.Result = reportItems; } } else { //doing goal report List <string> fnames = new List <string>(); foreach (string fileName in lstGoalFiles.Items) { fnames.Add(fileName); } List <ReportingGoalSummary> reportItems = OperationsReadOnly.GetReportingGoals(dtpGoalStart.Value, dtpGoalEnd.Value, fnames); if (selectedReportType == cstrCSVDataExtract) { StringBuilder stb = new StringBuilder(); stb.Append("Goal Id"); stb.Append(cstrSeparator); stb.Append("User Id"); stb.Append(cstrSeparator); stb.Append("User Display Name"); stb.Append(cstrSeparator); stb.Append("Description"); stb.Append(cstrSeparator); stb.Append("Target Measure"); stb.Append(cstrSeparator); stb.Append("Target Completion Date"); stb.Append(cstrSeparator); stb.Append("Completed"); stb.Append(cstrSeparator); stb.Append("Result Measure"); stb.Append(cstrSeparator); stb.Append("Result Measure Rating"); stb.Append(cstrSeparator); stb.Append("Actual Completion Date"); stb.Append(cstrSeparator); stb.Append("Result Timeliness Rating"); stb.Append(cstrSeparator); stb.Append("Positives"); stb.Append(cstrSeparator); stb.Append("Improvements"); stb.Append(Environment.NewLine); foreach (ReportingGoalSummary currItem in reportItems) { stb.Append(FormatResult(currItem.GoalId)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.UserId)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.UserDisplayName)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.Description)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.TargetMeasure)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.TargetCompletionDate)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.Completed)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.ResultMeasure)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.ResultMeasureRating)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.ActualCompletionDate)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.ResultTimelinessRating)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.Positives)); stb.Append(cstrSeparator); stb.Append(FormatResult(currItem.Improvements)); stb.Append(cstrSeparator); stb.Append(Environment.NewLine); } e.Result = stb.ToString(); } else { e.Result = reportItems; } } }
public void PopulateScreen(User usr) { dtpFilterDate.Value = OperationsReadOnly.RoundToMinute(DateTime.Now); m_currUser = usr; }
public void PopulateScreen(TimeEntry item, TimeEntry previousItem, TimeEntry nextItem, User usr) { m_item = item; m_prevItem = previousItem; m_nextItem = nextItem; m_currUser = usr; if (m_prevItem != null) { UserControls.ReadOnlyEntry ucItem = new UserControls.ReadOnlyEntry(); ucItem.Dock = DockStyle.Fill; ucItem.PopulateScreen(m_prevItem); tabPrevious.Controls.Add(ucItem); } if (m_nextItem != null) { UserControls.ReadOnlyEntry ucItem = new UserControls.ReadOnlyEntry(); ucItem.Dock = DockStyle.Fill; ucItem.PopulateScreen(m_nextItem); tabNext.Controls.Add(ucItem); } //ensure we are back to an empty state for consistency ResetScreen(); //populate & default drop downs List <Project> projs = OperationsReadOnly.GetProjectsForUser(m_currUser.UserId, true); cbxProjects.Items.AddRange(projs.ToArray()); if (item.ProjectId != Guid.Empty) { bool found = false; int currIndex = 0; while (!found && currIndex < projs.Count) { if (projs[currIndex].Id == item.ProjectId) { found = true; cbxProjects.SelectedIndex = currIndex; } currIndex++; } } List <Task> tsks = OperationsReadOnly.GetTasksForProjectAndUser(item.ProjectId, m_currUser.UserId, true); if (cbxTasks.Items.Count == 0) { cbxTasks.Items.AddRange(tsks.ToArray()); } if (item.TaskId != Guid.Empty) { bool found = false; int currIndex = 0; while (!found && currIndex < tsks.Count) { if (tsks[currIndex].Id == item.TaskId) { found = true; cbxTasks.SelectedIndex = currIndex; } currIndex++; } } //detault to first task if there is one and one is not selected if (cbxTasks.Items.Count > 0 && cbxTasks.SelectedIndex < 0) { //default to first task as per issue 2884 cbxTasks.SelectedIndex = 0; } txtDetails.Text = item.Details; dtpStart.Value = item.StartDateTime; dtpEnd.Value = item.EndDateTime; nudExc1.Value = Convert.ToInt32(item.ExceptionMinutes); txtExc1.Text = item.ExceptionDetails; //select the current tab initially tcEntries.SelectedTab = tabCurrent; }
public void PopulateScreen(User usr, TimeEntry lastTimeEntry, bool remindersOn, int reminderMilliseconds) { //indicate we are setting up the screen m_isInSetupMode = true; m_currUser = usr; m_lastTimeEntry = lastTimeEntry; m_reminderMilliseconds = reminderMilliseconds; if (lastTimeEntry == null) { //change enabled status chkNothing.Checked = true; pnlEntry.Enabled = false; chkNothing.Image = global::TRec.Windows.UI.Properties.Resources.stopwatch_on; dtpStart.Visible = false; } else { if (!m_isInSetupMode) { chkNothing.Checked = false; } pnlEntry.Enabled = true; chkNothing.Image = global::TRec.Windows.UI.Properties.Resources.stopwatch_off; dtpStart.Visible = true; } //ensure we are back to an empty state for consistency ResetScreen(); //populate & default drop downs Project currProj = m_lastTimeEntry == null ? null : OperationsReadOnly.GetProjectForUser(m_lastTimeEntry.ProjectId, m_currUser.UserId); Task currTask = m_lastTimeEntry == null ? null : OperationsReadOnly.GetTaskById(m_lastTimeEntry.TaskId, m_lastTimeEntry.ProjectId, m_currUser.UserId); SetupProjectAndTasks(currProj, currTask); dtpStart.Value = lastTimeEntry == null?OperationsReadOnly.RoundToMinute(DateTime.Now) : lastTimeEntry.StartDateTime; //if the start date is future, add 1 minute to that, otherwise add one minute to now DateTime greaterDate = dtpStart.Value > DateTime.Now ? dtpStart.Value : DateTime.Now; dtpEnd.Value = OperationsReadOnly.RoundToMinute(greaterDate.AddMinutes(1)); txtDetails.Text = lastTimeEntry == null ? string.Empty : lastTimeEntry.Details; nudExc1.Value = lastTimeEntry == null ? 0 : lastTimeEntry.ExceptionMinutes; txtExc1.Text = lastTimeEntry == null ? string.Empty : lastTimeEntry.ExceptionDetails; AreRemindersOn = remindersOn; ToggleReminders(); SetupGrid(); //reset the last preferred reminder if (reminderMilliseconds != 0) { nudInterval.Value = reminderMilliseconds / 1000 / 60; } //indicate we have finished setting up the screen m_isInSetupMode = false; SetupBottomLink(); SetupGoals(); }
private void SetupProjects() { m_projs = OperationsReadOnly.GetAllProjects(); m_projsRetrieved = DateTime.Now; dgProjects.DataSource = m_projs; }