リビジョン 189
未使用データ削除
見積書バグ修正
メニュー承認画面変更
協力会社検索、増減工事内は同じ内容を検索できるように変更
StringBuilder化途中
branches/src/ProcessManagement/ProcessManagement/Common/CommonMotions.cs | ||
---|---|---|
2555 | 2555 |
{ |
2556 | 2556 |
int RetSalary = 0; |
2557 | 2557 |
|
2558 |
string strSQL = "SELECT SUM(SAL.SALARY) FROM"; |
|
2559 |
strSQL += " (SELECT AX.hiduke,"; |
|
2560 |
strSQL += string.Format(" ROUND((AX.salary * {0}) / DATE_FORMAT(LAST_DAY(AX.hiduke), '%d')) AS SALARY,", CommonDefine.s_SalaryCorrection); |
|
2561 |
strSQL += " MAX(AX.StartD) FROM"; |
|
2562 |
strSQL += " (SELECT A.d hiduke, B.MonthlySalary salary, B.STARTDATE StartD FROM"; |
|
2558 |
StringBuilder strSQL = new StringBuilder(1200); |
|
2559 |
strSQL.Append("SELECT SUM(SAL.SALARY) FROM"); |
|
2560 |
strSQL.Append(" (SELECT AX.hiduke,"); |
|
2561 |
strSQL.AppendFormat(" ROUND((AX.salary * {0}) / DATE_FORMAT(LAST_DAY(AX.hiduke), '%d')) AS SALARY,", CommonDefine.s_SalaryCorrection); |
|
2562 |
strSQL.Append(" MAX(AX.StartD) FROM"); |
|
2563 |
strSQL.Append(" (SELECT A.d hiduke, B.MonthlySalary salary, B.STARTDATE StartD FROM"); |
|
2563 | 2564 |
|
2564 |
strSQL += " (SELECT A1.years, A2.month, A3.days, DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) AS d";
|
|
2565 |
strSQL += " FROM yearmaster AS A1, monthmaster AS A2, daymaster AS A3";
|
|
2565 |
strSQL.Append(" (SELECT A1.years, A2.month, A3.days, DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) AS d");
|
|
2566 |
strSQL.Append(" FROM yearmaster AS A1, monthmaster AS A2, daymaster AS A3");
|
|
2566 | 2567 |
|
2567 |
strSQL += " WHERE";
|
|
2568 |
strSQL.Append(" WHERE");
|
|
2568 | 2569 |
if (dtStart.Year == dtLast.Year) |
2569 | 2570 |
{ |
2570 |
strSQL += string.Format(" (A1.years = {0} AND A2.month IN(", dtStart.Year.ToString("0000"));
|
|
2571 |
strSQL.AppendFormat(" (A1.years = {0} AND A2.month IN(", dtStart.Year.ToString("0000"));
|
|
2571 | 2572 |
for (int i = dtStart.Month; i <= dtLast.Month; i++) |
2572 | 2573 |
{ |
2573 |
if (i != dtStart.Month) strSQL += ", ";
|
|
2574 |
strSQL += string.Format("{0} ", i);
|
|
2574 |
if (i != dtStart.Month) strSQL.Append(", ");
|
|
2575 |
strSQL.AppendFormat("{0} ", i);
|
|
2575 | 2576 |
} |
2576 |
strSQL += "))";
|
|
2577 |
strSQL.Append("))");
|
|
2577 | 2578 |
} |
2578 | 2579 |
else |
2579 | 2580 |
{ |
2580 |
strSQL += string.Format(" ((A1.years = {0} AND A2.month IN(", dtStart.Year.ToString("0000"));
|
|
2581 |
strSQL.AppendFormat(" ((A1.years = {0} AND A2.month IN(", dtStart.Year.ToString("0000"));
|
|
2581 | 2582 |
for (int i = dtStart.Month; i <= 12; i++) |
2582 | 2583 |
{ |
2583 |
if (i != dtStart.Month) strSQL += ", ";
|
|
2584 |
strSQL += string.Format("{0} ", i);
|
|
2584 |
if (i != dtStart.Month) strSQL.Append(", ");
|
|
2585 |
strSQL.AppendFormat("{0} ", i);
|
|
2585 | 2586 |
} |
2586 |
strSQL += "))";
|
|
2587 |
strSQL += string.Format(" OR (A1.years = {0} AND A2.month IN(", dtLast.Year.ToString("0000"));
|
|
2587 |
strSQL.Append("))");
|
|
2588 |
strSQL.AppendFormat(" OR (A1.years = {0} AND A2.month IN(", dtLast.Year.ToString("0000"));
|
|
2588 | 2589 |
for (int i = 1; i <= dtLast.Month; i++) |
2589 | 2590 |
{ |
2590 |
if (i != 1) strSQL += ", ";
|
|
2591 |
strSQL += string.Format("{0} ", i);
|
|
2591 |
if (i != 1) strSQL.Append(", ");
|
|
2592 |
strSQL.AppendFormat("{0} ", i);
|
|
2592 | 2593 |
} |
2593 |
strSQL += ")))";
|
|
2594 |
strSQL.Append(")))");
|
|
2594 | 2595 |
} |
2595 | 2596 |
|
2596 |
strSQL += " AND DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) IS NOT NULL";
|
|
2597 |
strSQL += string.Format(" AND (DATE('{0}') <= DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days))", dtStart.ToShortDateString());
|
|
2598 |
strSQL += string.Format(" AND DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) <= DATE('{0}'))", dtLast.ToShortDateString());
|
|
2599 |
strSQL += " ORDER BY d) A";
|
|
2600 |
strSQL += ", PERSONSALARYMASTER AS B";
|
|
2601 |
strSQL += " WHERE B.STARTDATE <= A.d";
|
|
2602 |
strSQL += string.Format(" AND B.PERSONCODE = {0}", PersonCode);
|
|
2603 |
strSQL += " ORDER BY A.d, B.STARTDATE DESC) AS AX";
|
|
2604 |
strSQL += " GROUP BY AX.hiduke";
|
|
2605 |
strSQL += " ORDER BY AX.hiduke";
|
|
2606 |
strSQL += " ) SAL";
|
|
2597 |
strSQL.Append(" AND DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) IS NOT NULL");
|
|
2598 |
strSQL.AppendFormat(" AND (DATE('{0}') <= DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days))", dtStart.ToShortDateString());
|
|
2599 |
strSQL.AppendFormat(" AND DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) <= DATE('{0}'))", dtLast.ToShortDateString());
|
|
2600 |
strSQL.Append(" ORDER BY d) A");
|
|
2601 |
strSQL.Append(", PERSONSALARYMASTER AS B");
|
|
2602 |
strSQL.Append(" WHERE B.STARTDATE <= A.d");
|
|
2603 |
strSQL.AppendFormat(" AND B.PERSONCODE = {0}", PersonCode);
|
|
2604 |
strSQL.Append(" ORDER BY A.d, B.STARTDATE DESC) AS AX");
|
|
2605 |
strSQL.Append(" GROUP BY AX.hiduke");
|
|
2606 |
strSQL.Append(" ORDER BY AX.hiduke");
|
|
2607 |
strSQL.Append(" ) SAL");
|
|
2607 | 2608 |
|
2608 | 2609 |
ArrayList ArData = new ArrayList(); |
2609 |
SalDB.ExecuteReader(strSQL, ref ArData); |
|
2610 |
SalDB.ExecuteReader(strSQL.ToString(), ref ArData);
|
|
2610 | 2611 |
|
2611 | 2612 |
foreach (object[] objRec in ArData) |
2612 | 2613 |
{ |
branches/src/ProcessManagement/ProcessManagement/Common/CommonVersion.cs | ||
---|---|---|
14 | 14 |
/// <summary> |
15 | 15 |
/// 本体バージョン |
16 | 16 |
/// </summary> |
17 |
public static int s_SystemVersion = 41;
|
|
17 |
public static int s_SystemVersion = 42;
|
|
18 | 18 |
|
19 | 19 |
/// <summary> |
20 | 20 |
/// コピー・環境バージョン |
branches/src/ProcessManagement/ProcessManagement/Common/Process/ClsExcute.cs | ||
---|---|---|
1234 | 1234 |
// パラメータセット |
1235 | 1235 |
frm.ConstructionCode = CurrentPara.IntExecParameter[0]; |
1236 | 1236 |
frm.OrderNo = CurrentPara.IntExecParameter[1]; |
1237 |
if (CurrentPara.BoolExecParameter.Count > 0) frm.EditLock = CurrentPara.BoolExecParameter[0]; |
|
1237 | 1238 |
|
1238 | 1239 |
// フォーム表示 |
1239 | 1240 |
frm.ShowDialog(); |
branches/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 MySql.Data.MySqlClient; // Data Provider for MySql |
|
10 |
|
|
11 |
using ProcessManagement.DB.MySql; |
|
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 : MySqlProcess |
|
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作成(DateTime型が変換できないのでCharに変換しておく) |
|
86 |
string strcmd = "SELECT"; |
|
87 |
|
|
88 |
strcmd += " PersonCode"; // 担当者コード |
|
89 |
strcmd += " ,DATE_FORMAT(DailyDataDate, '%Y/%m/%d')"; // 日報作成日 |
|
90 |
strcmd += " ,LineCount"; // 行番号 |
|
91 |
strcmd += " ,ConstructionCode"; // 工事番号 |
|
92 |
strcmd += " ,WorkContentsText"; // 作業内容 |
|
93 |
strcmd += ", DATE_FORMAT(EntryDate, '%Y/%m/%d %H:%i:%s')"; |
|
94 |
strcmd += ", DATE_FORMAT(UpdateDate, '%Y/%m/%d %H:%i:%s')"; |
|
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 |
// インターフェース |
|
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 |
// インターフェース |
|
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(", STR_TO_DATE('{0}','%Y/%m/%d')" |
|
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 += ", NOW()"; |
|
189 |
strcmd += ", NOW()"; |
|
190 |
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 = STR_TO_DATE('{0}','%Y/%m/%d')" |
|
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 = NOW()"; |
|
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 |
// インターフェース |
|
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 (MySqlException myex) |
|
312 |
{ |
|
313 |
logger.ErrorFormat("MySQLエラー:{0}:{1}", CommonMotions.GetMethodName(2), myex.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 = STR_TO_DATE('{0}','%Y/%m/%d')", 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 |
} |
branches/src/ProcessManagement/ProcessManagement/DB/IOAccess/IOActionScheduleData.cs | ||
---|---|---|
66 | 66 |
public bool SelectAction(string AddSQLString, ref List<ActionScheduleData> data, bool bConnect = true) |
67 | 67 |
{ |
68 | 68 |
// インターフェース |
69 |
string strcmd = "";
|
|
69 |
StringBuilder strcmd = new StringBuilder();
|
|
70 | 70 |
ArrayList arData = new ArrayList(); |
71 | 71 |
|
72 | 72 |
try |
73 | 73 |
{ |
74 | 74 |
// SQL作成(DateTime型が変換できないのでCharに変換しておく) |
75 |
strcmd = "SELECT";
|
|
76 |
strcmd += " DATE_FORMAT(TargetDate, '%Y/%m/%d')";
|
|
77 |
strcmd += " ,PersonCode";
|
|
78 |
strcmd += " ,ActionSchedule";
|
|
79 |
strcmd += " ,TargetYear";
|
|
80 |
strcmd += " ,TargetMonth";
|
|
81 |
strcmd += " ,TargetDay";
|
|
82 |
strcmd += " ,DATE_FORMAT(EntryDate, '%Y/%m/%d %H:%i:%s')";
|
|
83 |
strcmd += " ,DATE_FORMAT(UpdateDate, '%Y/%m/%d %H:%i:%s')";
|
|
84 |
strcmd += " FROM ActionScheduleData";
|
|
85 |
strcmd += AddSQLString;
|
|
75 |
strcmd.Append("SELECT");
|
|
76 |
strcmd.Append(" DATE_FORMAT(TargetDate, '%Y/%m/%d')");
|
|
77 |
strcmd.Append(" ,PersonCode");
|
|
78 |
strcmd.Append(" ,ActionSchedule");
|
|
79 |
strcmd.Append(" ,TargetYear");
|
|
80 |
strcmd.Append(" ,TargetMonth");
|
|
81 |
strcmd.Append(" ,TargetDay");
|
|
82 |
strcmd.Append(" ,DATE_FORMAT(EntryDate, '%Y/%m/%d %H:%i:%s')");
|
|
83 |
strcmd.Append(" ,DATE_FORMAT(UpdateDate, '%Y/%m/%d %H:%i:%s')");
|
|
84 |
strcmd.Append(" FROM ActionScheduleData");
|
|
85 |
strcmd.Append(AddSQLString);
|
|
86 | 86 |
|
87 | 87 |
// SQL実行 |
88 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return false; |
|
88 |
if (!ExecuteReader(strcmd.ToString(), ref arData, bConnect)) return false;
|
|
89 | 89 |
|
90 | 90 |
// データセット |
91 | 91 |
foreach (object[] objwrk in arData) |
... | ... | |
99 | 99 |
} |
100 | 100 |
catch (Exception ex) |
101 | 101 |
{ |
102 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
102 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
103 | 103 |
return false; |
104 | 104 |
} |
105 | 105 |
|
... | ... | |
114 | 114 |
/// <returns>true:成功 false:失敗</returns> |
115 | 115 |
public bool InsertAction(List<ActionScheduleData> data, bool bConnect = true) |
116 | 116 |
{ |
117 |
string strcmd = "";
|
|
117 |
StringBuilder strcmd = new StringBuilder();
|
|
118 | 118 |
try |
119 | 119 |
{ |
120 | 120 |
|
121 | 121 |
bool bColFirst = true; |
122 |
strcmd = "INSERT INTO ActionScheduleData";
|
|
123 |
strcmd += " (";
|
|
122 |
strcmd.Append("INSERT INTO ActionScheduleData");
|
|
123 |
strcmd.Append(" (");
|
|
124 | 124 |
foreach (var gender in Enum.GetValues(typeof(NameColumn))) |
125 | 125 |
{ |
126 |
if (!bColFirst) strcmd += ", ";
|
|
127 |
strcmd += gender.ToString();
|
|
126 |
if (!bColFirst) strcmd.Append(", ");
|
|
127 |
strcmd.Append(gender.ToString());
|
|
128 | 128 |
bColFirst = false; |
129 | 129 |
} |
130 |
strcmd += ") VALUES";
|
|
130 |
strcmd.Append(") VALUES");
|
|
131 | 131 |
|
132 | 132 |
bool bDataFirst = true; |
133 | 133 |
foreach (ActionScheduleData work in data) |
134 | 134 |
{ |
135 |
if (bDataFirst) strcmd += " (";
|
|
136 |
else strcmd += ", (";
|
|
135 |
if (bDataFirst) strcmd.Append(" (");
|
|
136 |
else strcmd.Append(", (");
|
|
137 | 137 |
|
138 |
strcmd += string.Format(" STR_TO_DATE('{0}','%Y/%m/%d')", work.TargetDate.ToShortDateString());
|
|
139 |
strcmd += string.Format(", {0}", work.PersonCode.ToString());
|
|
140 |
strcmd += string.Format(", '{0}'", work.ActionSchedule);
|
|
141 |
strcmd += string.Format(", {0}", work.TargetYear.ToString());
|
|
142 |
strcmd += string.Format(", {0}", work.TargetMonth.ToString());
|
|
143 |
strcmd += string.Format(", {0}", work.TargetDay.ToString());
|
|
144 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.EntryDate);
|
|
145 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.UpdateDate);
|
|
146 |
strcmd += ")";
|
|
138 |
strcmd.AppendFormat(" STR_TO_DATE('{0}','%Y/%m/%d')", work.TargetDate.ToShortDateString());
|
|
139 |
strcmd.AppendFormat(", {0}", work.PersonCode.ToString());
|
|
140 |
strcmd.AppendFormat(", '{0}'", work.ActionSchedule);
|
|
141 |
strcmd.AppendFormat(", {0}", work.TargetYear.ToString());
|
|
142 |
strcmd.AppendFormat(", {0}", work.TargetMonth.ToString());
|
|
143 |
strcmd.AppendFormat(", {0}", work.TargetDay.ToString());
|
|
144 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.EntryDate);
|
|
145 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.UpdateDate);
|
|
146 |
strcmd.Append(")");
|
|
147 | 147 |
|
148 | 148 |
bDataFirst = false; |
149 | 149 |
} |
150 | 150 |
|
151 |
if (!ExecuteNonQuery(strcmd, false)) return false; |
|
151 |
if (!ExecuteNonQuery(strcmd.ToString(), false)) return false;
|
|
152 | 152 |
|
153 | 153 |
return true; |
154 | 154 |
} |
155 | 155 |
catch (Exception ex) |
156 | 156 |
{ |
157 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
157 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
158 | 158 |
return false; |
159 | 159 |
} |
160 | 160 |
} |
... | ... | |
169 | 169 |
/// <returns></returns> |
170 | 170 |
public bool InsertAction(ActionScheduleData data, bool bConnect = true) |
171 | 171 |
{ |
172 |
string strcmd = "";
|
|
172 |
StringBuilder strcmd = new StringBuilder();
|
|
173 | 173 |
try |
174 | 174 |
{ |
175 | 175 |
|
176 | 176 |
bool bColFirst = true; |
177 |
strcmd = "INSERT INTO ActionScheduleData";
|
|
178 |
strcmd += " (";
|
|
177 |
strcmd.Append("INSERT INTO ActionScheduleData");
|
|
178 |
strcmd.Append(" (");
|
|
179 | 179 |
foreach (var gender in Enum.GetValues(typeof(NameColumn))) |
180 | 180 |
{ |
181 |
if (!bColFirst) strcmd += ", ";
|
|
182 |
strcmd += gender.ToString();
|
|
181 |
if (!bColFirst) strcmd.Append(", ");
|
|
182 |
strcmd.Append(gender.ToString());
|
|
183 | 183 |
bColFirst = false; |
184 | 184 |
} |
185 |
strcmd += ") VALUES (";
|
|
185 |
strcmd.Append(") VALUES (");
|
|
186 | 186 |
|
187 |
strcmd += string.Format(" STR_TO_DATE('{0}','%Y/%m/%d')", data.TargetDate.ToShortDateString());
|
|
188 |
strcmd += string.Format(", {0}", data.PersonCode.ToString());
|
|
189 |
strcmd += string.Format(", '{0}'", data.ActionSchedule);
|
|
190 |
strcmd += string.Format(", {0}", data.TargetYear.ToString());
|
|
191 |
strcmd += string.Format(", {0}", data.TargetMonth.ToString());
|
|
192 |
strcmd += string.Format(", {0}", data.TargetDay.ToString());
|
|
187 |
strcmd.AppendFormat(" STR_TO_DATE('{0}','%Y/%m/%d')", data.TargetDate.ToShortDateString());
|
|
188 |
strcmd.AppendFormat(", {0}", data.PersonCode.ToString());
|
|
189 |
strcmd.AppendFormat(", '{0}'", data.ActionSchedule);
|
|
190 |
strcmd.AppendFormat(", {0}", data.TargetYear.ToString());
|
|
191 |
strcmd.AppendFormat(", {0}", data.TargetMonth.ToString());
|
|
192 |
strcmd.AppendFormat(", {0}", data.TargetDay.ToString());
|
|
193 | 193 |
|
194 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", data.EntryDate);
|
|
195 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", data.UpdateDate);
|
|
196 |
strcmd += ")";
|
|
194 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", data.EntryDate);
|
|
195 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", data.UpdateDate);
|
|
196 |
strcmd.Append(")");
|
|
197 | 197 |
|
198 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
198 |
if (!ExecuteNonQuery(strcmd.ToString(), bConnect)) return false;
|
|
199 | 199 |
|
200 | 200 |
return true; |
201 | 201 |
} |
202 | 202 |
catch (Exception ex) |
203 | 203 |
{ |
204 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
204 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
205 | 205 |
return false; |
206 | 206 |
} |
207 | 207 |
} |
... | ... | |
216 | 216 |
/// <returns>true:成功 false:失敗</returns> |
217 | 217 |
public bool UpdateAction(string AddSQLString, ActionScheduleData data, bool bConnect = true) |
218 | 218 |
{ |
219 |
string strcmd = "";
|
|
219 |
StringBuilder strcmd = new StringBuilder();
|
|
220 | 220 |
try |
221 | 221 |
{ |
222 | 222 |
|
223 |
strcmd = "UPDATE ActionScheduleData";
|
|
223 |
strcmd.Append("UPDATE ActionScheduleData");
|
|
224 | 224 |
|
225 |
strcmd += " SET";
|
|
225 |
strcmd.Append(" SET");
|
|
226 | 226 |
|
227 |
strcmd += string.Format(" TargetDate = STR_TO_DATE('{0}','%Y/%m/%d')", data.TargetDate.ToShortDateString());
|
|
228 |
strcmd += string.Format(",PersonCode = {0}", data.PersonCode.ToString());
|
|
229 |
strcmd += string.Format(",ActionSchedule = '{0}'", data.ActionSchedule);
|
|
230 |
strcmd += string.Format(",TargetYear = {0}", data.TargetYear.ToString());
|
|
231 |
strcmd += string.Format(",TargetMonth = {0}", data.TargetMonth.ToString());
|
|
232 |
strcmd += string.Format(",TargetDay = {0}", data.TargetDay.ToString());
|
|
227 |
strcmd.AppendFormat(" TargetDate = STR_TO_DATE('{0}','%Y/%m/%d')", data.TargetDate.ToShortDateString());
|
|
228 |
strcmd.AppendFormat(",PersonCode = {0}", data.PersonCode.ToString());
|
|
229 |
strcmd.AppendFormat(",ActionSchedule = '{0}'", data.ActionSchedule);
|
|
230 |
strcmd.AppendFormat(",TargetYear = {0}", data.TargetYear.ToString());
|
|
231 |
strcmd.AppendFormat(",TargetMonth = {0}", data.TargetMonth.ToString());
|
|
232 |
strcmd.AppendFormat(",TargetDay = {0}", data.TargetDay.ToString());
|
|
233 | 233 |
|
234 |
strcmd += ", UpdateDate = NOW()";
|
|
235 |
strcmd += AddSQLString;
|
|
234 |
strcmd.Append(", UpdateDate = NOW()");
|
|
235 |
strcmd.Append(AddSQLString);
|
|
236 | 236 |
|
237 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
237 |
if (!ExecuteNonQuery(strcmd.ToString(), bConnect)) return false;
|
|
238 | 238 |
|
239 | 239 |
return true; |
240 | 240 |
} |
241 | 241 |
catch (Exception ex) |
242 | 242 |
{ |
243 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
243 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
244 | 244 |
return false; |
245 | 245 |
} |
246 | 246 |
} |
... | ... | |
344 | 344 |
/// <returns>Where文字列</returns> |
345 | 345 |
public string CreatePrimarykeyString(DateTime TargetDate, int PersonCode = 0) |
346 | 346 |
{ |
347 |
string strWork = string.Empty;
|
|
347 |
StringBuilder strWork = new StringBuilder();
|
|
348 | 348 |
try |
349 | 349 |
{ |
350 |
strWork = string.Format(" Where DATE(TargetDate) = STR_TO_DATE('{0}','%Y/%m/%d')", TargetDate.ToShortDateString());
|
|
350 |
strWork.AppendFormat(" Where DATE(TargetDate) = STR_TO_DATE('{0}','%Y/%m/%d')", TargetDate.ToShortDateString());
|
|
351 | 351 |
if(PersonCode != 0) |
352 |
strWork += string.Format(" And PersonCode = {0}", PersonCode.ToString());
|
|
352 |
strWork.AppendFormat(" And PersonCode = {0}", PersonCode.ToString());
|
|
353 | 353 |
|
354 |
return strWork.ToString(); |
|
354 | 355 |
} |
355 | 356 |
catch (Exception ex) |
356 | 357 |
{ |
357 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strWork); |
|
358 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strWork.ToString()); |
|
359 |
return string.Empty; |
|
358 | 360 |
} |
359 |
|
|
360 |
return strWork; |
|
361 | 361 |
} |
362 | 362 |
#endregion |
363 | 363 |
|
... | ... | |
369 | 369 |
/// <returns>Where文字列</returns> |
370 | 370 |
public string CreateSubkeyString(int TargetYear, int TargetMonth = 0, int TargetDay = 0, int PersonCode = 0) |
371 | 371 |
{ |
372 |
string strWork = string.Empty;
|
|
372 |
StringBuilder strWork = new StringBuilder();
|
|
373 | 373 |
try |
374 | 374 |
{ |
375 |
strWork = string.Format(" Where TargetYear = {0}", TargetYear.ToString());
|
|
375 |
strWork.AppendFormat(" Where TargetYear = {0}", TargetYear.ToString());
|
|
376 | 376 |
if (TargetMonth != 0) |
377 |
strWork += string.Format(" And TargetMonth = {0}", TargetMonth.ToString());
|
|
377 |
strWork.AppendFormat(" And TargetMonth = {0}", TargetMonth.ToString());
|
|
378 | 378 |
if (TargetDay != 0) |
379 |
strWork += string.Format(" And TargetDay = {0}", TargetDay.ToString());
|
|
379 |
strWork.AppendFormat(" And TargetDay = {0}", TargetDay.ToString());
|
|
380 | 380 |
if (PersonCode != 0) |
381 |
strWork += string.Format(" And PersonCode = {0}", PersonCode.ToString());
|
|
381 |
strWork.AppendFormat(" And PersonCode = {0}", PersonCode.ToString());
|
|
382 | 382 |
|
383 |
return strWork.ToString(); |
|
383 | 384 |
} |
384 | 385 |
catch (Exception ex) |
385 | 386 |
{ |
386 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strWork); |
|
387 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strWork.ToString()); |
|
388 |
return string.Empty; |
|
387 | 389 |
} |
388 |
|
|
389 |
return strWork; |
|
390 | 390 |
} |
391 | 391 |
#endregion |
392 | 392 |
} |
branches/src/ProcessManagement/ProcessManagement/DB/IOAccess/IOAttendanceDailyData.cs | ||
---|---|---|
87 | 87 |
private string CreateSelectSQL() |
88 | 88 |
{ |
89 | 89 |
// SQL作成(DateTime型が変換できないのでCharに変換しておく) |
90 |
string strcmd = "SELECT"; |
|
90 |
StringBuilder strcmd = new StringBuilder(); |
|
91 |
strcmd.Append("SELECT"); |
|
92 |
strcmd.Append(" PersonCode"); // 担当者コード |
|
93 |
strcmd.Append(" ,DATE_FORMAT(AttendanceDate, '%Y/%m/%d')"); // 日報作成日 |
|
94 |
strcmd.Append(" ,SeqNo"); // 明細行番号 |
|
95 |
strcmd.Append(" ,ActionResult"); // 行動実績 |
|
96 |
strcmd.Append(" ,OvertimeHours"); // 残業時間 |
|
97 |
strcmd.Append(" ,WorkingComment"); // コメント |
|
98 |
strcmd.Append(", DATE_FORMAT(EntryDate, '%Y/%m/%d %H:%i:%s')"); // 登録年月日 |
|
99 |
strcmd.Append(", DATE_FORMAT(UpdateDate, '%Y/%m/%d %H:%i:%s')"); // 更新年月日 |
|
100 |
strcmd.Append(" FROM AttendanceDailyData"); |
|
91 | 101 |
|
92 |
strcmd += " PersonCode"; // 担当者コード |
|
93 |
strcmd += " ,DATE_FORMAT(AttendanceDate, '%Y/%m/%d')"; // 日報作成日 |
|
94 |
strcmd += " ,SeqNo"; // 明細行番号 |
|
95 |
strcmd += " ,ActionResult"; // 行動実績 |
|
96 |
strcmd += " ,OvertimeHours"; // 残業時間 |
|
97 |
strcmd += " ,WorkingComment"; // コメント |
|
98 |
strcmd += ", DATE_FORMAT(EntryDate, '%Y/%m/%d %H:%i:%s')"; // 登録年月日 |
|
99 |
strcmd += ", DATE_FORMAT(UpdateDate, '%Y/%m/%d %H:%i:%s')"; // 更新年月日 |
|
100 |
strcmd += " FROM AttendanceDailyData"; |
|
101 |
|
|
102 |
return strcmd; |
|
102 |
return strcmd.ToString(); |
|
103 | 103 |
} |
104 | 104 |
#endregion |
105 | 105 |
|
... | ... | |
107 | 107 |
public bool SelectAction(string AddSQLString, ref List<AttendanceDailyData> data, bool bConnect = true) |
108 | 108 |
{ |
109 | 109 |
// インターフェース |
110 |
string strcmd = "";
|
|
110 |
StringBuilder strcmd = new StringBuilder();
|
|
111 | 111 |
ArrayList arData = new ArrayList(); |
112 | 112 |
|
113 | 113 |
try |
114 | 114 |
{ |
115 | 115 |
// SQL作成 |
116 |
strcmd = CreateSelectSQL() + AddSQLString; |
|
116 |
strcmd.Append(CreateSelectSQL()); |
|
117 |
strcmd.Append(AddSQLString); |
|
117 | 118 |
|
118 | 119 |
// SQL実行 |
119 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return false; |
|
120 |
if (!ExecuteReader(strcmd.ToString(), ref arData, bConnect)) return false;
|
|
120 | 121 |
|
121 | 122 |
// データセット |
122 | 123 |
foreach (object[] objwrk in arData) |
... | ... | |
130 | 131 |
} |
131 | 132 |
catch (Exception ex) |
132 | 133 |
{ |
133 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
134 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
134 | 135 |
return false; |
135 | 136 |
} |
136 | 137 |
} |
... | ... | |
140 | 141 |
public bool SelectAction(string AddSQLString, ref AttendanceDailyData data, bool bConnect = true) |
141 | 142 |
{ |
142 | 143 |
// インターフェース |
143 |
string strcmd = "";
|
|
144 |
StringBuilder strcmd = new StringBuilder();
|
|
144 | 145 |
ArrayList arData = new ArrayList(); |
145 | 146 |
|
146 | 147 |
try |
147 | 148 |
{ |
148 |
strcmd = CreateSelectSQL() + AddSQLString; |
|
149 |
strcmd.Append(CreateSelectSQL()); |
|
150 |
strcmd.Append(AddSQLString); |
|
149 | 151 |
|
150 | 152 |
// SQL実行 |
151 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return false; |
|
153 |
if (!ExecuteReader(strcmd.ToString(), ref arData, bConnect)) return false;
|
|
152 | 154 |
if (arData.Count == 0) return false; |
153 | 155 |
|
154 | 156 |
// データセット |
... | ... | |
162 | 164 |
} |
163 | 165 |
catch (Exception ex) |
164 | 166 |
{ |
165 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
167 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
166 | 168 |
return false; |
167 | 169 |
} |
168 | 170 |
} |
... | ... | |
176 | 178 |
/// <returns>true:成功 false:失敗</returns> |
177 | 179 |
public bool InsertAction(AttendanceDailyData work, bool bConnect = true) |
178 | 180 |
{ |
179 |
string strcmd = "";
|
|
181 |
StringBuilder strcmd = new StringBuilder();
|
|
180 | 182 |
try |
181 | 183 |
{ |
182 | 184 |
bool bColFirst = true; |
183 |
strcmd = "INSERT INTO AttendanceDailyData";
|
|
184 |
strcmd += " (";
|
|
185 |
strcmd.Append("INSERT INTO AttendanceDailyData");
|
|
186 |
strcmd.Append(" (");
|
|
185 | 187 |
foreach (var gender in Enum.GetValues(typeof(TableColumn))) |
186 | 188 |
{ |
187 |
if (!bColFirst) strcmd += ", ";
|
|
188 |
strcmd += gender.ToString();
|
|
189 |
if (!bColFirst) strcmd.Append(", ");
|
|
190 |
strcmd.Append(gender.ToString());
|
|
189 | 191 |
bColFirst = false; |
190 | 192 |
} |
191 |
strcmd += ") VALUES (";
|
|
193 |
strcmd.Append(") VALUES (");
|
|
192 | 194 |
|
193 |
strcmd += string.Format(" {0}", work.PersonCode); // 担当者コード
|
|
194 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d')"
|
|
195 |
strcmd.AppendFormat(" {0}", work.PersonCode); // 担当者コード
|
|
196 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d')"
|
|
195 | 197 |
, work.AttendanceDate.ToShortDateString()); // 日報作成日 |
196 |
strcmd += string.Format(", {0}", work.SeqNo); // 明細行番号
|
|
197 |
strcmd += string.Format(",'{0}'", work.ActionResult); // 行動実績
|
|
198 |
strcmd += string.Format(", {0}", work.OvertimeHours); // 残業時間
|
|
199 |
strcmd += string.Format(",'{0}'", work.WorkingComment); // コメント
|
|
198 |
strcmd.AppendFormat(", {0}", work.SeqNo); // 明細行番号
|
|
199 |
strcmd.AppendFormat(",'{0}'", work.ActionResult); // 行動実績
|
|
200 |
strcmd.AppendFormat(", {0}", work.OvertimeHours); // 残業時間
|
|
201 |
strcmd.AppendFormat(",'{0}'", work.WorkingComment); // コメント
|
|
200 | 202 |
|
201 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.EntryDate);
|
|
202 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.UpdateDate);
|
|
203 |
strcmd += ")";
|
|
203 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.EntryDate);
|
|
204 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.UpdateDate);
|
|
205 |
strcmd.Append(")");
|
|
204 | 206 |
|
205 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
207 |
if (!ExecuteNonQuery(strcmd.ToString(), bConnect)) return false;
|
|
206 | 208 |
|
207 | 209 |
return true; |
208 | 210 |
} |
209 | 211 |
catch (Exception ex) |
210 | 212 |
{ |
211 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
213 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
212 | 214 |
return false; |
213 | 215 |
} |
214 | 216 |
} |
... | ... | |
217 | 219 |
#region 複数追加処理 |
218 | 220 |
public bool InsertAction(List<AttendanceDailyData> data, bool bConnect = true) |
219 | 221 |
{ |
220 |
string strcmd = "";
|
|
222 |
StringBuilder strcmd = new StringBuilder();
|
|
221 | 223 |
try |
222 | 224 |
{ |
223 | 225 |
bool bColFirst = true; |
224 |
strcmd = "INSERT INTO AttendanceDailyData";
|
|
225 |
strcmd += " (";
|
|
226 |
strcmd.Append("INSERT INTO AttendanceDailyData");
|
|
227 |
strcmd.Append(" (");
|
|
226 | 228 |
foreach (var gender in Enum.GetValues(typeof(TableColumn))) |
227 | 229 |
{ |
228 |
if (!bColFirst) strcmd += ", ";
|
|
229 |
strcmd += gender.ToString();
|
|
230 |
if (!bColFirst) strcmd.Append(", ");
|
|
231 |
strcmd.Append(gender.ToString());
|
|
230 | 232 |
bColFirst = false; |
231 | 233 |
} |
232 |
strcmd += ") VALUES";
|
|
234 |
strcmd.Append(") VALUES");
|
|
233 | 235 |
|
234 | 236 |
bool bDataFirst = true; |
235 | 237 |
foreach (AttendanceDailyData work in data) |
236 | 238 |
{ |
237 |
if (bDataFirst) strcmd += " (";
|
|
238 |
else strcmd += ", (";
|
|
239 |
if (bDataFirst) strcmd.Append(" (");
|
|
240 |
else strcmd.Append(", (");
|
|
239 | 241 |
|
240 |
strcmd += string.Format(" {0}", work.PersonCode); // 担当者コード
|
|
241 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d')"
|
|
242 |
strcmd.AppendFormat(" {0}", work.PersonCode); // 担当者コード
|
|
243 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d')"
|
|
242 | 244 |
, work.AttendanceDate.ToShortDateString()); // 日報作成日 |
243 |
strcmd += string.Format(", {0}", work.SeqNo); // 明細行番号
|
|
244 |
strcmd += string.Format(",'{0}'", work.ActionResult); // 行動実績
|
|
245 |
strcmd += string.Format(", {0}", work.OvertimeHours); // 残業時間
|
|
246 |
strcmd += string.Format(",'{0}'", work.WorkingComment); // コメント
|
|
245 |
strcmd.AppendFormat(", {0}", work.SeqNo); // 明細行番号
|
|
246 |
strcmd.AppendFormat(",'{0}'", work.ActionResult); // 行動実績
|
|
247 |
strcmd.AppendFormat(", {0}", work.OvertimeHours); // 残業時間
|
|
248 |
strcmd.AppendFormat(",'{0}'", work.WorkingComment); // コメント
|
|
247 | 249 |
|
248 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.EntryDate);
|
|
249 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.UpdateDate);
|
|
250 |
strcmd += ")";
|
|
250 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.EntryDate);
|
|
251 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.UpdateDate);
|
|
252 |
strcmd.Append(")");
|
|
251 | 253 |
|
252 | 254 |
bDataFirst = false; |
253 | 255 |
} |
254 | 256 |
|
255 |
if (!ExecuteNonQuery(strcmd, false)) return false; |
|
257 |
if (!ExecuteNonQuery(strcmd.ToString(), false)) return false;
|
|
256 | 258 |
|
257 | 259 |
return true; |
258 | 260 |
} |
259 | 261 |
catch (Exception ex) |
260 | 262 |
{ |
261 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
263 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
262 | 264 |
return false; |
263 | 265 |
} |
264 | 266 |
} |
... | ... | |
273 | 275 |
/// <returns>true:成功 false:失敗</returns> |
274 | 276 |
public bool UpdateAction(string AddSQLString, AttendanceDailyData data, bool bConnect = true) |
275 | 277 |
{ |
276 |
string strcmd = "";
|
|
278 |
StringBuilder strcmd = new StringBuilder();
|
|
277 | 279 |
try |
278 | 280 |
{ |
279 | 281 |
|
280 |
strcmd = "UPDATE AttendanceDailyData";
|
|
282 |
strcmd.Append("UPDATE AttendanceDailyData");
|
|
281 | 283 |
|
282 |
strcmd += " SET";
|
|
284 |
strcmd.Append(" SET");
|
|
283 | 285 |
|
284 |
strcmd += string.Format(" PersonCode = {0}", data.PersonCode); // 担当者コード
|
|
285 |
strcmd += string.Format(",AttendanceDate = STR_TO_DATE('{0}','%Y/%m/%d')"
|
|
286 |
strcmd.AppendFormat(" PersonCode = {0}", data.PersonCode); // 担当者コード
|
|
287 |
strcmd.AppendFormat(",AttendanceDate = STR_TO_DATE('{0}','%Y/%m/%d')"
|
|
286 | 288 |
, data.AttendanceDate.ToShortDateString()); // 日報作成日 |
287 |
strcmd += string.Format(",SeqNo = {0} ", data.SeqNo); // 明細行番号
|
|
288 |
strcmd += string.Format(",ActionResult = '{0}'", data.ActionResult); // 行動実績
|
|
289 |
strcmd += string.Format(",OvertimeHours = {0}", data.OvertimeHours); // 残業時間
|
|
290 |
strcmd += string.Format(",WorkingComment = '{0}'", data.WorkingComment); // コメント
|
|
289 |
strcmd.AppendFormat(",SeqNo = {0} ", data.SeqNo); // 明細行番号
|
|
290 |
strcmd.AppendFormat(",ActionResult = '{0}'", data.ActionResult); // 行動実績
|
|
291 |
strcmd.AppendFormat(",OvertimeHours = {0}", data.OvertimeHours); // 残業時間
|
|
292 |
strcmd.AppendFormat(",WorkingComment = '{0}'", data.WorkingComment); // コメント
|
|
291 | 293 |
|
292 |
strcmd += ", UpdateDate = NOW()";
|
|
293 |
strcmd += AddSQLString;
|
|
294 |
strcmd.Append(", UpdateDate = NOW()");
|
|
295 |
strcmd.Append(AddSQLString);
|
|
294 | 296 |
|
295 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
297 |
if (!ExecuteNonQuery(strcmd.ToString(), bConnect)) return false;
|
|
296 | 298 |
|
297 | 299 |
return true; |
298 | 300 |
} |
299 | 301 |
catch (Exception ex) |
300 | 302 |
{ |
301 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
303 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
302 | 304 |
return false; |
303 | 305 |
} |
304 | 306 |
} |
... | ... | |
314 | 316 |
public bool DeleteAction(string AddSQLString, bool bConnect = true) |
315 | 317 |
{ |
316 | 318 |
// インターフェース |
317 |
string strcmd = "";
|
|
319 |
StringBuilder strcmd = new StringBuilder();
|
|
318 | 320 |
try |
319 | 321 |
{ |
320 |
strcmd = string.Format("{0}{1}", "DELETE FROM AttendanceDailyData", AddSQLString);
|
|
322 |
strcmd.AppendFormat("{0}{1}", "DELETE FROM AttendanceDailyData", AddSQLString);
|
|
321 | 323 |
|
322 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
324 |
if (!ExecuteNonQuery(strcmd.ToString(), bConnect)) return false;
|
|
323 | 325 |
|
324 | 326 |
return true; |
325 | 327 |
} |
326 | 328 |
catch (Exception ex) |
327 | 329 |
{ |
328 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
330 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
329 | 331 |
return false; |
330 | 332 |
} |
331 | 333 |
} |
... | ... | |
342 | 344 |
/// <returns></returns> |
343 | 345 |
public bool UpdateFeild(int PersonCode, DateTime AttendanceDate, int SeqNo, int FeildNo, object value, bool bConnect = true) |
344 | 346 |
{ |
345 |
string strcmd = "";
|
|
347 |
StringBuilder strcmd = new StringBuilder();
|
|
346 | 348 |
try |
347 | 349 |
{ |
348 |
strcmd = "UPDATE AttendanceDailyData";
|
|
350 |
strcmd.Append("UPDATE AttendanceDailyData");
|
|
349 | 351 |
|
350 |
strcmd += " SET";
|
|
352 |
strcmd.Append(" SET");
|
|
351 | 353 |
switch (FeildNo) |
352 | 354 |
{ |
353 | 355 |
case (int)TableColumn.PersonCode: |
354 |
strcmd += string.Format(" PersonCode = {0}", (int)value);
|
|
356 |
strcmd.AppendFormat(" PersonCode = {0}", (int)value);
|
|
355 | 357 |
break; |
356 | 358 |
case (int)TableColumn.AttendanceDate: |
357 |
strcmd += string.Format(" AttendanceDate = STR_TO_DATE('{0}','%Y/%m/%d')", ((DateTime)value).ToShortDateString());
|
|
359 |
strcmd.AppendFormat(" AttendanceDate = STR_TO_DATE('{0}','%Y/%m/%d')", ((DateTime)value).ToShortDateString());
|
|
358 | 360 |
break; |
359 | 361 |
case (int)TableColumn.SeqNo: |
360 |
strcmd += string.Format(" SeqNo = {0}", (int)value);
|
|
362 |
strcmd.AppendFormat(" SeqNo = {0}", (int)value);
|
|
361 | 363 |
break; |
362 | 364 |
case (int)TableColumn.ActionResult: |
363 |
strcmd += string.Format(" ActionResult = '{0}'", value.ToString());
|
|
365 |
strcmd.AppendFormat(" ActionResult = '{0}'", value.ToString());
|
|
364 | 366 |
break; |
365 | 367 |
case (int)TableColumn.OvertimeHours: |
366 |
strcmd += string.Format(" OvertimeHours = {0}", (double)value);
|
|
368 |
strcmd.AppendFormat(" OvertimeHours = {0}", (double)value);
|
|
367 | 369 |
break; |
368 | 370 |
case (int)TableColumn.WorkingComment: |
369 |
strcmd += string.Format(" WorkingComment = '{0}'", CommonMotions.cnvString(value));
|
|
371 |
strcmd.AppendFormat(" WorkingComment = '{0}'", CommonMotions.cnvString(value));
|
|
370 | 372 |
break; |
371 | 373 |
} |
372 | 374 |
|
373 |
strcmd += ", UpdateDate = NOW()";
|
|
374 |
strcmd += CreatePrimarykeyString(PersonCode, AttendanceDate, SeqNo);
|
|
375 |
strcmd.Append(", UpdateDate = NOW()");
|
|
376 |
strcmd.Append(CreatePrimarykeyString(PersonCode, AttendanceDate, SeqNo));
|
|
375 | 377 |
|
376 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
378 |
if (!ExecuteNonQuery(strcmd.ToString(), bConnect)) return false;
|
|
377 | 379 |
|
378 | 380 |
return true; |
379 | 381 |
} |
380 | 382 |
catch (Exception ex) |
381 | 383 |
{ |
382 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
384 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
383 | 385 |
return false; |
384 | 386 |
} |
385 | 387 |
} |
... | ... | |
428 | 430 |
/// <returns></returns> |
429 | 431 |
public string CreatePrimarykeyString(int PersonCode, DateTime AttendanceDate, int SeqNo = 0) |
430 | 432 |
{ |
431 |
string strWork = "";
|
|
433 |
StringBuilder strWork = new StringBuilder();
|
|
432 | 434 |
try |
433 | 435 |
{ |
434 |
strWork = string.Format(" WHERE PersonCode = {0}", PersonCode);
|
|
436 |
strWork.AppendFormat(" WHERE PersonCode = {0}", PersonCode);
|
|
435 | 437 |
if (AttendanceDate != DateTime.MinValue) |
436 |
strWork += string.Format(" AND AttendanceDate = STR_TO_DATE('{0}','%Y/%m/%d')", AttendanceDate.ToShortDateString());
|
|
438 |
strWork.AppendFormat(" AND AttendanceDate = STR_TO_DATE('{0}','%Y/%m/%d')", AttendanceDate.ToShortDateString());
|
|
437 | 439 |
if (SeqNo != 0) |
438 |
strWork += string.Format(" AND SeqNo = {0}", SeqNo); |
|
440 |
strWork.AppendFormat(" AND SeqNo = {0}", SeqNo); |
|
441 |
|
|
442 |
return strWork.ToString(); |
|
439 | 443 |
} |
440 | 444 |
catch (Exception ex) |
441 | 445 |
{ |
442 | 446 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strWork); |
447 |
return string.Empty; |
|
443 | 448 |
} |
444 |
|
|
445 |
return strWork; |
|
446 | 449 |
} |
447 | 450 |
#endregion |
448 | 451 |
|
branches/src/ProcessManagement/ProcessManagement/DB/IOAccess/IOAttendanceData.cs | ||
---|---|---|
92 | 92 |
private string CreateSelectSQL() |
93 | 93 |
{ |
94 | 94 |
// SQL作成(DateTime型が変換できないのでCharに変換しておく) |
95 |
string strcmd = "SELECT"; |
|
95 |
StringBuilder strcmd = new StringBuilder(); |
|
96 |
strcmd.Append("SELECT"); |
|
97 |
strcmd.Append(" PersonCode"); // 担当者コード |
|
98 |
strcmd.Append(" ,DATE_FORMAT(AttendanceMonth, '%Y/%m/%d')"); // 出勤管理年月 |
|
99 |
strcmd.Append(" ,LastDays"); // 当月最終日 |
|
100 |
strcmd.Append(" ,AttendDayCount"); // 出勤日数 |
|
101 |
strcmd.Append(" ,TotalOverTimes"); // 残業時間数 |
|
102 |
strcmd.Append(" ,DATE_FORMAT(OrderDate, '%Y/%m/%d')"); // 申請日 |
|
103 |
strcmd.Append(" ,OrderNo"); // 申請受付番号 |
|
104 |
strcmd.Append(", DATE_FORMAT(EntryDate, '%Y/%m/%d %H:%i:%s')"); // 更新年月日 |
|
105 |
strcmd.Append(", DATE_FORMAT(UpdateDate, '%Y/%m/%d %H:%i:%s')"); // 登録年月日 |
|
106 |
strcmd.Append(" FROM AttendanceData"); |
|
96 | 107 |
|
97 |
strcmd += " PersonCode"; // 担当者コード |
|
98 |
strcmd += " ,DATE_FORMAT(AttendanceMonth, '%Y/%m/%d')"; // 出勤管理年月 |
|
99 |
strcmd += " ,LastDays"; // 当月最終日 |
|
100 |
strcmd += " ,AttendDayCount"; // 出勤日数 |
|
101 |
strcmd += " ,TotalOverTimes"; // 残業時間数 |
|
102 |
strcmd += " ,DATE_FORMAT(OrderDate, '%Y/%m/%d')"; // 申請日 |
|
103 |
strcmd += " ,OrderNo"; // 申請受付番号 |
|
104 |
strcmd += ", DATE_FORMAT(EntryDate, '%Y/%m/%d %H:%i:%s')"; // 更新年月日 |
|
105 |
strcmd += ", DATE_FORMAT(UpdateDate, '%Y/%m/%d %H:%i:%s')"; // 登録年月日 |
|
106 |
strcmd += " FROM AttendanceData"; |
|
107 |
|
|
108 |
return strcmd; |
|
108 |
return strcmd.ToString(); |
|
109 | 109 |
} |
110 | 110 |
#endregion |
111 | 111 |
|
... | ... | |
113 | 113 |
public bool SelectAction(string AddSQLString, ref List<AttendanceData> data, bool bConnect = true) |
114 | 114 |
{ |
115 | 115 |
// インターフェース |
116 |
string strcmd = "";
|
|
116 |
StringBuilder strcmd = new StringBuilder();
|
|
117 | 117 |
ArrayList arData = new ArrayList(); |
118 | 118 |
|
119 | 119 |
try |
120 | 120 |
{ |
121 | 121 |
// SQL作成 |
122 |
strcmd = CreateSelectSQL() + AddSQLString; |
|
122 |
strcmd.Append(CreateSelectSQL()); |
|
123 |
strcmd.Append(AddSQLString); |
|
123 | 124 |
|
124 | 125 |
// SQL実行 |
125 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return false; |
|
126 |
if (!ExecuteReader(strcmd.ToString(), ref arData, bConnect)) return false;
|
|
126 | 127 |
|
127 | 128 |
// データセット |
128 | 129 |
foreach (object[] objwrk in arData) |
... | ... | |
136 | 137 |
} |
137 | 138 |
catch (Exception ex) |
138 | 139 |
{ |
139 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
140 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
140 | 141 |
return false; |
141 | 142 |
} |
142 | 143 |
} |
... | ... | |
146 | 147 |
public bool SelectAction(string AddSQLString, ref AttendanceData data, bool bConnect = true) |
147 | 148 |
{ |
148 | 149 |
// インターフェース |
149 |
string strcmd = "";
|
|
150 |
StringBuilder strcmd = new StringBuilder();
|
|
150 | 151 |
ArrayList arData = new ArrayList(); |
151 | 152 |
|
152 | 153 |
try |
153 | 154 |
{ |
154 |
strcmd = CreateSelectSQL() + AddSQLString; |
|
155 |
strcmd.Append(CreateSelectSQL()); |
|
156 |
strcmd.Append(AddSQLString); |
|
155 | 157 |
|
156 | 158 |
// SQL実行 |
157 |
if (!ExecuteReader(strcmd, ref arData, bConnect)) return false; |
|
159 |
if (!ExecuteReader(strcmd.ToString(), ref arData, bConnect)) return false;
|
|
158 | 160 |
if (arData.Count == 0) return false; |
159 | 161 |
|
160 | 162 |
// データセット |
... | ... | |
168 | 170 |
} |
169 | 171 |
catch (Exception ex) |
170 | 172 |
{ |
171 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
173 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
172 | 174 |
return false; |
173 | 175 |
} |
174 | 176 |
} |
... | ... | |
182 | 184 |
/// <returns>true:成功 false:失敗</returns> |
183 | 185 |
public bool InsertAction(AttendanceData work, bool bConnect = true) |
184 | 186 |
{ |
185 |
string strcmd = "";
|
|
187 |
StringBuilder strcmd = new StringBuilder();
|
|
186 | 188 |
try |
187 | 189 |
{ |
188 |
strcmd = "INSERT INTO AttendanceData";
|
|
190 |
strcmd.Append("INSERT INTO AttendanceData");
|
|
189 | 191 |
|
190 |
strcmd += "(";
|
|
192 |
strcmd.Append("(");
|
|
191 | 193 |
bool bFirst = true; |
192 | 194 |
foreach (var gender in Enum.GetValues(typeof(TableColumn))) |
193 | 195 |
{ |
194 |
if (!bFirst) strcmd += " ,";
|
|
195 |
strcmd += gender.ToString();
|
|
196 |
if (!bFirst) strcmd.Append(" ,");
|
|
197 |
strcmd.Append(gender.ToString());
|
|
196 | 198 |
bFirst = false; |
197 | 199 |
} |
198 |
strcmd += ") VALUES (";
|
|
200 |
strcmd.Append(") VALUES (");
|
|
199 | 201 |
|
200 |
strcmd += string.Format(" {0}", work.PersonCode); // 担当者コード
|
|
201 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d')"
|
|
202 |
strcmd.AppendFormat(" {0}", work.PersonCode); // 担当者コード
|
|
203 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d')"
|
|
202 | 204 |
, work.AttendanceMonth.ToShortDateString());// 日報作成日 |
203 |
strcmd += string.Format(", {0}", work.LastDays); // 当月最終日
|
|
204 |
strcmd += string.Format(", {0}", work.AttendDayCount); // 出勤日数
|
|
205 |
strcmd += string.Format(", {0}", work.TotalOverTimes); // 残業時間数
|
|
206 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d')"
|
|
205 |
strcmd.AppendFormat(", {0}", work.LastDays); // 当月最終日
|
|
206 |
strcmd.AppendFormat(", {0}", work.AttendDayCount); // 出勤日数
|
|
207 |
strcmd.AppendFormat(", {0}", work.TotalOverTimes); // 残業時間数
|
|
208 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d')"
|
|
207 | 209 |
, work.OrderDate.ToShortDateString()); // 申請日 |
208 |
strcmd += string.Format(", {0}", work.OrderNo); // 申請受付番号
|
|
210 |
strcmd.AppendFormat(", {0}", work.OrderNo); // 申請受付番号
|
|
209 | 211 |
|
210 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.EntryDate);
|
|
211 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.UpdateDate);
|
|
212 |
strcmd += ")";
|
|
212 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.EntryDate);
|
|
213 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.UpdateDate);
|
|
214 |
strcmd.Append(")");
|
|
213 | 215 |
|
214 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
216 |
if (!ExecuteNonQuery(strcmd.ToString(), bConnect)) return false;
|
|
215 | 217 |
|
216 | 218 |
return true; |
217 | 219 |
} |
218 | 220 |
catch (Exception ex) |
219 | 221 |
{ |
220 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
222 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
221 | 223 |
return false; |
222 | 224 |
} |
223 | 225 |
} |
... | ... | |
226 | 228 |
#region 複数追加処理 |
227 | 229 |
public bool InsertAction(List<AttendanceData> data, bool bConnect = true) |
228 | 230 |
{ |
229 |
string strcmd = "";
|
|
231 |
StringBuilder strcmd = new StringBuilder();
|
|
230 | 232 |
try |
231 | 233 |
{ |
232 | 234 |
bool bColFirst = true; |
233 |
strcmd = "INSERT INTO AttendanceData";
|
|
234 |
strcmd += " (";
|
|
235 |
strcmd.Append("INSERT INTO AttendanceData");
|
|
236 |
strcmd.Append(" (");
|
|
235 | 237 |
foreach (var gender in Enum.GetValues(typeof(TableColumn))) |
236 | 238 |
{ |
237 |
if (!bColFirst) strcmd += ", ";
|
|
238 |
strcmd += gender.ToString();
|
|
239 |
if (!bColFirst) strcmd.Append(", ");
|
|
240 |
strcmd.Append(gender.ToString());
|
|
239 | 241 |
bColFirst = false; |
240 | 242 |
} |
241 |
strcmd += ") VALUES";
|
|
243 |
strcmd.Append(") VALUES");
|
|
242 | 244 |
|
243 | 245 |
bool bDataFirst = true; |
244 | 246 |
foreach (AttendanceData work in data) |
245 | 247 |
{ |
246 |
if (bDataFirst) strcmd += " (";
|
|
247 |
else strcmd += ", (";
|
|
248 |
if (bDataFirst) strcmd.Append(" (");
|
|
249 |
else strcmd.Append(", (");
|
|
248 | 250 |
|
249 |
strcmd += string.Format(" {0}", work.PersonCode); // 担当者コード
|
|
250 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d')"
|
|
251 |
strcmd.AppendFormat(" {0}", work.PersonCode); // 担当者コード
|
|
252 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d')"
|
|
251 | 253 |
, work.AttendanceMonth.ToShortDateString());// 日報作成日 |
252 |
strcmd += string.Format(", {0}", work.LastDays); // 当月最終日
|
|
253 |
strcmd += string.Format(", {0}", work.AttendDayCount); // 出勤日数
|
|
254 |
strcmd += string.Format(", {0}", work.TotalOverTimes); // 残業時間数
|
|
255 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d')"
|
|
254 |
strcmd.AppendFormat(", {0}", work.LastDays); // 当月最終日
|
|
255 |
strcmd.AppendFormat(", {0}", work.AttendDayCount); // 出勤日数
|
|
256 |
strcmd.AppendFormat(", {0}", work.TotalOverTimes); // 残業時間数
|
|
257 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d')"
|
|
256 | 258 |
, work.OrderDate.ToShortDateString()); // 申請日 |
257 |
strcmd += string.Format(", {0}", work.OrderNo); // 申請受付番号
|
|
259 |
strcmd.AppendFormat(", {0}", work.OrderNo); // 申請受付番号
|
|
258 | 260 |
|
259 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.EntryDate);
|
|
260 |
strcmd += string.Format(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.UpdateDate);
|
|
261 |
strcmd += ")";
|
|
261 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.EntryDate);
|
|
262 |
strcmd.AppendFormat(", STR_TO_DATE('{0}','%Y/%m/%d %H:%i:%s')", work.UpdateDate);
|
|
263 |
strcmd.Append(")");
|
|
262 | 264 |
|
263 | 265 |
bDataFirst = false; |
264 | 266 |
} |
265 | 267 |
|
266 |
if (!ExecuteNonQuery(strcmd, false)) return false; |
|
268 |
if (!ExecuteNonQuery(strcmd.ToString(), false)) return false;
|
|
267 | 269 |
|
268 | 270 |
return true; |
269 | 271 |
} |
270 | 272 |
catch (Exception ex) |
271 | 273 |
{ |
272 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
274 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
273 | 275 |
return false; |
274 | 276 |
} |
275 | 277 |
} |
... | ... | |
284 | 286 |
/// <returns>true:成功 false:失敗</returns> |
285 | 287 |
public bool UpdateAction(string AddSQLString, AttendanceData data, bool bConnect = true) |
286 | 288 |
{ |
287 |
string strcmd = "";
|
|
289 |
StringBuilder strcmd = new StringBuilder();
|
|
288 | 290 |
try |
289 | 291 |
{ |
290 | 292 |
|
291 |
strcmd = "UPDATE AttendanceData";
|
|
293 |
strcmd.Append("UPDATE AttendanceData");
|
|
292 | 294 |
|
293 |
strcmd += " SET";
|
|
295 |
strcmd.Append(" SET");
|
|
294 | 296 |
|
295 |
strcmd += string.Format(" PersonCode = {0}", data.PersonCode); // 担当者コード
|
|
296 |
strcmd += string.Format(" ,AttendanceMonth = STR_TO_DATE('{0}','%Y/%m/%d')",
|
|
297 |
strcmd.AppendFormat(" PersonCode = {0}", data.PersonCode); // 担当者コード
|
|
298 |
strcmd.AppendFormat(" ,AttendanceMonth = STR_TO_DATE('{0}','%Y/%m/%d')",
|
|
297 | 299 |
data.AttendanceMonth.ToShortDateString()); // 出勤管理年月 |
298 |
strcmd += string.Format(" ,LastDays = {0} ", data.LastDays); // 当月最終日
|
|
299 |
strcmd += string.Format(" ,AttendDayCount = {0} ", data.AttendDayCount); // 出勤日数
|
|
300 |
strcmd += string.Format(" ,TotalOverTimes = {0} ", data.TotalOverTimes); // 残業時間数
|
|
301 |
strcmd += string.Format(" ,OrderDate = STR_TO_DATE('{0}','%Y/%m/%d')",
|
|
300 |
strcmd.AppendFormat(" ,LastDays = {0} ", data.LastDays); // 当月最終日
|
|
301 |
strcmd.AppendFormat(" ,AttendDayCount = {0} ", data.AttendDayCount); // 出勤日数
|
|
302 |
strcmd.AppendFormat(" ,TotalOverTimes = {0} ", data.TotalOverTimes); // 残業時間数
|
|
303 |
strcmd.AppendFormat(" ,OrderDate = STR_TO_DATE('{0}','%Y/%m/%d')",
|
|
302 | 304 |
data.OrderDate.ToShortDateString()); // 申請日 |
303 |
strcmd += string.Format(" ,OrderNo = {0} ", data.OrderNo); // 申請受付番号
|
|
305 |
strcmd.AppendFormat(" ,OrderNo = {0} ", data.OrderNo); // 申請受付番号
|
|
304 | 306 |
|
305 |
strcmd += ", UpdateDate = NOW()";
|
|
306 |
strcmd += AddSQLString;
|
|
307 |
strcmd.Append(", UpdateDate = NOW()");
|
|
308 |
strcmd.Append(AddSQLString);
|
|
307 | 309 |
|
308 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
310 |
if (!ExecuteNonQuery(strcmd.ToString(), bConnect)) return false;
|
|
309 | 311 |
|
310 | 312 |
return true; |
311 | 313 |
} |
312 | 314 |
catch (Exception ex) |
313 | 315 |
{ |
314 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
316 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
315 | 317 |
return false; |
316 | 318 |
} |
317 | 319 |
} |
... | ... | |
327 | 329 |
public bool DeleteAction(string AddSQLString, bool bConnect = true) |
328 | 330 |
{ |
329 | 331 |
// インターフェース |
330 |
string strcmd = "";
|
|
332 |
StringBuilder strcmd = new StringBuilder();
|
|
331 | 333 |
try |
332 | 334 |
{ |
333 |
strcmd = string.Format("{0}{1}", "DELETE FROM AttendanceData", AddSQLString);
|
|
335 |
strcmd.AppendFormat("{0}{1}", "DELETE FROM AttendanceData", AddSQLString);
|
|
334 | 336 |
|
335 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
337 |
if (!ExecuteNonQuery(strcmd.ToString(), bConnect)) return false;
|
|
336 | 338 |
|
337 | 339 |
return true; |
338 | 340 |
} |
339 | 341 |
catch (Exception ex) |
340 | 342 |
{ |
341 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
343 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
342 | 344 |
return false; |
343 | 345 |
} |
344 | 346 |
} |
... | ... | |
355 | 357 |
/// <returns></returns> |
356 | 358 |
public bool UpdateFeild(int PersonCode, DateTime AttendanceMonth, int FeildNo, object value, bool bConnect = true) |
357 | 359 |
{ |
358 |
string strcmd = "";
|
|
360 |
StringBuilder strcmd = new StringBuilder();
|
|
359 | 361 |
try |
360 | 362 |
{ |
361 |
strcmd = "UPDATE AttendanceData";
|
|
363 |
strcmd.Append("UPDATE AttendanceData");
|
|
362 | 364 |
|
363 |
strcmd += " SET";
|
|
365 |
strcmd.Append(" SET");
|
|
364 | 366 |
switch (FeildNo) |
365 | 367 |
{ |
366 | 368 |
case (int)TableColumn.PersonCode: |
367 |
strcmd += string.Format(" PersonCode = {0}", (int)value);
|
|
369 |
strcmd.AppendFormat(" PersonCode = {0}", (int)value);
|
|
368 | 370 |
break; |
369 | 371 |
case (int)TableColumn.AttendanceMonth: |
370 |
strcmd += string.Format(" AttendanceMonth = STR_TO_DATE('{0}','%Y/%m/%d')", ((DateTime)value).ToShortDateString());
|
|
372 |
strcmd.AppendFormat(" AttendanceMonth = STR_TO_DATE('{0}','%Y/%m/%d')", ((DateTime)value).ToShortDateString());
|
|
371 | 373 |
break; |
372 | 374 |
case (int)TableColumn.LastDays: |
373 |
strcmd += string.Format(" LastDays = {0}", (int)value);
|
|
375 |
strcmd.AppendFormat(" LastDays = {0}", (int)value);
|
|
374 | 376 |
break; |
375 | 377 |
case (int)TableColumn.AttendDayCount: |
376 |
strcmd += string.Format(" AttendDayCount = {0}", (int)value);
|
|
378 |
strcmd.AppendFormat(" AttendDayCount = {0}", (int)value);
|
|
377 | 379 |
break; |
378 | 380 |
case (int)TableColumn.TotalOverTimes: |
379 |
strcmd += string.Format(" TotalOverTimes = {0}", (double)value);
|
|
381 |
strcmd.AppendFormat(" TotalOverTimes = {0}", (double)value);
|
|
380 | 382 |
break; |
381 | 383 |
case (int)TableColumn.OrderDate: |
382 |
strcmd += string.Format(" OrderDate = STR_TO_DATE('{0}','%Y/%m/%d')", ((DateTime)value).ToShortDateString());
|
|
384 |
strcmd.AppendFormat(" OrderDate = STR_TO_DATE('{0}','%Y/%m/%d')", ((DateTime)value).ToShortDateString());
|
|
383 | 385 |
break; |
384 | 386 |
case (int)TableColumn.OrderNo: |
385 |
strcmd += string.Format(" OrderNo = {0}", (int)value);
|
|
387 |
strcmd.AppendFormat(" OrderNo = {0}", (int)value);
|
|
386 | 388 |
break; |
387 | 389 |
} |
388 | 390 |
|
389 |
strcmd += ", UpdateDate = NOW()";
|
|
390 |
strcmd += CreatePrimarykeyString(PersonCode, AttendanceMonth);
|
|
391 |
strcmd.Append(", UpdateDate = NOW()");
|
|
392 |
strcmd.Append(CreatePrimarykeyString(PersonCode, AttendanceMonth));
|
|
391 | 393 |
|
392 |
if (!ExecuteNonQuery(strcmd, bConnect)) return false; |
|
394 |
if (!ExecuteNonQuery(strcmd.ToString(), bConnect)) return false;
|
|
393 | 395 |
|
394 | 396 |
return true; |
395 | 397 |
} |
396 | 398 |
catch (Exception ex) |
397 | 399 |
{ |
398 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd); |
|
400 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", CommonMotions.GetMethodName(2), ex.Message, strcmd.ToString());
|
|
399 | 401 |
return false; |
400 | 402 |
} |
401 | 403 |
} |
... | ... | |
445 | 447 |
/// <returns></returns> |
他の形式にエクスポート: Unified diff