コード例 #1
0
        public bool StartMeeting(Meeting meeting)
        {
            DateTime now = DateTime.Now;
            List <ArchivedMeeting> archivedMeetings = GetArchivedMeetingByDate(now);
            ArchivedMeeting        archivedMeeting;

            int regbefminute = meeting is ModifiedMeeting?meetingModel.Get(((ModifiedMeeting)meeting).meeting_id).regMinBefMeeting : meeting.regMinBefMeeting;

            if (meeting.GetType() == typeof(ModifiedMeeting))
            {
                archivedMeeting = archivedMeetings.FindAll(x => x.meeting_id == ((ModifiedMeeting)meeting).meeting_id).Find(x => (x.meetingDatetime.AddMinutes(-regbefminute) < now && x.meetingDatetime.AddMinutes(x.duration) > now));
            }
            else
            {
                archivedMeeting = archivedMeetings.FindAll(x => x.meeting_id == meeting.id).Find(x => (x.meetingDatetime.AddMinutes(-regbefminute) < now && x.meetingDatetime.AddMinutes(x.duration) > now));
            }


            if (archivedMeeting == null)
            {
                Console.WriteLine("Creating archive of meeting");
                archivedMeeting = new ArchivedMeeting();

                if (meeting.GetType() == typeof(ModifiedMeeting))
                {
                    archivedMeeting.meeting_id         = ((ModifiedMeeting)meeting).meeting_id;
                    archivedMeeting.modifiedMeeting_id = meeting.id;
                }
                else
                {
                    archivedMeeting.meeting_id = meeting.id;
                }

                archivedMeeting.meetingDatetime = now.Date + (meeting.startDatetime).TimeOfDay;
                archivedMeeting.duration        = meeting.duration;
                archivedMeeting.name            = meeting.name;

                int archivedMeetingId = archivedMeetingModel.Add(archivedMeeting);

                if (archivedMeetingId != -1)
                {
                    archivedMeeting.id = archivedMeetingId;
                }
                else
                {
                    return(false);
                }
            }

            onGoingMeeting               = meeting;
            onGoingArchivedMeeting       = archivedMeeting;
            onGoingMeetingUserAttendance = GetMeetingUserAttendances(archivedMeeting);

            return(true);
        }
コード例 #2
0
        // This function creates and drops lot of connection because model has no function to get data from joined table.
        // TODO: Needs to be improved
        public List <Object[]> GetMeetingUserAttendances(ArchivedMeeting archivedMeeting)
        {
            List <Attendance> attendances    = attendanceModel.GetByFK(archivedMeeting.IDName, archivedMeeting.id);
            List <Object[]>   userAttendance = new List <Object[]>();

            List <User> users = GetMeetingUser(meetingModel.Get(archivedMeeting.meeting_id));

            foreach (User user in users)
            {
                Attendance attendance = attendances.Find(x => x.userId == user.id);
                if (attendance == null)
                {
                    attendance = new Attendance();
                    attendance.archivedMeetingId = archivedMeeting.id;
                    attendance.statusId          = 15;
                    attendance.regTime           = -1;
                    attendance.userId            = user.id;

                    List <UserStatus> userStatusHistory = userStatusModel.GetByFK(user.IDName, user.id);
                    foreach (UserStatus userStatus in userStatusHistory)
                    {
                        if (userStatus.startDate.Date <= archivedMeeting.meetingDatetime.Date && userStatus.endDate.Date >= archivedMeeting.meetingDatetime.Date)
                        {
                            attendance.statusId = userStatus.statusId;
                            break;
                        }
                    }

                    int id = attendanceModel.Add(attendance);
                    if (id == -1)
                    {
                        continue;
                    }
                    else
                    {
                        attendance.id = id;
                    }
                }

                userAttendance.Add(new Object[] { user, attendance });
            }

            return(userAttendance);
        }
