forked from TwinkmrMask/BookShop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Handler.cs
37 lines (35 loc) · 1.21 KB
/
Handler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Xml;
namespace task_14._04
{
class Handler : IDisposable
{
public void Dispose() { }
public void SetData(string links, string database)
{
XmlDocument document = new XmlDocument();
document.Load(getPath());
XmlElement root = document.DocumentElement;
foreach (XmlElement book in root)
{
if ((root != null) && (root.HasChildNodes))
{
using(PlatformDataBase dataBase = new PlatformDataBase(links, database))
dataBase.AddBooks(
book.Attributes["id"].Value,
book.Attributes["author"].Value,
book.Attributes["title"].Value,
book.Attributes["year"].Value
);
}
}
}
private string getPath()
{
Microsoft.Win32.OpenFileDialog openDialog = new Microsoft.Win32.OpenFileDialog();
openDialog.Filter = "Файл с книгами|*.xml";
openDialog.ShowDialog();
return openDialog.FileName;
}
}
}