Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        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;
        }