public Add_ChangeForm(Catalog temp, Town t, GRegion r, Country c) { InitializeComponent(); catalog = temp; button1.Text = "Изменить"; this.Text = "Изменение элемента"; button1.DialogResult = DialogResult.OK; button2.DialogResult = DialogResult.Cancel; changec = c; changet = t; changer = r; permtokens = new bool[] { true, true, true, true }; maintoken = true; type = (c != null) ? 2 : (r != null) ? 1 : 0; Prepare(); }
private void GetObject(StreamReader a) { string[] tmp = a.ReadLine().Split('|'); /*int pos1 = 0; * int pos2 = 0; * int pos3 = 0;*/ switch (tmp[0].ToLower()) { case "город": { bool isset = false; Town s = new Town(tmp[1], tmp[2], tmp[3], Convert.ToDouble(tmp[4]), tmp[5], Convert.ToDouble(tmp[6])); towns.Add(s); foreach (Country co in countrys) { if (co.Name == tmp[2]) { co.Add(s); isset = true; break; } } if (!isset) { Country c = new Country(tmp[2], "-", tmp[3], Convert.ToDouble(tmp[4])); c.Add(s); countrys.Add(c); } break; } case "регион": { bool isset = false; GRegion ss = new GRegion(tmp[1], tmp[2], tmp[3], Convert.ToDouble(tmp[4]), tmp[5], tmp[6]); regions.Add(ss); foreach (Country co in countrys) { if (co.Name == tmp[2]) { co.Add(ss); isset = true; break; } } if (!isset) { Country c = new Country(tmp[2], "-", tmp[3], Convert.ToDouble(tmp[4])); c.Add(ss); countrys.Add(c); } break; } case "страна": { Country sss = new Country(tmp[1], tmp[2], tmp[3], Convert.ToDouble(tmp[4]), tmp[5], Convert.ToDouble(tmp[6])); countrys.Add(sss); break; } } }
public void AddGeo() { //comboBox1_SelectedIndexChanged(sender, e); //string pattern1 = @"^[А-Я]{1}[а-яА-ЯЁ -]{2,20}$"; //string pattern2 = @"^[0-180]\.[0-60] [ю|с]\.ш\. [0-180]\.[0-60] [в|з]\.д\.$"; int i = comboBox1.SelectedIndex; switch (i) { case 0: { Town town = new Town(); town.Name = textBox1.Text; town.Country = textBox3.Text; town.Geopos = textBox4.Text; town.Citizens = (int)numericUpDown2.Value; town.Area = (int)numericUpDown1.Value; town.Materic = comboBox4.Text; catalog.UseTowns.Add(town); bool isset = false; foreach (Country co in catalog.UseCountrys) { if (co.Name == town.Country) { co.Add(town); isset = true; break; } } if (!isset) { Country c = new Country(town.Country, "-", town.Materic, Convert.ToDouble(town.Citizens)); c.Add(town); catalog.UseCountrys.Add(c); } break; } case 1: { GRegion region = new GRegion(); region.Name = textBox1.Text; region.Country = textBox3.Text; region.Capital = textBox2.Text; region.Citizens = (int)numericUpDown2.Value; region.Materic = comboBox4.Text; region.TypeRegion = comboBox2.Text; catalog.UseRegions.Add(region); bool isset = false; foreach (Country co in catalog.UseCountrys) { if (co.Name == region.Country) { co.Add(region); isset = true; break; } } if (!isset) { Country c = new Country(region.Country, "-", region.Materic, Convert.ToDouble(region.Citizens)); c.Add(region); catalog.UseCountrys.Add(c); } break; } case 2: { Country country = new Country(); country.Name = textBox1.Text; country.Capital = textBox2.Text; country.Politic = comboBox3.Text; country.Citizens = (int)numericUpDown2.Value; country.Area = (int)numericUpDown1.Value; country.Materic = comboBox4.Text; catalog.UseCountrys.Add(country); break; } } }