Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/FeliCa2Money.net/StationCode.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 184 - (show annotations) (download)
Wed Mar 26 11:36:49 2008 UTC (16 years, 2 months ago) by tmurakam
File size: 3501 byte(s)
misc fix
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 class Names
33 {
34 public string r1 = ""; // 会社名
35 public string r2 = ""; // 駅名 or 支店名
36 }
37
38 public StationCode()
39 {
40 conn = new System.Data.OleDb.OleDbConnection();
41 conn.ConnectionString = Properties.Settings.Default.StationCodeConnectionString;
42 conn.Open();
43 }
44
45 public void Dispose()
46 {
47 conn.Close();
48 }
49
50 private Names doQuery(string sql)
51 {
52 OleDbCommand cmd;
53 OleDbDataReader dr;
54
55 cmd = new OleDbCommand(sql, conn);
56 dr = cmd.ExecuteReader();
57
58 Names s = null;
59 if (dr.Read())
60 {
61 s = new Names();
62 if (!dr.IsDBNull(0))
63 {
64 s.r1 = dr.GetString(0);
65 }
66
67 if (!dr.IsDBNull(1))
68 {
69 s.r2 = dr.GetString(1);
70 }
71 }
72 dr.Close();
73 return s;
74 }
75
76 // 駅名を検索する
77 public Names getStationName(int area, int line, int station)
78 {
79 if (line == 0 && station == 0)
80 {
81 return null;
82 }
83 string sql = string.Format("SELECT CompanyName,StationName FROM StationCode WHERE"
84 + " AreaCode={0} AND LineCode={1} AND StationCode={2}", area, line, station);
85 return doQuery(sql);
86 }
87
88 // 店舗名を検索する
89 // area = -1 として検索すると、area 指定なしとみなす
90 public Names getShopName(int area, int terminal, int line, int station)
91 {
92 string sql = string.Format("SELECT CompanyName,ShopName FROM ShopCode WHERE"
93 + " TerminalCode={0} AND LineCode={1} AND StationCode={2}", terminal, line, station);
94 if (area >= 0)
95 {
96 sql += " AND AreaCode=" + area.ToString();
97 }
98 return doQuery(sql);
99 }
100
101 // バス停留所名を検索する
102 public Names getBusName(int line, int station)
103 {
104 string sql = string.Format("SELECT BusCompanyName,BusStationName FROM BusCode WHERE"
105 + " BusLineCode={0} AND BusStationCode={1}", line, station);
106 return doQuery(sql);
107 }
108 }
109 }

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