private void btn_search_enrollment_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var alunoContext = new AlunoContext();
                var aluno        = alunoContext.GetAluno(Txt_Enrollment.Text);

                if (aluno == null)
                {
                    this.Clear();
                    TxtBl_InfoMessage.Text       = "Aluno não Encontrado";
                    TxtBl_InfoMessage.Background = Brushes.Blue;
                    TxtBl_InfoMessage.Visibility = Visibility.Visible;
                }
                else
                {
                    TxtBl_BirthdateValue.Text  = aluno.BirthdateField;
                    TxtBl_CpfValue.Text        = aluno.Cpf;
                    TxtBl_EnrollmentValue.Text = aluno.Enrollment;
                    TxtBl_NameValue.Text       = aluno.Name;
                    if (aluno.Enabled)
                    {
                        TxtBl_InfoMessage.Text       = "Liberado";
                        TxtBl_InfoMessage.Background = Brushes.Green;
                        TxtBl_InfoMessage.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        TxtBl_InfoMessage.Text       = "Suspenso";
                        TxtBl_InfoMessage.Background = Brushes.Red;
                        TxtBl_InfoMessage.Visibility = Visibility.Visible;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log.LogException(ex);
                TxtBl_InfoMessage.Text       = "Erro";
                TxtBl_InfoMessage.Background = Brushes.Red;
                TxtBl_InfoMessage.Visibility = Visibility.Visible;
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            try
            {
                var serializer = new XmlSerializer(typeof(AlunosList));
                var alunos     = new AlunosList();
                using (var fs = new FileStream(Directories.ExportAlunoFileDirectory, FileMode.Open))
                {
                    alunos = (AlunosList)serializer.Deserialize(fs);
                }
                var alunoContext = new AlunoContext();

                foreach (var aluno in alunos.Alunos)
                {
                    var alunoDb = alunoContext.GetAluno(aluno.Enrollment);

                    if (alunoDb == null)
                    {
                        alunoContext.AddAluno(aluno);
                        Logger.Log.LogNew(aluno);
                    }
                    else if (alunoDb.Enabled != aluno.Enabled)
                    {
                        alunoContext.UpdateAluno(aluno);
                        Logger.Log.LogChanged(aluno);
                    }
                    else
                    {
                        Logger.Log.LogNotChanged(aluno);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log.LogException(ex);
            }
            Console.WriteLine("================================================");
            Console.WriteLine("End");
            Console.ReadKey();
        }