public void Update(object[] identifiedUserAttendance, int oldStatusId = 15) { User user = (User)identifiedUserAttendance[0]; Attendance attendance = (Attendance)identifiedUserAttendance[1]; if (meetingController.status == MeetingController.MEETING_STARTED) { ((Label)userGrids[user.id].Children[2]).Content = attendance.statusId == 2 ? "(" + attendance.regTime + ") " + statuses[attendance.statusId] : statuses[attendance.statusId]; switch (attendance.statusId) { case 1: ((Border)userGrids[user.id].Parent).BorderBrush = ((Label)userGrids[user.id].Children[2]).Background = Brushes.DarkGreen; break; case 2: ((Border)userGrids[user.id].Parent).BorderBrush = ((Label)userGrids[user.id].Children[2]).Background = Brushes.DarkOrange; break; case 15: ((Border)userGrids[user.id].Parent).BorderBrush = ((Label)userGrids[user.id].Children[2]).Background = Brushes.DarkRed; break; default: ((Border)userGrids[user.id].Parent).BorderBrush = ((Label)userGrids[user.id].Children[2]).Background = Brushes.DarkSlateBlue; break; } departmentWrapPanels[user.departmentId].Children.Remove((Border)userGrids[user.id].Parent); switch (oldStatusId) { case 1: last[user.departmentId][3]--; break; case 2: last[user.departmentId][1]--; break; case 15: last[user.departmentId][0]--; break; default: last[user.departmentId][2]--; break; } if (attendance.statusId == 1) { departmentWrapPanels[user.departmentId].Children.Insert(last[user.departmentId][0] + last[user.departmentId][1] + last[user.departmentId][2], (Border)userGrids[user.id].Parent); last[user.departmentId][3]++; ((Border)userGrids[user.id].Parent).Visibility = Visibility.Hidden; } else if (attendance.statusId == 2) { departmentWrapPanels[user.departmentId].Children.Insert(last[user.departmentId][0], (Border)userGrids[user.id].Parent); last[user.departmentId][1]++; ((Border)userGrids[user.id].Parent).Visibility = Visibility.Visible; } else if (attendance.statusId == 15) { departmentWrapPanels[user.departmentId].Children.Insert(0, (Border)userGrids[user.id].Parent); last[user.departmentId][0]++; ((Border)userGrids[user.id].Parent).Visibility = Visibility.Visible; } else { departmentWrapPanels[user.departmentId].Children.Insert(last[user.departmentId][0] + last[user.departmentId][1], (Border)userGrids[user.id].Parent); last[user.departmentId][2]++; ((Border)userGrids[user.id].Parent).Visibility = Visibility.Hidden; } foreach (KeyValuePair <int, DepartmentStatus> entry in departmentStatusWindows) { if (entry.Value != null && entry.Value.IsLoaded && entry.Value.IsActive) { entry.Value.Update(identifiedUserAttendance, oldStatusId); } } } foreach (KeyValuePair <string, AttendanceStatus> entry in attendanceStatusWindows) { if (entry.Value != null && entry.Value.IsLoaded && entry.Value.IsActive) { entry.Value.Update(); } } foreach (KeyValuePair <int, string> entry in departments) { departmentAttendance[entry.Key][0].Text = (last[entry.Key][0] + last[entry.Key][1] + last[entry.Key][3]).ToString(); departmentAttendance[entry.Key][1].Text = (last[entry.Key][3]).ToString(); departmentAttendance[entry.Key][2].Text = (last[entry.Key][1]).ToString(); departmentAttendance[entry.Key][3].Text = (last[entry.Key][0]).ToString(); } int grandTotal = last.Sum(x => x.Value[0] + x.Value[1] + x.Value[2] + x.Value[3]); int totalAttendance = last.Sum(x => x.Value[0] + x.Value[1] + x.Value[3]); int totalArrived = last.Sum(x => x.Value[3]); int totalFree = last.Sum(x => x.Value[2]); int totalLate = last.Sum(x => x.Value[1]); int totalMissing = last.Sum(x => x.Value[0]); AttendanceLabel1.Text = totalAttendance.ToString(); AttendanceLabel2.Text = totalArrived.ToString(); AttendanceLabel3.Text = totalLate.ToString(); AttendanceLabel4.Text = totalMissing.ToString(); AttendancePercentageLabel1.Text = Math.Round((((double)totalArrived / totalAttendance) * 100)).ToString() + '%'; AttendancePercentageLabel2.Text = Math.Round((((double)totalLate / totalAttendance) * 100)).ToString() + '%'; AttendancePercentageLabel3.Text = Math.Round((((double)totalMissing / totalAttendance) * 100)).ToString() + '%'; //Add a new chart-series chart.Series.Clear(); string seriesname = "Хүмүүс"; chart.Series.Add(seriesname); //set the chart-type to "Pie" chart.Series[seriesname].ChartType = SeriesChartType.Pie; chart.Series[seriesname].Font = new System.Drawing.Font("Arial", 13f, System.Drawing.FontStyle.Bold); chart.Series[seriesname].Label = "#PERCENT{0 %}"; chart.Series[seriesname].LegendText = "#VALX"; //Add some datapoints so the series. in this case you can pass the values to this method chart.Series[seriesname].Points.AddXY("Ирсэн", totalArrived); chart.Series[seriesname].Points.AddXY("Хоцорсон", totalLate); chart.Series[seriesname].Points.AddXY("Чөлөөтэй", totalFree); chart.Series[seriesname].Points.AddXY("Ирээгүй", totalMissing); chart.Series[0].Points[0].Color = System.Drawing.Color.LightGreen; chart.Series[0].Points[1].Color = System.Drawing.Color.LightSalmon; chart.Series[0].Points[2].Color = System.Drawing.Color.LightSkyBlue; chart.Series[0].Points[3].Color = System.Drawing.Color.LightCoral; }
public void PlaceUsers(List <object[]> userAttendances) { try { if (userAttendances == null || userAttendances.Count == 0) { return; } last = new Dictionary <int, int[]>(); foreach (KeyValuePair <int, string> entry in departments) { last.Add(entry.Key, new int[4]); } ArchivedMeeting archivedMeeting = meetingController.onGoingArchivedMeeting; foreach (object[] obj in userAttendances) { User user = (User)obj[0]; Attendance att = (Attendance)obj[1]; System.Windows.Controls.Grid DynamicGrid = new System.Windows.Controls.Grid { Background = new SolidColorBrush(Colors.White), Width = 60 }; Border border = new Border { BorderThickness = new Thickness(1, 1, 1, 0), Margin = new Thickness(5, 5, 5, 5) }; border.Child = DynamicGrid; DynamicGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); DynamicGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(60) }); DynamicGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(30) }); DynamicGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(30) }); BitmapImage webImage = meetingController.GetUserImage(user); float scaleHeight = (float)60 / (float)webImage.Height; float scaleWidth = (float)60 / (float)webImage.Width; float scale = Math.Max(scaleHeight, scaleWidth); Image image = new Image { Source = webImage, Height = (int)(webImage.Width * scale), Width = (int)(webImage.Height * scale) }; Label name = new Label { Content = user.fname + " " + user.lname, HorizontalAlignment = HorizontalAlignment.Center, FontSize = 15 }; Label status = new Label { Content = att.statusId == 2 ? "(" + att.regTime + ") " + statuses[att.statusId] : statuses[att.statusId], Foreground = Brushes.White, HorizontalAlignment = HorizontalAlignment.Stretch, HorizontalContentAlignment = HorizontalAlignment.Center, FontWeight = FontWeights.Bold }; switch (att.statusId) { case 1: border.BorderBrush = status.Background = Brushes.DarkGreen; break; case 2: border.BorderBrush = status.Background = Brushes.DarkOrange; break; case 15: border.BorderBrush = status.Background = Brushes.DarkRed; break; default: border.BorderBrush = status.Background = Brushes.DarkSlateBlue; break; } System.Windows.Controls.Grid.SetColumn(image, 0); System.Windows.Controls.Grid.SetColumn(name, 0); System.Windows.Controls.Grid.SetColumn(status, 0); System.Windows.Controls.Grid.SetRow(image, 0); System.Windows.Controls.Grid.SetRow(name, 1); System.Windows.Controls.Grid.SetRow(status, 2); DynamicGrid.Children.Add(image); DynamicGrid.Children.Add(name); DynamicGrid.Children.Add(status); if (att.statusId == 1) { if (last[user.departmentId][0] + last[user.departmentId][1] + last[user.departmentId][2] < departmentWrapPanels[user.departmentId].Children.Count) { departmentWrapPanels[user.departmentId].Children.Insert(last[user.departmentId][0] + last[user.departmentId][1] + last[user.departmentId][2], border); } else { departmentWrapPanels[user.departmentId].Children.Add(border); } last[user.departmentId][3]++; border.Visibility = Visibility.Hidden; } else if (att.statusId == 2) { if (last[user.departmentId][0] < departmentWrapPanels[user.departmentId].Children.Count) { departmentWrapPanels[user.departmentId].Children.Insert(last[user.departmentId][0], border); } else { departmentWrapPanels[user.departmentId].Children.Add(border); } last[user.departmentId][1]++; border.Visibility = Visibility.Visible; } else if (att.statusId == 15) { departmentWrapPanels[user.departmentId].Children.Insert(0, border); last[user.departmentId][0]++; border.Visibility = Visibility.Visible; } else { if (last[user.departmentId][0] + last[user.departmentId][1] < departmentWrapPanels[user.departmentId].Children.Count) { departmentWrapPanels[user.departmentId].Children.Insert(last[user.departmentId][0] + last[user.departmentId][1], border); } else { departmentWrapPanels[user.departmentId].Children.Add(border); } last[user.departmentId][2]++; border.Visibility = Visibility.Hidden; } userGrids.Add(user.id, DynamicGrid); } foreach (KeyValuePair <int, string> entry in departments) { if (!last.ContainsKey(entry.Key)) { last.Add(entry.Key, new int[4]); } departmentAttendance[entry.Key][0].Text = ((int)(last[entry.Key][0] + last[entry.Key][1] + last[entry.Key][3])).ToString(); departmentAttendance[entry.Key][1].Text = last[entry.Key][3].ToString(); departmentAttendance[entry.Key][2].Text = last[entry.Key][1].ToString(); departmentAttendance[entry.Key][3].Text = last[entry.Key][0].ToString(); } int grandTotal = last.Sum(x => x.Value[0] + x.Value[1] + x.Value[2] + x.Value[3]); int totalAttendance = last.Sum(x => x.Value[0] + x.Value[1] + x.Value[3]); int totalArrived = last.Sum(x => x.Value[3]); int totalFree = last.Sum(x => x.Value[2]); int totalLate = last.Sum(x => x.Value[1]); int totalMissing = last.Sum(x => x.Value[0]); AttendanceLabel1.Text = totalAttendance.ToString(); AttendanceLabel2.Text = totalArrived.ToString(); AttendanceLabel3.Text = totalLate.ToString(); AttendanceLabel4.Text = totalMissing.ToString(); AttendancePercentageLabel1.Text = Math.Round((((double)totalArrived / totalAttendance) * 100)).ToString() + '%'; AttendancePercentageLabel2.Text = Math.Round((((double)totalLate / totalAttendance) * 100)).ToString() + '%'; AttendancePercentageLabel3.Text = Math.Round((((double)totalMissing / totalAttendance) * 100)).ToString() + '%'; //Add a new chart-series chart.Series.Clear(); string seriesname = "Хүмүүс"; chart.Series.Add(seriesname); //set the chart-type to "Pie" chart.Series[seriesname].ChartType = SeriesChartType.Pie; chart.Series[seriesname].Font = new System.Drawing.Font("Arial", 13f, System.Drawing.FontStyle.Bold); chart.Series[seriesname].Label = "#PERCENT{0 %}"; chart.Series[seriesname].LegendText = "#VALX"; //Add some datapoints so the series. in this case you can pass the values to this method chart.Series[seriesname].Points.AddXY("Ирсэн", totalArrived); chart.Series[seriesname].Points.AddXY("Хоцорсон", totalLate); chart.Series[seriesname].Points.AddXY("Чөлөөтэй", totalFree); chart.Series[seriesname].Points.AddXY("Ирээгүй", totalMissing); chart.Series[0].Points[0].Color = System.Drawing.Color.LightGreen; chart.Series[0].Points[1].Color = System.Drawing.Color.LightSalmon; chart.Series[0].Points[2].Color = System.Drawing.Color.LightSkyBlue; chart.Series[0].Points[3].Color = System.Drawing.Color.LightCoral; } catch (Exception ex) { MessageBox.Show("Хурлын цонх нээхэд алдаа гарлаа. Алдааны мессеж: " + ex.ToString()); } }