예제 #1
0
        private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            table.Rows.Clear();
            char      letter = comboBox.SelectedItem.ToString()[0];
            Hashtable temp   = manager.getDeps();

            foreach (DictionaryEntry element in temp)
            {
                Department dep  = (Department)element.Value;
                string     name = dep.getName();

                if (name[0].Equals(letter))
                {
                    List <Municipality> mun = dep.GetMunicipalities();
                    foreach (Municipality entry in mun)
                    {
                        int n = table.Rows.Add();

                        table.Rows[n].Cells[0].Value = dep.getCode();
                        table.Rows[n].Cells[1].Value = dep.getName();
                        table.Rows[n].Cells[2].Value = entry.GetCode();
                        table.Rows[n].Cells[3].Value = entry.GetName();
                        table.Rows[n].Cells[4].Value = entry.Gettype();
                    }
                }
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool flag = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                using (var reader = new StreamReader(openFileDialog1.FileName))
                {
                    String raw = reader.ReadLine();
                    while (raw != null && flag)
                    {
                        raw = reader.ReadLine();
                        string[] report = raw.Split(',');
                        if (report[0].Equals("Fuente: DANE."))
                        {
                            flag = false;
                        }
                        else
                        {
                            manager.addDepartment(report[2], report[0]);
                            manager.addMunicipality(report[0], report[3], report[1], report[4]);
                        }
                    }
                }
            }

            // Carga la tabla
            Hashtable temp = manager.getDeps();

            foreach (DictionaryEntry element in temp)
            {
                Department dep = (Department)element.Value;

                List <Municipality> mun = dep.GetMunicipalities();

                foreach (Municipality entry in mun)
                {
                    int n = table.Rows.Add();

                    table.Rows[n].Cells[0].Value = dep.getCode();
                    table.Rows[n].Cells[1].Value = dep.getName();
                    table.Rows[n].Cells[2].Value = entry.GetCode();
                    table.Rows[n].Cells[3].Value = entry.GetName();
                    table.Rows[n].Cells[4].Value = entry.Gettype();
                }
            }
            graphButton.Enabled = true;
            comboBox.Enabled    = true;
        }