예제 #1
0
        private void filterButton_Click(object sender, EventArgs e)
        {
            ClassQueryGet filters = new ClassQueryGet();

            if (!textBox01_NomeTurma.Text.Trim().Equals(""))
            {
                filters.Nome = textBox01_NomeTurma.Text.Trim();
            }

            int itemsCount = centralPanel.Controls.Count;

            for (int i = itemsCount - 1; i > 0; i--)
            {
                if (centralPanel.Controls[i].Name == "noTurmas")
                {
                    centralPanel.Controls.Remove(centralPanel.Controls[i]);
                    continue;
                }

                Type objectType = centralPanel.Controls[i].GetType();

                if (objectType == typeof(Panel))
                {
                    centralPanel.Controls.Remove(centralPanel.Controls[i]);
                    itemsCount--;
                }
            }

            loadingText.Visible    = true;
            loadingCircle1.Visible = true;

            if (filterSelectedSerie != null)
            {
                filters.IdSerie = filterSelectedSerie.Id;
            }
            if (filterSelectedTeacher != null)
            {
                filters.RgProfessor = filterSelectedTeacher.RG;
            }

            listTurmas(filters);
        }
예제 #2
0
        private async void listTurmas(ClassQueryGet filters)
        {
            try
            {
                var apiPath = RestService.For <ApiService>(Routes.baseUrl);
                if ((filters == null) || ((filters.Nome == null) && (filters.IdSerie == null) && (filters.RgProfessor == null)))
                {
                    var dataResponse = await apiPath.GetTurmasAsync();

                    turmas = JsonConvert.DeserializeObject <TurmasApiResponse[]>(dataResponse.ToString());
                }
                else
                {
                    var dataResponse = await apiPath.GetTurmasFilteredAsync(filters);

                    turmas = JsonConvert.DeserializeObject <TurmasApiResponse[]>(dataResponse.ToString());
                }

                loadingText.Visible    = false;
                loadingCircle1.Visible = false;

                if (turmas.Length == 0)
                {
                    Label noTurmas = new Label();
                    noTurmas.Name     = "noTurmas";
                    noTurmas.Text     = "Não há turmas cadastradas!";
                    noTurmas.Font     = new Font(Styles.defaultFont.FontFamily, Convert.ToInt32(Styles.defaultFont.SizeInPoints));
                    noTurmas.AutoSize = true;
                    noTurmas.Location = new Point(20, 20);
                    centralPanel.Controls.Add(noTurmas);
                }
                else
                {
                    int i;
                    int indexSerie   = 0;
                    int indexTeacher = 0;
                    for (i = 0; i < turmas.Length; i++)
                    {
                        TurmasApiResponse turmasData = turmas[i];

                        for (indexSerie = 0; indexSerie < idSerieList.Count; indexSerie++)
                        {
                            if (idSerieList[indexSerie] == turmasData.IdSerie)
                            {
                                break;
                            }
                        }

                        for (indexTeacher = 0; indexTeacher < siglaTeacherList.Count; indexTeacher++)
                        {
                            if (rgTeacherList[indexTeacher] == turmasData.RgProfessor)
                            {
                                break;
                            }
                        }

                        Turmas turma = new Turmas(turmasData.ID, turmasData.Nome, turmasData.IdCores, turmasData.IdIcone, turmasData.IdSerie, turmasData.RgProfessor, turmasData.Icone, turmasData.Colors, siglaSerieList[indexSerie], siglaTeacherList[indexTeacher], i);
                        centralPanel.Controls.Add(turma.getTurmaPanel());
                    }
                    Panel panel = new Panel();
                    panel.Size     = new Size(1, 20);
                    panel.Location = new Point(20, (20 + Styles.seriesSize.Height) * (i));
                    centralPanel.Controls.Add(panel);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Um erro occoreu: " + ex.ToString());
            }
        }