コード例 #3
0
        public bool StopMeeting()
        {
            foreach (MeetingStatus ms in mainWindow.meetingStatusWindows)
            {
                ms.Dispatcher.Invoke(() =>
                {
                    foreach (KeyValuePair <int, DepartmentStatus> ds in ms.departmentStatusWindows)
                    {
                        ds.Value.Close();
                    }
                    ms.departmentStatusWindows.Clear();
                    foreach (KeyValuePair <string, AttendanceStatus> attSW in ms.attendanceStatusWindows)
                    {
                        attSW.Value.Close();
                    }
                    ms.departmentStatusWindows.Clear();
                    int newDuration = (int)((DateTime.Now.TimeOfDay - onGoingMeeting.startDatetime.TimeOfDay).TotalMinutes) - 1;
                    newDuration     = newDuration < 0 ? 0 : newDuration;
                    ms.ShowAttendanceStatus("\"" + onGoingMeeting.name + "\" хурал дууслаа.\nОгноо: " + DateTime.Today.ToString(@"yyyy-MM-dd") + "\nҮргэлжилсэн хугацаа: " + newDuration + " минут");
                });
            }

            if (onGoingMeetingUserAttendance != null && onGoingMeetingUserAttendance.Count > 0)
            {
                foreach (Object[] userAttendance in onGoingMeetingUserAttendance)
                {
                    Attendance attendance = (Attendance)userAttendance[1];
                    if (attendance.statusId == 15)
                    {
                        attendance.statusId = 14;
                        attendanceModel.Set(attendance);
                    }
                }
                scannerHandler.Stop();
                onGoingMeeting = null;
                onGoingMeetingUserAttendance.Clear();
                onGoingArchivedMeeting = null;
                status = IDLE;
                return(true);
            }
            status = IDLE;
            return(false);
        }
コード例 #4
0
        public void PlaceUsers(List <object[]> userAttendances)
        {
            try
            {
                if (userAttendances == null || userAttendances.Count == 0)
                {
                    return;
                }

                last = new int[4];

                ArchivedMeeting archivedMeeting = meetingController.archivedMeetingModel.Get(((Attendance)(userAttendances.First()[1])).archivedMeetingId);
                foreach (object[] obj in userAttendances)
                {
                    User       user = (User)obj[0];
                    Attendance att  = (Attendance)obj[1];

                    if (user.departmentId != departmentId)
                    {
                        continue;
                    }

                    Grid DynamicGrid = new Grid
                    {
                        Background = new SolidColorBrush(Colors.White),
                        Width      = 120
                    };

                    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(100)
                    });
                    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)120 / (float)webImage.Height;
                    float       scaleWidth  = (float)100 / (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            = 17
                    };

                    ComboBox combobox = new ComboBox
                    {
                        FontWeight = FontWeights.Bold,
                        FontSize   = 17
                    };

                    foreach (KeyValuePair <int, string> entry in statuses)
                    {
                        if (entry.Key == 14)
                        {
                            continue;
                        }
                        ComboBoxItem comboboxItem = new ComboBoxItem
                        {
                            Content                    = entry.Key == 2 ? "(" + (att.regTime != -1 ? att.regTime : 0) + ")" + statuses[entry.Key] : entry.Value,
                            Foreground                 = Brushes.Black,
                            HorizontalAlignment        = HorizontalAlignment.Stretch,
                            HorizontalContentAlignment = HorizontalAlignment.Center,
                            FontWeight                 = FontWeights.Bold,
                            FontSize                   = 15
                        };

                        comboboxItem.Tag = entry.Key;

                        switch (entry.Key)
                        {
                        case 1: comboboxItem.Background = Brushes.LightGreen; break;

                        case 2: comboboxItem.Background = Brushes.LightSalmon; break;

                        case 15: comboboxItem.Background = Brushes.LightCoral; break;

                        default: comboboxItem.Background = Brushes.LightBlue; break;
                        }

                        combobox.Items.Add(comboboxItem);
                        if (entry.Key == att.statusId)
                        {
                            combobox.SelectedItem = comboboxItem;

                            switch (entry.Key)
                            {
                            case 1: border.BorderBrush = Brushes.DarkGreen; break;

                            case 2: border.BorderBrush = Brushes.DarkOrange; break;

                            case 15: border.BorderBrush = Brushes.DarkRed; break;

                            default: border.BorderBrush = Brushes.DarkSlateBlue; break;
                            }
                        }
                    }

                    combobox.SelectionChanged += (e, o) =>
                    {
                        ChangeUserAttendance(obj, e);
                    };

                    Grid.SetColumn(image, 0);
                    Grid.SetColumn(name, 0);
                    Grid.SetColumn(combobox, 0);
                    Grid.SetRow(image, 0);
                    Grid.SetRow(name, 1);
                    Grid.SetRow(combobox, 2);
                    DynamicGrid.Children.Add(image);
                    DynamicGrid.Children.Add(name);
                    DynamicGrid.Children.Add(combobox);

                    if (att.statusId == 1)
                    {
                        depAttWrapPanel.Children.Insert(last[0] + last[1] + last[2], border);
                        last[3]++;
                    }
                    else if (att.statusId == 2)
                    {
                        depAttWrapPanel.Children.Insert(last[0], border);
                        last[1]++;
                    }
                    else if (att.statusId == 15)
                    {
                        depAttWrapPanel.Children.Insert(0, border);
                        last[0]++;
                    }
                    else
                    {
                        depAttWrapPanel.Children.Insert(last[0] + last[1], border);
                        last[2]++;
                    }
                    userGrids.Add(user.id, DynamicGrid);
                }

                depAttTextBox1.Text = (last[0] + last[1] + last[3]).ToString();
                depAttTextBox2.Text = (last[3]).ToString();
                depAttTextBox3.Text = (last[1]).ToString();
                depAttTextBox4.Text = (last[0]).ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Хурлын цонх нээхэд алдаа гарлаа. Алдааны мессеж: " + ex.ToString());
            }
        }
