예제 #1
0
        private void btnLoadConstituencyXml_Click(Object sender, EventArgs e)
        {
            OpenFileDialog openDialog = new OpenFileDialog();

            openDialog.Filter = "XML Files|*.xml|All files|*.*";
            if (openDialog.ShowDialog() == DialogResult.OK)
            {
                PopulationData data   = null;
                StreamReader   reader = null;
                try
                {
                    reader = new StreamReader(openDialog.FileName);
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(reader.ReadToEnd());
                    foreach (XmlNode node in xmlDoc.ChildNodes)
                    {
                        if (node.Name == "electiondata")
                        {
                            data = PopulationData.Load(node);
                        }
                    }
                }
                finally
                {
                    if (reader != null)
                    {
                        reader.Dispose();
                    }
                }
                if ((data != null) && (data.Data != null))
                {
                    Int32 year = Convert.ToInt32(edtYear.Value);
                    PopulationDataEntry dataEntry = GetPopulationData(year);
                    if (rbxNational.Checked && chkBuengKan.Checked)
                    {
                        ModifyPopulationDataForBuengKan(dataEntry);
                    }
                    dataEntry.SortSubEntitiesByEnglishName();

                    var entitie = data.Data.FlatList(new List <EntityType>()
                    {
                        EntityType.Bangkok, EntityType.Changwat, EntityType.Amphoe, EntityType.KingAmphoe, EntityType.Khet
                    });
                    foreach (PopulationDataEntry entry in entitie)
                    {
                        entry.CopyPopulationToConstituencies(dataEntry);
                    }

                    ConstituencyStatisticsViewer dialog = new ConstituencyStatisticsViewer(data.Data);
                    dialog.Show();
                }
            }
        }
예제 #2
0
        private void btnLoadConstituencyXml_Click(Object sender, EventArgs e)
        {
            OpenFileDialog openDialog = new OpenFileDialog();
            openDialog.Filter = "XML Files|*.xml|All files|*.*";
            if ( openDialog.ShowDialog() == DialogResult.OK )
            {
                PopulationData data = null;
                StreamReader reader = null;
                try
                {

                    reader = new StreamReader(openDialog.FileName);
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(reader.ReadToEnd());
                    foreach ( XmlNode node in xmlDoc.ChildNodes )
                    {
                        if ( node.Name == "electiondata" )
                        {
                            data = PopulationData.Load(node);
                        }
                    }
                }
                finally
                {
                    if ( reader != null )
                    {
                        reader.Dispose();
                    }
                }
                if ( (data != null) && (data.Data != null) )
                {
                    Int32 year = Convert.ToInt32(edtYear.Value);
                    PopulationDataEntry dataEntry = GetPopulationData(year);
                    if ( rbxNational.Checked && chkBuengKan.Checked )
                    {
                        ModifyPopulationDataForBuengKan(dataEntry);
                    }
                    dataEntry.SortSubEntitiesByEnglishName();

                    var entitie = data.Data.FlatList(new List<EntityType>() { EntityType.Bangkok, EntityType.Changwat, EntityType.Amphoe, EntityType.KingAmphoe, EntityType.Khet });
                    foreach ( PopulationDataEntry entry in entitie )
                    {
                        entry.CopyPopulationToConstituencies(dataEntry);
                    }

                    ConstituencyStatisticsViewer dialog = new ConstituencyStatisticsViewer(data.Data);
                    dialog.Show();
                }
            }
        }