Exemplo n.º 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);
                }
            }
        }