עליך להתחבר בכדי להוריד קבצים מהאתר
על מנת להבטיח שמשאבינו לא ינוצלו לרעה.
1 : public class WebsiteDB
2 : {
3 : . . .
4 :
5 : public WebsiteDB()
6 : {
7 : . . .
8 : }
9 : public Websites SelectAll()
10 : {
11 : . . .
12 : }
13 : public Websites SelectByName(string name)
14 : {
15 : . . .
16 : }
17 : public Website SelectByID(string id)
18 : {
19 : . . .
20 : }
21 : private Websites Select()
22 : {
23 : Websites websites = null;
24 : try
25 : {
26 : command.Connection = connection;
27 : connection.Open();
28 : reader = command.ExecuteReader();
29 : websites = CreateModel();
30 : }
31 : catch (Exception e)
32 : {
33 :
34 : }
35 : finally
36 : {
37 : if (reader != null)
38 : reader.Close();
39 : if (connection.State == ConnectionState.Open)
40 : connection.Close();
41 : }
42 : return websites;
43 : }
44 : private Websites CreateModel()
45 : {
46 : Websites websites = new Websites();
47 : Website website;
48 : while (reader.Read())
49 : {
50 : website = new Website();
51 : website.WebsiteID = (int)reader["WebsiteID"];
52 : website.Name = reader["Name"].ToString();
53 : website.LogoLink = reader["LogoLink"].ToString();
54 : website.Link = reader["Link"].ToString();
55 : websites.Add(website);
56 : }
57 : return websites;
58 : }
59 : }