Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //kde se bere string okres:
- public static void Tfilllevel3(string soubor)
- {
- HtmlAgilityPack.HtmlDocument dokument = new HtmlAgilityPack.HtmlDocument();
- dokument.Load(soubor, System.Text.Encoding.GetEncoding(28592));
- //načte dokument se správným kódováním (volby.cz, diakritika)
- //zjištění distric ID - zjistíme jméno okresu a provnáme s DB
- HtmlNode h3 = dokument.DocumentNode.SelectSingleNode("//h3[2]");
- //odstraníme "Okres: " abychom dostali jen jméno okresu
- string okres = h3.InnerText.ToString();
- okres = okres.Remove(0, 8);
- //budeme zjišťovat districtid
- int rid = dbo.getdistrictid(okres);
- }
- public static int getdistrictid(string okres)
- {
- string dname = okres;
- string cstring = Properties.Settings.Default.volbydbConnectionString;
- using (SqlConnection sqlpripojeni = new SqlConnection(cstring))
- using (SqlCommand getrid = new SqlCommand("SELECT DistrictId FROM Districts WHERE Name= @Districtname", sqlpripojeni))
- {
- getrid.Parameters.Add(new SqlParameter("@Districtname", SqlDbType.NVarChar, dname.Length)).Value = dname;
- sqlpripojeni.Open();
- return Convert.ToInt32(getrid.ExecuteScalar());
- }
- }
- //Stale vraci 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement