Develop and Download Open Source Software

Browse Subversion Repository

Contents of /tags/FeliCa2Money-2.2/StationCode.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 109 - (show annotations) (download)
Sun Mar 9 06:14:50 2008 UTC (16 years, 1 month ago) by tmurakam
File size: 3481 byte(s)
ver 2.2

1 /*
2 * FeliCa2Money
3 *
4 * Copyright (C) 2001-2008 Takuya Murakami
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 // stationcode.mdb アクセスクラス (試作中)
22
23 using System;
24 using System.Data.OleDb;
25
26 namespace FeliCa2Money
27 {
28 class StationCode : IDisposable
29 {
30 private OleDbConnection conn;
31
32 public StationCode()
33 {
34 conn = new System.Data.OleDb.OleDbConnection();
35 conn.ConnectionString = Properties.Settings.Default.StationCodeConnectionString;
36 conn.Open();
37 }
38
39 public void Dispose()
40 {
41 conn.Close();
42 }
43
44 private string[] doQuery(string sql)
45 {
46 OleDbCommand cmd;
47 OleDbDataReader dr;
48
49 cmd = new OleDbCommand(sql, conn);
50 dr = cmd.ExecuteReader();
51
52 string[] result = null;
53 if (dr.Read())
54 {
55 result = new string[2];
56 if (dr.IsDBNull(0))
57 {
58 result[0] = "";
59 }
60 else
61 {
62 result[0] = dr.GetString(0);
63 }
64
65 if (dr.IsDBNull(1))
66 {
67 result[1] = "";
68 }
69 else
70 {
71 result[1] = dr.GetString(1);
72 }
73 }
74 dr.Close();
75 return result;
76 }
77
78 // 駅名を検索する
79 public string[] getStationName(int area, int line, int station)
80 {
81 string sql = string.Format("SELECT CompanyName,StationName FROM StationCode WHERE"
82 + " AreaCode={0} AND LineCode={1} AND StationCode={2}", area, line, station);
83 return doQuery(sql);
84 }
85
86 // 店舗名を検索する
87 // area = -1 として検索すると、area 指定なしとみなす
88 public string[] getShopName(int area, int terminal, int line, int station)
89 {
90 string sql = string.Format("SELECT CompanyName,ShopName FROM ShopCode WHERE"
91 + " TerminalCode={0} AND LineCode={1} AND StationCode={2}", terminal, line, station);
92 if (area >= 0)
93 {
94 sql += " AND AreaCode=" + area.ToString();
95 }
96 return doQuery(sql);
97 }
98
99 // バス停留所名を検索する
100 public string[] getBusName(int line, int station)
101 {
102 string sql = string.Format("SELECT BusCompanyName,BusStationName FROM BusCode WHERE"
103 + " BusLineCode={0} AND BusStationCode={1}", line, station);
104 return doQuery(sql);
105 }
106 }
107 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26