public ProjectCostManagerPage() { InitializeComponent(); List <Project> projects = dbContext.Project.ToList(); foreach (var i in projects) { UC_Project P = new UC_Project(); P.ProjectID = i.ProjectID; P.ProjectName = i.ProjectName; if (((DateTime)i.EndDate).Ticks - ((DateTime)i.StartDate).Ticks == 0) { P.progressBar.Value = 100; } else { P.progressBar.Value = Convert.ToDouble((DateTime.Now.Ticks - ((DateTime)i.StartDate).Ticks)) / Convert.ToDouble((((DateTime)i.EndDate).Ticks - ((DateTime)i.StartDate).Ticks)) * 100; } P.Height = 165; P.Width = 158; P.Tag = i; P.Margin = new Thickness(5); P.Click += OpenProject; this.wrapPanel.Children.Add(P); } }
private void OpenProject(object sender, MouseEventArgs e) { UC_Project p = sender as UC_Project; Project project = p.Tag as Project; Window_ProjectDetails w = new Window_ProjectDetails(); string DeptName = dbContext.Departments.Where(x => x.DepartmentID == project.RequiredDeptID).Select(x => x.DepartmentName).Single(); w.ProjectID = project.ProjectID; w.ProjectName = project.ProjectName; w.ProgressByTasks = p.progressBar.Value; w.RequiredDepartment = DeptName; w.TotalCost = (double)project.Budget; w.Show(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { List <Project> projects = dbContext.Projects.ToList(); foreach (var i in projects) { UC_Project P = new UC_Project(); P.ProjectID = i.ProjectID; P.ProjectName = i.ProjectName; P.progressBar.Value = Convert.ToDouble((DateTime.Now.Ticks - ((DateTime)i.StartDate).Ticks)) / Convert.ToDouble((((DateTime)i.EndDate).Ticks - ((DateTime)i.StartDate).Ticks)) * 100; P.Height = 165; P.Width = 158; P.Tag = i; P.Margin = new Thickness(5); P.Click += OpenProject; this.wrapPanel.Children.Add(P); } }