| using System;  | 
| using System.Data;  | 
| using System.Configuration;  | 
| using System.Web;  | 
| using System.Web.Security;  | 
| using System.Web.UI;  | 
| using System.Web.UI.HtmlControls;  | 
| using System.Web.UI.WebControls;  | 
| using System.Web.UI.WebControls.WebParts;  | 
|   | 
| using System.Collections;  | 
| using System.Data.OracleClient;  | 
|   | 
| namespace CCSTrace.CCS.Object  | 
| {  | 
|     public class Addr_Contrast  | 
|     {  | 
|         public static Hashtable m_TotalData = null;  | 
|         public static String DefaultDept = "市區巡修課";  | 
|         private OracleConnection _ConnectionTPC;  | 
|         private RecordLog _PLog;  | 
|   | 
|         public Addr_Contrast(OracleConnection _Conn, OracleTransaction _Trx, RecordLog _Log)  | 
|         {  | 
|             _ConnectionTPC = _Conn;  | 
|             _PLog = _Log;  | 
|   | 
|             String SqlStmt;  | 
|             String City;  | 
|             ArrayList m_Data = new ArrayList();  | 
|             String Tmp = "";  | 
|   | 
|             if (m_TotalData != null)  | 
|                 return;  | 
|   | 
|             m_TotalData = new Hashtable();  | 
|             SqlStmt = "SELECT DEPTID,CITY,TOWN,ROAD FROM CCS.ADDR_CONTRAST ORDER BY CITY,TOWN,ROAD";  | 
|   | 
|             OracleCommand Command = null;  | 
|             OracleDataReader reader = null;  | 
|             try  | 
|             {  | 
|                 Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Trx);  | 
|                 reader = Command.ExecuteReader();  | 
|   | 
|                 while (reader.Read())  | 
|                 {  | 
|                     ArrayList m_Record = new ArrayList();  | 
|                     City = reader["CITY"].ToString();  | 
|                     m_Record.Add(City);  | 
|                     m_Record.Add(reader["TOWN"].ToString());  | 
|                     m_Record.Add(reader["ROAD"].ToString());  | 
|                     m_Record.Add(Convert.ToInt32(reader["DEPTID"].ToString()));  | 
|   | 
|                     if (Tmp.Equals(City))  | 
|                         m_Data.Add(m_Record);  | 
|                     else  | 
|                     {  | 
|                         m_TotalData.Add(Tmp, m_Data);  | 
|                         Tmp = City;  | 
|                         m_Data = new ArrayList();  | 
|                         m_Data.Add(m_Record);  | 
|                     }  | 
|                 }  | 
|                 m_TotalData.Add(Tmp, m_Data);  | 
|             }  | 
|             catch (Exception e)  | 
|             {  | 
|                 Console.WriteLine(e.StackTrace);  | 
|                 m_TotalData = null;  | 
|             }  | 
|             finally  | 
|             {  | 
|                 reader.Close();  | 
|                 Command.Dispose();  | 
|             }  | 
|   | 
|         }  | 
|   | 
|         public int findDeptID(String City, String Region, String Road)  | 
|         {  | 
|             int Dept = 0;  | 
|             ArrayList m_Data = (ArrayList)m_TotalData[City];  | 
|   | 
|             try  | 
|             {  | 
|                 for (int i = 0; i < m_Data.Count; i++)  | 
|                 {  | 
|                     ArrayList Tmp = (ArrayList)m_Data[i];  | 
|                     String m_Region = Tmp[1].ToString().Trim();  | 
|                     String m_Road = Tmp[2].ToString().Trim();  | 
|                     int DeptID = Convert.ToInt32(Tmp[3].ToString());  | 
|   | 
|                     if ((Region.Trim().Equals(m_Region)) && (Road.Trim().Equals(m_Road)))  | 
|                         return DeptID;  | 
|                 }  | 
|             }  | 
|             catch (Exception)  | 
|             {  | 
|                 _PLog.Warn("無法取得所屬巡修部門代號,預設案件所屬巡修部門為市區巡修課!");  | 
|             }  | 
|             // 當找不到部門別時,Default 設定為市巡  | 
|             Dept = CCS.CCSMain.EOSCodelist.getKeyID(CCS.LocalVariable.Dept, DefaultDept);  | 
|             return Dept;  | 
|         }  | 
|   | 
|     }  | 
| }  |