예제 #1
0
        void InsertAndFindingError(string[] ListLine, StackPanel Stp)
        {
            var    thisUser             = DialogLogginViewModel.Users[0];
            var    DisciplineRegistered = ST.GetListDisciplineForThisUser(thisUser.ID).ToList();
            string speak = string.Empty;

            foreach (string Line in ListLine)
            {
                TextBlock Announcement = new TextBlock();
                Announcement.FontSize = 14;
                int    CheckDiscipline = 1;
                string ID   = Line.Substring(0, 5);
                var    data = ST.IsDateRegister().ToList()[0];
                foreach (GetListDisciplineForThisUser_Result Discipline in DisciplineRegistered)
                {
                    if (Discipline.DisciplineID != ID)
                    {
                        CheckDiscipline = 1;
                    }
                    else if (Discipline.DisciplineID == ID.Trim() && Discipline.DisciplineStatus == true)
                    {
                        CheckDiscipline         = 0;
                        Announcement.Foreground = new SolidColorBrush(Colors.Red);
                        Announcement.Text       = ID + " Discipline had registered";
                        break;
                    }
                    else if (Discipline.DisciplineID == ID.Trim() && Discipline.DisciplineStatus == false)
                    {
                        CheckDiscipline = 1;
                    }
                }
                if (CheckDiscipline == 1 && ID != " " && ID != "\n" && ID != null)
                {
                    try
                    {
                        ST.InsertRegisterStudyUnit(thisUser.ID, ID, data.SemesterID);
                        ST.SaveChanges();
                        Announcement.Foreground = new SolidColorBrush(Colors.Green);
                        Announcement.Text       = ID + " Successfully";
                    }
                    catch
                    {
                        Announcement.Foreground = new SolidColorBrush(Colors.Red);
                        Announcement.Text       = ID + " Discipline not open or does not exist. Please check back...";
                    }
                }
                speak += Announcement.Text + "...";
                warningAudio.SpeakAsync(speak);
                if (Announcement != null || Announcement.Text != " ")
                {
                    Stp.Children.Add(Announcement);
                }
            }
        }
        public MainMenuViewModel()
        {
            CheckDateRegister = bool.Parse(ST.IsDateRegister().ToList()[0].IsDateRegister.ToString());
            try
            {
                _hour   = Int32.Parse(ST.GetDateRegisterUnit().ToList()[0].Hour.ToString());
                _minute = Int32.Parse(ST.GetDateRegisterUnit().ToList()[0].Minute.ToString());
                _second = Int32.Parse(ST.GetDateRegisterUnit().ToList()[0].Second.ToString());
            }
            catch { }
            _timer          = new DispatcherTimer(DispatcherPriority.Normal);
            _timer.Interval = TimeSpan.FromSeconds(1);

            _timer.Tick += Timer_Tick;
            _timer.Start();
            //event close register
            UpdateCloseTimeRegister.OnMessageTransmitted += OnCloseTimeRegisterUnit;
        }
        private void OnGetHeightALesson(Grid Grd)
        {
            var data     = ST.IsDateRegister().ToList()[0];
            var thisUser = DialogLogginViewModel.Users[0];

            Height    = Math.Round(Grd.ActualHeight / 11 - 1, 0);
            Width     = Math.Round(Grd.ActualWidth / 6.5, 0);
            Monday    = new ObservableCollection <GetScheduleForDetail1_Result>(ST.GetScheduleForDetail1(thisUser.ID, data.SemesterName, "Monday", Height, Width));
            Tuesday   = new ObservableCollection <GetScheduleForDetail1_Result>(ST.GetScheduleForDetail1(thisUser.ID, data.SemesterName, "Tuesday", Height, Width));
            Wednesday = new ObservableCollection <GetScheduleForDetail1_Result>(ST.GetScheduleForDetail1(thisUser.ID, data.SemesterName, "Wednesday", Height, Width));
            Thursday  = new ObservableCollection <GetScheduleForDetail1_Result>(ST.GetScheduleForDetail1(thisUser.ID, data.SemesterName, "Thursday", Height, Width));
            Friday    = new ObservableCollection <GetScheduleForDetail1_Result>(ST.GetScheduleForDetail1(thisUser.ID, data.SemesterName, "Friday", Height, Width));
            Saturday  = new ObservableCollection <GetScheduleForDetail1_Result>(ST.GetScheduleForDetail1(thisUser.ID, data.SemesterName, "Saturday", Height, Width));
            AddEmpty(Monday);
            AddEmpty(Tuesday);
            AddEmpty(Wednesday);
            AddEmpty(Thursday);
            AddEmpty(Friday);
            AddEmpty(Saturday);
        }