Exemple #1
0
        private void CarregarGrid()
        {
            dataGridView1.Rows.Clear();

            XmlDocument dataArquivo = new XmlDocument();

            dataArquivo = data.CarregarXml();

            XmlNode dis = dataArquivo.SelectSingleNode("DISCIPLINAS");

            XmlNodeList disFilhas = dis.ChildNodes;

            for (int i = 0; i < disFilhas.Count; i++)
            {
                Disciplina disciplinaGrid = new Disciplina();

                disciplinaGrid.nome = disFilhas[i].Name;

                XmlNode trimestre1 = dataArquivo.SelectSingleNode("DISCIPLINAS/" + disFilhas[i].Value + "/TRIMESTRE1");
                if (!string.IsNullOrEmpty(trimestre1.InnerText))
                {
                    disciplinaGrid.trimestre1 = Convert.ToDouble(trimestre1.InnerText);
                }

                XmlNode trimestre2 = dataArquivo.SelectSingleNode("DISCIPLINAS/" + disFilhas[i].Value + "/TRIMESTRE2");
                if (!string.IsNullOrEmpty(trimestre2.InnerText))
                {
                    disciplinaGrid.trimestre2 = Convert.ToDouble(trimestre2.InnerText);
                }

                XmlNode trimestre3 = dataArquivo.SelectSingleNode("DISCIPLINAS/" + disFilhas[i].Value + "/TRIMESTRE3");
                if (!string.IsNullOrEmpty(trimestre3.InnerText))
                {
                    disciplinaGrid.trimestre3 = Convert.ToDouble(trimestre3.InnerText);
                }

                XmlNode recuperacao = dataArquivo.SelectSingleNode("DISCIPLINAS/" + disFilhas[i].Value + "/RECUPERACAO");
                if (!string.IsNullOrEmpty(recuperacao.InnerText))
                {
                    disciplinaGrid.recuperacao = Convert.ToDouble(recuperacao.InnerText);
                }

                XmlNode media = dataArquivo.SelectSingleNode("DISCIPLINAS/" + disFilhas[i].Value + "/MEDIA");
                if (!string.IsNullOrEmpty(media.InnerText))
                {
                    disciplinaGrid.media = Convert.ToDouble(media.InnerText);
                }

                XmlNode total = dataArquivo.SelectSingleNode("DISCIPLINAS/" + disFilhas[i].Value + "/TOTAL");
                if (!string.IsNullOrEmpty(total.InnerText))
                {
                    disciplinaGrid.total = Convert.ToDouble(total.InnerText);
                }

                XmlNode aprovacao = dataArquivo.SelectSingleNode("DISCIPLINAS/" + disFilhas[i].Value + "/APROVACAO");
                if (!string.IsNullOrEmpty(aprovacao.InnerText))
                {
                    disciplinaGrid.aprovacao = aprovacao.InnerText;
                }

                dataGridView1.Rows.Add(disciplinaGrid.nome, disciplinaGrid.trimestre1, disciplinaGrid.trimestre2, disciplinaGrid.trimestre3, disciplinaGrid.recuperacao, disciplinaGrid.media, disciplinaGrid.total, disciplinaGrid.aprovacao);
            }
        }