Exemplo n.º 1
0
        //fill taskss that are underway to task combobox
        private void FillTasks(int projectid)
        {
            cboTask.Items.Clear();

            ProjectDatabaseDataSet.ProjectsRow projectRow =
                dsProject.Projects.FindByProjectID(projectid);
            DataRow[] taskRows =
                projectRow.GetChildRows("FK_Tasks_Projects");
            foreach (ProjectDatabaseDataSet.TasksRow taskRow in dsProject.Tasks)
            {
                if (taskRow.ProjectID == projectRow.ProjectID &&
                    taskRow.StatusID == 2)
                {
                    this.cboTask.DisplayMember = "TaskName";
                    this.cboTask.ValueMember   = "TaskID";
                    this.cboTask.DataSource    = dsProject.Tables["Tasks"];

                    cboTask.Items.Add(new TasksCombo
                    {
                        name = taskRow.TaskName,
                        id   = taskRow.TaskID.ToString()
                    });
                }
            }
        }
Exemplo n.º 2
0
        // select changed from project to project
        private void lstProject_SelectedIndexChanged(object sender, EventArgs e)
        {
            lstvEmployee.Items.Clear();             //clears listview so listview will not display info from previous selected projects
            txtHours.Clear();
            if (isLoaded)                           //makes sure isloaded is set to true
            {
                if (lstProject.SelectedIndex != -1) //if there is a selection
                {
                    int projectID = (int)lstProject.SelectedValue;

                    ProjectDatabaseDataSet.ProjectsRow projectRow = dsProject.Projects.FindByProjectID(projectID);
                    txtName.Text        = projectRow.ProjectName;
                    txtDescription.Text = projectRow.Description;
                    txtStatus.Text      = projectRow.StatusID.ToString();
                    txtStartDate.Text   = projectRow.StartDate.ToString();
                    txtEndDate.Text     = projectRow.EndDate.ToString();

                    int projectManager = (int)projectRow[1];

                    foreach (DataRow employees in dsProject.Employees.Rows)
                    {
                        if ((int)employees[0] == projectManager)
                        {
                            txtManager.Text = employees["FullName"].ToString();
                            //local variable for total hours worked on project
                            decimal projectHours = 0;
                            foreach (DataRow tasks in dsProject.Tasks.Rows)
                            {
                                if ((int)tasks[2] == projectID)
                                {
                                    int taskID = (int)tasks[0];

                                    foreach (DataRow employeeTask in dsProject.Work.Rows)
                                    {
                                        if ((int)employeeTask[2] == taskID)
                                        {
                                            int employeeID = (int)employeeTask[1];
                                            //local variable for suming task hours for a project
                                            decimal taskHours = 0;
                                            foreach (DataRow employee in dsProject.Employees.Rows)
                                            {
                                                if ((int)employee[0] == employeeID)
                                                {
                                                    //sums task hours
                                                    taskHours += decimal.Parse(employeeTask[4].ToString());
                                                    ListViewItem item = new ListViewItem(employee["FullName"].ToString());
                                                    item.SubItems.Add(tasks[1].ToString());
                                                    item.SubItems.Add(employeeTask[3].ToString());
                                                    item.SubItems.Add(employeeTask[4].ToString());
                                                    //adds to listview
                                                    lstvEmployee.Items.Add(item);
                                                    //to sum local variable for calculating project total hours
                                                    projectHours += taskHours;
                                                    //displays total hours
                                                    txtHours.Text = projectHours.ToString();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }