コード例 #1
0
 private void OnProjectListSelectedIndexChanged(object sender, EventArgs e)
 {
     if (listTotalsProject.SelectedItem is Project_DO)
     {
         SelectedProject = listTotalsProject.SelectedItem as Project_DO;
         SetTotalsProject(SelectedProject);
     }
 }
コード例 #2
0
        private void OnListItems_SubItemEndEditing(object sender, CommonControls.SubItemEndEditingEventArgs e)
        {
            bool valid = false;

            switch (listItems.ColumnName(e.SubItem))
            {
            case COL_PROJECT:
                if (listProjects.SelectedItem != null)
                {
                    Project_DO project = listProjects.SelectedItem as Project_DO;
                    e.Item.SubItems[e.SubItem].Text        = project.Name;
                    ((TimeCardEntry_DO)e.Item.Tag).Project = project;
                    valid = true;
                }
                break;

            case COL_START:
                if (textStartTimeInput.ForeColor == Color.Black)
                {
                    e.Item.SubItems[e.SubItem].Text = textStartTimeInput.Text;
                    valid = true;
                }
                break;

            case COL_END:
                if (textEndTimeInput.ForeColor == Color.Black)
                {
                    e.Item.SubItems[e.SubItem].Text = textEndTimeInput.Text;
                    valid = true;
                }
                break;

            case COL_MEMO:
                if (((TimeCardEntry_DO)e.Item.Tag).IsValid)
                {
                    e.Item.SubItems[e.SubItem].Text = textMemo.Text;
                    valid = true;
                }
                break;
            }

            if (valid)
            {
                LoadLineItemFromRow(e.Item);
                UpdateDatabase(e.Item.Tag as TimeCardEntry_DO);
                SelectedProject = ((TimeCardEntry_DO)e.Item.Tag).Project;
                UpdateTotals(SelectedProject);
            }
        }
コード例 #3
0
        private void UpdateTotals(Project_DO project)
        {
            if (project == null)
            {
                return;
            }

            TimeSpan dayTotal, weekTotal;

            DataSource.TotalsForProjectDateRangeGet(project.ID, CurrentDate.GetDateOnly(), CurrentDate.GetDateOnly().AddDays(1), out dayTotal);
            DateTime startOfWeek = CurrentDate.GetStartOfWeek();

            DataSource.TotalsForProjectDateRangeGet(project.ID, startOfWeek, startOfWeek.AddDays(7), out weekTotal);
            textDayTotal.Text  = dayTotal.TotalHours.ToString();
            textWeekTotal.Text = weekTotal.TotalHours.ToString();
        }
コード例 #4
0
        private void SetTotalsProject(Project_DO project)
        {
            Project_DO selected = null;

            if (listTotalsProject.Items.Count > 0)
            {
                foreach (Project_DO projectInList in listTotalsProject.Items)
                {
                    if (projectInList.ID == project.ID)
                    {
                        selected = projectInList;
                        break;
                    }
                }
            }

            if (selected != null)
            {
                UpdateTotals(selected);
            }
        }
コード例 #5
0
        public virtual DBResult ProjectsGet(out ProjectList projects)
        {
            projects = new ProjectList();
            DBResult result;

            QueryString sql = DB.Format(
                $"SELECT * FROM timekeep.projects ORDER by name");
            DatabaseDataReader reader;

            result = DB.Query(sql, out reader);
            using (reader)
            {
                if (result.ResultCode == DBResult.Result.Success)
                {
                    while (reader.Read())
                    {
                        Project_DO project = DataReaderConverter.CreateClassFromDataReader <Project_DO>(reader);
                        projects.Add(project);
                    }
                }
            }
            return(result);
        }
コード例 #6
0
 public TimeCardEntry_DO()
 {
     Project = new Project_DO();
 }