コード例 #5
0
ファイル: MeetingStatus.xaml.cs プロジェクト: peakdot/irts
        public void BuildDepartControls()
        {
            departmentWrapPanels    = new Dictionary <int, WrapPanel>();
            departmentAttendance    = new Dictionary <int, TextBlock[]>();
            departmentStatusWindows = new Dictionary <int, DepartmentStatus>();
            userGrids = new Dictionary <int, System.Windows.Controls.Grid>();
            last      = new Dictionary <int, int[]>();
            gridDeparts.Children.Clear();
            gridDeparts.RowDefinitions.Clear();
            gridDeparts.ColumnDefinitions.Clear();

            for (int i = 0; i < 5; i++)
            {
                gridDeparts.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
            }
            int count = 0;

            foreach (KeyValuePair <int, string> entry in departments)
            {
                if (count % 5 == 0)
                {
                    gridDeparts.RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    });
                }

                Border border1 = new Border
                {
                    BorderBrush     = Brushes.Gray,
                    BorderThickness = new Thickness(1, 1, 1, 1),
                    Margin          = new Thickness(10, 10, 10, 10)
                };

                System.Windows.Controls.Grid DynamicGrid = new System.Windows.Controls.Grid
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Background          = new SolidColorBrush(Colors.White)
                };

                DynamicGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                DynamicGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(30)
                });
                DynamicGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(30)
                });
                DynamicGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(30)
                });
                DynamicGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(30)
                });
                DynamicGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(50)
                });
                DynamicGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                border1.Child = DynamicGrid;

                Border border = new Border
                {
                    BorderBrush     = Brushes.Gray,
                    BorderThickness = new Thickness(0, 0, 1, 1)
                };
                var converter = new BrushConverter();
                border.Child = new TextBlock
                {
                    TextWrapping        = TextWrapping.Wrap,
                    Text                = entry.Value,
                    FontWeight          = FontWeights.Bold,
                    FontSize            = 17,
                    Foreground          = Brushes.White,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch,
                    TextAlignment       = TextAlignment.Center,
                    Background          = (Brush)converter.ConvertFromString("#FF007ACC"),
                };

                border.PreviewMouseUp += (e, o) =>
                {
                    ShowDepartmentStatus(entry.Key);
                    Console.WriteLine("Clicked textbox");
                };

                Border border2 = new Border {
                    BorderBrush = Brushes.Gray, BorderThickness = new Thickness(0, 0, 0, 1)
                };
                border2.Child = new TextBlock
                {
                    TextWrapping  = TextWrapping.Wrap,
                    Text          = "0",
                    FontWeight    = FontWeights.Bold,
                    FontSize      = 25,
                    Background    = Brushes.LightGray,
                    TextAlignment = TextAlignment.Center
                };

                Border border3 = new Border {
                    BorderBrush = Brushes.Gray, BorderThickness = new Thickness(0, 0, 0, 1)
                };
                border3.Child = new TextBlock
                {
                    TextWrapping  = TextWrapping.Wrap,
                    Text          = "0",
                    FontWeight    = FontWeights.Bold,
                    FontSize      = 25,
                    Background    = Brushes.LightGreen,
                    TextAlignment = TextAlignment.Center
                };

                Border border4 = new Border {
                    BorderBrush = Brushes.Gray, BorderThickness = new Thickness(0, 0, 0, 1)
                };
                border4.Child = new TextBlock
                {
                    TextWrapping  = TextWrapping.Wrap,
                    Text          = "0",
                    FontWeight    = FontWeights.Bold,
                    FontSize      = 25,
                    Background    = Brushes.LightSalmon,
                    TextAlignment = TextAlignment.Center
                };

                Border border5 = new Border {
                    BorderBrush = Brushes.Gray, BorderThickness = new Thickness(0, 0, 0, 1)
                };
                border5.Child = new TextBlock
                {
                    TextWrapping  = TextWrapping.Wrap,
                    Text          = "0",
                    FontWeight    = FontWeights.Bold,
                    FontSize      = 25,
                    Background    = Brushes.LightCoral,
                    TextAlignment = TextAlignment.Center
                };

                WrapPanel wp = new WrapPanel
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Orientation         = System.Windows.Controls.Orientation.Horizontal
                };

                ScrollViewer sv = new ScrollViewer
                {
                    VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
                    HorizontalAlignment         = HorizontalAlignment.Stretch,
                    Name = "scroll" + count
                };
                sv.Content = wp;

                System.Windows.Controls.Grid.SetRow(border, 0);
                System.Windows.Controls.Grid.SetColumn(border, 0);
                DynamicGrid.Children.Add(border);
                System.Windows.Controls.Grid.SetRow(border2, 0);
                System.Windows.Controls.Grid.SetColumn(border2, 1);
                DynamicGrid.Children.Add(border2);
                System.Windows.Controls.Grid.SetRow(border3, 0);
                System.Windows.Controls.Grid.SetColumn(border3, 2);
                DynamicGrid.Children.Add(border3);
                System.Windows.Controls.Grid.SetRow(border4, 0);
                System.Windows.Controls.Grid.SetColumn(border4, 3);
                DynamicGrid.Children.Add(border4);
                System.Windows.Controls.Grid.SetRow(border5, 0);
                System.Windows.Controls.Grid.SetColumn(border5, 4);
                DynamicGrid.Children.Add(border5);

                System.Windows.Controls.Grid.SetRow(sv, 1);
                System.Windows.Controls.Grid.SetColumn(sv, 0);
                System.Windows.Controls.Grid.SetColumnSpan(sv, 5);
                DynamicGrid.Children.Add(sv);

                System.Windows.Controls.Grid.SetRow(border1, count / 5);
                System.Windows.Controls.Grid.SetColumn(border1, count % 5);
                gridDeparts.Children.Add(border1);

                departmentWrapPanels.Add(entry.Key, wp);
                departmentAttendance.Add(entry.Key, new TextBlock[5]);
                departmentAttendance[entry.Key][0] = (TextBlock)border2.Child;
                departmentAttendance[entry.Key][1] = (TextBlock)border3.Child;
                departmentAttendance[entry.Key][2] = (TextBlock)border4.Child;
                departmentAttendance[entry.Key][3] = (TextBlock)border5.Child;
                count++;
            }

            // Create the interop host control.
            System.Windows.Forms.Integration.WindowsFormsHost host =
                new System.Windows.Forms.Integration.WindowsFormsHost
            {
                FontSize   = 20,
                FontWeight = FontWeights.Bold
            };
            chart = new Chart();
            Title title = chart.Titles.Add("Нийт албан хаагч");

            title.Font = new System.Drawing.Font("Arial", 15f, System.Drawing.FontStyle.Bold);
            chart.Legends.Add("Тайлбар");
            chart.Legends[0].LegendStyle = LegendStyle.Table;
            chart.Legends[0].Docking     = Docking.Bottom;
            chart.Legends[0].Alignment   = System.Drawing.StringAlignment.Center;
            chart.Legends[0].BorderColor = System.Drawing.Color.Black;
            chart.Legends[0].Font        = new System.Drawing.Font("Arial", 12f);

            //Add a new chart-series
            chart.Series.Clear();

            //Add some datapoints so the series. in this case you can pass the values to this method
            chart.ChartAreas.Add("Default");

            //Add some datapoints so the series. in this case you can pass the values to this method
            host.Child = chart;
            System.Windows.Controls.Grid.SetRow(host, 1);
            System.Windows.Controls.Grid.SetColumn(host, 4);
            gridDeparts.Children.Add(host);

            ArchivedMeeting archivedMeeting = meetingController.onGoingArchivedMeeting;

            meetingName.Text = archivedMeeting.name;
            meetingDate.Text = archivedMeeting.meetingDatetime.ToString("yyyy/MM/dd HH:mm");
        }
コード例 #6
0
ファイル: MeetingStatus.xaml.cs プロジェクト: peakdot/irts
        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());
            }
        }