リビジョン 64
請求入力処理変更に伴う不要ファイル削除
branches/src/ProcessManagement/ProcessManagement/DB/IOAccess/IORequestTotalData.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Threading.Tasks; |
|
6 |
using System.Collections; |
|
7 |
|
|
8 |
using log4net; |
|
9 |
using MySql.Data.MySqlClient; |
|
10 |
|
|
11 |
using ProcessManagement.DB.MySql; |
|
12 |
using ProcessManagement.DB.Core; |
|
13 |
using ProcessManagement.DataModel; |
|
14 |
|
|
15 |
using ProcessManagement.Common; |
|
16 |
|
|
17 |
namespace ProcessManagement.DB.IOAccess |
|
18 |
{ |
|
19 |
/// <summary> |
|
20 |
/// 請求合計データアクセスクラス |
|
21 |
/// </summary> |
|
22 |
public class IORequestTotalData : MySqlProcess |
|
23 |
{ |
|
24 |
#region 定義部 |
|
25 |
/// <summary> |
|
26 |
/// log4netログを使用する |
|
27 |
/// </summary> |
|
28 |
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
|
29 |
#endregion |
|
30 |
|
|
31 |
#region 定数 |
|
32 |
/// <summary> |
|
33 |
/// 請求データフィールド並び |
|
34 |
/// </summary> |
|
35 |
public enum NameColumn |
|
36 |
{ |
|
37 |
RequestNo = 0, |
|
38 |
OrderNo, |
|
39 |
OrderersDivision, |
|
40 |
OrderersCode, |
|
41 |
BillCreationDate, |
|
42 |
BillTotalPrice, |
|
43 |
BillPrice, |
|
44 |
TaxPrice, |
|
45 |
AmountBlance, |
|
46 |
AmountPaid, |
|
47 |
PricePaid, |
|
48 |
TaxPricePaid, |
|
49 |
PriceBalance, |
|
50 |
TaxBalance, |
|
51 |
AssignedFlg, |
|
52 |
ENTRY_DATE, |
|
53 |
UPDATE_DATE, |
|
54 |
} |
|
55 |
#endregion |
|
56 |
|
|
57 |
#region コンストラクタ |
|
58 |
public IORequestTotalData() |
|
59 |
: base(DBCommon.Instance.DBConnectString) |
|
60 |
{ |
|
61 |
} |
|
62 |
#endregion |
|
63 |
|
|
64 |
#region 請求合計データ検索 |
|
65 |
public bool SelectAction(string AddSQLString, ref List<RequestTotalData> data, bool bConnect = true) |
|
66 |
{ |
|
67 |
//Oracle インターフェース |
|
68 |
string strcmd = ""; |
|
69 |
ArrayList arData = new ArrayList(); |
|
70 |
|
|
71 |
try |
|
72 |
{ |
|
73 |
// SQL作成(oracleのDateTime型が変換できないのでCharに変換しておく) |
|
74 |
strcmd = "SELECT"; |
|
75 |
strcmd += " RequestNo"; |
|
76 |
strcmd += " ,OrderNo"; |
|
77 |
strcmd += " ,OrderersDivision"; |
|
78 |
strcmd += " ,OrderersCode"; |
|
79 |
strcmd += " ,DATE_FORMAT(BillCreationDate, '%Y/%m/%d')"; |
|
80 |
strcmd += " ,BillTotalPrice"; |
|
81 |
strcmd += " ,BillPrice"; |
|
82 |
strcmd += " ,TaxPrice"; |
|
83 |
strcmd += " ,AmountBlance"; |
|
84 |
strcmd += " ,AmountPaid"; |
|
85 |
strcmd += " ,PricePaid"; |
|
86 |
strcmd += " ,TaxPricePaid"; |
|
87 |
strcmd += " ,PriceBalance"; |
|
88 |
strcmd += " ,TaxBalance"; |
|
89 |
strcmd += " ,AssignedFlg"; |
|
90 |
strcmd += " ,DATE_FORMAT(EntryDate, '%Y/%m/%d %H:%i:%s')"; |
|
91 |
strcmd += " ,DATE_FORMAT(UpdateDate, '%Y/%m/%d %H:%i:%s')"; |
|
92 |
strcmd += " FROM RequestTotalData"; |
|
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 |
RequestTotalData work = new RequestTotalData(); |
|
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 |
#endregion |
|
115 |
|
|
116 |
#region 請求合計データ複数追加 |
|
117 |
/// <summary> |
|
118 |
/// 請求合計データ複数追加 |
|
119 |
/// </summary> |
|
120 |
/// <param name="data">請求合計データ</param> |
|
121 |
/// <returns>true:成功 false:失敗</returns> |
|
122 |
public bool InsertAction(List<RequestTotalData> data, bool bConnect = true) |
|
123 |
{ |
|
124 |
string strcmd = ""; |
|
125 |
try |
|
126 |
{ |
|
127 |
|
|
128 |
foreach (RequestTotalData work in data) |
|
129 |
{ |
|
130 |
if (!InsertAction(work, bConnect)) return false; |
|
131 |
} |
|
132 |
return true; |
|
133 |
} |
|
134 |
catch (Exception ex) |
|
135 |
{ |
|
136 |
logger.ErrorFormat("システムエラー::{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
137 |
return false; |
|
138 |
} |
|
139 |
} |
|
140 |
#endregion |
|
141 |
|
|
142 |
#region 請求合計データ1件追加 |
|
143 |
/// <summary> |
|
144 |
/// 請求合計データ1件追加 |
|
145 |
/// </summary> |
|
146 |
/// <param name="data"></param> |
|
147 |
/// <param name="bConnect"></param> |
|
148 |
/// <returns></returns> |
|
149 |
public bool InsertAction(RequestTotalData data, bool bConnect = true) |
|
150 |
{ |
|
151 |
string strcmd = ""; |
|
152 |
try |
|
153 |
{ |
|
154 |
|
|
155 |
strcmd = "INSERT INTO RequestTotalData"; |
|
156 |
|
|
157 |
strcmd += " VALUES ("; |
|
158 |
|
|
159 |
strcmd += string.Format(" {0}", data.RequestNo.ToString()); |
|
160 |
strcmd += string.Format(", {0}", data.OrderNo.ToString()); |
|
161 |
strcmd += string.Format(", {0}", data.OrderersDivision.ToString()); |
|
162 |
strcmd += string.Format(", {0}", data.OrderersCode.ToString()); |
|
163 |
strcmd += string.Format(", DATE_FORMAT('{0}','%Y/%m/%d')", data.BillCreationDate.ToShortDateString()); |
|
164 |
strcmd += string.Format(", {0}", data.BillTotalPrice.ToString()); |
|
165 |
strcmd += string.Format(", {0}", data.BillPrice.ToString()); |
|
166 |
strcmd += string.Format(", {0}", data.TaxPrice.ToString()); |
|
167 |
strcmd += string.Format(", {0}", data.AmountBlance.ToString()); |
|
168 |
strcmd += string.Format(", {0}", data.AmountPaid.ToString()); |
|
169 |
strcmd += string.Format(", {0}", data.PricePaid.ToString()); |
|
170 |
strcmd += string.Format(", {0}", data.TaxPricePaid.ToString()); |
|
171 |
strcmd += string.Format(", {0}", data.PriceBalance.ToString()); |
|
172 |
strcmd += string.Format(", {0}", data.TaxBalance.ToString()); |
|
173 |
strcmd += string.Format(", {0}", (data.AssignedFlg ? 1 : 0).ToString()); |
|
174 |
|
|
175 |
strcmd += ", DATE_FORMAT(DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s'),'%Y/%m/%d %H:%i:%s')"; |
|
176 |
strcmd += ", DATE_FORMAT(DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s'),'%Y/%m/%d %H:%i:%s')"; |
|
177 |
strcmd = strcmd + ")"; |
|
178 |
|
|
179 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
180 |
|
|
181 |
return true; |
|
182 |
} |
|
183 |
catch (Exception ex) |
|
184 |
{ |
|
185 |
logger.ErrorFormat("システムエラー::{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
186 |
return false; |
|
187 |
} |
|
188 |
} |
|
189 |
#endregion |
|
190 |
|
|
191 |
#region 請求合計データ更新 |
|
192 |
/// <summary> |
|
193 |
/// 請求合計データ更新 |
|
194 |
/// </summary> |
|
195 |
/// <param name="AddSQLString">更新条件SQL文字列</param> |
|
196 |
/// <param name="data">請求合計データ</param> |
|
197 |
/// <returns>true:成功 false:失敗</returns> |
|
198 |
public bool UpdateAction(string AddSQLString, RequestTotalData data, bool bConnect = true) |
|
199 |
{ |
|
200 |
string strcmd = ""; |
|
201 |
try |
|
202 |
{ |
|
203 |
|
|
204 |
strcmd = "UPDATE RequestTotalData"; |
|
205 |
|
|
206 |
strcmd += " SET"; |
|
207 |
|
|
208 |
// strcmd += string.Format(" RequestNo = {0}", data.RequestNo.ToString()); |
|
209 |
// strcmd += string.Format(",OrderNo = {0}", data.OrderNo.ToString()); |
|
210 |
strcmd += string.Format(" OrderersDivision = {0}", data.OrderersDivision.ToString()); |
|
211 |
strcmd += string.Format(",OrderersCode = {0}", data.OrderersCode.ToString()); |
|
212 |
strcmd += string.Format(",BillCreationDate = DATE_FORMAT('{0}','%Y/%m/%d')", data.BillCreationDate.ToShortDateString()); |
|
213 |
strcmd += string.Format(",BillTotalPrice = {0}", data.BillTotalPrice.ToString()); |
|
214 |
strcmd += string.Format(",BillPrice = {0}", data.BillPrice.ToString()); |
|
215 |
strcmd += string.Format(",TaxPrice = {0}", data.TaxPrice.ToString()); |
|
216 |
strcmd += string.Format(",AmountBlance = {0}", data.AmountBlance.ToString()); |
|
217 |
strcmd += string.Format(",AmountPaid = {0}", data.AmountPaid.ToString()); |
|
218 |
strcmd += string.Format(",PricePaid = {0}", data.PricePaid.ToString()); |
|
219 |
strcmd += string.Format(",TaxPricePaid = {0}", data.TaxPricePaid.ToString()); |
|
220 |
strcmd += string.Format(",PriceBalance = {0}", data.PriceBalance.ToString()); |
|
221 |
strcmd += string.Format(",TaxBalance = {0}", data.TaxBalance.ToString()); |
|
222 |
strcmd += string.Format(",AssignedFlg = {0}", (data.AssignedFlg ? 1 : 0).ToString()); |
|
223 |
strcmd += ", UpdateDate = DATE_FORMAT(DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s'),'%Y/%m/%d %H:%i:%s')"; |
|
224 |
strcmd += string.Format(" Where RequestNo = {0}", data.RequestNo.ToString()); |
|
225 |
strcmd += string.Format(" And OrderNo = {0}", data.OrderNo.ToString()); |
|
226 |
strcmd += AddSQLString; |
|
227 |
|
|
228 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
229 |
|
|
230 |
return true; |
|
231 |
} |
|
232 |
catch (Exception ex) |
|
233 |
{ |
|
234 |
logger.ErrorFormat("システムエラー::{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
235 |
return false; |
|
236 |
} |
|
237 |
} |
|
238 |
#endregion |
|
239 |
|
|
240 |
#region 請求合計データ削除 |
|
241 |
/// <summary> |
|
242 |
/// 請求合計データ削除 |
|
243 |
/// </summary> |
|
244 |
/// <param name="AddSQLString">削除条件SQL文字列</param> |
|
245 |
/// <param name="bConnect"></param> |
|
246 |
/// <returns></returns> |
|
247 |
public bool DeleteAction(string AddSQLString, bool bConnect = true) |
|
248 |
{ |
|
249 |
//Oracle インターフェース |
|
250 |
string strcmd = ""; |
|
251 |
try |
|
252 |
{ |
|
253 |
strcmd = string.Format("{0}{1}", "DELETE FROM RequestTotalData", AddSQLString); |
|
254 |
|
|
255 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
256 |
|
|
257 |
return true; |
|
258 |
} |
|
259 |
catch (Exception ex) |
|
260 |
{ |
|
261 |
logger.ErrorFormat("システムエラー::{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
262 |
return false; |
|
263 |
} |
|
264 |
} |
|
265 |
#endregion |
|
266 |
|
|
267 |
#region OracleDataReaderより構造体へセットする |
|
268 |
/// <summary> |
|
269 |
/// OracleDataReaderより構造体へセットする |
|
270 |
/// </summary> |
|
271 |
/// <param name="reader">OracleDataReader</param> |
|
272 |
/// <param name="wrk">構造体</param> |
|
273 |
public void Reader2Struct(object[] objwrk, ref RequestTotalData wrk) |
|
274 |
{ |
|
275 |
try |
|
276 |
{ |
|
277 |
// データ取得 |
|
278 |
wrk.RequestNo = int.Parse(objwrk[(int)NameColumn.RequestNo].ToString()); |
|
279 |
wrk.OrderNo = int.Parse(objwrk[(int)NameColumn.OrderNo].ToString()); |
|
280 |
wrk.OrderersDivision = int.Parse(objwrk[(int)NameColumn.OrderersDivision].ToString()); |
|
281 |
wrk.OrderersCode = int.Parse(objwrk[(int)NameColumn.OrderersCode].ToString()); |
|
282 |
wrk.BillCreationDate = DateTime.Parse(objwrk[(int)NameColumn.BillCreationDate].ToString()); |
|
283 |
wrk.BillTotalPrice = int.Parse(objwrk[(int)NameColumn.BillTotalPrice].ToString()); |
|
284 |
wrk.BillPrice = int.Parse(objwrk[(int)NameColumn.BillPrice].ToString()); |
|
285 |
wrk.TaxPrice = int.Parse(objwrk[(int)NameColumn.TaxPrice].ToString()); |
|
286 |
wrk.AmountBlance = int.Parse(objwrk[(int)NameColumn.AmountBlance].ToString()); |
|
287 |
wrk.AmountPaid = int.Parse(objwrk[(int)NameColumn.AmountPaid].ToString()); |
|
288 |
wrk.PricePaid = int.Parse(objwrk[(int)NameColumn.PricePaid].ToString()); |
|
289 |
wrk.TaxPricePaid = int.Parse(objwrk[(int)NameColumn.TaxPricePaid].ToString()); |
|
290 |
wrk.PriceBalance = int.Parse(objwrk[(int)NameColumn.PriceBalance].ToString()); |
|
291 |
wrk.TaxBalance = int.Parse(objwrk[(int)NameColumn.TaxBalance].ToString()); |
|
292 |
wrk.AssignedFlg = int.Parse(objwrk[(int)NameColumn.TaxBalance].ToString()) == 1 ? true : false; |
|
293 |
|
|
294 |
wrk.EntryDate = DateTime.Parse(objwrk[(int)NameColumn.ENTRY_DATE].ToString()); |
|
295 |
wrk.UpdateDate = DateTime.Parse(objwrk[(int)NameColumn.UPDATE_DATE].ToString()); |
|
296 |
} |
|
297 |
catch (MySqlException myex) |
|
298 |
{ |
|
299 |
logger.ErrorFormat("MySQLエラー:{0}:{1}", CommonMotions.GetMethodName(2), myex.Message); |
|
300 |
} |
|
301 |
catch (Exception ex) |
|
302 |
{ |
|
303 |
logger.ErrorFormat("システムエラー::{0}:{1}:{2}", CommonMotions.GetMethodName(), ex.Message); |
|
304 |
} |
|
305 |
} |
|
306 |
#endregion |
|
307 |
|
|
308 |
#region 構造体クリア |
|
309 |
/// <summary> |
|
310 |
/// 構造体クリア |
|
311 |
/// </summary> |
|
312 |
/// <param name="wrk"></param> |
|
313 |
public void ClearStruct(ref RequestTotalData wrk) |
|
314 |
{ |
|
315 |
try |
|
316 |
{ |
|
317 |
// データ取得 |
|
318 |
wrk.RequestNo = 0; |
|
319 |
wrk.OrderNo = 0; |
|
320 |
wrk.OrderersDivision = 0; |
|
321 |
wrk.OrderersCode = 0; |
|
322 |
wrk.BillCreationDate = DateTime.MinValue; |
|
323 |
wrk.BillTotalPrice = 0; |
|
324 |
wrk.BillPrice = 0; |
|
325 |
wrk.TaxPrice = 0; |
|
326 |
wrk.AmountBlance = 0; |
|
327 |
wrk.AmountPaid = 0; |
|
328 |
wrk.PricePaid = 0; |
|
329 |
wrk.TaxPricePaid = 0; |
|
330 |
wrk.PriceBalance = 0; |
|
331 |
wrk.TaxBalance = 0; |
|
332 |
wrk.AssignedFlg = false; |
|
333 |
|
|
334 |
wrk.EntryDate = DateTime.Now; |
|
335 |
wrk.UpdateDate = DateTime.Now; |
|
336 |
} |
|
337 |
catch (MySqlException myex) |
|
338 |
{ |
|
339 |
logger.ErrorFormat("MySQLエラー:{0}:{1}", CommonMotions.GetMethodName(2), myex.Message); |
|
340 |
} |
|
341 |
catch (Exception ex) |
|
342 |
{ |
|
343 |
logger.ErrorFormat("システムエラー::{0}:{1}:{2}", CommonMotions.GetMethodName(), ex.Message); |
|
344 |
} |
|
345 |
} |
|
346 |
#endregion |
|
347 |
|
|
348 |
#region 主キー検索の文字列を返す |
|
349 |
/// <summary> |
|
350 |
/// 主キー検索の文字列を返す |
|
351 |
/// </summary> |
|
352 |
/// <param name="BusinessTypeCode"></param> |
|
353 |
/// <returns>Where文字列</returns> |
|
354 |
public string CreatePrimarykeyString(int RequestNo, int OrderNo = 0) |
|
355 |
{ |
|
356 |
string strWork = string.Empty; |
|
357 |
try |
|
358 |
{ |
|
359 |
strWork = string.Format(" Where RequestNo = {0}", RequestNo.ToString()); |
|
360 |
if (OrderNo != 0) |
|
361 |
strWork += string.Format(" And OrderNo = {0}", OrderNo.ToString()); |
|
362 |
} |
|
363 |
catch (Exception ex) |
|
364 |
{ |
|
365 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strWork); |
|
366 |
} |
|
367 |
|
|
368 |
return strWork; |
|
369 |
} |
|
370 |
#endregion |
|
371 |
|
|
372 |
} |
|
373 |
} |
他の形式にエクスポート: Unified diff