リビジョン 124
請求完了時台帳ロック修正
不要ファイル削除
trunk/src/ProcessManagement/ProcessManagement/Common/CommonVersion.cs | ||
---|---|---|
14 | 14 |
/// <summary> |
15 | 15 |
/// 本体バージョン |
16 | 16 |
/// </summary> |
17 |
public static int s_SystemVersion = 26;
|
|
17 |
public static int s_SystemVersion = 27;
|
|
18 | 18 |
|
19 | 19 |
/// <summary> |
20 | 20 |
/// コピー・環境バージョン |
trunk/src/ProcessManagement/ProcessManagement/DB/IOAccess/IODailyData.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Data; |
|
6 |
using System.Collections; |
|
7 |
|
|
8 |
using log4net; |
|
9 |
using Oracle.ManagedDataAccess.Client; |
|
10 |
|
|
11 |
using ProcessManagement.DB.Oracle; |
|
12 |
using ProcessManagement.DB.Core; |
|
13 |
using ProcessManagement.DataModel; |
|
14 |
using ProcessManagement.Common; |
|
15 |
|
|
16 |
namespace ProcessManagement.DB.IOAccess |
|
17 |
{ |
|
18 |
/// <summary> |
|
19 |
/// 日報データDBアクセス |
|
20 |
/// </summary> |
|
21 |
public class IODailyData : OracleProcess |
|
22 |
{ |
|
23 |
#region 定義部 |
|
24 |
/// <summary> |
|
25 |
/// log4netログを使用する |
|
26 |
/// </summary> |
|
27 |
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
|
28 |
#endregion |
|
29 |
|
|
30 |
#region 定数 |
|
31 |
/// <summary> |
|
32 |
/// データフィールド並び |
|
33 |
/// </summary> |
|
34 |
public enum TableColumn |
|
35 |
{ |
|
36 |
/// <summary> |
|
37 |
/// 作成者コード |
|
38 |
/// </summary> |
|
39 |
PersonCode, |
|
40 |
/// <summary> |
|
41 |
/// 日報作成日 |
|
42 |
/// </summary> |
|
43 |
DailyDataDate, |
|
44 |
/// <summary> |
|
45 |
/// 行番号 |
|
46 |
/// </summary> |
|
47 |
LineCount, |
|
48 |
/// <summary> |
|
49 |
/// 工事番号 |
|
50 |
/// </summary> |
|
51 |
ConstructionCode, |
|
52 |
/// <summary> |
|
53 |
/// 作業内容 |
|
54 |
/// </summary> |
|
55 |
WorkContentsText, |
|
56 |
/// <summary> |
|
57 |
/// 登録年月日 |
|
58 |
/// </summary> |
|
59 |
EntryDate, |
|
60 |
/// <summary> |
|
61 |
/// 更新年月日 |
|
62 |
/// </summary> |
|
63 |
UpdateDate, |
|
64 |
} |
|
65 |
#endregion |
|
66 |
|
|
67 |
#region コンストラクタ |
|
68 |
/// <summary> |
|
69 |
/// コンストラクタ |
|
70 |
/// </summary> |
|
71 |
/// <param name="ConnectionString"></param> |
|
72 |
public IODailyData() |
|
73 |
: base(DBCommon.Instance.DBConnectString) |
|
74 |
{ |
|
75 |
} |
|
76 |
|
|
77 |
#endregion |
|
78 |
|
|
79 |
#region SQL作成 |
|
80 |
/// <summary> |
|
81 |
/// SQL作成 |
|
82 |
/// </summary> |
|
83 |
private string CreateSelectSQL() |
|
84 |
{ |
|
85 |
// SQL作成(oracleのDateTime型が変換できないのでCharに変換しておく) |
|
86 |
string strcmd = "SELECT"; |
|
87 |
|
|
88 |
strcmd += " PersonCode"; // 担当者コード |
|
89 |
strcmd += " ,TO_CHAR(DailyDataDate, 'YYYY/MM/DD')"; // 日報作成日 |
|
90 |
strcmd += " ,LineCount"; // 行番号 |
|
91 |
strcmd += " ,ConstructionCode"; // 工事番号 |
|
92 |
strcmd += " ,WorkContentsText"; // 作業内容 |
|
93 |
strcmd += ", TO_CHAR(EntryDate, 'YYYY/MM/DD HH24:MI:ss')"; // 登録年月日 |
|
94 |
strcmd += ", TO_CHAR(UpdateDate, 'YYYY/MM/DD HH24:MI:ss')"; // 更新年月日 |
|
95 |
strcmd += " FROM DailyData"; |
|
96 |
|
|
97 |
return strcmd; |
|
98 |
} |
|
99 |
#endregion |
|
100 |
|
|
101 |
#region 複数読込み処理 |
|
102 |
public bool SelectAction(string AddSQLString, ref List<DailyData> data, bool bConnect = true) |
|
103 |
{ |
|
104 |
//Oracle インターフェース |
|
105 |
string strcmd = ""; |
|
106 |
ArrayList arData = new ArrayList(); |
|
107 |
|
|
108 |
try |
|
109 |
{ |
|
110 |
// SQL作成 |
|
111 |
strcmd = CreateSelectSQL() + AddSQLString; |
|
112 |
|
|
113 |
// SQL実行 |
|
114 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return false; |
|
115 |
|
|
116 |
// データセット |
|
117 |
foreach (object[] objwrk in arData) |
|
118 |
{ |
|
119 |
DailyData work = new DailyData(); |
|
120 |
Reader2Struct(objwrk, ref work); |
|
121 |
data.Add(work); |
|
122 |
} |
|
123 |
|
|
124 |
return true; |
|
125 |
} |
|
126 |
catch (Exception ex) |
|
127 |
{ |
|
128 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
129 |
return false; |
|
130 |
} |
|
131 |
} |
|
132 |
#endregion |
|
133 |
|
|
134 |
#region 1件読込み処理 |
|
135 |
public bool SelectAction(string AddSQLString, ref DailyData data, bool bConnect = true) |
|
136 |
{ |
|
137 |
//Oracle インターフェース |
|
138 |
string strcmd = ""; |
|
139 |
ArrayList arData = new ArrayList(); |
|
140 |
|
|
141 |
try |
|
142 |
{ |
|
143 |
strcmd = CreateSelectSQL() + AddSQLString; |
|
144 |
|
|
145 |
// SQL実行 |
|
146 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return false; |
|
147 |
if (arData.Count == 0) return false; |
|
148 |
|
|
149 |
// データセット |
|
150 |
foreach (object[] objwrk in arData) |
|
151 |
{ |
|
152 |
Reader2Struct(objwrk, ref data); |
|
153 |
break; |
|
154 |
} |
|
155 |
|
|
156 |
return true; |
|
157 |
} |
|
158 |
catch (Exception ex) |
|
159 |
{ |
|
160 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
161 |
return false; |
|
162 |
} |
|
163 |
} |
|
164 |
#endregion |
|
165 |
|
|
166 |
#region 1件追加処理 |
|
167 |
/// <summary> |
|
168 |
/// 担当者毎経費データ追加 |
|
169 |
/// </summary> |
|
170 |
/// <param name="data">担当者毎経費データデータ</param> |
|
171 |
/// <returns>true:成功 false:失敗</returns> |
|
172 |
public bool InsertAction(DailyData work, bool bConnect = true) |
|
173 |
{ |
|
174 |
string strcmd = ""; |
|
175 |
try |
|
176 |
{ |
|
177 |
strcmd = "INSERT INTO DailyData"; |
|
178 |
|
|
179 |
strcmd += " VALUES ("; |
|
180 |
|
|
181 |
strcmd += string.Format(" {0}", work.PersonCode); // 担当者コード |
|
182 |
strcmd += string.Format(", TO_DATE('{0}','YYYY/MM/DD')" |
|
183 |
, work.DailyDataDate.ToShortDateString()); // 日報作成日 |
|
184 |
strcmd += string.Format(", {0}", work.LineCoount); // 行番号 |
|
185 |
strcmd += string.Format(", {0}", work.ConstructionCode); // 工事番号 |
|
186 |
strcmd += string.Format(",'{0}'", work.WorkContentsText); // 作業内容 |
|
187 |
|
|
188 |
strcmd += ", TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
189 |
strcmd += ", TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
190 |
strcmd = strcmd + ")"; |
|
191 |
|
|
192 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
193 |
|
|
194 |
return true; |
|
195 |
} |
|
196 |
catch (Exception ex) |
|
197 |
{ |
|
198 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
199 |
return false; |
|
200 |
} |
|
201 |
} |
|
202 |
#endregion |
|
203 |
|
|
204 |
#region 複数追加処理 |
|
205 |
public bool InsertAction(List<DailyData> data, bool bConnect = true) |
|
206 |
{ |
|
207 |
string strcmd = ""; |
|
208 |
try |
|
209 |
{ |
|
210 |
|
|
211 |
foreach (DailyData work in data) |
|
212 |
{ |
|
213 |
if (!InsertAction(work, bConnect)) return false; |
|
214 |
} |
|
215 |
return true; |
|
216 |
} |
|
217 |
catch (Exception ex) |
|
218 |
{ |
|
219 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
220 |
return false; |
|
221 |
} |
|
222 |
} |
|
223 |
#endregion |
|
224 |
|
|
225 |
#region 更新処理 |
|
226 |
/// <summary> |
|
227 |
/// 担当者毎経費データ更新 |
|
228 |
/// </summary> |
|
229 |
/// <param name="AddSQLString">更新条件SQL文字列</param> |
|
230 |
/// <param name="data">担当者毎経費データデータ</param> |
|
231 |
/// <returns>true:成功 false:失敗</returns> |
|
232 |
public bool UpdateAction(string AddSQLString, DailyData data, bool bConnect = true) |
|
233 |
{ |
|
234 |
string strcmd = ""; |
|
235 |
try |
|
236 |
{ |
|
237 |
|
|
238 |
strcmd = "UPDATE DailyData"; |
|
239 |
|
|
240 |
strcmd += " SET"; |
|
241 |
|
|
242 |
strcmd += string.Format(" PersonCode = {0}", data.PersonCode); // 担当者コード |
|
243 |
strcmd += string.Format(",DailyDataDate = TO_DATE('{0}','YYYY/MM/DD')" |
|
244 |
, data.DailyDataDate.ToShortDateString()); // 日報作成日 |
|
245 |
strcmd += string.Format(",LineCoount = {0}", data.LineCoount); // 行番号 |
|
246 |
strcmd += string.Format(",ConstructionCode = {0}", data.ConstructionCode); // 工事番号 |
|
247 |
strcmd += string.Format(",WorkContentsText = '{0}'", data.WorkContentsText); // 作業内容 |
|
248 |
|
|
249 |
strcmd += ", UpdateDate = TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
250 |
strcmd += AddSQLString; |
|
251 |
|
|
252 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
253 |
|
|
254 |
return true; |
|
255 |
} |
|
256 |
catch (Exception ex) |
|
257 |
{ |
|
258 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
259 |
return false; |
|
260 |
} |
|
261 |
} |
|
262 |
#endregion |
|
263 |
|
|
264 |
#region 削除処理 |
|
265 |
/// <summary> |
|
266 |
/// 担当者毎経費データ削除 |
|
267 |
/// </summary> |
|
268 |
/// <param name="AddSQLString">削除条件SQL文字列</param> |
|
269 |
/// <param name="data">担当者毎経費データデータ</param> |
|
270 |
/// <returns>true:成功 false:失敗</returns> |
|
271 |
public bool DeleteAction(string AddSQLString, bool bConnect = true) |
|
272 |
{ |
|
273 |
//Oracle インターフェース |
|
274 |
string strcmd = ""; |
|
275 |
try |
|
276 |
{ |
|
277 |
strcmd = string.Format("{0}{1}", "DELETE FROM DailyData", AddSQLString); |
|
278 |
|
|
279 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
280 |
|
|
281 |
return true; |
|
282 |
} |
|
283 |
catch (Exception ex) |
|
284 |
{ |
|
285 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
286 |
return false; |
|
287 |
} |
|
288 |
} |
|
289 |
#endregion |
|
290 |
|
|
291 |
#region データセット処理 |
|
292 |
/// <summary> |
|
293 |
/// OracleDataReaderより構造体へセットする |
|
294 |
/// </summary> |
|
295 |
/// <param name="reader">OracleDataReader</param> |
|
296 |
/// <param name="wrk">構造体</param> |
|
297 |
public void Reader2Struct(object[] objwrk, ref DailyData wrk) |
|
298 |
{ |
|
299 |
try |
|
300 |
{ |
|
301 |
// データ取得 |
|
302 |
wrk.PersonCode = int.Parse(objwrk[(int)TableColumn.PersonCode].ToString()); // 担当者コード |
|
303 |
wrk.DailyDataDate = DateTime.Parse(objwrk[(int)TableColumn.DailyDataDate].ToString()); // 日報作成日 |
|
304 |
wrk.LineCoount = int.Parse(objwrk[(int)TableColumn.LineCount].ToString()); // 行番号 |
|
305 |
wrk.ConstructionCode = int.Parse(objwrk[(int)TableColumn.ConstructionCode].ToString()); // 工事番号 |
|
306 |
wrk.WorkContentsText = objwrk[(int)TableColumn.WorkContentsText].ToString(); // 作業内容 |
|
307 |
|
|
308 |
wrk.EntryDate = DateTime.Parse(objwrk[(int)TableColumn.EntryDate].ToString()); |
|
309 |
wrk.UpdateDate = DateTime.Parse(objwrk[(int)TableColumn.UpdateDate].ToString()); |
|
310 |
} |
|
311 |
catch (OracleException oraex) |
|
312 |
{ |
|
313 |
logger.ErrorFormat("オラクルエラー:{0}:{1}", CommonMotions.GetMethodName(2), oraex.Message); |
|
314 |
} |
|
315 |
catch (Exception ex) |
|
316 |
{ |
|
317 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(2), ex.Message); |
|
318 |
} |
|
319 |
} |
|
320 |
#endregion |
|
321 |
|
|
322 |
#region 検索文字列作成処理 |
|
323 |
/// <summary> |
|
324 |
/// 主キー検索の文字列を返す |
|
325 |
/// </summary> |
|
326 |
/// <param name="PersonCode"></param> |
|
327 |
/// <param name="ActionDate"></param> |
|
328 |
/// <param name="DataType"></param> |
|
329 |
/// <param name="DataAddCount"></param> |
|
330 |
/// <returns></returns> |
|
331 |
public string CreatePrimarykeyString(int PersonCode, DateTime DailyDataDate, int LineCount) |
|
332 |
{ |
|
333 |
string strWork = ""; |
|
334 |
try |
|
335 |
{ |
|
336 |
strWork = string.Format(" WHERE PersonCode = {0}", PersonCode); |
|
337 |
if (DailyDataDate != DateTime.MinValue) |
|
338 |
strWork += string.Format(" AND DailyDataDate = TO_DATE('{0}','YYYY/MM/DD')", DailyDataDate.ToShortDateString()); |
|
339 |
if (LineCount != 0) |
|
340 |
strWork += string.Format(" AND LineCount = {0}", LineCount); |
|
341 |
} |
|
342 |
catch (Exception ex) |
|
343 |
{ |
|
344 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strWork); |
|
345 |
} |
|
346 |
|
|
347 |
return strWork; |
|
348 |
} |
|
349 |
#endregion |
|
350 |
|
|
351 |
} |
|
352 |
} |
trunk/src/ProcessManagement/ProcessManagement/DB/IOAccess/IOProceedingsDataAttendee.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Data; |
|
6 |
using System.Collections; |
|
7 |
|
|
8 |
using log4net; |
|
9 |
using Oracle.ManagedDataAccess.Client; |
|
10 |
|
|
11 |
using ProcessManagement.DB.Oracle; |
|
12 |
using ProcessManagement.DB.Core; |
|
13 |
using ProcessManagement.DataModel; |
|
14 |
using ProcessManagement.Common; |
|
15 |
|
|
16 |
namespace ProcessManagement.DB.IOAccess |
|
17 |
{ |
|
18 |
/// <summary> |
|
19 |
/// 発注者打ち合わせ議事録データアクセス(出席者) |
|
20 |
/// </summary> |
|
21 |
public class IOProceedingsDataAttend : OracleProcess |
|
22 |
{ |
|
23 |
#region 定義部 |
|
24 |
/// <summary> |
|
25 |
/// log4netログを使用する |
|
26 |
/// </summary> |
|
27 |
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
|
28 |
#endregion |
|
29 |
|
|
30 |
#region 定数 |
|
31 |
/// <summary> |
|
32 |
/// データフィールド並び |
|
33 |
/// </summary> |
|
34 |
public enum TableColumn |
|
35 |
{ |
|
36 |
/// <summary> |
|
37 |
/// 工事番号 |
|
38 |
/// </summary> |
|
39 |
ConstructionCode, |
|
40 |
/// <summary> |
|
41 |
/// 議事録作成日 |
|
42 |
/// </summary> |
|
43 |
ProceedingsDataDate, |
|
44 |
/// <summary> |
|
45 |
/// 会議時間開始 |
|
46 |
/// </summary> |
|
47 |
StartMeetingTime, |
|
48 |
/// <summary> |
|
49 |
/// データ行番号 |
|
50 |
/// </summary> |
|
51 |
SeqNo, |
|
52 |
/// <summary> |
|
53 |
/// 出席者所属 |
|
54 |
/// </summary> |
|
55 |
Department, |
|
56 |
/// <summary> |
|
57 |
/// 出席者氏名 |
|
58 |
/// </summary> |
|
59 |
AttendName, |
|
60 |
/// <summary> |
|
61 |
/// 登録年月日 |
|
62 |
/// </summary> |
|
63 |
EntryDate, |
|
64 |
/// <summary> |
|
65 |
/// 更新年月日 |
|
66 |
/// </summary> |
|
67 |
UpdateDate, |
|
68 |
} |
|
69 |
#endregion |
|
70 |
|
|
71 |
#region コンストラクタ |
|
72 |
/// <summary> |
|
73 |
/// コンストラクタ |
|
74 |
/// </summary> |
|
75 |
/// <param name="ConnectionString"></param> |
|
76 |
public IOProceedingsDataAttend() |
|
77 |
: base(DBCommon.Instance.DBConnectString) |
|
78 |
{ |
|
79 |
} |
|
80 |
|
|
81 |
#endregion |
|
82 |
|
|
83 |
#region SQL作成 |
|
84 |
/// <summary> |
|
85 |
/// SQL作成 |
|
86 |
/// </summary> |
|
87 |
private string CreateSelectSQL() |
|
88 |
{ |
|
89 |
// SQL作成(oracleのDateTime型が変換できないのでCharに変換しておく) |
|
90 |
string strcmd = "SELECT"; |
|
91 |
|
|
92 |
strcmd += " ConstructionCode"; // 工事番号 |
|
93 |
strcmd += " ,TO_CHAR(ProceedingsDataDate, 'YYYY/MM/DD')"; // 議事録作成日 |
|
94 |
strcmd += " ,StartMeetingTime"; // 会議時間開始 |
|
95 |
strcmd += " ,SeqNo"; // データ行番号 |
|
96 |
strcmd += " ,Department"; // 出席者所属 |
|
97 |
strcmd += " ,AttendName"; // 出席者氏名 |
|
98 |
strcmd += ", TO_CHAR(EntryDate, 'YYYY/MM/DD HH24:MI:ss')"; // 登録年月日 |
|
99 |
strcmd += ", TO_CHAR(UpdateDate, 'YYYY/MM/DD HH24:MI:ss')"; // 更新年月日 |
|
100 |
strcmd += " FROM ProceedingsDataAttend"; |
|
101 |
|
|
102 |
return strcmd; |
|
103 |
} |
|
104 |
#endregion |
|
105 |
|
|
106 |
#region 複数読込み処理 |
|
107 |
public bool SelectAction(string AddSQLString, ref List<ProceedingsDataAttend> data, bool bConnect = true) |
|
108 |
{ |
|
109 |
//Oracle インターフェース |
|
110 |
string strcmd = ""; |
|
111 |
ArrayList arData = new ArrayList(); |
|
112 |
|
|
113 |
try |
|
114 |
{ |
|
115 |
// SQL作成 |
|
116 |
strcmd = CreateSelectSQL() + AddSQLString; |
|
117 |
|
|
118 |
// SQL実行 |
|
119 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return false; |
|
120 |
|
|
121 |
// データセット |
|
122 |
foreach (object[] objwrk in arData) |
|
123 |
{ |
|
124 |
ProceedingsDataAttend work = new ProceedingsDataAttend(); |
|
125 |
Reader2Struct(objwrk, ref work); |
|
126 |
data.Add(work); |
|
127 |
} |
|
128 |
|
|
129 |
return true; |
|
130 |
} |
|
131 |
catch (Exception ex) |
|
132 |
{ |
|
133 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
134 |
return false; |
|
135 |
} |
|
136 |
} |
|
137 |
#endregion |
|
138 |
|
|
139 |
#region 1件読込み処理 |
|
140 |
public bool SelectAction(string AddSQLString, ref ProceedingsDataAttend data, bool bConnect = true) |
|
141 |
{ |
|
142 |
//Oracle インターフェース |
|
143 |
string strcmd = ""; |
|
144 |
ArrayList arData = new ArrayList(); |
|
145 |
|
|
146 |
try |
|
147 |
{ |
|
148 |
strcmd = CreateSelectSQL() + AddSQLString; |
|
149 |
|
|
150 |
// SQL実行 |
|
151 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return false; |
|
152 |
if (arData.Count == 0) return false; |
|
153 |
|
|
154 |
// データセット |
|
155 |
foreach (object[] objwrk in arData) |
|
156 |
{ |
|
157 |
Reader2Struct(objwrk, ref data); |
|
158 |
break; |
|
159 |
} |
|
160 |
|
|
161 |
return true; |
|
162 |
} |
|
163 |
catch (Exception ex) |
|
164 |
{ |
|
165 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
166 |
return false; |
|
167 |
} |
|
168 |
} |
|
169 |
#endregion |
|
170 |
|
|
171 |
#region 1件追加処理 |
|
172 |
/// <summary> |
|
173 |
/// 担当者毎経費データ追加 |
|
174 |
/// </summary> |
|
175 |
/// <param name="data">担当者毎経費データデータ</param> |
|
176 |
/// <returns>true:成功 false:失敗</returns> |
|
177 |
public bool InsertAction(ProceedingsDataAttend work, bool bConnect = true) |
|
178 |
{ |
|
179 |
string strcmd = ""; |
|
180 |
try |
|
181 |
{ |
|
182 |
strcmd = "INSERT INTO ProceedingsDataAttend"; |
|
183 |
|
|
184 |
strcmd += " ("; |
|
185 |
bool bFirst = true; |
|
186 |
foreach (var gender in Enum.GetValues(typeof(TableColumn))) |
|
187 |
{ |
|
188 |
if (!bFirst) strcmd += " ,"; |
|
189 |
strcmd += gender.ToString(); |
|
190 |
bFirst = false; |
|
191 |
} |
|
192 |
strcmd += ") VALUES ("; |
|
193 |
|
|
194 |
strcmd += string.Format(" {0}", work.ConstructionCode); // 工事番号 |
|
195 |
|
|
196 |
strcmd += string.Format(", TO_DATE('{0}','YYYY/MM/DD')" |
|
197 |
, work.ProceedingsDataDate.ToShortDateString());// 議事録作成日 |
|
198 |
|
|
199 |
strcmd += string.Format(", {0}", work.StartMeetingTime); // 会議時間開始 |
|
200 |
strcmd += string.Format(", {0}", work.SeqNo); // データ行番号 |
|
201 |
|
|
202 |
strcmd += string.Format(",'{0}'", work.Department); // 出席者所属 |
|
203 |
strcmd += string.Format(",'{0}'", work.AttendName); // 出席者氏名 |
|
204 |
|
|
205 |
strcmd += ", TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
206 |
strcmd += ", TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
207 |
strcmd = strcmd + ")"; |
|
208 |
|
|
209 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
210 |
|
|
211 |
return true; |
|
212 |
} |
|
213 |
catch (Exception ex) |
|
214 |
{ |
|
215 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
216 |
return false; |
|
217 |
} |
|
218 |
} |
|
219 |
#endregion |
|
220 |
|
|
221 |
#region 複数追加処理 |
|
222 |
public bool InsertAction(List<ProceedingsDataAttend> data, bool bConnect = true) |
|
223 |
{ |
|
224 |
string strcmd = ""; |
|
225 |
try |
|
226 |
{ |
|
227 |
|
|
228 |
foreach (ProceedingsDataAttend work in data) |
|
229 |
{ |
|
230 |
if (!InsertAction(work, bConnect)) return false; |
|
231 |
} |
|
232 |
return true; |
|
233 |
} |
|
234 |
catch (Exception ex) |
|
235 |
{ |
|
236 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
237 |
return false; |
|
238 |
} |
|
239 |
} |
|
240 |
#endregion |
|
241 |
|
|
242 |
#region 更新処理 |
|
243 |
/// <summary> |
|
244 |
/// 担当者毎経費データ更新 |
|
245 |
/// </summary> |
|
246 |
/// <param name="AddSQLString">更新条件SQL文字列</param> |
|
247 |
/// <param name="data">担当者毎経費データデータ</param> |
|
248 |
/// <returns>true:成功 false:失敗</returns> |
|
249 |
public bool UpdateAction(string AddSQLString, ProceedingsDataAttend data, bool bConnect = true) |
|
250 |
{ |
|
251 |
string strcmd = ""; |
|
252 |
try |
|
253 |
{ |
|
254 |
|
|
255 |
strcmd = "UPDATE ProceedingsDataAttend"; |
|
256 |
|
|
257 |
strcmd += " SET"; |
|
258 |
|
|
259 |
strcmd += string.Format(" ConstructionCode = {0}", data.ConstructionCode); // 工事番号 |
|
260 |
|
|
261 |
strcmd += string.Format(",ProceedingsDataDate = TO_DATE('{0}','YYYY/MM/DD')" |
|
262 |
, data.ProceedingsDataDate.ToShortDateString()); // 議事録作成日 |
|
263 |
|
|
264 |
strcmd += string.Format(",StartMeetingTime = {0}", data.StartMeetingTime); // 会議時間開始 |
|
265 |
strcmd += string.Format(",SeqNo = {0}", data.SeqNo); // データ行番号 |
|
266 |
|
|
267 |
strcmd += string.Format(",Department = '{0}'", data.Department); // 出席者所属 |
|
268 |
strcmd += string.Format(",AttendName = '{0}'", data.AttendName); // 出席者氏名 |
|
269 |
|
|
270 |
strcmd += ", UpdateDate = TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
271 |
strcmd += AddSQLString; |
|
272 |
|
|
273 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
274 |
|
|
275 |
return true; |
|
276 |
} |
|
277 |
catch (Exception ex) |
|
278 |
{ |
|
279 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
280 |
return false; |
|
281 |
} |
|
282 |
} |
|
283 |
#endregion |
|
284 |
|
|
285 |
#region 削除処理 |
|
286 |
/// <summary> |
|
287 |
/// 担当者毎経費データ削除 |
|
288 |
/// </summary> |
|
289 |
/// <param name="AddSQLString">削除条件SQL文字列</param> |
|
290 |
/// <param name="data">担当者毎経費データデータ</param> |
|
291 |
/// <returns>true:成功 false:失敗</returns> |
|
292 |
public bool DeleteAction(string AddSQLString, bool bConnect = true) |
|
293 |
{ |
|
294 |
//Oracle インターフェース |
|
295 |
string strcmd = ""; |
|
296 |
try |
|
297 |
{ |
|
298 |
strcmd = string.Format("{0}{1}", "DELETE FROM ProceedingsDataAttend", AddSQLString); |
|
299 |
|
|
300 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
301 |
|
|
302 |
return true; |
|
303 |
} |
|
304 |
catch (Exception ex) |
|
305 |
{ |
|
306 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
307 |
return false; |
|
308 |
} |
|
309 |
} |
|
310 |
#endregion |
|
311 |
|
|
312 |
#region データセット処理 |
|
313 |
/// <summary> |
|
314 |
/// OracleDataReaderより構造体へセットする |
|
315 |
/// </summary> |
|
316 |
/// <param name="reader">OracleDataReader</param> |
|
317 |
/// <param name="wrk">構造体</param> |
|
318 |
public void Reader2Struct(object[] objwrk, ref ProceedingsDataAttend wrk) |
|
319 |
{ |
|
320 |
try |
|
321 |
{ |
|
322 |
// データ取得 |
|
323 |
wrk.ConstructionCode = int.Parse(objwrk[(int)TableColumn.ConstructionCode].ToString()); // 工事番号 |
|
324 |
wrk.ProceedingsDataDate = DateTime.Parse(objwrk[(int)TableColumn.ProceedingsDataDate].ToString()); // 議事録作成日 |
|
325 |
wrk.StartMeetingTime = int.Parse(objwrk[(int)TableColumn.StartMeetingTime].ToString()); // 会議時間開始 |
|
326 |
wrk.SeqNo = int.Parse(objwrk[(int)TableColumn.SeqNo].ToString()); // データ行番号 |
|
327 |
|
|
328 |
wrk.Department = objwrk[(int)TableColumn.Department].ToString(); // 出席者所属 |
|
329 |
wrk.AttendName = objwrk[(int)TableColumn.AttendName].ToString(); // 出席者氏名 |
|
330 |
|
|
331 |
wrk.EntryDate = DateTime.Parse(objwrk[(int)TableColumn.EntryDate].ToString()); |
|
332 |
wrk.UpdateDate = DateTime.Parse(objwrk[(int)TableColumn.UpdateDate].ToString()); |
|
333 |
} |
|
334 |
catch (OracleException oraex) |
|
335 |
{ |
|
336 |
logger.ErrorFormat("オラクルエラー:{0}:{1}", CommonMotions.GetMethodName(2), oraex.Message); |
|
337 |
} |
|
338 |
catch (Exception ex) |
|
339 |
{ |
|
340 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(2), ex.Message); |
|
341 |
} |
|
342 |
} |
|
343 |
#endregion |
|
344 |
|
|
345 |
#region 検索文字列作成処理 |
|
346 |
/// <summary> |
|
347 |
/// 主キー検索の文字列を返す |
|
348 |
/// </summary> |
|
349 |
/// <param name="PersonCode"></param> |
|
350 |
/// <param name="ActionDate"></param> |
|
351 |
/// <param name="DataType"></param> |
|
352 |
/// <param name="DataAddCount"></param> |
|
353 |
/// <returns></returns> |
|
354 |
public string CreatePrimarykeyString(int ConstructionCode, DateTime ProceedingsDataDate, int StartMeetingTime = 0, int SeqNo = 0) |
|
355 |
{ |
|
356 |
string strWork = ""; |
|
357 |
try |
|
358 |
{ |
|
359 |
strWork = string.Format(" WHERE ConstructionCode = {0}", ConstructionCode); |
|
360 |
if (ProceedingsDataDate != DateTime.MinValue) |
|
361 |
strWork += string.Format(" AND ProceedingsDataDate = TO_DATE('{0}','YYYY/MM/DD')", ProceedingsDataDate.ToShortDateString()); |
|
362 |
if (StartMeetingTime != 0) |
|
363 |
strWork += string.Format(" AND StartMeetingTime = {0}", StartMeetingTime); |
|
364 |
if (SeqNo != 0) |
|
365 |
strWork += string.Format(" AND SeqNo = {0}", SeqNo); |
|
366 |
} |
|
367 |
catch (Exception ex) |
|
368 |
{ |
|
369 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strWork); |
|
370 |
} |
|
371 |
|
|
372 |
return strWork; |
|
373 |
} |
|
374 |
#endregion |
|
375 |
|
|
376 |
} |
|
377 |
} |
trunk/src/ProcessManagement/ProcessManagement/DB/IOAccess/IOMConstructionWork.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Data; |
|
6 |
using System.Collections; |
|
7 |
|
|
8 |
using log4net; |
|
9 |
using Oracle.ManagedDataAccess.Client; |
|
10 |
|
|
11 |
using ProcessManagement.DB.Oracle; |
|
12 |
using ProcessManagement.DB.Core; |
|
13 |
using ProcessManagement.DataModel; |
|
14 |
using ProcessManagement.Common; |
|
15 |
|
|
16 |
namespace ProcessManagement.DB.IOAccess |
|
17 |
{ |
|
18 |
/// <summary> |
|
19 |
/// 施工工種マスタDBアクセス |
|
20 |
/// </summary> |
|
21 |
public class IOMConstructionWork : OracleProcess |
|
22 |
{ |
|
23 |
#region 定義部 |
|
24 |
/// <summary> |
|
25 |
/// log4netログを使用する |
|
26 |
/// </summary> |
|
27 |
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
|
28 |
#endregion |
|
29 |
|
|
30 |
#region 定数 |
|
31 |
/// <summary> |
|
32 |
/// 施工工種マスタフィールド並び |
|
33 |
/// </summary> |
|
34 |
public enum ConstructionWorkMasterColumn |
|
35 |
{ |
|
36 |
ComponentCode = 0, |
|
37 |
ItemCode, |
|
38 |
WorkCode, |
|
39 |
DisplayOrder, |
|
40 |
ItemName, |
|
41 |
WorkName, |
|
42 |
UnitName, |
|
43 |
UnitPrice, |
|
44 |
DeleteFlg, |
|
45 |
EntryDate, |
|
46 |
UpdateDate, |
|
47 |
} |
|
48 |
#endregion |
|
49 |
|
|
50 |
#region コンストラクタ |
|
51 |
/// <summary> |
|
52 |
/// コンストラクタ |
|
53 |
/// </summary> |
|
54 |
/// <param name="ConnectionString"></param> |
|
55 |
public IOMConstructionWork() |
|
56 |
: base(DBCommon.Instance.DBConnectString) |
|
57 |
{ |
|
58 |
} |
|
59 |
|
|
60 |
#endregion |
|
61 |
|
|
62 |
#region パブリックメソッド |
|
63 |
/// <summary> |
|
64 |
/// 施工工種マスタ検索 |
|
65 |
/// </summary> |
|
66 |
/// <param name="AddSQLString">検索条件SQL文字列</param> |
|
67 |
/// <param name="data">施工工種マスタデータ</param> |
|
68 |
/// <returns>true:成功 false:失敗</returns> |
|
69 |
public bool SelectAction(string AddSQLString, ref List<ConstructionWorkMaster> data, bool bConnect = true) |
|
70 |
{ |
|
71 |
//Oracle インターフェース |
|
72 |
string strcmd = ""; |
|
73 |
ArrayList arData = new ArrayList(); |
|
74 |
|
|
75 |
try |
|
76 |
{ |
|
77 |
// SQL作成(oracleのDateTime型が変換できないのでCharに変換しておく) |
|
78 |
strcmd = "SELECT"; |
|
79 |
|
|
80 |
strcmd += " ComponentCode"; |
|
81 |
strcmd += ", ItemCode"; |
|
82 |
strcmd += ", WorkCode"; |
|
83 |
strcmd += ", DisplayOrder"; |
|
84 |
strcmd += ", ItemName"; |
|
85 |
strcmd += ", WorkName"; |
|
86 |
strcmd += ", UnitName"; |
|
87 |
strcmd += ", UnitPrice"; |
|
88 |
strcmd += ", DeleteFlg"; |
|
89 |
|
|
90 |
strcmd += ", TO_CHAR(EntryDate, 'YYYY/MM/DD HH24:MI:ss')"; |
|
91 |
strcmd += ", TO_CHAR(UpdateDate, 'YYYY/MM/DD HH24:MI:ss')"; |
|
92 |
strcmd += " FROM ConstructionWorkMaster"; |
|
93 |
strcmd += AddSQLString; |
|
94 |
|
|
95 |
// SQL実行 |
|
96 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return false; |
|
97 |
|
|
98 |
// データセット |
|
99 |
foreach (object[] objwrk in arData) |
|
100 |
{ |
|
101 |
ConstructionWorkMaster work = new ConstructionWorkMaster(); |
|
102 |
Reader2Struct(objwrk, ref work); |
|
103 |
data.Add(work); |
|
104 |
} |
|
105 |
|
|
106 |
return true; |
|
107 |
} |
|
108 |
catch (Exception ex) |
|
109 |
{ |
|
110 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
111 |
return false; |
|
112 |
} |
|
113 |
} |
|
114 |
|
|
115 |
/// <summary> |
|
116 |
/// 施工工種マスタ追加 |
|
117 |
/// </summary> |
|
118 |
/// <param name="data">施工工種マスタデータ</param> |
|
119 |
/// <returns>true:成功 false:失敗</returns> |
|
120 |
public bool InsertAction(List<ConstructionWorkMaster> data, bool bConnect = true) |
|
121 |
{ |
|
122 |
string strcmd = ""; |
|
123 |
try |
|
124 |
{ |
|
125 |
|
|
126 |
foreach (ConstructionWorkMaster work in data) |
|
127 |
{ |
|
128 |
strcmd = "INSERT INTO ConstructionWorkMaster"; |
|
129 |
|
|
130 |
strcmd += " VALUES ("; |
|
131 |
|
|
132 |
strcmd += string.Format(" {0}", work.ComponentCode); |
|
133 |
strcmd += string.Format(",{0}", work.ItemCode); |
|
134 |
strcmd += string.Format(",{0}", work.WorkCode); |
|
135 |
strcmd += string.Format(",{0}", work.DisplayOrder); |
|
136 |
|
|
137 |
strcmd += string.Format(",'{0}'", work.ItemName); |
|
138 |
strcmd += string.Format(",'{0}'", work.WorkName); |
|
139 |
strcmd += string.Format(",'{0}'", work.UnitName); |
|
140 |
strcmd += string.Format(",{0}", work.UnitPrice); |
|
141 |
strcmd += string.Format(",{0}", work.DeleteFlg); |
|
142 |
|
|
143 |
strcmd += ", TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
144 |
strcmd += ", TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
145 |
strcmd = strcmd + ")"; |
|
146 |
|
|
147 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
148 |
} |
|
149 |
return true; |
|
150 |
} |
|
151 |
catch (Exception ex) |
|
152 |
{ |
|
153 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
154 |
return false; |
|
155 |
} |
|
156 |
} |
|
157 |
|
|
158 |
/// <summary> |
|
159 |
/// 施工工種マスタ更新 |
|
160 |
/// </summary> |
|
161 |
/// <param name="AddSQLString">更新条件SQL文字列</param> |
|
162 |
/// <param name="data">施工工種マスタデータ</param> |
|
163 |
/// <returns>true:成功 false:失敗</returns> |
|
164 |
public bool UpdateAction(string AddSQLString, ConstructionWorkMaster data, bool bConnect = true) |
|
165 |
{ |
|
166 |
string strcmd = ""; |
|
167 |
try |
|
168 |
{ |
|
169 |
|
|
170 |
strcmd = "UPDATE ConstructionWorkMaster"; |
|
171 |
|
|
172 |
strcmd += " SET"; |
|
173 |
|
|
174 |
strcmd += string.Format(" ComponentCode = {0}", data.ComponentCode); |
|
175 |
strcmd += string.Format(",ItemCode = {0}", data.ItemCode); |
|
176 |
strcmd += string.Format(",WorkCode = {0}", data.WorkCode); |
|
177 |
strcmd += string.Format(",DisplayOrder = {0}", data.DisplayOrder); |
|
178 |
|
|
179 |
strcmd += string.Format(",ItemName = '{0}'", data.ItemName); |
|
180 |
strcmd += string.Format(",WorkName = '{0}'", data.WorkName); |
|
181 |
strcmd += string.Format(",UnitName = '{0}'", data.UnitName); |
|
182 |
strcmd += string.Format(",UnitPrice = {0}", data.UnitPrice); |
|
183 |
strcmd += string.Format(",DeleteFlg = {0}", data.DeleteFlg); |
|
184 |
|
|
185 |
strcmd += ", UpdateDate = TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
186 |
strcmd += AddSQLString; |
|
187 |
|
|
188 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
189 |
|
|
190 |
return true; |
|
191 |
} |
|
192 |
catch (Exception ex) |
|
193 |
{ |
|
194 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
195 |
return false; |
|
196 |
} |
|
197 |
} |
|
198 |
|
|
199 |
|
|
200 |
/// <summary> |
|
201 |
/// 施工工種マスタ削除 |
|
202 |
/// </summary> |
|
203 |
/// <param name="AddSQLString">削除条件SQL文字列</param> |
|
204 |
/// <param name="data">施工工種マスタデータ</param> |
|
205 |
/// <returns>true:成功 false:失敗</returns> |
|
206 |
public bool DeleteAction(string AddSQLString, bool bConnect = true) |
|
207 |
{ |
|
208 |
//Oracle インターフェース |
|
209 |
string strcmd = ""; |
|
210 |
try |
|
211 |
{ |
|
212 |
strcmd = string.Format("{0}{1}", "DELETE FROM ConstructionWorkMaster", AddSQLString); |
|
213 |
|
|
214 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
215 |
|
|
216 |
return true; |
|
217 |
} |
|
218 |
catch (Exception ex) |
|
219 |
{ |
|
220 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
221 |
return false; |
|
222 |
} |
|
223 |
} |
|
224 |
|
|
225 |
/// <summary> |
|
226 |
/// 論理削除 |
|
227 |
/// </summary> |
|
228 |
/// <param name="ItemCode">カテゴリタイプ</param> |
|
229 |
/// <param name="Key2">名称コード</param> |
|
230 |
/// <param name="Key3">登録履歴</param> |
|
231 |
/// <returns>成功時:true 失敗時:false</returns> |
|
232 |
public bool LogicalDeleteAction(int ComponentCode, int ItemCode, int WorkCode, bool bConnect = true) |
|
233 |
{ |
|
234 |
// Where文字列作成 |
|
235 |
string strWhere = CreatePrimarykeyString(ComponentCode, ItemCode, WorkCode); |
|
236 |
try |
|
237 |
{ |
|
238 |
List<ConstructionWorkMaster> workList = new List<ConstructionWorkMaster>(); |
|
239 |
// データ読込 |
|
240 |
if (SelectAction(strWhere, ref workList, bConnect)) |
|
241 |
{ |
|
242 |
if (workList.Count == 0) return true; |
|
243 |
|
|
244 |
// 削除フラグ |
|
245 |
workList[0].DeleteFlg = 1; |
|
246 |
// データ更新 |
|
247 |
if (!UpdateAction(strWhere, workList[0], bConnect)) |
|
248 |
{ |
|
249 |
rollback(); |
|
250 |
return false; |
|
251 |
} |
|
252 |
} |
|
253 |
return true; |
|
254 |
} |
|
255 |
catch (Exception ex) |
|
256 |
{ |
|
257 |
logger.ErrorFormat("システムエラー::{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strWhere); |
|
258 |
return false; |
|
259 |
} |
|
260 |
} |
|
261 |
|
|
262 |
/// <summary> |
|
263 |
/// OracleDataReaderより構造体へセットする |
|
264 |
/// </summary> |
|
265 |
/// <param name="reader">OracleDataReader</param> |
|
266 |
/// <param name="wrk">構造体</param> |
|
267 |
public void Reader2Struct(object[] objwrk, ref ConstructionWorkMaster wrk) |
|
268 |
{ |
|
269 |
try |
|
270 |
{ |
|
271 |
// データ取得 |
|
272 |
wrk.ComponentCode = int.Parse(objwrk[(int)ConstructionWorkMasterColumn.ComponentCode].ToString()); |
|
273 |
wrk.ItemCode = int.Parse(objwrk[(int)ConstructionWorkMasterColumn.ItemCode].ToString()); |
|
274 |
wrk.WorkCode = int.Parse(objwrk[(int)ConstructionWorkMasterColumn.WorkCode].ToString()); |
|
275 |
wrk.DisplayOrder = int.Parse(objwrk[(int)ConstructionWorkMasterColumn.DisplayOrder].ToString()); |
|
276 |
|
|
277 |
wrk.ItemName = objwrk[(int)ConstructionWorkMasterColumn.ItemName].ToString(); |
|
278 |
wrk.WorkName = objwrk[(int)ConstructionWorkMasterColumn.WorkName].ToString(); |
|
279 |
wrk.UnitName = objwrk[(int)ConstructionWorkMasterColumn.UnitName].ToString(); |
|
280 |
wrk.UnitPrice = int.Parse(objwrk[(int)ConstructionWorkMasterColumn.UnitPrice].ToString()); |
|
281 |
|
|
282 |
wrk.DeleteFlg = int.Parse(objwrk[(int)ConstructionWorkMasterColumn.DeleteFlg].ToString()); |
|
283 |
|
|
284 |
wrk.EntryDate = DateTime.Parse(objwrk[(int)ConstructionWorkMasterColumn.EntryDate].ToString()); |
|
285 |
wrk.UpdateDate = DateTime.Parse(objwrk[(int)ConstructionWorkMasterColumn.UpdateDate].ToString()); |
|
286 |
} |
|
287 |
catch (OracleException oraex) |
|
288 |
{ |
|
289 |
logger.ErrorFormat("オラクルエラー:{0}:{1}", CommonMotions.GetMethodName(2), oraex.Message); |
|
290 |
} |
|
291 |
catch (Exception ex) |
|
292 |
{ |
|
293 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(2), ex.Message); |
|
294 |
} |
|
295 |
} |
|
296 |
|
|
297 |
|
|
298 |
#endregion |
|
299 |
|
|
300 |
#region パブリックメソッド(特殊処理) |
|
301 |
/// <summary> |
|
302 |
/// 最大値を取得する |
|
303 |
/// </summary> |
|
304 |
/// <param name="AddSQLString"></param> |
|
305 |
/// <param name="bConnect"></param> |
|
306 |
/// <returns></returns> |
|
307 |
public int GetMaxWorkCodeCount(string AddSQLString, bool bConnect = true) |
|
308 |
{ |
|
309 |
//Oracle インターフェース |
|
310 |
string strcmd = ""; |
|
311 |
ArrayList arData = new ArrayList(); |
|
312 |
int iRet = 0; |
|
313 |
try |
|
314 |
{ |
|
315 |
// SQL作成 |
|
316 |
strcmd = "SELECT MAX(WorkCode) FROM ConstructionWorkMaster" + AddSQLString; |
|
317 |
|
|
318 |
// SQL実行 |
|
319 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return iRet; |
|
320 |
|
|
321 |
// データセット |
|
322 |
foreach (object[] objwrk in arData) |
|
323 |
{ |
|
324 |
if (objwrk[0].ToString().Equals("")) |
|
325 |
iRet = 0; |
|
326 |
else |
|
327 |
iRet = int.Parse(objwrk[0].ToString()); |
|
328 |
} |
|
329 |
} |
|
330 |
catch (Exception ex) |
|
331 |
{ |
|
332 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
333 |
} |
|
334 |
|
|
335 |
return iRet; |
|
336 |
} |
|
337 |
|
|
338 |
/// <summary> |
|
339 |
/// 主キー検索の文字列を返す |
|
340 |
/// </summary> |
|
341 |
/// <param name="WorkCode">項目コード</param> |
|
342 |
/// <param name="History">登録履歴</param> |
|
343 |
/// <returns>Where文字列</returns> |
|
344 |
public string CreatePrimarykeyString(int ComponentCode, int ItemCode, int WorkCode = 0) |
|
345 |
{ |
|
346 |
string strWork = ""; |
|
347 |
try |
|
348 |
{ |
|
349 |
strWork = string.Format(" Where ComponentCode = {0} And ItemCode = {1}", ComponentCode, ItemCode); |
|
350 |
if (WorkCode != 0) strWork += string.Format(" And WorkCode = {0}", WorkCode); |
|
351 |
|
|
352 |
} |
|
353 |
catch (Exception ex) |
|
354 |
{ |
|
355 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strWork); |
|
356 |
} |
|
357 |
|
|
358 |
return strWork; |
|
359 |
} |
|
360 |
|
|
361 |
/// <summary> |
|
362 |
/// 指定表示順の最大値を取得する |
|
363 |
/// </summary> |
|
364 |
/// <param name="AddSQLString"></param> |
|
365 |
/// <param name="bConnect"></param> |
|
366 |
/// <returns></returns> |
|
367 |
public int GetMaxDisplayOrder(string AddSQLString, bool bConnect = true) |
|
368 |
{ |
|
369 |
//Oracle インターフェース |
|
370 |
string strcmd = ""; |
|
371 |
ArrayList arData = new ArrayList(); |
|
372 |
int iRet = 0; |
|
373 |
try |
|
374 |
{ |
|
375 |
// SQL作成 |
|
376 |
strcmd = "SELECT MAX(DisplayOrder) FROM ConstructionWorkMaster" + AddSQLString; |
|
377 |
|
|
378 |
// SQL実行 |
|
379 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return iRet; |
|
380 |
|
|
381 |
// データセット |
|
382 |
foreach (object[] objwrk in arData) |
|
383 |
{ |
|
384 |
if (objwrk[0].ToString().Equals("null")) |
|
385 |
iRet = 0; |
|
386 |
else |
|
387 |
iRet = int.Parse(objwrk[0].ToString()); |
|
388 |
} |
|
389 |
|
|
390 |
} |
|
391 |
catch (Exception ex) |
|
392 |
{ |
|
393 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
394 |
} |
|
395 |
|
|
396 |
return iRet; |
|
397 |
} |
|
398 |
#endregion |
|
399 |
} |
|
400 |
} |
trunk/src/ProcessManagement/ProcessManagement/DB/IOAccess/IOMConstructionItemOLD.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Collections; |
|
6 |
|
|
7 |
using log4net; |
|
8 |
using Oracle.ManagedDataAccess.Client; |
|
9 |
|
|
10 |
using ProcessManagement.DB.Oracle; |
|
11 |
using ProcessManagement.DB.Core; |
|
12 |
using ProcessManagement.DataModel; |
|
13 |
|
|
14 |
using ProcessManagement.Common; |
|
15 |
|
|
16 |
namespace ProcessManagement.DB.IOAccess |
|
17 |
{ |
|
18 |
/// <summary> |
|
19 |
/// 工事項目マスタアクセスクラス |
|
20 |
/// </summary> |
|
21 |
public class IOMConstructionItemOLD : OracleProcess |
|
22 |
{ |
|
23 |
#region 定義部 |
|
24 |
/// <summary> |
|
25 |
/// log4netログを使用する |
|
26 |
/// </summary> |
|
27 |
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
|
28 |
#endregion |
|
29 |
|
|
30 |
#region 定数 |
|
31 |
/// <summary> |
|
32 |
/// 工事項目マスタフィールド並び |
|
33 |
/// </summary> |
|
34 |
public enum NameColumn |
|
35 |
{ |
|
36 |
ComponentCode = 0, |
|
37 |
ItemCode, |
|
38 |
DisplayOrder, |
|
39 |
ItemName, |
|
40 |
SubitemsFlg, |
|
41 |
DeleteFlg, |
|
42 |
EntryDate, |
|
43 |
UpdateDate, |
|
44 |
} |
|
45 |
#endregion |
|
46 |
|
|
47 |
#region コンストラクタ |
|
48 |
/// <summary> |
|
49 |
/// コンストラクタ |
|
50 |
/// </summary> |
|
51 |
/// <param name="ConnectionString"></param> |
|
52 |
public IOMConstructionItemOLD() |
|
53 |
: base(DBCommon.Instance.DBConnectString) |
|
54 |
{ |
|
55 |
} |
|
56 |
|
|
57 |
#endregion |
|
58 |
|
|
59 |
#region パブリックメソッド |
|
60 |
/// <summary> |
|
61 |
/// 工事項目マスタ検索 |
|
62 |
/// </summary> |
|
63 |
/// <param name="AddSQLString">検索条件SQL文字列</param> |
|
64 |
/// <param name="data">工事項目マスタデータ</param> |
|
65 |
/// <returns>true:成功 false:失敗</returns> |
|
66 |
private string CreateSelectSQL() |
|
67 |
{ |
|
68 |
// SQL作成(oracleのDateTime型が変換できないのでCharに変換しておく) |
|
69 |
string strcmd = "SELECT"; |
|
70 |
strcmd += " ComponentCode"; |
|
71 |
strcmd += " ,ItemCode"; |
|
72 |
strcmd += " ,DisplayOrder"; |
|
73 |
strcmd += " ,ItemName"; |
|
74 |
strcmd += " ,SubitemsFlg"; |
|
75 |
strcmd += " ,DeleteFlg"; |
|
76 |
strcmd += " ,TO_CHAR(EntryDate, 'YYYY/MM/DD HH24:MI:ss')"; |
|
77 |
strcmd += " ,TO_CHAR(UpdateDate, 'YYYY/MM/DD HH24:MI:ss')"; |
|
78 |
strcmd += " FROM ConstructionItemMaster_OLD"; |
|
79 |
|
|
80 |
return strcmd; |
|
81 |
} |
|
82 |
public bool SelectAction(string AddSQLString, ref List<ConstructionItemOLDMaster> data, bool bConnect = true) |
|
83 |
{ |
|
84 |
//Oracle インターフェース |
|
85 |
string strcmd = ""; |
|
86 |
ArrayList arData = new ArrayList(); |
|
87 |
|
|
88 |
try |
|
89 |
{ |
|
90 |
// SQL作成(oracleのDateTime型が変換できないのでCharに変換しておく) |
|
91 |
strcmd = CreateSelectSQL() + AddSQLString; |
|
92 |
|
|
93 |
// SQL実行 |
|
94 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return false; |
|
95 |
|
|
96 |
// データセット |
|
97 |
foreach (object[] objwrk in arData) |
|
98 |
{ |
|
99 |
ConstructionItemOLDMaster work = new ConstructionItemOLDMaster(); |
|
100 |
Reader2Struct(objwrk, ref work); |
|
101 |
data.Add(work); |
|
102 |
} |
|
103 |
|
|
104 |
return true; |
|
105 |
} |
|
106 |
catch (Exception ex) |
|
107 |
{ |
|
108 |
logger.ErrorFormat("システムエラー::{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
109 |
return false; |
|
110 |
} |
|
111 |
|
|
112 |
} |
|
113 |
public bool SelectAction(string AddSQLString, ref ConstructionItemOLDMaster data, bool bConnect = true) |
|
114 |
{ |
|
115 |
//Oracle インターフェース |
|
116 |
string strcmd = ""; |
|
117 |
ArrayList arData = new ArrayList(); |
|
118 |
|
|
119 |
try |
|
120 |
{ |
|
121 |
// SQL作成(oracleのDateTime型が変換できないのでCharに変換しておく) |
|
122 |
strcmd = CreateSelectSQL() + AddSQLString; |
|
123 |
|
|
124 |
// SQL実行 |
|
125 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return false; |
|
126 |
// データ無 |
|
127 |
if (arData.Count == 0) return false; |
|
128 |
|
|
129 |
// データセット |
|
130 |
foreach (object[] objwrk in arData) |
|
131 |
{ |
|
132 |
Reader2Struct(objwrk, ref data); |
|
133 |
break; |
|
134 |
} |
|
135 |
|
|
136 |
return true; |
|
137 |
} |
|
138 |
catch (Exception ex) |
|
139 |
{ |
|
140 |
logger.ErrorFormat("システムエラー::{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
141 |
return false; |
|
142 |
} |
|
143 |
|
|
144 |
} |
|
145 |
|
|
146 |
/// <summary> |
|
147 |
/// 工事項目マスタ追加 |
|
148 |
/// </summary> |
|
149 |
/// <param name="data">工事項目マスタデータ</param> |
|
150 |
/// <returns>true:成功 false:失敗</returns> |
|
151 |
public bool InsertAction(List<ConstructionItemOLDMaster> data, bool bConnect = true) |
|
152 |
{ |
|
153 |
string strcmd = ""; |
|
154 |
try |
|
155 |
{ |
|
156 |
|
|
157 |
foreach (ConstructionItemOLDMaster work in data) |
|
158 |
{ |
|
159 |
strcmd = "INSERT INTO ConstructionItemMaster_OLD"; |
|
160 |
|
|
161 |
strcmd += " VALUES ("; |
|
162 |
|
|
163 |
strcmd += string.Format(" {0}", work.ComponentCode.ToString()); |
|
164 |
strcmd += string.Format(", {0}", work.ItemCode.ToString()); |
|
165 |
strcmd += string.Format(", {0}", work.DisplayOrder.ToString()); |
|
166 |
strcmd += string.Format(", '{0}'", work.ItemName); |
|
167 |
strcmd += string.Format(", {0}", work.SubitemsFlg.ToString()); |
|
168 |
strcmd += string.Format(", {0}", work.DeleteFlg.ToString()); |
|
169 |
|
|
170 |
strcmd += ", TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
171 |
strcmd += ", TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
172 |
strcmd = strcmd + ")"; |
|
173 |
|
|
174 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
175 |
} |
|
176 |
return true; |
|
177 |
} |
|
178 |
catch (Exception ex) |
|
179 |
{ |
|
180 |
logger.ErrorFormat("システムエラー::{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
181 |
return false; |
|
182 |
} |
|
183 |
} |
|
184 |
|
|
185 |
/// <summary> |
|
186 |
/// 工事項目マスタ更新 |
|
187 |
/// </summary> |
|
188 |
/// <param name="AddSQLString">更新条件SQL文字列</param> |
|
189 |
/// <param name="data">工事項目マスタデータ</param> |
|
190 |
/// <returns>true:成功 false:失敗</returns> |
|
191 |
public bool UpdateAction(string AddSQLString, ConstructionItemOLDMaster data, bool bConnect = true) |
|
192 |
{ |
|
193 |
string strcmd = ""; |
|
194 |
try |
|
195 |
{ |
|
196 |
|
|
197 |
strcmd = "UPDATE ConstructionItemMaster_OLD"; |
|
198 |
|
|
199 |
strcmd += " SET"; |
|
200 |
|
|
201 |
strcmd += string.Format(" ComponentCode = {0}", data.ComponentCode.ToString()); |
|
202 |
strcmd += string.Format(",ItemCode = {0}", data.ItemCode.ToString()); |
|
203 |
strcmd += string.Format(",DisplayOrder = {0}", data.DisplayOrder.ToString()); |
|
204 |
strcmd += string.Format(",ItemName = '{0}'", data.ItemName); |
|
205 |
strcmd += string.Format(",SubitemsFlg = {0}", data.SubitemsFlg.ToString()); |
|
206 |
strcmd += string.Format(",DeleteFlg = {0}", data.DeleteFlg.ToString()); |
|
207 |
|
|
208 |
strcmd += ", UpdateDate = TO_DATE(TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS'),'YYYY/MM/DD HH24:MI:SS')"; |
|
209 |
strcmd += AddSQLString; |
|
210 |
|
|
211 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
212 |
|
|
213 |
return true; |
|
214 |
} |
|
215 |
catch (Exception ex) |
|
216 |
{ |
|
217 |
logger.ErrorFormat("システムエラー::{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
218 |
return false; |
|
219 |
} |
|
220 |
} |
|
221 |
|
|
222 |
|
|
223 |
/// <summary> |
|
224 |
/// 工事項目マスタ削除 |
|
225 |
/// </summary> |
|
226 |
/// <param name="AddSQLString">削除条件SQL文字列</param> |
|
227 |
/// <param name="data">工事項目マスタデータ</param> |
|
228 |
/// <returns>true:成功 false:失敗</returns> |
|
229 |
public bool DeleteAction(string AddSQLString, bool bConnect = true) |
|
230 |
{ |
|
231 |
//Oracle インターフェース |
|
232 |
string strcmd = ""; |
|
233 |
try |
|
234 |
{ |
|
235 |
strcmd = string.Format("{0}{1}", "DELETE FROM ConstructionItemMaster_OLD", AddSQLString); |
|
236 |
|
|
237 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
238 |
|
|
239 |
return true; |
|
240 |
} |
|
241 |
catch (Exception ex) |
|
242 |
{ |
|
243 |
logger.ErrorFormat("システムエラー::{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
244 |
return false; |
|
245 |
} |
|
246 |
} |
|
247 |
|
|
248 |
/// <summary> |
|
249 |
/// 論理削除 |
|
250 |
/// </summary> |
|
251 |
/// <param name="ItemCode">カテゴリタイプ</param> |
|
252 |
/// <param name="Key2">名称コード</param> |
|
253 |
/// <param name="Key3">登録履歴</param> |
|
254 |
/// <returns>成功時:true 失敗時:false</returns> |
|
255 |
public bool LogicalDeleteAction(int ComponentCode, int ItemCode, bool bConnect = true) |
|
256 |
{ |
|
257 |
// Where文字列作成 |
|
258 |
string strWhere = CreatePrimarykeyString(ComponentCode, ItemCode); |
|
259 |
try |
|
260 |
{ |
|
261 |
List<ConstructionItemOLDMaster> workList = new List<ConstructionItemOLDMaster>(); |
|
262 |
// データ読込 |
|
263 |
if (SelectAction(strWhere, ref workList, bConnect)) |
|
264 |
{ |
|
265 |
if (workList.Count == 0) return true; |
|
266 |
|
|
267 |
// 削除フラグ |
|
268 |
workList[0].DeleteFlg = 1; |
|
269 |
// データ更新 |
|
270 |
if (!UpdateAction(strWhere, workList[0], bConnect)) |
|
271 |
{ |
|
272 |
rollback(); |
|
273 |
return false; |
|
274 |
} |
|
275 |
} |
|
276 |
return true; |
|
277 |
} |
|
278 |
catch (Exception ex) |
|
279 |
{ |
|
280 |
logger.ErrorFormat("システムエラー::{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strWhere); |
|
281 |
return false; |
|
282 |
} |
|
283 |
} |
|
284 |
/// <summary> |
|
285 |
/// OracleDataReaderより構造体へセットする |
|
286 |
/// </summary> |
|
287 |
/// <param name="reader">OracleDataReader</param> |
|
288 |
/// <param name="wrk">構造体</param> |
|
289 |
public void Reader2Struct(object[] objwrk, ref ConstructionItemOLDMaster wrk) |
|
290 |
{ |
|
291 |
try |
|
292 |
{ |
|
293 |
// データ取得 |
|
294 |
wrk.ComponentCode = CommonMotions.cnvInt(objwrk[(int)NameColumn.ComponentCode].ToString()); |
|
295 |
wrk.ItemCode = CommonMotions.cnvInt(objwrk[(int)NameColumn.ItemCode].ToString()); |
|
296 |
wrk.DisplayOrder = CommonMotions.cnvInt(objwrk[(int)NameColumn.DisplayOrder].ToString()); |
|
297 |
wrk.ItemName = objwrk[(int)NameColumn.ItemName].ToString(); |
|
298 |
wrk.SubitemsFlg = CommonMotions.cnvInt(objwrk[(int)NameColumn.SubitemsFlg].ToString()); |
|
299 |
wrk.DeleteFlg = CommonMotions.cnvInt(objwrk[(int)NameColumn.DeleteFlg].ToString()); |
|
300 |
|
|
301 |
wrk.EntryDate = DateTime.Parse(objwrk[(int)NameColumn.EntryDate].ToString()); |
|
302 |
wrk.UpdateDate = DateTime.Parse(objwrk[(int)NameColumn.UpdateDate].ToString()); |
|
303 |
} |
|
304 |
catch (OracleException oraex) |
|
305 |
{ |
|
306 |
logger.ErrorFormat("オラクルエラー:{0}:{1}", CommonMotions.GetMethodName(), oraex.Message); |
|
307 |
} |
|
308 |
catch (Exception ex) |
|
309 |
{ |
|
310 |
logger.ErrorFormat("システムエラー::{0}:{1}:{2}", CommonMotions.GetMethodName(), ex.Message); |
|
311 |
} |
|
312 |
} |
|
313 |
|
|
314 |
#endregion |
|
315 |
|
|
316 |
#region パブリックメソッド(特殊処理) |
|
317 |
|
|
318 |
/// <summary> |
|
319 |
/// 最大値を取得する |
|
320 |
/// </summary> |
|
321 |
/// <param name="AddSQLString"></param> |
|
322 |
/// <param name="bConnect"></param> |
|
323 |
/// <returns></returns> |
|
324 |
public int SelectMaxItemCodeCount(string AddSQLString, bool bConnect = true) |
|
325 |
{ |
|
326 |
//Oracle インターフェース |
|
327 |
string strcmd = ""; |
|
328 |
ArrayList arData = new ArrayList(); |
|
329 |
int iRet = 0; |
|
330 |
try |
|
331 |
{ |
|
332 |
// SQL作成 |
|
333 |
strcmd = "SELECT MAX(ItemCode) FROM ConstructionItemMaster_OLD" + AddSQLString; |
|
334 |
|
|
335 |
// SQL実行 |
|
336 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return iRet; |
|
337 |
|
|
338 |
// データセット |
|
339 |
foreach (object[] objwrk in arData) |
他の形式にエクスポート: Unified diff