h-you / trunk / src / ProcessManagement / ProcessManagement / Common / CommonMotions.cs @ 484
履歴 | 表示 | アノテート | ダウンロード (198 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Diagnostics; |
6 |
using System.Windows.Forms; |
7 |
using System.Drawing; |
8 |
using System.IO; |
9 |
using System.Text.RegularExpressions; |
10 |
using System.Data; |
11 |
using System.Security.Cryptography; |
12 |
using System.Globalization; |
13 |
using System.Runtime.InteropServices; |
14 |
using System.Collections; |
15 |
|
16 |
using Microsoft.VisualBasic; //for StrConv |
17 |
|
18 |
using log4net; |
19 |
using log4net.Appender; |
20 |
using log4net.Repository.Hierarchy; |
21 |
|
22 |
using ProcessManagement.DB.Core; |
23 |
using ProcessManagement.DataModel; |
24 |
using ProcessManagement.DB.IOAccess; |
25 |
using ProcessManagement.Forms.CustomControls; |
26 |
using ProcessManagement.Forms.DataEntry; |
27 |
|
28 |
namespace ProcessManagement.Common |
29 |
{ |
30 |
/// <summary> |
31 |
/// 工事管理システム共通クラス |
32 |
/// </summary> |
33 |
public static class CommonMotions |
34 |
{ |
35 |
#region 定義部 |
36 |
/// <summary> |
37 |
/// log4netログを使用する |
38 |
/// </summary> |
39 |
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
40 |
#endregion |
41 |
|
42 |
#region 変数 |
43 |
/// <summary> |
44 |
/// 定義ファイル読込クラス定義 |
45 |
/// </summary> |
46 |
private static DefinitionFileRead m_dfr_model = null; |
47 |
|
48 |
/// <summary> |
49 |
/// 管理マスタデータ保持領域 |
50 |
/// </summary> |
51 |
private static SystemMaster m_systemMaster = new SystemMaster(); |
52 |
|
53 |
/// <summary> |
54 |
/// 消費税データ保持領域 |
55 |
/// </summary> |
56 |
private static List<ConsumptionTax> m_ConsumptionTax = new List<ConsumptionTax>(); |
57 |
|
58 |
/// <summary> |
59 |
/// ログインユーザー担当者データ |
60 |
/// </summary> |
61 |
private static PersonInChargeMaster m_LoginUserData = new PersonInChargeMaster(); |
62 |
|
63 |
/// <summary> |
64 |
/// ログインユーザー参照部署データ |
65 |
/// </summary> |
66 |
private static List<PersonDepartmentMaster> m_LoginUserRefDepartment = new List<PersonDepartmentMaster>(); |
67 |
|
68 |
/// <summary> |
69 |
/// ログインユーザーセキュリティ区分 |
70 |
/// </summary> |
71 |
private static SecurityMaster m_LoginUserSecurity = new SecurityMaster(); |
72 |
|
73 |
/// <summary> |
74 |
/// ログインユーザー処理起動区分 |
75 |
/// </summary> |
76 |
private static List<ProcessExcute> m_LoginUserProcExe = new List<ProcessExcute>(); |
77 |
|
78 |
/// <summary> |
79 |
/// 製品ファイルバージョン格納エリア |
80 |
/// </summary> |
81 |
private static FileVersionInfo m_ProductVersionInfo = FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location); |
82 |
|
83 |
/// <summary> |
84 |
/// RGBカラーテーブル |
85 |
/// </summary> |
86 |
private static Color[] m_RGBColor = new Color[256]; |
87 |
|
88 |
#endregion |
89 |
|
90 |
#region コンストラクタ |
91 |
/// <summary> |
92 |
/// 何もしない |
93 |
/// </summary> |
94 |
#endregion |
95 |
|
96 |
#region プロパティ |
97 |
/// <summary> |
98 |
/// 本稼働フラグ |
99 |
/// </summary> |
100 |
public static bool ProductionExecution |
101 |
{ |
102 |
get { return CommonDefine.m_ProductionExecution; } |
103 |
} |
104 |
/// <summary> |
105 |
/// 定義ファイル読込クラス |
106 |
/// </summary> |
107 |
public static DefinitionFileRead DFRModel |
108 |
{ |
109 |
get { return m_dfr_model; } |
110 |
} |
111 |
|
112 |
/// <summary> |
113 |
/// 管理マスタデータ |
114 |
/// </summary> |
115 |
public static SystemMaster SystemMasterData |
116 |
{ |
117 |
get { return m_systemMaster; } |
118 |
set { m_systemMaster = value; } |
119 |
} |
120 |
|
121 |
/// <summary> |
122 |
/// 消費税データ |
123 |
/// </summary> |
124 |
public static List<ConsumptionTax> ConsumptionTax |
125 |
{ |
126 |
get { return m_ConsumptionTax; } |
127 |
set { m_ConsumptionTax = value; } |
128 |
} |
129 |
|
130 |
/// <summary> |
131 |
/// ログインユーザー担当者データ |
132 |
/// </summary> |
133 |
public static PersonInChargeMaster LoginUserData |
134 |
{ |
135 |
get { return m_LoginUserData; } |
136 |
set { m_LoginUserData = value; } |
137 |
} |
138 |
|
139 |
/// <summary> |
140 |
/// ログインユーザー参照部署データ |
141 |
/// </summary> |
142 |
public static List<PersonDepartmentMaster> LoginUserRefDepartment |
143 |
{ |
144 |
get { return m_LoginUserRefDepartment; } |
145 |
set { m_LoginUserRefDepartment = value; } |
146 |
} |
147 |
|
148 |
/// <summary> |
149 |
/// ログインユーザーセキュリティ区分 |
150 |
/// </summary> |
151 |
public static SecurityMaster LoginUserSecurity |
152 |
{ |
153 |
get { return m_LoginUserSecurity; } |
154 |
set { m_LoginUserSecurity = value; } |
155 |
} |
156 |
|
157 |
/// <summary> |
158 |
/// ログインユーザー処理起動区分 |
159 |
/// </summary> |
160 |
public static List<ProcessExcute> LoginUserProcExe |
161 |
{ |
162 |
get { return m_LoginUserProcExe; } |
163 |
set { m_LoginUserProcExe = value; } |
164 |
} |
165 |
|
166 |
/// <summary> |
167 |
/// RGBカラーテーブル |
168 |
/// </summary> |
169 |
public static Color[] RGBColor |
170 |
{ |
171 |
get { return m_RGBColor; } |
172 |
set { m_RGBColor = value; } |
173 |
} |
174 |
|
175 |
/// <summary> |
176 |
/// 製品ファイルバージョン格納エリア |
177 |
/// </summary> |
178 |
public static FileVersionInfo ProductVersionInfo |
179 |
{ |
180 |
get { return m_ProductVersionInfo; } |
181 |
} |
182 |
|
183 |
#endregion |
184 |
|
185 |
#region 初期化 |
186 |
/// <summary> |
187 |
/// 初期化 |
188 |
/// </summary> |
189 |
public static bool Initialize() |
190 |
{ |
191 |
try |
192 |
{ |
193 |
// 定義ファイル読込 |
194 |
DefinitionFileInit(); |
195 |
|
196 |
// 他共通クラス初期化 |
197 |
DBCommon.Instance.Initialize(); |
198 |
|
199 |
// 管理マスタ取得 |
200 |
if (!SetSystemMaster()) return false; |
201 |
// 消費税データ取得 |
202 |
if (!SetconsumptionTax()) return false; |
203 |
|
204 |
// RGBカラーパレット作成処理 |
205 |
CreatePalette(); |
206 |
|
207 |
return true; |
208 |
} |
209 |
catch (Exception ex) |
210 |
{ |
211 |
logger.ErrorFormat("初期化エラー:{0}:{1}", GetMethodName(), ex.Message); |
212 |
return false; |
213 |
} |
214 |
} |
215 |
#endregion |
216 |
|
217 |
#region ---------- データ変換メソッド |
218 |
#region 西暦を和暦に変換する |
219 |
/// <summary> |
220 |
/// 西暦を和暦に変換する |
221 |
/// </summary> |
222 |
/// <returns></returns> |
223 |
public static string cnvJapaneseCalendar(DateTime Terget) |
224 |
{ |
225 |
try |
226 |
{ |
227 |
CultureInfo culture = new CultureInfo("ja-JP", true); |
228 |
culture.DateTimeFormat.Calendar = new JapaneseCalendar(); |
229 |
|
230 |
return Terget.ToString("ggyy年M月d日", culture); |
231 |
} |
232 |
catch (Exception ex) |
233 |
{ |
234 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
235 |
return string.Empty; |
236 |
} |
237 |
} |
238 |
#endregion |
239 |
|
240 |
#region 今の年号を取得する |
241 |
/// <summary> |
242 |
/// 今の年号を取得する |
243 |
/// </summary> |
244 |
/// <returns></returns> |
245 |
public static string GetNameOfAnEra(DateTime TargetDate) |
246 |
{ |
247 |
try |
248 |
{ |
249 |
CultureInfo culture = new CultureInfo("ja-JP", true); |
250 |
culture.DateTimeFormat.Calendar = new JapaneseCalendar(); |
251 |
|
252 |
return TargetDate.ToString("gg", culture); |
253 |
} |
254 |
catch (Exception ex) |
255 |
{ |
256 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
257 |
return string.Empty; |
258 |
} |
259 |
} |
260 |
#endregion |
261 |
|
262 |
#region Int値より文字列に変化して指定位置に指定文字を入れる。(工事番号編集) |
263 |
/// <summary> |
264 |
/// Int値より文字列に変化して指定位置に指定文字を入れる。 |
265 |
/// </summary> |
266 |
/// <param name="strCode"></param> |
267 |
/// <returns></returns> |
268 |
public static string cnvStringCodeFromInt(int IntCode, string strCode, int iPoint) |
269 |
{ |
270 |
try |
271 |
{ |
272 |
// 文字列変換 |
273 |
string strWork = IntCode.ToString(); |
274 |
// 指定位置が文字列長を超えている場合はエラー |
275 |
if (strWork.Length <= iPoint) return string.Empty; |
276 |
// 文字挿入 |
277 |
strWork = strWork.Substring(0, iPoint) + strCode + strWork.Substring(iPoint); |
278 |
return strWork; |
279 |
} |
280 |
catch (System.Exception ex) |
281 |
{ |
282 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
283 |
return string.Empty; |
284 |
} |
285 |
} |
286 |
#endregion |
287 |
|
288 |
#region 文字列より指定文字を除去してInt値に変換する |
289 |
/// <summary> |
290 |
/// 文字列より指定文字を除去してInt値に変換する |
291 |
/// </summary> |
292 |
/// <param name="strCode"></param> |
293 |
/// <returns></returns> |
294 |
public static int cnvIntFromStringCode(string strCode, string strRemove) |
295 |
{ |
296 |
try |
297 |
{ |
298 |
// 文字列除去後変換 |
299 |
return cnvInt(strCode.Replace(strRemove, "")); |
300 |
} |
301 |
catch (System.Exception ex) |
302 |
{ |
303 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
304 |
return 0; |
305 |
} |
306 |
} |
307 |
#endregion |
308 |
|
309 |
#region オブジェクトを日付に変換する |
310 |
/// <summary> |
311 |
/// 日付返還変換 |
312 |
/// </summary> |
313 |
/// <param name="sendData"></param> |
314 |
/// <returns></returns> |
315 |
public static DateTime cnvDate(object sendData) |
316 |
{ |
317 |
DateTime dtDateWork = DateTime.MinValue; |
318 |
try |
319 |
{ |
320 |
// 空判定 |
321 |
if (sendData == null) return dtDateWork; |
322 |
if (sendData.ToString().Length == 0) return dtDateWork; |
323 |
|
324 |
// 変換 |
325 |
bool bRet = DateTime.TryParse(sendData.ToString(), out dtDateWork); |
326 |
|
327 |
return dtDateWork; |
328 |
} |
329 |
catch (System.Exception ex) |
330 |
{ |
331 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
332 |
return dtDateWork; |
333 |
} |
334 |
} |
335 |
#endregion |
336 |
|
337 |
#region オブジェクトより数値変換(long) |
338 |
/// <summary> |
339 |
/// オブジェクトより数値変換(long) |
340 |
/// </summary> |
341 |
/// <param name="sendData"></param> |
342 |
/// <returns></returns> |
343 |
public static long cnvLong(object sendData) |
344 |
{ |
345 |
try |
346 |
{ |
347 |
long retData = 0; |
348 |
|
349 |
// 空判定 |
350 |
if (sendData == null) return retData; |
351 |
if (sendData.ToString().Trim().Length == 0) return retData; |
352 |
|
353 |
// 変換 |
354 |
long.TryParse(sendData.ToString().Replace(",", "").Replace("\\", "").Trim(), out retData); |
355 |
|
356 |
return retData; |
357 |
} |
358 |
catch (System.Exception ex) |
359 |
{ |
360 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
361 |
return 0; |
362 |
} |
363 |
} |
364 |
#endregion |
365 |
|
366 |
#region オブジェクトより数値変換(int) |
367 |
/// <summary> |
368 |
/// オブジェクトより数値変換(int) |
369 |
/// </summary> |
370 |
/// <param name="sendData"></param> |
371 |
/// <returns></returns> |
372 |
public static int cnvInt(object sendData) |
373 |
{ |
374 |
try |
375 |
{ |
376 |
int retData = 0; |
377 |
|
378 |
// 空判定 |
379 |
if (sendData == null) return retData; |
380 |
if (sendData.ToString().Trim().Length == 0) return retData; |
381 |
|
382 |
// 変換 |
383 |
int.TryParse(sendData.ToString().Replace(",", "").Replace("\\", "").Trim(), out retData); |
384 |
|
385 |
return retData; |
386 |
} |
387 |
catch (System.Exception ex) |
388 |
{ |
389 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
390 |
return 0; |
391 |
} |
392 |
} |
393 |
#endregion |
394 |
|
395 |
#region オブジェクトより数値変換(string) |
396 |
/// <summary> |
397 |
/// オブジェクトより数値変換(string) |
398 |
/// </summary> |
399 |
/// <param name="sendData"></param> |
400 |
/// <returns></returns> |
401 |
public static string cnvString(object sendData) |
402 |
{ |
403 |
try |
404 |
{ |
405 |
string retData = string.Empty; |
406 |
|
407 |
// 空判定 |
408 |
if (sendData == null) return retData; |
409 |
if (sendData.ToString().Trim().Length == 0) return retData; |
410 |
|
411 |
|
412 |
// 変換 |
413 |
retData = sendData.ToString(); |
414 |
|
415 |
return retData; |
416 |
} |
417 |
catch (System.Exception ex) |
418 |
{ |
419 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
420 |
return ""; |
421 |
} |
422 |
} |
423 |
#endregion |
424 |
|
425 |
#region オブジェクトより数値変換(double) |
426 |
/// <summary> |
427 |
/// オブジェクトより数値変換(double) |
428 |
/// </summary> |
429 |
/// <param name="sendData"></param> |
430 |
/// <returns></returns> |
431 |
public static double cnvDouble(object sendData) |
432 |
{ |
433 |
try |
434 |
{ |
435 |
double retData = 0; |
436 |
|
437 |
// 空判定 |
438 |
if (sendData == null) return retData; |
439 |
if (sendData.ToString().Trim().Length == 0) return retData; |
440 |
|
441 |
|
442 |
// 変換 |
443 |
double.TryParse(sendData.ToString().Replace(",", "").Replace("\\", "").Trim(), out retData); |
444 |
|
445 |
return retData; |
446 |
} |
447 |
catch (System.Exception ex) |
448 |
{ |
449 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
450 |
return 0; |
451 |
} |
452 |
} |
453 |
#endregion |
454 |
|
455 |
#region オブジェクトより数値変換(float) |
456 |
/// <summary> |
457 |
/// オブジェクトより数値変換(float) |
458 |
/// </summary> |
459 |
/// <param name="sendData"></param> |
460 |
/// <returns></returns> |
461 |
public static float cnvFloat(object sendData) |
462 |
{ |
463 |
try |
464 |
{ |
465 |
float retData = 0; |
466 |
|
467 |
// 空判定 |
468 |
if (sendData == null) return retData; |
469 |
if (sendData.ToString().Trim().Length == 0) return retData; |
470 |
|
471 |
|
472 |
// 変換 |
473 |
float.TryParse(sendData.ToString().Replace(",", "").Replace("\\", "").Trim(), out retData); |
474 |
|
475 |
return retData; |
476 |
} |
477 |
catch (System.Exception ex) |
478 |
{ |
479 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
480 |
return 0; |
481 |
} |
482 |
} |
483 |
#endregion |
484 |
|
485 |
#region オブジェクトより数値変換(decimal) |
486 |
/// <summary> |
487 |
/// オブジェクトより数値変換(decimal) |
488 |
/// </summary> |
489 |
/// <param name="sendData"></param> |
490 |
/// <returns></returns> |
491 |
public static decimal cnvDecimal(object sendData) |
492 |
{ |
493 |
try |
494 |
{ |
495 |
decimal retData = 0; |
496 |
|
497 |
// 空判定 |
498 |
if (sendData == null) return retData; |
499 |
if (sendData.ToString().Trim().Length == 0) return retData; |
500 |
|
501 |
|
502 |
// 変換 |
503 |
decimal.TryParse(sendData.ToString().Replace(",", "").Replace("\\", "").Trim(), out retData); |
504 |
|
505 |
return retData; |
506 |
} |
507 |
catch (System.Exception ex) |
508 |
{ |
509 |
Console.WriteLine("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
510 |
return 0; |
511 |
} |
512 |
} |
513 |
#endregion |
514 |
|
515 |
#region オブジェクトよりBool値変換(bool) |
516 |
/// <summary> |
517 |
/// オブジェクトよりBool値変換(bool) |
518 |
/// </summary> |
519 |
/// <param name="sendData"></param> |
520 |
/// <returns></returns> |
521 |
public static bool cnvBool(object sendData) |
522 |
{ |
523 |
try |
524 |
{ |
525 |
bool retData = false; |
526 |
|
527 |
// 空判定 |
528 |
if (sendData == null) return retData; |
529 |
if (sendData.ToString().Trim().Length == 0) return retData; |
530 |
|
531 |
// 変換 |
532 |
bool.TryParse(sendData.ToString(), out retData); |
533 |
|
534 |
return retData; |
535 |
} |
536 |
catch (System.Exception ex) |
537 |
{ |
538 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
539 |
return false; |
540 |
} |
541 |
} |
542 |
#endregion |
543 |
|
544 |
#region オブジェクトより数値変換(TimeSpan) |
545 |
/// <summary> |
546 |
/// オブジェクトより数値変換(TimeSpan) |
547 |
/// </summary> |
548 |
/// <param name="sendData"></param> |
549 |
/// <returns></returns> |
550 |
public static TimeSpan cnvTimeSpan(object sendData) |
551 |
{ |
552 |
try |
553 |
{ |
554 |
TimeSpan retData = TimeSpan.Zero; |
555 |
|
556 |
// 空判定 |
557 |
if (sendData == null) return retData; |
558 |
if (sendData.ToString().Trim().Length == 0) return retData; |
559 |
|
560 |
|
561 |
// 変換 |
562 |
TimeSpan.TryParse(sendData.ToString().Trim(), out retData); |
563 |
|
564 |
return retData; |
565 |
} |
566 |
catch (System.Exception ex) |
567 |
{ |
568 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
569 |
return TimeSpan.MinValue; |
570 |
} |
571 |
} |
572 |
#endregion |
573 |
|
574 |
#region decimal値をTimeSpan値へ変換する |
575 |
/// <summary> |
576 |
/// decimal値をTimeSpan値へ変換する |
577 |
/// </summary> |
578 |
public static TimeSpan cnvDecimal2TimeSpan(decimal sendData) |
579 |
{ |
580 |
try |
581 |
{ |
582 |
TimeSpan retData = TimeSpan.Zero; |
583 |
|
584 |
// 空判定 |
585 |
if (sendData.ToString().Trim().Length == 0) return retData; |
586 |
|
587 |
// 変換 |
588 |
retData = new TimeSpan((int)sendData, (int)((sendData % 1) * 100.00m), 0); |
589 |
|
590 |
return retData; |
591 |
} |
592 |
catch (System.Exception ex) |
593 |
{ |
594 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
595 |
return TimeSpan.MinValue; |
596 |
} |
597 |
} |
598 |
#endregion |
599 |
|
600 |
#region TimeSpan値をdecimal値へ変換する |
601 |
/// <summary> |
602 |
/// TimeSpan値をdecimal値へ変換する |
603 |
/// </summary> |
604 |
public static decimal cnvTimeSpan2Decimal(TimeSpan sendData) |
605 |
{ |
606 |
try |
607 |
{ |
608 |
decimal retData = 0; |
609 |
|
610 |
// 空判定 |
611 |
if (sendData.ToString().Trim().Length == 0) return retData; |
612 |
|
613 |
// 変換 |
614 |
retData = sendData.Hours + (sendData.Minutes / 100.00m); |
615 |
|
616 |
return retData; |
617 |
} |
618 |
catch (System.Exception ex) |
619 |
{ |
620 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
621 |
return 0.0m; |
622 |
} |
623 |
} |
624 |
#endregion |
625 |
|
626 |
#region 四捨五入 |
627 |
/// <summary> |
628 |
/// 四捨五入 |
629 |
/// </summary> |
630 |
/// <param name="InputData"></param> |
631 |
/// <returns></returns> |
632 |
public static int cnvRound(double InputData) |
633 |
{ |
634 |
int retRoundData = 0; |
635 |
try |
636 |
{ |
637 |
retRoundData = (int)Math.Round(InputData, MidpointRounding.AwayFromZero); |
638 |
|
639 |
return retRoundData; |
640 |
} |
641 |
catch (System.Exception ex) |
642 |
{ |
643 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
644 |
return retRoundData; |
645 |
} |
646 |
} |
647 |
#endregion |
648 |
|
649 |
#region 切り上げ |
650 |
/// <summary> |
651 |
/// 切り上げ |
652 |
/// </summary> |
653 |
/// <param name="InputData"></param> |
654 |
/// <returns></returns> |
655 |
public static int cnvRoundUp(double InputData) |
656 |
{ |
657 |
int retRoundData = 0; |
658 |
try |
659 |
{ |
660 |
retRoundData = (int)Math.Ceiling(InputData); |
661 |
|
662 |
return retRoundData; |
663 |
} |
664 |
catch (System.Exception ex) |
665 |
{ |
666 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
667 |
return retRoundData; |
668 |
} |
669 |
} |
670 |
#endregion |
671 |
|
672 |
#region 切り捨て |
673 |
/// <summary> |
674 |
/// 切り捨て |
675 |
/// </summary> |
676 |
/// <param name="InputData"></param> |
677 |
/// <returns></returns> |
678 |
public static int cnvTruncate(double InputData) |
679 |
{ |
680 |
int retRoundData = 0; |
681 |
try |
682 |
{ |
683 |
retRoundData = (int)Math.Truncate(InputData); |
684 |
|
685 |
return retRoundData; |
686 |
} |
687 |
catch (System.Exception ex) |
688 |
{ |
689 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
690 |
return retRoundData; |
691 |
} |
692 |
} |
693 |
#endregion |
694 |
|
695 |
#region 四捨五入(四捨五入位置指定) |
696 |
/// <summary> |
697 |
/// 四捨五入(四捨五入位置指定) |
698 |
/// </summary> |
699 |
/// <param name="value"></param> |
700 |
/// <param name="pos"></param> |
701 |
/// <returns></returns> |
702 |
public static int IntRound(double value, int pos) |
703 |
{ |
704 |
// 何乗かを求める |
705 |
int posion = (int)Math.Pow(10, (pos + 1)); |
706 |
|
707 |
int upperval = (int)(value / posion); |
708 |
upperval *= posion; |
709 |
int lowerval = (int)(value % posion); |
710 |
int chkval = (int)(lowerval / Math.Pow(10, pos)); |
711 |
if (chkval > 4) upperval += (1 * posion); |
712 |
|
713 |
return upperval; |
714 |
} |
715 |
#endregion |
716 |
|
717 |
#region 切り捨て(切り捨て位置指定) |
718 |
/// <summary> |
719 |
/// 切り捨て(切り捨て位置指定) |
720 |
/// </summary> |
721 |
/// <param name="value"></param> |
722 |
/// <param name="pos"></param> |
723 |
/// <returns></returns> |
724 |
public static int IntRoundDown(double value, int pos) |
725 |
{ |
726 |
// 何乗かを求める |
727 |
int posion = (int)Math.Pow(10, (pos + 1)); |
728 |
|
729 |
int upperval = (int)(value / posion); |
730 |
upperval *= posion; |
731 |
|
732 |
return upperval; |
733 |
} |
734 |
#endregion |
735 |
|
736 |
#region 切り上げ(切り上げ位置指定) |
737 |
/// <summary> |
738 |
/// 切り上げ(切り上げ位置指定) |
739 |
/// </summary> |
740 |
/// <param name="value"></param> |
741 |
/// <param name="pos"></param> |
742 |
/// <returns></returns> |
743 |
public static int IntRoundUp(double value, int pos) |
744 |
{ |
745 |
// 何乗かを求める |
746 |
int posion = (int)Math.Pow(10, (pos + 1)); |
747 |
|
748 |
int upperval = (int)(value / posion); |
749 |
upperval *= posion; |
750 |
int lowerval = (int)(value % posion); |
751 |
int chkval = (int)(lowerval / Math.Pow(10, pos)); |
752 |
if (chkval > 0) upperval += (1 * posion); |
753 |
|
754 |
return upperval; |
755 |
} |
756 |
public static decimal DecimalRoundUp(decimal value, int pos) |
757 |
{ |
758 |
// 何乗かを求める |
759 |
int posion = (int)Math.Pow(10, pos); |
760 |
|
761 |
return (Math.Ceiling(value * posion) / posion); |
762 |
} |
763 |
#endregion |
764 |
|
765 |
#region 0~26までの数字をA~Zに変換する |
766 |
/// <summary> |
767 |
/// 0~26までの数字をA~Zに変換する |
768 |
/// </summary> |
769 |
/// <param name="num"></param> |
770 |
/// <returns></returns> |
771 |
public static string cnvNumberToAlphaCharacter(int num) |
772 |
{ |
773 |
try |
774 |
{ |
775 |
// ----- 16進数文字列 -> 数値 |
776 |
int CnvCode = Convert.ToInt32("0041", 16); // 'A' |
777 |
int LastCode = Convert.ToInt32("005A", 16); // 'Z' |
778 |
|
779 |
// 'Z'を超えたら余剰を使って変換する |
780 |
int work = (CnvCode + num); |
781 |
if (work <= LastCode) |
782 |
{ |
783 |
// 変換値を加算する |
784 |
CnvCode += num; |
785 |
} |
786 |
else |
787 |
{ |
788 |
CnvCode += (work % LastCode); |
789 |
} |
790 |
// 'Z'を超えたら採番しない |
791 |
//if (CnvCode > LastCode) return string.Empty; |
792 |
|
793 |
// 数値(文字コード) -> 文字 |
794 |
char c = Convert.ToChar(CnvCode); |
795 |
// 英字「文字列」 |
796 |
string newChar = c.ToString(); |
797 |
|
798 |
return newChar; |
799 |
} |
800 |
catch (System.Exception ex) |
801 |
{ |
802 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
803 |
return ""; |
804 |
} |
805 |
} |
806 |
#endregion |
807 |
|
808 |
#region 日付が最小値ならば"未定"文字を返す |
809 |
/// <summary> |
810 |
/// 日付が最小値ならば"未定"文字を返す |
811 |
/// </summary> |
812 |
/// <param name="srcDate"></param> |
813 |
/// <returns></returns> |
814 |
public static string cnvDateToUndecidedString(DateTime srcDate) |
815 |
{ |
816 |
try |
817 |
{ |
818 |
string work = ""; |
819 |
if (srcDate.Equals(DateTime.MinValue)) |
820 |
work = CommonDefine.s_UndecidedString; |
821 |
else |
822 |
work = srcDate.ToShortDateString(); |
823 |
|
824 |
return work; |
825 |
} |
826 |
catch (System.Exception ex) |
827 |
{ |
828 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
829 |
return ""; |
830 |
} |
831 |
} |
832 |
#endregion |
833 |
|
834 |
#region オブジェクトより日付を返す(文字列が"未定"文字ならば日付最小値を返す) |
835 |
/// <summary> |
836 |
/// オブジェクトより日付を返す |
837 |
/// 文字列が"未定"文字ならば日付最小値を返す |
838 |
/// </summary> |
839 |
/// <param name="srcDate"></param> |
840 |
/// <returns></returns> |
841 |
public static DateTime cnvUndecidedStringToDate(object srcDate) |
842 |
{ |
843 |
DateTime work = DateTime.MinValue; |
844 |
try |
845 |
{ |
846 |
if (!srcDate.Equals(CommonDefine.s_UndecidedString)) |
847 |
work = cnvDate(srcDate); |
848 |
|
849 |
return work; |
850 |
} |
851 |
catch (System.Exception ex) |
852 |
{ |
853 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
854 |
return work; |
855 |
} |
856 |
} |
857 |
#endregion |
858 |
|
859 |
#region オブジェクトより数値(文字列が"未定"文字ならば0を返す) |
860 |
/// <summary> |
861 |
/// オブジェクトより数値 |
862 |
/// 文字列が"未定"文字ならば0を返す |
863 |
/// </summary> |
864 |
/// <param name="srcDate"></param> |
865 |
/// <returns></returns> |
866 |
public static double cnvUndecidedStringToDouble(object srcDate) |
867 |
{ |
868 |
double work = 0; |
869 |
try |
870 |
{ |
871 |
if (!srcDate.Equals(CommonDefine.s_UndecidedString)) |
872 |
work = cnvDouble(srcDate); |
873 |
|
874 |
return work; |
875 |
} |
876 |
catch (System.Exception ex) |
877 |
{ |
878 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
879 |
return work; |
880 |
} |
881 |
} |
882 |
#endregion |
883 |
|
884 |
#region 色指定文字列より色を返す |
885 |
/// <summary> |
886 |
/// 色指定文字列より色を返す |
887 |
/// </summary> |
888 |
/// <param name="strColor"></param> |
889 |
/// <returns></returns> |
890 |
public static Color cnvStringToColor(string strColor) |
891 |
{ |
892 |
Color ColorRet = Color.White; |
893 |
try |
894 |
{ |
895 |
// 色文字列チェック |
896 |
if (!CommonMotions.chkObjectIsNull(strColor) && strColor.Length != 0) |
897 |
{ |
898 |
ColorRet = ColorTranslator.FromHtml(strColor); |
899 |
} |
900 |
return ColorRet; |
901 |
} |
902 |
catch (System.Exception ex) |
903 |
{ |
904 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
905 |
return ColorRet; |
906 |
} |
907 |
} |
908 |
#endregion |
909 |
|
910 |
#region 色指定文字列より色を返す・設定無しは指定場所のデフォルトを返す |
911 |
/// <summary> |
912 |
/// 色指定文字列より色を返す・設定無しは指定場所のデフォルトを返す |
913 |
/// </summary> |
914 |
/// <param name="strColor"></param> |
915 |
/// <param name="point"></param> |
916 |
/// <returns></returns> |
917 |
public static Color getBackForeColor(string strColor, TermMaster.PalceOfColorDef point) |
918 |
{ |
919 |
Color ColorRet = Color.White; |
920 |
try |
921 |
{ |
922 |
// デフォルトセット |
923 |
if (point == TermMaster.PalceOfColorDef.BackColor) |
924 |
{ // 背景 |
925 |
ColorRet = Color.White; |
926 |
} |
927 |
else if (point == TermMaster.PalceOfColorDef.ForeColor) |
928 |
{ // 文字色 |
929 |
ColorRet = Color.Black; |
930 |
} |
931 |
else |
932 |
{ |
933 |
ColorRet = Color.Transparent; |
934 |
} |
935 |
|
936 |
if (!chkObjectIsNull(strColor) && strColor.Length != 0) |
937 |
{ |
938 |
} |
939 |
else |
940 |
{ |
941 |
strColor = String.Format("0x{0:X2}{1:X2}{2:X2}", ColorRet.R, ColorRet.G, ColorRet.B); |
942 |
} |
943 |
|
944 |
ColorRet = cnvStringToColor(strColor); |
945 |
|
946 |
return ColorRet; |
947 |
} |
948 |
catch (System.Exception ex) |
949 |
{ |
950 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
951 |
return ColorRet; |
952 |
} |
953 |
} |
954 |
#endregion |
955 |
|
956 |
#region 補色を取得する |
957 |
/// <summary> |
958 |
/// 補色を取得する |
959 |
/// </summary> |
960 |
/// <param name="color"></param> |
961 |
/// <returns></returns> |
962 |
public static Color GetComplementaryColor(Color color) |
963 |
{ |
964 |
try |
965 |
{ |
966 |
byte r = (byte)(color.R ^ 0xFF); |
967 |
byte g = (byte)(color.G ^ 0xFF); |
968 |
byte b = (byte)(color.B ^ 0xFF); |
969 |
|
970 |
return Color.FromArgb(r, g, b); |
971 |
} |
972 |
catch (System.Exception ex) |
973 |
{ |
974 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
975 |
return color; |
976 |
} |
977 |
} |
978 |
#endregion |
979 |
|
980 |
#region 指定桁数の数値最大値を返す |
981 |
/// <summary> |
982 |
/// 指定桁数の数値最大値を返す |
983 |
/// </summary> |
984 |
/// <param name="NumLen"></param> |
985 |
/// <returns></returns> |
986 |
public static int CreateMaxNumeric(int NumLen) |
987 |
{ |
988 |
try |
989 |
{ |
990 |
string strNum = string.Empty; |
991 |
for (int i = 0; i < NumLen; i++) |
992 |
{ |
993 |
strNum += "9"; |
994 |
} |
995 |
|
996 |
return cnvInt(strNum); |
997 |
} |
998 |
catch (System.Exception ex) |
999 |
{ |
1000 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
1001 |
return 0; |
1002 |
} |
1003 |
} |
1004 |
#endregion |
1005 |
|
1006 |
#region RGBカラーパレット作成処理 |
1007 |
/// <summary> |
1008 |
/// RGBカラーパレット作成処理 |
1009 |
/// </summary> |
1010 |
/// <returns></returns> |
1011 |
private static void CreatePalette() |
1012 |
{ |
1013 |
try |
1014 |
{ |
1015 |
// 青→緑 |
1016 |
for (int i = 0; i < 64; i++) |
1017 |
{ |
1018 |
int _green = i * 4; |
1019 |
m_RGBColor[i] = Color.FromArgb(255, 0, _green, 255 - _green); |
1020 |
} |
1021 |
// 緑→黄 |
1022 |
for (int i = 0; i < 64; i++) |
1023 |
{ |
1024 |
int _red = i * 4; |
1025 |
m_RGBColor[i + 64] = Color.FromArgb(255, _red, 255, 0); |
1026 |
|
1027 |
} |
1028 |
// 黄→赤 |
1029 |
for (int i = 0; i < 128; i++) |
1030 |
{ |
1031 |
int _green = 255 - i * 2; |
1032 |
m_RGBColor[i + 128] = Color.FromArgb(255, 255, _green, 0); |
1033 |
} |
1034 |
} |
1035 |
catch (Exception ex) |
1036 |
{ |
1037 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
1038 |
} |
1039 |
} |
1040 |
#endregion |
1041 |
|
1042 |
#region 半角数字を全角数字に変換する。 |
1043 |
/// <summary> |
1044 |
/// 半角数字を全角数字に変換する。 |
1045 |
/// </summary> |
1046 |
public static string HanToZenNum(string s) |
1047 |
{ |
1048 |
return Regex.Replace(s, "[0-9]", p => ((char)(p.Value[0] - '0' + '0')).ToString()); |
1049 |
} |
1050 |
#endregion |
1051 |
|
1052 |
#endregion |
1053 |
|
1054 |
#region ---------- データチェックメソッド |
1055 |
#region ディレクトリの存在チェック |
1056 |
/// <summary> |
1057 |
/// ディレクトリの存在チェック |
1058 |
/// </summary> |
1059 |
/// <param name="DirectryName">フォルダパス</param> |
1060 |
/// <returns></returns> |
1061 |
public static bool ChkDirPath(string DirectryName, bool CreateFlg = false) |
1062 |
{ |
1063 |
try |
1064 |
{ |
1065 |
// フォルダ (ディレクトリ) が存在しているかどうか確認する |
1066 |
if (!Directory.Exists(@DirectryName)) |
1067 |
{ |
1068 |
// 作成フラグOffならばエラー |
1069 |
if (!CreateFlg) return false; |
1070 |
|
1071 |
// ディレクトリを作成する |
1072 |
Directory.CreateDirectory(@DirectryName); |
1073 |
} |
1074 |
|
1075 |
return true; |
1076 |
} |
1077 |
catch (Exception ex) |
1078 |
{ |
1079 |
logger.ErrorFormat(ex.Message); |
1080 |
return false; |
1081 |
} |
1082 |
} |
1083 |
#endregion |
1084 |
|
1085 |
#region オブジェクトのNullチェック |
1086 |
/// <summary> |
1087 |
/// オブジェクトのNullチェック |
1088 |
/// </summary> |
1089 |
/// <param name="sendData">オブジェクト</param> |
1090 |
/// <returns></returns> |
1091 |
public static bool chkObjectIsNull(Object sendData) |
1092 |
{ |
1093 |
try |
1094 |
{ |
1095 |
if (sendData == null) return true; |
1096 |
|
1097 |
return false; |
1098 |
} |
1099 |
catch (System.Exception ex) |
1100 |
{ |
1101 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
1102 |
return false; |
1103 |
} |
1104 |
} |
1105 |
#endregion |
1106 |
|
1107 |
#region 数値チェック |
1108 |
/// <summary> |
1109 |
/// 数値チェック |
1110 |
/// </summary> |
1111 |
/// <param name="data">Long文字列</param> |
1112 |
/// <param name="indispensable">入力必須チェック</param> |
1113 |
/// <returns>true:正常 false:異常</returns> |
1114 |
public static bool chkNumeric(object CheckData, bool indispensable = false) |
1115 |
{ |
1116 |
try |
1117 |
{ |
1118 |
if (chkObjectIsNull(CheckData)) return false; |
1119 |
|
1120 |
string RecvData = cnvString(CheckData); |
1121 |
double revData = 0; |
1122 |
// 必須入力チェック |
1123 |
if (indispensable) |
1124 |
{ |
1125 |
if (RecvData.Replace(",", "").Replace("\\", "").Trim().Length == 0) return false; |
1126 |
} |
1127 |
// Nullが入っていなくてレングスが0は数値として扱う |
1128 |
if (RecvData.Replace(",", "").Replace("\\", "").Trim().Length == 0) return true; |
1129 |
|
1130 |
return double.TryParse(RecvData.Replace(",", "").Replace("\\", "").Trim(), out revData); |
1131 |
} |
1132 |
catch (System.Exception ex) |
1133 |
{ |
1134 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
1135 |
return false; |
1136 |
} |
1137 |
} |
1138 |
#endregion |
1139 |
|
1140 |
#region 数値チェック(long) |
1141 |
/// <summary> |
1142 |
/// 数値チェック(long) |
1143 |
/// </summary> |
1144 |
/// <param name="data">Long文字列</param> |
1145 |
/// <param name="indispensable">入力必須チェック</param> |
1146 |
/// <returns>true:正常 false:異常</returns> |
1147 |
public static bool chkNumeric(object sendData, ref long retData, bool indispensable = false) |
1148 |
{ |
1149 |
try |
1150 |
{ |
1151 |
// 必須入力チェック |
1152 |
if (indispensable) |
1153 |
{ |
1154 |
if (cnvString(sendData).Replace(",", "").Replace("\\", "").Trim().Length == 0) return false; |
1155 |
} |
1156 |
|
1157 |
return long.TryParse(cnvString(sendData).Replace(",", "").Replace("\\", "").Trim(), out retData); |
1158 |
} |
1159 |
catch (System.Exception ex) |
1160 |
{ |
1161 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
1162 |
return false; |
1163 |
} |
1164 |
} |
1165 |
#endregion |
1166 |
|
1167 |
#region 数値チェック(int) |
1168 |
/// <summary> |
1169 |
/// 数値チェック(int) |
1170 |
/// </summary> |
1171 |
/// <param name="data">Long文字列</param> |
1172 |
/// <param name="indispensable">入力必須チェック</param> |
1173 |
/// <returns>true:正常 false:異常</returns> |
1174 |
public static bool chkNumeric(object sendData, ref int retData, bool indispensable = false) |
1175 |
{ |
1176 |
try |
1177 |
{ |
1178 |
// 必須入力チェック |
1179 |
if (indispensable) |
1180 |
{ |
1181 |
if (cnvString(sendData).Replace(",", "").Replace("\\", "").Trim().Length == 0) return false; |
1182 |
} |
1183 |
|
1184 |
return int.TryParse(cnvString(sendData).Replace(",", "").Replace("\\", "").Trim(), out retData); |
1185 |
} |
1186 |
catch (System.Exception ex) |
1187 |
{ |
1188 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
1189 |
return false; |
1190 |
} |
1191 |
} |
1192 |
#endregion |
1193 |
|
1194 |
#region 数値チェック(double) |
1195 |
/// <summary> |
1196 |
/// 数値チェック(double) |
1197 |
/// </summary> |
1198 |
/// <param name="data">Long文字列</param> |
1199 |
/// <param name="indispensable">入力必須チェック</param> |
1200 |
/// <returns>true:正常 false:異常</returns> |
1201 |
public static bool chkNumeric(object sendData, ref double retData, bool indispensable = false) |
1202 |
{ |
1203 |
try |
1204 |
{ |
1205 |
// 必須入力チェック |
1206 |
if (indispensable) |
1207 |
{ |
1208 |
if (cnvString(sendData).Replace(",", "").Replace("\\", "").Trim().Length == 0) return false; |
1209 |
} |
1210 |
|
1211 |
return double.TryParse(cnvString(sendData).Replace(",", "").Replace("\\", "").Trim(), out retData); |
1212 |
} |
1213 |
catch (System.Exception ex) |
1214 |
{ |
1215 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
1216 |
return false; |
1217 |
} |
1218 |
} |
1219 |
#endregion |
1220 |
|
1221 |
#region 時間チェック(TimeSpan) |
1222 |
/// <summary> |
1223 |
/// 時間チェック(TimeSpan) |
1224 |
/// </summary> |
1225 |
/// <returns>true:正常 false:異常</returns> |
1226 |
public static bool chkTimeSpan(object sendData, ref TimeSpan retData, bool indispensable = false) |
1227 |
{ |
1228 |
try |
1229 |
{ |
1230 |
// 必須入力チェック |
1231 |
if (indispensable) |
1232 |
{ |
1233 |
if (cnvString(sendData).Trim().Length == 0) return false; |
1234 |
} |
1235 |
|
1236 |
return TimeSpan.TryParse(cnvString(sendData).Replace(",", "").Replace("\\", "").Trim(), out retData); |
1237 |
} |
1238 |
catch (System.Exception ex) |
1239 |
{ |
1240 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
1241 |
return false; |
1242 |
} |
1243 |
} |
1244 |
#endregion |
1245 |
|
1246 |
#region 文字列長さチェック(UTF-8) |
1247 |
/// <summary> |
1248 |
/// 文字列長さチェック(UTF-8) |
1249 |
/// </summary> |
1250 |
/// <param name="strData">対象文字列</param> |
1251 |
/// <param name="lngMaxLen">最大長</param> |
1252 |
/// <param name="indispensable">入力必須チェック</param> |
1253 |
/// <returns>true:正常 false:異常</returns> |
1254 |
public static bool chkStringLength(string strData, int lngMaxLen, bool indispensable = false) |
1255 |
{ |
1256 |
bool bRet = true; |
1257 |
//int lngLen = 0; |
1258 |
try |
1259 |
{ |
1260 |
|
1261 |
//Encoding sjis = Encoding.GetEncoding("shift-jis"); |
1262 |
Encoding utf8 = Encoding.GetEncoding("utf-8"); |
1263 |
|
1264 |
// 必須入力チェック |
1265 |
if (indispensable) |
1266 |
{ |
1267 |
if (strData.Length == 0) bRet = false; |
1268 |
} |
1269 |
// S-Jisチェック |
1270 |
//lngLen = sjis.GetByteCount(strData); |
1271 |
// UTF-8チェック |
1272 |
//lngLen = utf8.GetByteCount(strData); |
1273 |
//if (lngLen > lngMaxLen) bRet = false; |
1274 |
// C#内はUTFなので文字長だけをチェックする |
1275 |
if (strData.Length > lngMaxLen) bRet = false; |
1276 |
} |
1277 |
catch (System.Exception ex) |
1278 |
{ |
1279 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
1280 |
bRet = false; |
1281 |
} |
1282 |
|
1283 |
return bRet; |
1284 |
} |
1285 |
#endregion |
1286 |
|
1287 |
#region 郵便番号チェック |
1288 |
/// <summary> |
1289 |
/// 郵便番号チェック |
1290 |
/// </summary> |
1291 |
/// <param name="strData">郵便番号文字列</param> |
1292 |
/// <returns>true:正常 false:異常</returns> |
1293 |
public static bool chkZipcode(string strdata) |
1294 |
{ |
1295 |
bool bRet = false; |
1296 |
|
1297 |
Regex regex = new Regex("^[0-9]{3}[-][0-9]{4}$"); |
1298 |
if (regex.IsMatch(strdata)) |
1299 |
{ |
1300 |
bRet = true; |
1301 |
} |
1302 |
return bRet; |
1303 |
} |
1304 |
#endregion |
1305 |
|
1306 |
#region 電話番号/FAX番号チェック |
1307 |
/// <summary> |
1308 |
/// 電話番号/FAX番号チェック |
1309 |
/// </summary> |
1310 |
/// <param name="data">電話番号文字列</param> |
1311 |
/// <returns>true:正常 false:異常</returns> |
1312 |
public static bool chkPhoneNumber(string strdata) |
1313 |
{ |
1314 |
bool bRet = false; |
1315 |
|
1316 |
Regex regex = new Regex("^[0-9]{2,5}-[0-9]{1,4}-[0-9]{3,4}$"); |
1317 |
if (regex.IsMatch(strdata)) |
1318 |
{ |
1319 |
bRet = true; |
1320 |
} |
1321 |
return bRet; |
1322 |
} |
1323 |
#endregion |
1324 |
|
1325 |
#region メールアドレスチェック |
1326 |
/// <summary> |
1327 |
/// メールアドレスチェック |
1328 |
/// </summary> |
1329 |
/// <param name="data">電話番号文字列</param> |
1330 |
/// <returns>true:正常 false:異常</returns> |
1331 |
public static bool chkMailAddress(string strdata) |
1332 |
{ |
1333 |
bool bRet = false; |
1334 |
|
1335 |
Regex regex = new Regex(@"\A\P{Cc}+@\P{Cc}+\z"); |
1336 |
if (regex.IsMatch(strdata)) |
1337 |
{ |
1338 |
bRet = true; |
1339 |
} |
1340 |
return bRet; |
1341 |
} |
1342 |
#endregion |
1343 |
|
1344 |
#region 日付チェック |
1345 |
/// <summary> |
1346 |
/// 日付チェック |
1347 |
/// </summary> |
1348 |
/// <param name="data">日付文字列</param> |
1349 |
/// <returns>true:正常 false:異常</returns> |
1350 |
public static bool chkDate(string strdata) |
1351 |
{ |
1352 |
bool bRet = true; |
1353 |
try |
1354 |
{ |
1355 |
DateTime dtwork = DateTime.MinValue; |
1356 |
|
1357 |
return DateTime.TryParse(strdata, out dtwork); |
1358 |
} |
1359 |
catch (System.Exception ex) |
1360 |
{ |
1361 |
logger.DebugFormat("chkDate Error message:{0}", ex.Message); |
1362 |
bRet = false; |
1363 |
} |
1364 |
return bRet; |
1365 |
} |
1366 |
#endregion |
1367 |
|
1368 |
#region 対象が空かどうかをチェックする |
1369 |
/// <summary> |
1370 |
/// 対象が空かどうかをチェックする |
1371 |
/// </summary> |
1372 |
/// <param name="objCell"></param> |
1373 |
/// <param name="iColumn"></param> |
1374 |
/// <returns>true:空 flase:有効</returns> |
1375 |
public static bool chkCellBlank(object objCell) |
1376 |
{ |
1377 |
try |
1378 |
{ |
1379 |
if (chkObjectIsNull(objCell)) return true; |
1380 |
if (objCell.ToString().Length == 0) return true; |
1381 |
|
1382 |
return false; |
1383 |
} |
1384 |
catch (System.Exception ex) |
1385 |
{ |
1386 |
logger.DebugFormat("chkDate Error message:{0}", ex.Message); |
1387 |
return true; |
1388 |
} |
1389 |
} |
1390 |
#endregion |
1391 |
|
1392 |
#region 指定文字が全てひらがなのチェック |
1393 |
/// <summary> |
1394 |
/// 指定文字が全てひらがなのチェック |
1395 |
/// </summary> |
1396 |
/// <param name="str"></param> |
1397 |
/// <returns></returns> |
1398 |
public static bool chkIsHiragana(string str) |
1399 |
{ |
1400 |
return Regex.IsMatch(str, @"^\p{IsHiragana}*$"); |
1401 |
} |
1402 |
#endregion |
1403 |
|
1404 |
#region 指定文字が全てカタカナのチェック |
1405 |
/// <summary> |
1406 |
/// 指定文字が全てカタカナのチェック |
1407 |
/// </summary> |
1408 |
/// <param name="str"></param> |
1409 |
/// <returns></returns> |
1410 |
public static bool chkIsKatakana(string str) |
1411 |
{ |
1412 |
return Regex.IsMatch(str, @"^\p{IsKatakana}*$"); |
1413 |
} |
1414 |
#endregion |
1415 |
|
1416 |
#region 指定文字が全て数字のチェック |
1417 |
/// <summary> |
1418 |
/// 指定文字が全て数字のチェック |
1419 |
/// </summary> |
1420 |
/// <param name="str"></param> |
1421 |
/// <returns></returns> |
1422 |
public static bool chkIsNumeric(string str) |
1423 |
{ |
1424 |
return Regex.IsMatch(str, @"[^a-zA-z0-9-_]"); |
1425 |
} |
1426 |
#endregion |
1427 |
|
1428 |
#region 画面フィールド入力必須チェック |
1429 |
/// <summary> |
1430 |
/// 画面フィールド入力必須チェック |
1431 |
/// </summary> |
1432 |
/// <param name="dispControl">コントロールオブジェクト</param> |
1433 |
/// <returns>false:エラー true:エラーなし</returns> |
1434 |
public static bool DispFieldIndispensable(Control dispControl) |
1435 |
{ |
1436 |
bool bAns = true; |
1437 |
try |
1438 |
{ |
1439 |
// 必須入力チェック |
1440 |
if (chkObjectIsNull(dispControl)) |
1441 |
{ |
1442 |
bAns = false; |
1443 |
} |
1444 |
else |
1445 |
{ |
1446 |
if (dispControl.Text.ToString().Length == 0) |
1447 |
{ |
1448 |
bAns = false; |
1449 |
} |
1450 |
} |
1451 |
} |
1452 |
catch (Exception ex) |
1453 |
{ |
1454 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", GetMethodName(), GetMethodName(2), ex.Message); |
1455 |
bAns = false; |
1456 |
} |
1457 |
finally |
1458 |
{ |
1459 |
// 背景色変更 |
1460 |
chgBackColor(dispControl, bAns); |
1461 |
} |
1462 |
return bAns; |
1463 |
} |
1464 |
#endregion |
1465 |
|
1466 |
#region 画面フィールド入力文字数チェック |
1467 |
/// <summary> |
1468 |
/// 画面フィールド入力文字数チェック |
1469 |
/// </summary> |
1470 |
/// <param name="dispControl">コントロールオブジェクト</param> |
1471 |
/// <param name="sLength">文字列長</param> |
1472 |
/// <param name="indispensable">true:必須入力チェック</param> |
1473 |
/// <returns>false:エラー true:エラーなし</returns> |
1474 |
public static bool DispFieldLengthCheck(Control dispControl, int sLength, bool indispensable = false) |
1475 |
{ |
1476 |
bool bAns = true; |
1477 |
try |
1478 |
{ |
1479 |
// 必須入力チェック |
1480 |
if (indispensable) |
1481 |
{ |
1482 |
bAns = DispFieldIndispensable(dispControl); |
1483 |
} |
1484 |
|
1485 |
if (dispControl.Text.ToString().Length != 0) |
1486 |
{ |
1487 |
// レングスチェック |
1488 |
bAns = chkStringLength(dispControl.Text.ToString(), sLength); |
1489 |
} |
1490 |
} |
1491 |
catch (Exception ex) |
1492 |
{ |
1493 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", GetMethodName(), GetMethodName(2), ex.Message); |
1494 |
bAns = false; |
1495 |
} |
1496 |
finally |
1497 |
{ |
1498 |
// 背景色変更 |
1499 |
chgBackColor(dispControl, bAns); |
1500 |
} |
1501 |
return bAns; |
1502 |
} |
1503 |
#endregion |
1504 |
|
1505 |
#region 画面フィールド入力日付チェック |
1506 |
/// <summary> |
1507 |
/// 画面フィールド入力日付チェック |
1508 |
/// </summary> |
1509 |
/// <param name="dispControl">コントロールオブジェクト</param> |
1510 |
/// <param name="indispensable">true:必須入力チェック</param> |
1511 |
/// <returns>false:エラー true:エラーなし</returns> |
1512 |
public static bool DispFieldDateCheck(Control dispControl, bool indispensable = false) |
1513 |
{ |
1514 |
bool bAns = true; |
1515 |
try |
1516 |
{ |
1517 |
// 必須入力チェック |
1518 |
if (indispensable) |
1519 |
{ |
1520 |
bAns = DispFieldIndispensable(dispControl); |
1521 |
} |
1522 |
|
1523 |
if (dispControl.Text.ToString().Length != 0) |
1524 |
{ |
1525 |
// 未定はエラーにしない |
1526 |
if (!indispensable && dispControl.Text.Equals(CommonDefine.s_UndecidedString)) { } |
1527 |
else |
1528 |
// 日付チェック |
1529 |
bAns = chkDate(dispControl.Text.ToString()); |
1530 |
} |
1531 |
} |
1532 |
catch (Exception ex) |
1533 |
{ |
1534 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", GetMethodName(), GetMethodName(2), ex.Message); |
1535 |
bAns = false; |
1536 |
} |
1537 |
finally |
1538 |
{ |
1539 |
// 背景色変更 |
1540 |
chgBackColor(dispControl, bAns); |
1541 |
} |
1542 |
return bAns; |
1543 |
} |
1544 |
#endregion |
1545 |
|
1546 |
#region 画面フィールドコンボボックスチェック |
1547 |
/// <summary> |
1548 |
/// 画面フィールド入力コンボボックスチェック |
1549 |
/// </summary> |
1550 |
/// <param name="dispControl">コントロールオブジェクト</param> |
1551 |
/// <param name="indispensable">true:必須入力チェック</param> |
1552 |
/// <returns>false:エラー true:エラーなし</returns> |
1553 |
public static bool DispFieldCombCheck(Control dispControl, bool indispensable = false) |
1554 |
{ |
1555 |
bool bAns = true; |
1556 |
try |
1557 |
{ |
1558 |
ComboBox comboBox = (ComboBox)dispControl; |
1559 |
// 必須入力チェック |
1560 |
if (indispensable) |
1561 |
{ |
1562 |
bAns = DispFieldIndispensable(dispControl); |
1563 |
// 必須時未定はエラー |
1564 |
if (dispControl.Text.Equals(CommonDefine.s_UndecidedString)) bAns = false; |
1565 |
} |
1566 |
|
1567 |
if (dispControl.Text.ToString().Length != 0) |
1568 |
{ |
1569 |
// 未定はエラーにしない |
1570 |
if (!indispensable && dispControl.Text.Equals(CommonDefine.s_UndecidedString)) { } |
1571 |
else |
1572 |
{ |
1573 |
// 入力チェック |
1574 |
if (dispControl.Text.ToString().Length == 0) bAns = false; |
1575 |
} |
1576 |
} |
1577 |
} |
1578 |
catch (Exception ex) |
1579 |
{ |
1580 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", GetMethodName(), GetMethodName(2), ex.Message); |
1581 |
bAns = false; |
1582 |
} |
1583 |
finally |
1584 |
{ |
1585 |
// 背景色変更 |
1586 |
chgBackColor(dispControl, bAns); |
1587 |
} |
1588 |
return bAns; |
1589 |
} |
1590 |
#endregion |
1591 |
|
1592 |
#region 画面フィールド入力郵便番号チェック |
1593 |
/// <summary> |
1594 |
/// 画面フィールド入力郵便番号チェック |
1595 |
/// </summary> |
1596 |
/// <param name="dispControl">コントロールオブジェクト</param> |
1597 |
/// <param name="indispensable">true:必須入力チェック</param> |
1598 |
/// <returns>false:エラー true:エラーなし</returns> |
1599 |
public static bool DispFieldZipCodeCheck(Control dispControl, bool indispensable = false) |
1600 |
{ |
1601 |
bool bAns = true; |
1602 |
try |
1603 |
{ |
1604 |
// 必須入力チェック |
1605 |
if (indispensable) |
1606 |
{ |
1607 |
bAns = DispFieldIndispensable(dispControl); |
1608 |
} |
1609 |
|
1610 |
if (dispControl.Text.ToString().Length != 0) |
1611 |
{ |
1612 |
// 郵便番号チェック |
1613 |
bAns = chkZipcode(dispControl.Text.ToString()); |
1614 |
} |
1615 |
} |
1616 |
catch (Exception ex) |
1617 |
{ |
1618 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", GetMethodName(), GetMethodName(2), ex.Message); |
1619 |
bAns = false; |
1620 |
} |
1621 |
finally |
1622 |
{ |
1623 |
// 背景色変更 |
1624 |
chgBackColor(dispControl, bAns); |
1625 |
} |
1626 |
return bAns; |
1627 |
} |
1628 |
#endregion |
1629 |
|
1630 |
#region 画面フィールド入力Intチェック |
1631 |
/// <summary> |
1632 |
/// 画面フィールド入力Intチェック |
1633 |
/// </summary> |
1634 |
/// <param name="dispControl">コントロールオブジェクト</param> |
1635 |
/// <param name="indispensable">true:必須入力チェック</param> |
1636 |
/// <returns>false:エラー true:エラーなし</returns> |
1637 |
public static bool DispFieldIntCheck(Control dispControl, bool indispensable = false) |
1638 |
{ |
1639 |
bool bAns = true; |
1640 |
try |
1641 |
{ |
1642 |
// 必須入力チェック |
1643 |
if (indispensable) |
1644 |
{ |
1645 |
bAns = DispFieldIndispensable(dispControl); |
1646 |
} |
1647 |
|
1648 |
if (dispControl.Text.ToString().Length != 0) |
1649 |
{ |
1650 |
int work = 0; |
1651 |
// 数値チェック |
1652 |
//bAns = chkNumeric(dispControl.Text.ToString(), ref work); |
1653 |
bAns = int.TryParse(dispControl.Text.ToString(), out work); |
1654 |
} |
1655 |
} |
1656 |
catch (Exception ex) |
1657 |
{ |
1658 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", GetMethodName(), GetMethodName(2), ex.Message); |
1659 |
bAns = false; |
1660 |
} |
1661 |
finally |
1662 |
{ |
1663 |
// 背景色変更 |
1664 |
chgBackColor(dispControl, bAns); |
1665 |
} |
1666 |
return bAns; |
1667 |
} |
1668 |
#endregion |
1669 |
|
1670 |
#region 画面フィールド入力Doubleチェック |
1671 |
/// <summary> |
1672 |
/// 画面フィールド入力Doubleチェック |
1673 |
/// </summary> |
1674 |
/// <param name="dispControl">コントロールオブジェクト</param> |
1675 |
/// <param name="indispensable">true:必須入力チェック</param> |
1676 |
/// <returns>false:エラー true:エラーなし</returns> |
1677 |
public static bool DispFieldDoubleCheck(Control dispControl, bool indispensable = false) |
1678 |
{ |
1679 |
bool bAns = true; |
1680 |
try |
1681 |
{ |
1682 |
// 必須入力チェック |
1683 |
if (indispensable) |
1684 |
{ |
1685 |
bAns = DispFieldIndispensable(dispControl); |
1686 |
} |
1687 |
|
1688 |
if (dispControl.Text.ToString().Length != 0) |
1689 |
{ |
1690 |
double work = 0; |
1691 |
// 数値チェック |
1692 |
bAns = chkNumeric(dispControl.Text.ToString(), ref work); |
1693 |
} |
1694 |
} |
1695 |
catch (Exception ex) |
1696 |
{ |
1697 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", GetMethodName(), GetMethodName(2), ex.Message); |
1698 |
bAns = false; |
1699 |
} |
1700 |
finally |
1701 |
{ |
1702 |
// 背景色変更 |
1703 |
chgBackColor(dispControl, bAns); |
1704 |
} |
1705 |
return bAns; |
1706 |
} |
1707 |
#endregion |
1708 |
|
1709 |
#region 画面フィールド入力電話番号チェック |
1710 |
/// <summary> |
1711 |
/// 画面フィールド入力電話番号チェック |
1712 |
/// </summary> |
1713 |
/// <param name="dispControl">コントロールオブジェクト</param> |
1714 |
/// <param name="indispensable">true:必須入力チェック</param> |
1715 |
/// <returns>false:エラー true:エラーなし</returns> |
1716 |
public static bool DispFieldPhoneNumberCheck(Control dispControl, bool indispensable = false) |
1717 |
{ |
1718 |
bool bAns = true; |
1719 |
try |
1720 |
{ |
1721 |
// 必須入力チェック |
1722 |
if (indispensable) |
1723 |
{ |
1724 |
bAns = DispFieldIndispensable(dispControl); |
1725 |
} |
1726 |
|
1727 |
if (dispControl.Text.ToString().Length != 0) |
1728 |
{ |
1729 |
// 電話番号チェック |
1730 |
bAns = chkPhoneNumber(dispControl.Text.ToString()); |
1731 |
} |
1732 |
} |
1733 |
catch (Exception ex) |
1734 |
{ |
1735 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", GetMethodName(), GetMethodName(2), ex.Message); |
1736 |
bAns = false; |
1737 |
} |
1738 |
finally |
1739 |
{ |
1740 |
// 背景色変更 |
1741 |
chgBackColor(dispControl, bAns); |
1742 |
} |
1743 |
return bAns; |
1744 |
} |
1745 |
#endregion |
1746 |
|
1747 |
#region 画面フィールド入力メールアドレスチェック |
1748 |
/// <summary> |
1749 |
/// 画面フィールド入力メールアドレスチェック |
1750 |
/// </summary> |
1751 |
/// <param name="dispControl">コントロールオブジェクト</param> |
1752 |
/// <param name="indispensable">true:必須入力チェック</param> |
1753 |
/// <returns>false:エラー true:エラーなし</returns> |
1754 |
public static bool DispFieldMailAddressCheck(Control dispControl, bool indispensable = false) |
1755 |
{ |
1756 |
bool bAns = true; |
1757 |
try |
1758 |
{ |
1759 |
// 必須入力チェック |
1760 |
if (indispensable) |
1761 |
{ |
1762 |
bAns = DispFieldIndispensable(dispControl); |
1763 |
} |
1764 |
|
1765 |
if (dispControl.Text.ToString().Length != 0) |
1766 |
{ |
1767 |
// メールアドレスチェック |
1768 |
bAns = chkMailAddress(dispControl.Text.ToString()); |
1769 |
} |
1770 |
} |
1771 |
catch (Exception ex) |
1772 |
{ |
1773 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", GetMethodName(), GetMethodName(2), ex.Message); |
1774 |
bAns = false; |
1775 |
} |
1776 |
finally |
1777 |
{ |
1778 |
// 背景色変更 |
1779 |
chgBackColor(dispControl, bAns); |
1780 |
} |
1781 |
return bAns; |
1782 |
} |
1783 |
#endregion |
1784 |
|
1785 |
#region 画面フィールド入力カタカナチェック |
1786 |
/// <summary> |
1787 |
/// 画面フィールド入力カタカナチェック |
1788 |
/// </summary> |
1789 |
public static bool DispFieldKatakanaCheck(Control dispControl, bool indispensable = false) |
1790 |
{ |
1791 |
bool bAns = true; |
1792 |
try |
1793 |
{ |
1794 |
// 必須入力チェック |
1795 |
if (indispensable) |
1796 |
{ |
1797 |
bAns = DispFieldIndispensable(dispControl); |
1798 |
} |
1799 |
|
1800 |
if (dispControl.Text.ToString().Length != 0) |
1801 |
{ |
1802 |
// カタカナチェック |
1803 |
bAns = chkIsKatakana(dispControl.Text.ToString()); |
1804 |
} |
1805 |
} |
1806 |
catch (Exception ex) |
1807 |
{ |
1808 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", GetMethodName(), GetMethodName(2), ex.Message); |
1809 |
bAns = false; |
1810 |
} |
1811 |
finally |
1812 |
{ |
1813 |
// 背景色変更 |
1814 |
chgBackColor(dispControl, bAns); |
1815 |
} |
1816 |
return bAns; |
1817 |
} |
1818 |
#endregion |
1819 |
|
1820 |
#region 画面フィールド入力ひらながチェック |
1821 |
/// <summary> |
1822 |
/// 画面フィールド入力ひらがなチェック |
1823 |
/// </summary> |
1824 |
public static bool DispFieldHiraganaCheck(Control dispControl, bool indispensable = false) |
1825 |
{ |
1826 |
bool bAns = true; |
1827 |
try |
1828 |
{ |
1829 |
// 必須入力チェック |
1830 |
if (indispensable) |
1831 |
{ |
1832 |
bAns = DispFieldIndispensable(dispControl); |
1833 |
} |
1834 |
|
1835 |
if (dispControl.Text.ToString().Length != 0) |
1836 |
{ |
1837 |
// ひらながチェック |
1838 |
bAns = chkIsHiragana(dispControl.Text.ToString()); |
1839 |
} |
1840 |
} |
1841 |
catch (Exception ex) |
1842 |
{ |
1843 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", GetMethodName(), GetMethodName(2), ex.Message); |
1844 |
bAns = false; |
1845 |
} |
1846 |
finally |
1847 |
{ |
1848 |
// 背景色変更 |
1849 |
chgBackColor(dispControl, bAns); |
1850 |
} |
1851 |
return bAns; |
1852 |
} |
1853 |
#endregion |
1854 |
|
1855 |
#region 指定した日が第何週かを求める |
1856 |
/// <summary> |
1857 |
/// 指定した日が第何週かを求める |
1858 |
/// </summary> |
1859 |
/// <param name="date"></param> |
1860 |
/// <returns></returns> |
1861 |
public static int NthWeek(DateTime date) |
1862 |
{ |
1863 |
int w = (int)(new DateTime(date.Year, date.Month, 1).DayOfWeek); |
1864 |
return (date.Day + w - 1) / 7 + 1; |
1865 |
|
1866 |
} |
1867 |
#endregion |
1868 |
#endregion |
1869 |
|
1870 |
#region ---------- 工事管理システム専用 |
1871 |
|
1872 |
#region システム起動確認データ取得 |
1873 |
/// <summary> |
1874 |
/// システム起動確認データ取得 |
1875 |
/// </summary> |
1876 |
public static void GetSystemExecute(ref SystemExecute recordRec) |
1877 |
{ |
1878 |
IOSystemExecute SysExecDB = new IOSystemExecute(); |
1879 |
try |
1880 |
{ |
1881 |
// システムのバージョンをチェックする |
1882 |
// キーを取得する |
1883 |
int PCode = CommonDefine.ExePrimaryCode.First(x => x.Value.Equals("システムバージョン")).Key; |
1884 |
|
1885 |
// バージョン読込 |
1886 |
string strSQL = SysExecDB.CreatePrimarykeyString(PCode); |
1887 |
if (!SysExecDB.SelectAction(strSQL, ref recordRec)) |
1888 |
{ // レコード無時はエラー |
1889 |
logger.ErrorFormat("バージョンチェックデータ読込みエラー:{0}", CommonMotions.GetMethodName()); |
1890 |
return; |
1891 |
} |
1892 |
} |
1893 |
catch (Exception ex) |
1894 |
{ |
1895 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
1896 |
} |
1897 |
finally |
1898 |
{ |
1899 |
SysExecDB.close(); SysExecDB = null; |
1900 |
} |
1901 |
} |
1902 |
#endregion |
1903 |
|
1904 |
#region 製品版・確認運用時Trueを返す |
1905 |
/// <summary> |
1906 |
/// 製品版・確認運用時Trueを返す |
1907 |
/// </summary> |
1908 |
/// <returns></returns> |
1909 |
public static bool OperationConfirmation() |
1910 |
{ |
1911 |
try |
1912 |
{ |
1913 |
bool bRet = false; |
1914 |
switch (ProductDefine.ProductType) |
1915 |
{ |
1916 |
case (int)ProductDefine.ProductTypeDef.Originals: |
1917 |
case (int)ProductDefine.ProductTypeDef.ProductsModelType2_1: |
1918 |
case (int)ProductDefine.ProductTypeDef.ProductsModelType2_2: |
1919 |
break; |
1920 |
case (int)ProductDefine.ProductTypeDef.ProductsModelType1: |
1921 |
// 一人親方バージョンはtrue |
1922 |
bRet = true; |
1923 |
break; |
1924 |
default: |
1925 |
break; |
1926 |
} |
1927 |
return bRet; |
1928 |
} |
1929 |
catch (Exception ex) |
1930 |
{ |
1931 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
1932 |
return false; |
1933 |
} |
1934 |
} |
1935 |
#endregion |
1936 |
|
1937 |
#region 実行ファイル名称よりタイトル取得 |
1938 |
/// <summary> |
1939 |
/// 実行ファイル名称よりタイトル取得 |
1940 |
/// </summary> |
1941 |
/// <returns></returns> |
1942 |
public static string GetExecFileName() |
1943 |
{ |
1944 |
try |
1945 |
{ |
1946 |
FileVersionInfo CurVersionInfo = CommonMotions.ProductVersionInfo; |
1947 |
StringBuilder strTitle = new StringBuilder(); |
1948 |
for (int i = 0; i < CurVersionInfo.ProductName.Length; i++) |
1949 |
{ |
1950 |
if (i < 1) strTitle.Append(CurVersionInfo.ProductName.Substring(i, 1)); |
1951 |
else strTitle.AppendFormat(" {0}", CurVersionInfo.ProductName.Substring(i, 1)); |
1952 |
} |
1953 |
|
1954 |
return strTitle.ToString(); |
1955 |
} |
1956 |
catch (Exception ex) |
1957 |
{ |
1958 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
1959 |
return string.Empty; |
1960 |
} |
1961 |
} |
1962 |
#endregion |
1963 |
|
1964 |
#region 定義ファイル読込 |
1965 |
/// <summary> |
1966 |
/// 定義ファイル読込 |
1967 |
/// </summary> |
1968 |
private static void DefinitionFileInit() |
1969 |
{ |
1970 |
try |
1971 |
{ |
1972 |
//定義ファイル読込 |
1973 |
System.IO.FileStream fs = new System.IO.FileStream(CommonDefine.s_DefinitionFileName, System.IO.FileMode.Open); |
1974 |
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(DefinitionFileRead)); |
1975 |
m_dfr_model = (DefinitionFileRead)serializer.Deserialize(fs); |
1976 |
} |
1977 |
catch (Exception ex) |
1978 |
{ |
1979 |
logger.ErrorFormat("定義ファイル読込エラー:{0}:{1}", GetMethodName(), ex.Message); |
1980 |
} |
1981 |
} |
1982 |
|
1983 |
#endregion |
1984 |
|
1985 |
#region 管理マスタ取得 |
1986 |
/// <summary> |
1987 |
/// 管理マスタ取得 |
1988 |
/// </summary> |
1989 |
public static bool SetSystemMaster() |
1990 |
{ |
1991 |
// 管理マスタクラス |
1992 |
IOMSystem ocDB = new IOMSystem(); |
1993 |
try |
1994 |
{ |
1995 |
// 管理マスタ取得 |
1996 |
// 1レコードだけなので取り出す |
1997 |
StringBuilder strSQL = new StringBuilder(); |
1998 |
strSQL.Append(" Where SystemCode = 1"); |
1999 |
if (!ocDB.SelectAction(strSQL.ToString(), ref m_systemMaster)) return false; |
2000 |
|
2001 |
return true; |
2002 |
} |
2003 |
catch (Exception ex) |
2004 |
{ |
2005 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2006 |
return false; |
2007 |
} |
2008 |
finally |
2009 |
{ |
2010 |
ocDB.close(); ocDB = null; |
2011 |
} |
2012 |
} |
2013 |
#endregion |
2014 |
|
2015 |
#region 消費税データ取得 |
2016 |
/// <summary> |
2017 |
/// 消費税データ取得 |
2018 |
/// </summary> |
2019 |
public static bool SetconsumptionTax() |
2020 |
{ |
2021 |
// 消費税データクラス |
2022 |
IOMConsumptionTax TaxDB = new IOMConsumptionTax(); |
2023 |
try |
2024 |
{ |
2025 |
// 消費税データ取得 |
2026 |
StringBuilder strSQL = new StringBuilder(); |
2027 |
m_ConsumptionTax.Clear(); |
2028 |
strSQL.Append(" Order By StartDate"); |
2029 |
if (!TaxDB.SelectAction(strSQL.ToString(), ref m_ConsumptionTax)) return false; |
2030 |
|
2031 |
return true; |
2032 |
} |
2033 |
catch (Exception ex) |
2034 |
{ |
2035 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2036 |
return false; |
2037 |
} |
2038 |
finally |
2039 |
{ |
2040 |
TaxDB.close(); TaxDB = null; |
2041 |
} |
2042 |
} |
2043 |
#endregion |
2044 |
|
2045 |
#region メソッド名を取得する |
2046 |
/// <summary> |
2047 |
/// メソッド名を取得する |
2048 |
/// </summary> |
2049 |
/// <param name="StackCnt"></param> |
2050 |
/// <returns></returns> |
2051 |
public static string GetMethodName(int stackCnt = 1) |
2052 |
{ |
2053 |
try |
2054 |
{ |
2055 |
StringBuilder sb = new StringBuilder(); |
2056 |
|
2057 |
// 一つ前のスタック情報 |
2058 |
StackFrame stackFrame = new StackFrame(stackCnt); |
2059 |
|
2060 |
// 呼び出し元メソッドの情報出力 |
2061 |
System.Reflection.MethodBase method = stackFrame.GetMethod(); |
2062 |
|
2063 |
// Method取得失敗は戻る |
2064 |
if (method == null) return string.Empty; |
2065 |
|
2066 |
// 正しく取得できているかの判定 |
2067 |
if (method.DeclaringType != null && !string.IsNullOrEmpty(method.DeclaringType.Name)) |
2068 |
{ |
2069 |
// 型名 |
2070 |
sb.AppendFormat("[TYPE]{0}", method.DeclaringType.Name); |
2071 |
} |
2072 |
|
2073 |
if (!string.IsNullOrEmpty(method.Name)) |
2074 |
{ |
2075 |
// 編集済みの場合は区切りを入れる |
2076 |
if (0 < sb.Length) sb.Append('/'); |
2077 |
|
2078 |
// メソッド名 |
2079 |
sb.AppendFormat("[METHOD]{0}", method.Name); |
2080 |
} |
2081 |
return sb.ToString(); |
2082 |
} |
2083 |
catch (Exception ex) |
2084 |
{ |
2085 |
logger.ErrorFormat(ex.Message); |
2086 |
} |
2087 |
return string.Empty; |
2088 |
} |
2089 |
#endregion |
2090 |
|
2091 |
#region 期数から期の年を取得する |
2092 |
/// <summary> |
2093 |
/// 期数から期の年を取得する |
2094 |
/// </summary> |
2095 |
/// <param name="PeriodCount"></param> |
2096 |
/// <returns></returns> |
2097 |
public static int PeriodCountToYear(int PeriodCount) |
2098 |
{ |
2099 |
IOMBizPeriodHistory BizHisDB = new IOMBizPeriodHistory(); |
2100 |
try |
2101 |
{ |
2102 |
// 今の年を取得する |
2103 |
int iYear = DateTime.Now.Year; |
2104 |
|
2105 |
StringBuilder strSQL = new StringBuilder(); |
2106 |
BizPeriodHistory BizHisRec = new BizPeriodHistory(); |
2107 |
|
2108 |
// 営業期 |
2109 |
strSQL.Append(BizHisDB.CreatePrimarykeyString(PeriodCount, (int)BizPeriodHistory.PeriodFlagDef.BizPeriod)); |
2110 |
|
2111 |
// 運営期履歴情報読込 |
2112 |
if (!BizHisDB.SelectAction(strSQL.ToString(), ref BizHisRec)) return iYear; |
2113 |
|
2114 |
iYear = BizHisRec.BeginDate.Year; |
2115 |
|
2116 |
return iYear; |
2117 |
} |
2118 |
catch (Exception ex) |
2119 |
{ |
2120 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2121 |
return 0; |
2122 |
} |
2123 |
finally |
2124 |
{ |
2125 |
BizHisDB.close(); BizHisDB = null; |
2126 |
} |
2127 |
} |
2128 |
#endregion |
2129 |
|
2130 |
#region システム設定が営業期数の時にtrueを返す |
2131 |
/// <summary> |
2132 |
/// システム設定が営業期数の時にtrueを返す |
2133 |
/// </summary> |
2134 |
/// <returns></returns> |
2135 |
public static bool BasePeriodYear() |
2136 |
{ |
2137 |
bool bret = false; |
2138 |
try |
2139 |
{ |
2140 |
switch (CommonMotions.SystemMasterData.ConstructionNoBase) |
2141 |
{ |
2142 |
case (int)SystemMaster.ConstrNoBaseDef.BusinessPeriod: |
2143 |
bret = true; |
2144 |
break; |
2145 |
default: |
2146 |
bret = false; |
2147 |
break; |
2148 |
} |
2149 |
|
2150 |
return bret; |
2151 |
} |
2152 |
catch (Exception ex) |
2153 |
{ |
2154 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2155 |
return bret; |
2156 |
} |
2157 |
} |
2158 |
#endregion |
2159 |
|
2160 |
#region 年度選択ラベル初期セット |
2161 |
/// <summary> |
2162 |
/// 年度選択ラベル初期セット |
2163 |
/// </summary> |
2164 |
/// <param name="control"></param> |
2165 |
public static void SetSerchTitle(Label lbl1, Label lbl2, NumericUpDown updown, Label lbl3) |
2166 |
{ |
2167 |
try |
2168 |
{ |
2169 |
int nlabelX = lbl1.Location.X; |
2170 |
int nCtrlDef = updown.Location.X - lbl2.Location.X; |
2171 |
|
2172 |
// タイトル文字セット |
2173 |
lbl1.Text = GetYearTitle(); |
2174 |
lbl3.Text = GetYearTitle(false); |
2175 |
|
2176 |
// タイトル表示制御 |
2177 |
if (BasePeriodYear()) |
2178 |
{ |
2179 |
lbl2.Visible = true; |
2180 |
} |
2181 |
else |
2182 |
{ |
2183 |
lbl2.Visible = false; |
2184 |
|
2185 |
Point po = updown.Location; |
2186 |
po.X -= nCtrlDef; |
2187 |
updown.Location = po; |
2188 |
|
2189 |
Point po2 = lbl3.Location; |
2190 |
po2.X -= nCtrlDef; |
2191 |
lbl3.Location = po2; |
2192 |
} |
2193 |
} |
2194 |
catch (Exception ex) |
2195 |
{ |
2196 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2197 |
} |
2198 |
} |
2199 |
#endregion |
2200 |
|
2201 |
#region 管理マスタの指定により年度名称を返す |
2202 |
/// <summary> |
2203 |
/// 管理マスタの指定により年度名称を返す |
2204 |
/// </summary> |
2205 |
/// <returns></returns> |
2206 |
public static string GetYearTitle(bool bTitle = true) |
2207 |
{ |
2208 |
string strTitle = string.Empty; |
2209 |
try |
2210 |
{ |
2211 |
if (bTitle) |
2212 |
{ |
2213 |
if (BasePeriodYear()) |
2214 |
{ |
2215 |
strTitle = "営業期数"; |
2216 |
} |
2217 |
else |
2218 |
{ |
2219 |
strTitle = "工事年度"; |
2220 |
} |
2221 |
} |
2222 |
else |
2223 |
{ |
2224 |
if (BasePeriodYear()) |
2225 |
{ |
2226 |
strTitle = "期"; |
2227 |
} |
2228 |
else |
2229 |
{ |
2230 |
strTitle = "年度"; |
2231 |
} |
2232 |
} |
2233 |
|
2234 |
return strTitle; |
2235 |
} |
2236 |
catch (Exception ex) |
2237 |
{ |
2238 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2239 |
return strTitle; |
2240 |
} |
2241 |
} |
2242 |
#endregion |
2243 |
|
2244 |
#region 工事情報より期の最大・最少を取得する |
2245 |
/// <summary> |
2246 |
/// 工事情報より期の最大・最少を取得する |
2247 |
/// </summary> |
2248 |
/// <param name="StartDate"></param> |
2249 |
/// <returns></returns> |
2250 |
public static void GetPeriodYearMinMax(ref int min, ref int max) |
2251 |
{ |
2252 |
IOConstructionBaseInfo cbiDB = new IOConstructionBaseInfo(); |
2253 |
try |
2254 |
{ |
2255 |
StringBuilder strSQL = new StringBuilder(); |
2256 |
bool bPeriod = CommonMotions.BasePeriodYear(); |
2257 |
if (bPeriod) |
2258 |
{ // ----- 営業期ベースの時 |
2259 |
strSQL.Append("SELECT MIN(CONSTRUCTIONPERIOD), MAX(CONSTRUCTIONPERIOD) FROM CONSTRUCTIONBASEINFO"); |
2260 |
} |
2261 |
else |
2262 |
{ // ----- 工事年度ベースの時 |
2263 |
strSQL.Append("SELECT MIN(ConstructionYear), MAX(ConstructionYear) FROM CONSTRUCTIONBASEINFO"); |
2264 |
} |
2265 |
|
2266 |
ArrayList arList = new ArrayList(); |
2267 |
if (!cbiDB.ExecuteReader(strSQL.ToString(), ref arList)) return; |
2268 |
|
2269 |
object[] wrkobj = (object[])arList[0]; |
2270 |
min = cnvInt(wrkobj[0]); |
2271 |
max = cnvInt(wrkobj[1]); |
2272 |
if (bPeriod) |
2273 |
{ // ----- 営業期ベースの時 |
2274 |
if (min < 1) |
2275 |
{ |
2276 |
min = 1; |
2277 |
max = 1; |
2278 |
} |
2279 |
} |
2280 |
else |
2281 |
{ // ----- 工事年度ベースの時 |
2282 |
if (min < 1) |
2283 |
{ |
2284 |
min = CommonMotions.SystemMasterData.ConstrBeginDate.Year; |
2285 |
max = CommonMotions.SystemMasterData.ConstrCompDate.Year; |
2286 |
} |
2287 |
} |
2288 |
} |
2289 |
catch (Exception ex) |
2290 |
{ |
2291 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2292 |
} |
2293 |
finally |
2294 |
{ |
2295 |
cbiDB.close(); cbiDB = null; |
2296 |
} |
2297 |
} |
2298 |
#endregion |
2299 |
|
2300 |
#region 管理マスタの現在年を取得する |
2301 |
/// <summary> |
2302 |
/// 管理マスタの現在年を取得する |
2303 |
/// </summary> |
2304 |
/// <returns></returns> |
2305 |
public static int GetPeriodYear() |
2306 |
{ |
2307 |
try |
2308 |
{ |
2309 |
int nYearVal = DateTime.Now.Year; |
2310 |
|
2311 |
if (CommonMotions.BasePeriodYear()) |
2312 |
{ |
2313 |
// ----- 営業期ベースの時 |
2314 |
nYearVal = CommonMotions.SystemMasterData.BusinessPeriod; |
2315 |
} |
2316 |
else |
2317 |
{ |
2318 |
// ----- 工事年度ベースの時 |
2319 |
nYearVal = CommonMotions.SystemMasterData.ConstrYear; |
2320 |
} |
2321 |
|
2322 |
return nYearVal; |
2323 |
} |
2324 |
catch (System.Exception ex) |
2325 |
{ |
2326 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2327 |
return 0; |
2328 |
} |
2329 |
} |
2330 |
#endregion |
2331 |
|
2332 |
#region 対象日より営業期・工事年度を取得する |
2333 |
/// <summary> |
2334 |
/// 対象日より営業期・工事年度を取得する |
2335 |
/// </summary> |
2336 |
/// <param name="NowDay"></param> |
2337 |
/// <returns></returns> |
2338 |
public static int ConvDate2YearOrPeriod(DateTime NowDay) |
2339 |
{ |
2340 |
IOMBizPeriodHistory BizHisDB = new IOMBizPeriodHistory(); |
2341 |
try |
2342 |
{ |
2343 |
int nRetVal = 0; |
2344 |
|
2345 |
// 範囲に入るデータを取得する |
2346 |
StringBuilder strSQL = new StringBuilder(); |
2347 |
|
2348 |
strSQL.AppendFormat(" WHERE (DATE(BeginDate) <= DATE('{0}'))", NowDay.ToShortDateString()); |
2349 |
strSQL.AppendFormat(" AND (DATE('{0}') <= DATE(CompleteDate))", NowDay.ToShortDateString()); |
2350 |
strSQL.AppendFormat(" And PeriodFlag = {0}", CommonMotions.SystemMasterData.ConstructionNoBase); |
2351 |
strSQL.Append(" Order By PeriodFlag Asc, PeriodYear Asc"); |
2352 |
|
2353 |
List<BizPeriodHistory> BizList = new List<BizPeriodHistory>(); |
2354 |
if (!BizHisDB.SelectAction(strSQL.ToString(), ref BizList)) return 0; |
2355 |
|
2356 |
nRetVal = BizList[0].PeriodYear; |
2357 |
|
2358 |
return nRetVal; |
2359 |
} |
2360 |
catch (Exception ex) |
2361 |
{ |
2362 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2363 |
return 0; |
2364 |
} |
2365 |
finally |
2366 |
{ |
2367 |
BizHisDB.close(); BizHisDB = null; |
2368 |
} |
2369 |
} |
2370 |
#endregion |
2371 |
|
2372 |
#region ポイントに規定値を加算して戻す |
2373 |
/// <summary> |
2374 |
/// ポイントに規定値を加算して戻す |
2375 |
/// </summary> |
2376 |
/// <param name="PosPoint"></param> |
2377 |
public static Point SetFormPosion(Point PosPoint) |
2378 |
{ |
2379 |
Point po = PosPoint; |
2380 |
try |
2381 |
{ |
2382 |
po.X += CommonDefine.s_DefalutShiftValue; |
2383 |
po.Y += CommonDefine.s_DefalutShiftValue; |
2384 |
|
2385 |
return po; |
2386 |
} |
2387 |
catch (Exception ex) |
2388 |
{ |
2389 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", GetMethodName(), GetMethodName(2), ex.Message); |
2390 |
return po; |
2391 |
} |
2392 |
} |
2393 |
#endregion |
2394 |
|
2395 |
#region フィールドバックカラー変更処理 |
2396 |
/// <summary> |
2397 |
/// フィールドバックカラー変更処理(あまりカッコ良くない^^;) |
2398 |
/// </summary> |
2399 |
/// <param name="objCtrl"></param> |
2400 |
/// <param name="chgColor"></param> |
2401 |
public static void chgBackColor(object objCtrl, bool bPara, bool bWarning = false) |
2402 |
{ |
2403 |
try |
2404 |
{ |
2405 |
// エラー色・ワーニング色 |
2406 |
Color ErrorColor = CommonDefine.s_clrError; |
2407 |
if (bWarning) ErrorColor = CommonDefine.s_clrWarning; |
2408 |
|
2409 |
if (objCtrl.GetType().Equals(typeof(TextBox)) |
2410 |
|| objCtrl.GetType().Equals(typeof(TextBoxEX))) |
2411 |
{ |
2412 |
TextBox wrk = (TextBox)objCtrl; |
2413 |
if (bPara) |
2414 |
{ |
2415 |
wrk.BackColor = CommonDefine.s_clrNormal; |
2416 |
} |
2417 |
else |
2418 |
{ |
2419 |
wrk.BackColor = ErrorColor; |
2420 |
wrk.Focus(); |
2421 |
} |
2422 |
} |
2423 |
else if (objCtrl.GetType().Equals(typeof(DataGridViewTextBoxCell))) |
2424 |
{ |
2425 |
DataGridViewTextBoxCell wrk = (DataGridViewTextBoxCell)objCtrl; |
2426 |
if (bPara) |
2427 |
{ |
2428 |
wrk.Style.BackColor = CommonDefine.s_clrNormal; |
2429 |
} |
2430 |
else |
2431 |
{ |
2432 |
wrk.Style.BackColor = ErrorColor; |
2433 |
wrk.Selected = true; |
2434 |
} |
2435 |
} |
2436 |
else if (objCtrl.GetType().Equals(typeof(ComboBoxEX)) |
2437 |
|| objCtrl.GetType().Equals(typeof(ComboBox))) |
2438 |
{ |
2439 |
ComboBox wrk = (ComboBox)objCtrl; |
2440 |
if (bPara) |
2441 |
{ |
2442 |
wrk.BackColor = CommonDefine.s_clrNormal; |
2443 |
} |
2444 |
else |
2445 |
{ |
2446 |
wrk.BackColor = ErrorColor; |
2447 |
wrk.Focus(); |
2448 |
} |
2449 |
} |
2450 |
else if (objCtrl.GetType().Equals(typeof(ListBox))) |
2451 |
{ |
2452 |
ListBox wrk = (ListBox)objCtrl; |
2453 |
if (bPara) |
2454 |
{ |
2455 |
wrk.BackColor = CommonDefine.s_clrNormal; |
2456 |
} |
2457 |
else |
2458 |
{ |
2459 |
wrk.BackColor = ErrorColor; |
2460 |
wrk.Focus(); |
2461 |
} |
2462 |
} |
2463 |
else if (objCtrl.GetType().Equals(typeof(Label))) |
2464 |
{ |
2465 |
Label wrk = (Label)objCtrl; |
2466 |
if (bPara) |
2467 |
{ |
2468 |
wrk.BackColor = CommonDefine.s_clrNormal; |
2469 |
} |
2470 |
else |
2471 |
{ |
2472 |
wrk.BackColor = ErrorColor; |
2473 |
} |
2474 |
} |
2475 |
else if (objCtrl.GetType().Equals(typeof(NumericUpDown))) |
2476 |
{ |
2477 |
NumericUpDown wrk = (NumericUpDown)objCtrl; |
2478 |
if (bPara) |
2479 |
{ |
2480 |
wrk.BackColor = CommonDefine.s_clrNormal; |
2481 |
} |
2482 |
else |
2483 |
{ |
2484 |
wrk.BackColor = ErrorColor; |
2485 |
} |
2486 |
} |
2487 |
else if (objCtrl.GetType().Equals(typeof(DateTimePicker))) |
2488 |
{ |
2489 |
DateTimePicker wrk = (DateTimePicker)objCtrl; |
2490 |
if (bPara) |
2491 |
{ |
2492 |
wrk.BackColor = CommonDefine.s_clrNormal; |
2493 |
} |
2494 |
else |
2495 |
{ |
2496 |
wrk.BackColor = ErrorColor; |
2497 |
} |
2498 |
} |
2499 |
} |
2500 |
catch (Exception ex) |
2501 |
{ |
2502 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", GetMethodName(), GetMethodName(2), ex.Message); |
2503 |
} |
2504 |
} |
2505 |
#endregion |
2506 |
|
2507 |
#region 営業期数より工事年を取得する |
2508 |
/// <summary> |
2509 |
/// 営業期数より工事年を取得する |
2510 |
/// </summary> |
2511 |
/// <param name="Period"></param> |
2512 |
/// <returns></returns> |
2513 |
public static int BusinessPeriodToConstructionYears(int Period) |
2514 |
{ |
2515 |
try |
2516 |
{ |
2517 |
int Beginning = 0; |
2518 |
int diffwork = 0; |
2519 |
int RetYears = 0; |
2520 |
string strwork = string.Empty; |
2521 |
|
2522 |
// 現在期との差分を求める |
2523 |
diffwork = Period - CommonMotions.SystemMasterData.BusinessPeriod; |
2524 |
|
2525 |
// 期首月を取得する |
2526 |
Beginning = CommonMotions.SystemMasterData.BusinessBeginDate.Month; |
2527 |
|
2528 |
// 年数を求める |
2529 |
DateTime dateWork = DateTime.Now; |
2530 |
int nowMounth = DateTime.Now.Month; |
2531 |
// 期首月を境に年度を計算する |
2532 |
int iYear = 0; |
2533 |
if (nowMounth < Beginning) |
2534 |
iYear = dateWork.AddYears(-1).Year; |
2535 |
else |
2536 |
iYear = dateWork.Year; |
2537 |
|
2538 |
// ベース年を求める |
2539 |
RetYears = iYear + diffwork; |
2540 |
|
2541 |
return RetYears; |
2542 |
} |
2543 |
catch (Exception ex) |
2544 |
{ |
2545 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2546 |
return 0; |
2547 |
} |
2548 |
} |
2549 |
#endregion |
2550 |
|
2551 |
#region 発注者名を法人格を含んだ形で連結する |
2552 |
/// <summary> |
2553 |
/// 発注者名を法人格を含んだ形で連結する |
2554 |
/// </summary> |
2555 |
/// <param name="master"></param> |
2556 |
/// <returns></returns> |
2557 |
public static string OrderersNameUnion(OrderersMaster master) |
2558 |
{ |
2559 |
try |
2560 |
{ |
2561 |
string strRet = string.Empty; |
2562 |
|
2563 |
if (master.CorporateStatusPoint == (int)BusinessTypeMaster.StatusNamePointDef.Forword) |
2564 |
strRet = master.CorporateStatusName + " " + master.OrderersName1 + " " + master.OrderersName2; |
2565 |
else if (master.CorporateStatusPoint == (int)BusinessTypeMaster.StatusNamePointDef.Back) |
2566 |
strRet = master.OrderersName1 + " " + master.CorporateStatusName + " " + master.OrderersName2; |
2567 |
else |
2568 |
strRet = master.OrderersName1 + " " + master.OrderersName2; |
2569 |
|
2570 |
return strRet; |
2571 |
} |
2572 |
catch (Exception ex) |
2573 |
{ |
2574 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2575 |
return string.Empty; |
2576 |
} |
2577 |
} |
2578 |
#endregion |
2579 |
|
2580 |
#region メッセージ送信メソッド(テキストボックス背景文字表示用) |
2581 |
/// <summary> |
2582 |
/// メッセージ送信メソッド |
2583 |
/// </summary> |
2584 |
/// <param name="hWnd"></param> |
2585 |
/// <param name="Msg"></param> |
2586 |
/// <param name="wParam"></param> |
2587 |
/// <param name="lParam"></param> |
2588 |
/// <returns></returns> |
2589 |
[DllImport("user32.dll", CharSet = CharSet.Unicode)] |
2590 |
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, string lParam); |
2591 |
#endregion |
2592 |
|
2593 |
#region ファイルの時間を取得する |
2594 |
/// <summary> |
2595 |
/// ファイルの時間を取得する |
2596 |
/// </summary> |
2597 |
/// <param name="FilePath">ファイルパス</param> |
2598 |
/// <param name="flg">取得日付フラグ</param> |
2599 |
/// <returns></returns> |
2600 |
public static DateTime GetFileTimeStamp(string FilePath, char flg) |
2601 |
{ |
2602 |
try |
2603 |
{ |
2604 |
DateTime dtDateTime = DateTime.MinValue; |
2605 |
|
2606 |
if (flg == 'C') |
2607 |
{ |
2608 |
// 作成日時を取得する |
2609 |
dtDateTime = File.GetCreationTime(@FilePath); |
2610 |
} |
2611 |
else if (flg == 'U') |
2612 |
{ |
2613 |
// 更新日時を取得する |
2614 |
dtDateTime = File.GetLastWriteTime(@FilePath); |
2615 |
} |
2616 |
else if (flg == 'A') |
2617 |
{ |
2618 |
// アクセス日時を取得する |
2619 |
dtDateTime = File.GetLastAccessTime(@FilePath); |
2620 |
} |
2621 |
|
2622 |
return dtDateTime; |
2623 |
} |
2624 |
catch (Exception ex) |
2625 |
{ |
2626 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2627 |
return DateTime.Now; |
2628 |
} |
2629 |
} |
2630 |
#endregion |
2631 |
|
2632 |
#region ファイルパスよりmd5のハッシュ値を返す |
2633 |
/// <summary> |
2634 |
/// ファイルパスよりmd5のハッシュ値を返す |
2635 |
/// </summary> |
2636 |
/// <param name="FilePath"></param> |
2637 |
/// <returns></returns> |
2638 |
public static string GetFileHashData(string FilePath) |
2639 |
{ |
2640 |
try |
2641 |
{ |
2642 |
//ファイルを開く |
2643 |
FileStream fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read); |
2644 |
|
2645 |
//MD5CryptoServiceProviderオブジェクトを作成 |
2646 |
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); |
2647 |
|
2648 |
//ハッシュ値を計算する |
2649 |
byte[] bs = md5.ComputeHash(fs); |
2650 |
|
2651 |
//リソースを解放する |
2652 |
md5.Clear(); |
2653 |
//ファイルを閉じる |
2654 |
fs.Close(); |
2655 |
|
2656 |
return BitConverter.ToString(bs).ToLower().Replace("-", ""); |
2657 |
|
2658 |
} |
2659 |
catch (Exception ex) |
2660 |
{ |
2661 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2662 |
return string.Empty; |
2663 |
} |
2664 |
} |
2665 |
#endregion |
2666 |
|
2667 |
#region 郵便番号より住所を検索する |
2668 |
/// <summary> |
2669 |
/// 郵便番号より住所を検索する |
2670 |
/// </summary> |
2671 |
/// <param name="ZipCode">郵便番号</param> |
2672 |
public static void SearchZipCode2Address(string ZipCode, ref string Address1, ref string Address2) |
2673 |
{ |
2674 |
Address1 = ""; //住所 |
2675 |
Address2 = ""; //住所 |
2676 |
|
2677 |
//処理時間を計測 |
2678 |
Stopwatch sw = new Stopwatch(); |
2679 |
//処理時間計測開始 |
2680 |
sw.Start(); |
2681 |
|
2682 |
// 郵便番号セット |
2683 |
string sKey = ZipCode; |
2684 |
|
2685 |
//文字列の前後のスペースをとる |
2686 |
sKey = sKey.Trim(' '); |
2687 |
//Microsoft.VisualBasic名前空間のStrConv関数を使って、全角文字を半角文字に変換 |
2688 |
sKey = Strings.StrConv(sKey, VbStrConv.Narrow, 0); |
2689 |
|
2690 |
// 文字列の長さを取得する |
2691 |
int iLength = sKey.Length; |
2692 |
// '-'がある場合は先頭文字目の後から '-' を検索し、見つかった位置を取得する |
2693 |
int iFind = 0; |
2694 |
if ((iFind = sKey.IndexOf('-', 0)) != 0) |
2695 |
{ |
2696 |
//左から3文字+"-"文字以降をtmpZip変数に代入 |
2697 |
sKey = sKey.Substring(0, 3) + sKey.Substring(iFind + 1); |
2698 |
} |
2699 |
try |
2700 |
{ |
2701 |
//StreamReaderオブジェクトの作成 |
2702 |
StreamReader sr = new StreamReader(@CommonDefine.s_AddressFilePath, Encoding.Default); |
2703 |
|
2704 |
//1行ずつ読み込み |
2705 |
string dat = ""; |
2706 |
while ((dat = sr.ReadLine()) != null) |
2707 |
{ |
2708 |
string tmpZip = ""; |
2709 |
|
2710 |
//カンマで区切られた文字列を取得 |
2711 |
string[] sbuf = dat.Split(','); |
2712 |
//配列の3番目が郵便番号 |
2713 |
tmpZip = sbuf[2].Trim('"'); |
2714 |
|
2715 |
//入力された郵便番号と比較 |
2716 |
if (sKey == tmpZip) |
2717 |
{ |
2718 |
//住所を作成 |
2719 |
//都道府県名+市区町村名+町域名 |
2720 |
Address1 = sbuf[6].Trim('"') + sbuf[7].Trim('"'); |
2721 |
Address2 = sbuf[8].Trim('"'); |
2722 |
|
2723 |
sw.Stop(); //処理時間計測終了 |
2724 |
|
2725 |
// 処理時間をTimeSpan構造体で書式付き表示 |
2726 |
TimeSpan ts = sw.Elapsed; |
2727 |
// 出力例:00:00:00.9984668 |
2728 |
logger.DebugFormat("処理時間:{0}", ts.ToString()); |
2729 |
|
2730 |
break; //ループを抜ける |
2731 |
} |
2732 |
Application.DoEvents(); |
2733 |
} |
2734 |
//ファイルを閉じる |
2735 |
sr.Close(); |
2736 |
} |
2737 |
catch (Exception ex) |
2738 |
{ |
2739 |
//ファイルエラーが発生した場合 |
2740 |
MessageBox.Show(ex.Message, "ファイルエラー", MessageBoxButtons.OK, MessageBoxIcon.Error); |
2741 |
//処理を抜ける |
2742 |
return; |
2743 |
} |
2744 |
} |
2745 |
#endregion |
2746 |
|
2747 |
#region 文字列より指定文字から後ろを省いて戻す |
2748 |
/// <summary> |
2749 |
/// 文字列より指定文字から後ろを省いて戻す |
2750 |
/// </summary> |
2751 |
/// <param name="Mijiretu"></param> |
2752 |
/// <param name="Delimiter"></param> |
2753 |
/// <returns></returns> |
2754 |
public static string ComentSucstring(string Mijiretu, string Delimiter) |
2755 |
{ |
2756 |
string strRet = Mijiretu; |
2757 |
try |
2758 |
{ |
2759 |
|
2760 |
if (Mijiretu.IndexOf(Delimiter) < 0) return strRet; |
2761 |
int TargetCnt = Mijiretu.IndexOf(Delimiter) - 1; |
2762 |
|
2763 |
if (TargetCnt>0) |
2764 |
strRet = Mijiretu.Substring(0, TargetCnt); |
2765 |
|
2766 |
return strRet; |
2767 |
} |
2768 |
catch (Exception ex) |
2769 |
{ |
2770 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2771 |
return string.Empty; |
2772 |
} |
2773 |
} |
2774 |
#endregion |
2775 |
|
2776 |
#region 今の時間をセパレータを除いた文字列で戻す |
2777 |
/// <summary> |
2778 |
/// 今の時間をセパレータを除いた文字列で戻す |
2779 |
/// </summary> |
2780 |
/// <returns></returns> |
2781 |
public static string stringNowJikan() |
2782 |
{ |
2783 |
string[] wrk = DateTime.Now.ToShortDateString().Split('/'); |
2784 |
|
2785 |
string[] wrk2 = DateTime.Now.ToShortTimeString().Split(':'); |
2786 |
|
2787 |
return string.Format("{0}{1}{2}{3}{4}{5}" |
2788 |
, wrk[0], wrk[1], wrk[2] |
2789 |
, wrk2[0], wrk2[1], wrk2[2]); |
2790 |
} |
2791 |
#endregion |
2792 |
|
2793 |
#region 経過日数を工数で返す |
2794 |
/// <summary> |
2795 |
/// 経過日数を工数で返す |
2796 |
/// </summary> |
2797 |
/// <param name="StartDate"></param> |
2798 |
/// <param name="CompDate"></param> |
2799 |
/// <returns></returns> |
2800 |
public static double DiffMounthTimes(DateTime StartDate, DateTime CompDate) |
2801 |
{ |
2802 |
// 差分計算 |
2803 |
TimeSpan DiffDate = CompDate - StartDate; |
2804 |
|
2805 |
// 当日までなので+1日する |
2806 |
TimeSpan wrkts = new TimeSpan(1, 0, 0, 0); |
2807 |
DiffDate = DiffDate + wrkts; |
2808 |
|
2809 |
// 工数の最小単位で割って10分の1にする |
2810 |
//return (((double)DiffDate.Days) / CommonDefine.s_ManHourUnitDays) / 10; |
2811 |
// 日数から月数へ変換する |
2812 |
return ClsCalendar.cnvMonthFromDays(DiffDate.Days); |
2813 |
} |
2814 |
#endregion |
2815 |
|
2816 |
#region 文字列を指定文字で指定レングス分埋める |
2817 |
/// <summary> |
2818 |
/// 文字列を指定文字で指定レングス分埋める |
2819 |
/// </summary> |
2820 |
/// <param name="OrgString"></param> |
2821 |
/// <param name="SetLength"></param> |
2822 |
/// <param name="Before"></param> |
2823 |
/// <returns></returns> |
2824 |
public static string SetBlankString(string OrgString, string SetString, int SetLength, bool Before) |
2825 |
{ |
2826 |
try |
2827 |
{ |
2828 |
string strRet = string.Empty; |
2829 |
int stringLength = OrgString.Length; |
2830 |
|
2831 |
// 文字列を埋める |
2832 |
for (int i = 0; i < (SetLength - stringLength); i++) strRet += SetString; |
2833 |
|
2834 |
// 前か後か |
2835 |
if (Before) |
2836 |
{ |
2837 |
strRet = strRet + OrgString; |
2838 |
} |
2839 |
else |
2840 |
{ |
2841 |
strRet = OrgString + strRet; |
2842 |
} |
2843 |
|
2844 |
return strRet; |
2845 |
} |
2846 |
catch (Exception ex) |
2847 |
{ |
2848 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2849 |
return string.Empty; |
2850 |
} |
2851 |
} |
2852 |
#endregion |
2853 |
|
2854 |
#region 現在年を西暦で求める |
2855 |
/// <summary> |
2856 |
/// 現在年を西暦で求める |
2857 |
/// </summary> |
2858 |
public static int GetBaseCounstructionYear(int years) |
2859 |
{ |
2860 |
try |
2861 |
{ |
2862 |
int Beginning = 0; |
2863 |
int diffwork = 0; |
2864 |
string strwork = string.Empty; |
2865 |
if (CommonMotions.BasePeriodYear()) |
2866 |
{ // ----- 営業期ベースの時 |
2867 |
|
2868 |
// 現在期との差分を求める |
2869 |
diffwork = years - SystemMasterData.BusinessPeriod; |
2870 |
|
2871 |
// 期首月を取得する |
2872 |
Beginning = SystemMasterData.BusinessBeginDate.Month; |
2873 |
} |
2874 |
else |
2875 |
{ // ----- 営業年度ベースの時 |
2876 |
|
2877 |
// 現在期との差分を求める |
2878 |
diffwork = years - SystemMasterData.ConstrYear; |
2879 |
|
2880 |
// 期首月を取得する |
2881 |
Beginning = SystemMasterData.ConstrBeginDate.Month; |
2882 |
} |
2883 |
|
2884 |
// 年数を求める |
2885 |
DateTime dateWork = DateTime.Now; |
2886 |
int nowMounth = DateTime.Now.Month; |
2887 |
// 期首月を境に年度を計算する |
2888 |
int iYear = 0; |
2889 |
if (nowMounth < Beginning) |
2890 |
iYear = dateWork.AddYears(-1).Year; |
2891 |
else |
2892 |
iYear = dateWork.Year; |
2893 |
|
2894 |
// ベース年を求める |
2895 |
return (iYear + diffwork); |
2896 |
} |
2897 |
catch (System.Exception ex) |
2898 |
{ |
2899 |
logger.ErrorFormat("システムエラー:{0}:{1}", GetMethodName(), ex.Message); |
2900 |
return 0; |
2901 |
} |
2902 |
} |
2903 |
#endregion |
2904 |
|
2905 |
#region 指定期・指定年度の期首日・期末日を取得する |
2906 |
/// <summary> |
2907 |
/// 指定期・指定年度の期首日・期末日を取得する |
2908 |
/// </summary> |
2909 |
/// <param name="nYear"></param> |
2910 |
/// <param name="bBeginDay"></param> |
2911 |
/// <param name="bPeriod"></param> |
2912 |
/// <returns></returns> |
2913 |
public static DateTime GetOpeningEndDate(int nYear, bool bBeginDay = true) |
2914 |
{ |
2915 |
IOMBizPeriodHistory BizHisDB = new IOMBizPeriodHistory(); |
2916 |
try |
2917 |
{ |
2918 |
DateTime dtRet = DateTime.Now.Date; |
2919 |
|
2920 |
StringBuilder strSQL = new StringBuilder(); |
2921 |
BizPeriodHistory BizHisRec = new BizPeriodHistory(); |
2922 |
|
2923 |
if (BasePeriodYear()) |
2924 |
{ // 営業期 |
2925 |
strSQL.Append(BizHisDB.CreatePrimarykeyString(nYear, (int)BizPeriodHistory.PeriodFlagDef.BizPeriod)); |
2926 |
} |
2927 |
else |
2928 |
{ // 工事年度 |
2929 |
strSQL.Append(BizHisDB.CreatePrimarykeyString(nYear, (int)BizPeriodHistory.PeriodFlagDef.ConstrYear)); |
2930 |
} |
2931 |
|
2932 |
// 運営期履歴情報読込 |
2933 |
if (!BizHisDB.SelectAction(strSQL.ToString(), ref BizHisRec)) return dtRet; |
2934 |
|
2935 |
if (bBeginDay) |
2936 |
{ |
2937 |
// 期首取得時 |
2938 |
dtRet = BizHisRec.BeginDate; |
2939 |
} |
2940 |
else |
2941 |
{ |
2942 |
// 期末取得時 |
2943 |
dtRet = BizHisRec.CompleteDate; |
2944 |
} |
2945 |
|
2946 |
return dtRet; |
2947 |
} |
2948 |
catch (System.Exception ex) |
2949 |
{ |
2950 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
2951 |
return DateTime.Today; |
2952 |
} |
2953 |
finally |
2954 |
{ |
2955 |
BizHisDB.close(); BizHisDB = null; |
2956 |
} |
2957 |
} |
2958 |
#endregion |
2959 |
|
2960 |
#region TimeSpanから年数を取得する |
2961 |
/// <summary> |
2962 |
/// TimeSpanから年数を取得する(切り上げ) |
2963 |
/// </summary> |
2964 |
/// <param name="timespan"></param> |
2965 |
/// <returns></returns> |
2966 |
public static int GetTimeSpanYears(this TimeSpan timespan) |
2967 |
{ |
2968 |
return CommonMotions.cnvRoundUp((double)timespan.Days / 365.2425); |
2969 |
} |
2970 |
#endregion |
2971 |
|
2972 |
#region TimeSpanから月数を取得する |
2973 |
/// <summary> |
2974 |
/// TimeSpanから月数を取得する |
2975 |
/// </summary> |
2976 |
/// <param name="timespan"></param> |
2977 |
/// <returns></returns> |
2978 |
public static int GetTimeSpanMonths(this TimeSpan timespan) |
2979 |
{ |
2980 |
return (int)((double)timespan.Days / 30.436875); |
2981 |
} |
2982 |
#endregion |
2983 |
|
2984 |
#region 工事種別より工事詳細台帳が作成OKかどうかをチェックする |
2985 |
/// <summary> |
2986 |
/// 工事種別より工事詳細台帳が作成OKかどうかをチェックする |
2987 |
/// </summary> |
2988 |
/// <param name="ConstructionType"></param> |
2989 |
/// <returns></returns> |
2990 |
public static bool CheckCreateLedgerData(int ConstructionStatusFlg, int ConstructionType) |
2991 |
{ |
2992 |
try |
2993 |
{ |
2994 |
bool ExcuteFlg = false; |
2995 |
int[] Status = new int[] { CommonDefine.ProjectsStatus.First(x => x.Value.Equals("一般補修工事")).Key, |
2996 |
CommonDefine.ProjectsStatus.First(x => x.Value.Equals("空家補修工事")).Key, |
2997 |
CommonDefine.ProjectsStatus.First(x => x.Value.Equals("Hit'sV工事")).Key, |
2998 |
}; |
2999 |
for (int i = 0; i < Status.Length; i++) |
3000 |
{ |
3001 |
//if (ConstructionStatusFlg == Status[i] && ConstructionType == CommonDefine.s_CreateLedgerData[i]) |
3002 |
if (ConstructionStatusFlg == Status[i]) |
3003 |
{ |
3004 |
ExcuteFlg = true; |
3005 |
break; |
3006 |
} |
3007 |
} |
3008 |
return ExcuteFlg; |
3009 |
} |
3010 |
catch (Exception ex) |
3011 |
{ |
3012 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3013 |
return false; |
3014 |
} |
3015 |
} |
3016 |
#endregion |
3017 |
|
3018 |
#region 予算書・台帳給与金額計算処理 |
3019 |
/// <summary> |
3020 |
/// 予算書・台帳給与金額計算処理 |
3021 |
/// </summary> |
3022 |
public static void CalcPayValueData(double MonthryCost, double OrdersPrice, int workingCount, |
3023 |
ref double ExecutionAmount, ref double AmountConfigRate, |
3024 |
bool bSalaryCorrection = true) |
3025 |
{ |
3026 |
try |
3027 |
{ |
3028 |
// 受注金額が0の場合は1として計算する |
3029 |
if (OrdersPrice == 0) OrdersPrice = 1; |
3030 |
|
3031 |
// 日当計算 |
3032 |
double DairySalary =0; |
3033 |
if (bSalaryCorrection) |
3034 |
DairySalary = (MonthryCost * CommonDefine.s_SalaryCorrection) / CommonDefine.s_ManHourUnitMonth; |
3035 |
else |
3036 |
DairySalary = MonthryCost / CommonDefine.s_ManHourUnitMonth; |
3037 |
|
3038 |
// 給与支払総額 |
3039 |
int iInput = CommonMotions.cnvRound(DairySalary * workingCount); |
3040 |
|
3041 |
// 実行金額に給与支払総額をセットする |
3042 |
ExecutionAmount = iInput; |
3043 |
|
3044 |
// 金額構成率計算 |
3045 |
AmountConfigRate = (iInput / OrdersPrice) * 100.0; |
3046 |
|
3047 |
// 構成率が範囲外の場合は0にする |
3048 |
if (AmountConfigRate < -999.00 || 999.00 < AmountConfigRate) AmountConfigRate = 0; |
3049 |
} |
3050 |
catch (Exception ex) |
3051 |
{ |
3052 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3053 |
} |
3054 |
} |
3055 |
#endregion |
3056 |
|
3057 |
#region 給与取得SQL作成処理 |
3058 |
/// <summary> |
3059 |
/// 給与取得SQL作成処理 |
3060 |
/// </summary> |
3061 |
private static string GetSalaryValue(int PersonCode, DateTime GetData) |
3062 |
{ |
3063 |
try |
3064 |
{ |
3065 |
// SQL作成 |
3066 |
StringBuilder strSQL = new StringBuilder(); |
3067 |
strSQL.Append("SELECT"); |
3068 |
strSQL.Append(" A.MONTHLYSALARY"); |
3069 |
strSQL.Append(", A.YEARSALARY"); |
3070 |
strSQL.Append(", A.PERSONCODE"); |
3071 |
strSQL.Append(", A.STARTDATE"); |
3072 |
strSQL.Append(" FROM PERSONSALARYMASTER As A"); |
3073 |
strSQL.Append(" , (SELECT"); |
3074 |
strSQL.Append(" BB.PERSONCODE"); |
3075 |
strSQL.Append(" , MAX(BB.STARTDATE) sDate"); |
3076 |
strSQL.Append(" FROM PERSONSALARYMASTER As BB"); |
3077 |
strSQL.AppendFormat(" WHERE BB.PERSONCODE = {0}", PersonCode); |
3078 |
strSQL.AppendFormat(" AND DATE(BB.StartDate) <= DATE('{0}')", GetData.ToShortDateString()); |
3079 |
strSQL.Append(" GROUP BY BB.PERSONCODE) As B"); |
3080 |
strSQL.Append(" WHERE A.PERSONCODE = B.PERSONCODE"); |
3081 |
strSQL.Append(" AND A.STARTDATE = B.sDate"); |
3082 |
|
3083 |
return strSQL.ToString(); |
3084 |
} |
3085 |
catch (Exception ex) |
3086 |
{ |
3087 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3088 |
return string.Empty; |
3089 |
} |
3090 |
} |
3091 |
#endregion |
3092 |
|
3093 |
#region 担当者給与金額取得処理(単独処理) |
3094 |
/// <summary> |
3095 |
/// 担当者給与金額取得処理(単独処理) |
3096 |
/// </summary> |
3097 |
public static bool GetSalaryValue(int PersonCode, ref double MonthryCost, ref double YearsCost, DateTime GetData) |
3098 |
{ |
3099 |
IOMPersonInCharge PersonDB = new IOMPersonInCharge(); |
3100 |
try |
3101 |
{ |
3102 |
// 初期値セット |
3103 |
MonthryCost = 0; |
3104 |
YearsCost = 0; |
3105 |
|
3106 |
// データ取得 |
3107 |
string strSQL = GetSalaryValue(PersonCode, GetData); |
3108 |
ArrayList arList = new ArrayList(); |
3109 |
if (!PersonDB.ExecuteReader(strSQL, ref arList)) return false; |
3110 |
if (arList.Count < 1) return false; |
3111 |
object[] objGetData = (object[])arList[0]; |
3112 |
|
3113 |
// 取得値セット |
3114 |
MonthryCost = CommonMotions.cnvDouble(objGetData[0]); |
3115 |
YearsCost = CommonMotions.cnvDouble(objGetData[1]); |
3116 |
|
3117 |
return true; |
3118 |
} |
3119 |
catch (Exception ex) |
3120 |
{ |
3121 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3122 |
return false; |
3123 |
} |
3124 |
finally |
3125 |
{ |
3126 |
PersonDB.close(); PersonDB = null; |
3127 |
} |
3128 |
} |
3129 |
#endregion |
3130 |
|
3131 |
#region 担当者給与金額取得処理(セッションコネクト別) |
3132 |
/// <summary> |
3133 |
/// 担当者給与金額取得処理(セッションコネクト別) |
3134 |
/// </summary> |
3135 |
public static bool GetSalaryValue(IOMPersonInCharge PersonDB, int PersonCode, |
3136 |
ref double MonthryCost, ref double YearsCost, DateTime GetData) |
3137 |
{ |
3138 |
try |
3139 |
{ |
3140 |
// 初期値セット |
3141 |
MonthryCost = 0; |
3142 |
YearsCost = 0; |
3143 |
|
3144 |
// データ取得 |
3145 |
string strSQL = GetSalaryValue(PersonCode, GetData); |
3146 |
ArrayList arList = new ArrayList(); |
3147 |
if (!PersonDB.ExecuteReader(strSQL, ref arList, false)) return false; |
3148 |
object[] objGetData = (object[])arList[0]; |
3149 |
|
3150 |
// 取得値セット |
3151 |
MonthryCost = CommonMotions.cnvDouble(objGetData[0]); |
3152 |
YearsCost = CommonMotions.cnvDouble(objGetData[1]); |
3153 |
|
3154 |
return true; |
3155 |
} |
3156 |
catch (Exception ex) |
3157 |
{ |
3158 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3159 |
return false; |
3160 |
} |
3161 |
} |
3162 |
#endregion |
3163 |
|
3164 |
#region 与えられたキー値より機密管理区分データを取得する |
3165 |
/// <summary> |
3166 |
/// 与えられたキー値より機密管理区分データを取得する |
3167 |
/// </summary> |
3168 |
/// <param name="KeyValue"></param> |
3169 |
/// <returns></returns> |
3170 |
public static KeyValuePair<int, string> SearchSecurityRankList(int KeyValue) |
3171 |
{ |
3172 |
KeyValuePair<int, string> RetPairvalue = new KeyValuePair<int, string>(0, string.Empty); |
3173 |
try |
3174 |
{ |
3175 |
for (int i = 0; i < CommonDefine.SecurityRankList.Count; i++) |
3176 |
{ |
3177 |
if (CommonDefine.SecurityRankList[i].Key == KeyValue) |
3178 |
{ |
3179 |
RetPairvalue = CommonDefine.SecurityRankList[i]; |
3180 |
} |
3181 |
} |
3182 |
|
3183 |
return RetPairvalue; |
3184 |
} |
3185 |
catch (Exception ex) |
3186 |
{ |
3187 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3188 |
return RetPairvalue; |
3189 |
} |
3190 |
} |
3191 |
#endregion |
3192 |
|
3193 |
#region 与えられたキー値より機密区分範囲データを取得する |
3194 |
/// <summary> |
3195 |
/// 与えられたキー値より機密区分範囲データを取得する |
3196 |
/// </summary> |
3197 |
/// <param name="KeyValue"></param> |
3198 |
/// <returns></returns> |
3199 |
public static KeyValuePair<int, string> SearchSecurityRangeList(int KeyValue) |
3200 |
{ |
3201 |
KeyValuePair<int, string> RetPairvalue = new KeyValuePair<int, string>(0, string.Empty); |
3202 |
try |
3203 |
{ |
3204 |
for (int i = 0; i < CommonDefine.SecurityRangeList.Count; i++) |
3205 |
{ |
3206 |
if (CommonDefine.SecurityRangeList[i].Key == KeyValue) |
3207 |
{ |
3208 |
RetPairvalue = CommonDefine.SecurityRangeList[i]; |
3209 |
} |
3210 |
} |
3211 |
|
3212 |
return RetPairvalue; |
3213 |
} |
3214 |
catch (Exception ex) |
3215 |
{ |
3216 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3217 |
return RetPairvalue; |
3218 |
} |
3219 |
} |
3220 |
#endregion |
3221 |
|
3222 |
#region 登録完了メッセージ表示 |
3223 |
/// <summary> |
3224 |
/// 登録完了メッセージ表示 |
3225 |
/// </summary> |
3226 |
/// <param name="strTitle"></param> |
3227 |
public static void EntryEndMessage(string strTitle) |
3228 |
{ |
3229 |
try |
3230 |
{ |
3231 |
string strMes = string.Format("{0} 登録完了しました。", strTitle); |
3232 |
|
3233 |
MessageBox.Show(strMes, "登録完了メッセージ", MessageBoxButtons.OK, MessageBoxIcon.Information); |
3234 |
} |
3235 |
catch (Exception ex) |
3236 |
{ |
3237 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3238 |
} |
3239 |
} |
3240 |
public static void EntryEndMessage(string strTitle, string strTitle2) |
3241 |
{ |
3242 |
try |
3243 |
{ |
3244 |
string strMes = string.Format("{0} {1}完了しました。", strTitle, strTitle2); |
3245 |
string strGuidance = string.Format("{0}完了メッセージ", strTitle2); |
3246 |
|
3247 |
MessageBox.Show(strMes, strGuidance, MessageBoxButtons.OK, MessageBoxIcon.Information); |
3248 |
} |
3249 |
catch (Exception ex) |
3250 |
{ |
3251 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3252 |
} |
3253 |
} |
3254 |
#endregion |
3255 |
|
3256 |
#region 削除完了メッセージ表示 |
3257 |
/// <summary> |
3258 |
/// 削除完了メッセージ表示 |
3259 |
/// </summary> |
3260 |
/// <param name="strTitle"></param> |
3261 |
public static void RemoveEndMessage(string strTitle) |
3262 |
{ |
3263 |
try |
3264 |
{ |
3265 |
string strMes = string.Format("{0} 削除完了しました。", strTitle); |
3266 |
|
3267 |
MessageBox.Show(strMes, "削除完了メッセージ", MessageBoxButtons.OK, MessageBoxIcon.Information); |
3268 |
} |
3269 |
catch (Exception ex) |
3270 |
{ |
3271 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3272 |
} |
3273 |
} |
3274 |
#endregion |
3275 |
|
3276 |
#region 経過給与を計算する |
3277 |
/// <summary> |
3278 |
/// 経過給与を計算する |
3279 |
/// </summary> |
3280 |
/// <param name="dtStart"></param> |
3281 |
/// <param name="PersonCode"></param> |
3282 |
/// <returns></returns> |
3283 |
public static int CalcElapsedSalary(IOMPersonInCharge SalDB, DateTime dtStart, DateTime dtLast, int PersonCode, bool bConnect = true) |
3284 |
{ |
3285 |
try |
3286 |
{ |
3287 |
int RetSalary = 0; |
3288 |
|
3289 |
StringBuilder strSQL = new StringBuilder(); |
3290 |
strSQL.Append("SELECT SUM(SAL.SALARY) FROM"); |
3291 |
strSQL.Append(" (SELECT AX.hiduke,"); |
3292 |
//strSQL.AppendFormat(" ROUND((AX.salary * {0}) / DATE_FORMAT(LAST_DAY(AX.hiduke), '%d')) AS SALARY,", CommonDefine.s_SalaryCorrection); |
3293 |
strSQL.AppendFormat(" ROUND((AX.salary * {0}) / 30) AS SALARY,", CommonDefine.s_SalaryCorrection); |
3294 |
strSQL.Append(" MAX(AX.StartD) FROM"); |
3295 |
strSQL.Append(" (SELECT A.d hiduke, B.MonthlySalary salary, B.STARTDATE StartD FROM"); |
3296 |
|
3297 |
strSQL.Append(" (SELECT A1.years, A2.month, A3.days, DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) AS d"); |
3298 |
strSQL.Append(" FROM yearmaster AS A1, monthmaster AS A2, daymaster AS A3"); |
3299 |
|
3300 |
strSQL.Append(" WHERE"); |
3301 |
if (dtStart.Year == dtLast.Year) |
3302 |
{ |
3303 |
strSQL.AppendFormat(" (A1.years = {0} AND A2.month IN(", dtStart.Year.ToString("0000")); |
3304 |
for (int i = dtStart.Month; i <= dtLast.Month; i++) |
3305 |
{ |
3306 |
if (i != dtStart.Month) strSQL.Append(", "); |
3307 |
strSQL.AppendFormat("{0} ", i); |
3308 |
} |
3309 |
strSQL.Append("))"); |
3310 |
} |
3311 |
else |
3312 |
{ |
3313 |
strSQL.Append(" ("); |
3314 |
|
3315 |
for (int iYear = dtStart.Year; iYear <= dtLast.Year; iYear++) |
3316 |
{ |
3317 |
// 先頭以外はORを追加する |
3318 |
if (iYear != dtStart.Year) strSQL.AppendFormat(" OR"); |
3319 |
|
3320 |
strSQL.AppendFormat(" (A1.years = {0}", iYear.ToString("0000")); |
3321 |
strSQL.Append(" AND A2.month IN ("); |
3322 |
|
3323 |
if (iYear == dtStart.Year) |
3324 |
{ // 先頭年 |
3325 |
for (int i = dtStart.Month; i <= 12; i++) |
3326 |
{ |
3327 |
if (i != dtStart.Month) strSQL.Append(", "); |
3328 |
strSQL.AppendFormat("{0} ", i); |
3329 |
} |
3330 |
} |
3331 |
else if (iYear == dtLast.Year) |
3332 |
{ // 最終年 |
3333 |
for (int i = 1; i <= dtLast.Month; i++) |
3334 |
{ |
3335 |
if (i != 1) strSQL.Append(", "); |
3336 |
strSQL.AppendFormat("{0} ", i); |
3337 |
} |
3338 |
} |
3339 |
else |
3340 |
{ // 以外の年 |
3341 |
for (int i = 1; i <= 12; i++) |
3342 |
{ |
3343 |
if (i != 1) strSQL.Append(", "); |
3344 |
strSQL.AppendFormat("{0} ", i); |
3345 |
} |
3346 |
} |
3347 |
strSQL.Append("))"); |
3348 |
} |
3349 |
strSQL.Append(")"); |
3350 |
} |
3351 |
|
3352 |
strSQL.Append(" AND DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) IS NOT NULL"); |
3353 |
strSQL.AppendFormat(" AND (DATE('{0}') <= DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days))", dtStart.ToShortDateString()); |
3354 |
strSQL.AppendFormat(" AND DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) <= DATE('{0}'))", dtLast.ToShortDateString()); |
3355 |
strSQL.Append(" ORDER BY d) A"); |
3356 |
strSQL.Append(", PERSONSALARYMASTER AS B"); |
3357 |
strSQL.AppendFormat(" WHERE B.PERSONCODE = {0}", PersonCode); |
3358 |
strSQL.Append(" AND B.STARTDATE <= A.d"); |
3359 |
strSQL.Append(" ORDER BY A.d, B.STARTDATE DESC) AS AX"); |
3360 |
strSQL.Append(" GROUP BY AX.hiduke"); |
3361 |
strSQL.Append(" ORDER BY AX.hiduke"); |
3362 |
strSQL.Append(" ) AS SAL"); |
3363 |
|
3364 |
ArrayList ArData = new ArrayList(); |
3365 |
if(!SalDB.ExecuteReader(strSQL.ToString(), ref ArData, bConnect)) return 0; |
3366 |
|
3367 |
foreach (object[] objRec in ArData) |
3368 |
{ |
3369 |
RetSalary += CommonMotions.cnvInt(objRec[0]); |
3370 |
} |
3371 |
|
3372 |
return RetSalary; |
3373 |
} |
3374 |
catch (Exception ex) |
3375 |
{ |
3376 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3377 |
return 0; |
3378 |
} |
3379 |
} |
3380 |
#endregion |
3381 |
|
3382 |
#region 期間より零れた経過給与を取得する |
3383 |
/// <summary> |
3384 |
/// 期間より零れた経過給与を取得する |
3385 |
/// </summary> |
3386 |
/// <returns></returns> |
3387 |
public static void CalcSpilledSalary(IOMPersonInCharge SalDB |
3388 |
, int TargetYear, DateTime dtStart, DateTime dtLast |
3389 |
, int PersonCode |
3390 |
, ref int NextDiffDay |
3391 |
, ref int PrevDiffDay) |
3392 |
{ |
3393 |
try |
3394 |
{ |
3395 |
|
3396 |
DateTime dtDefaultStart = CommonMotions.GetOpeningEndDate(TargetYear, true); |
3397 |
DateTime dtDefaultEnd = CommonMotions.GetOpeningEndDate(TargetYear, false); |
3398 |
|
3399 |
StringBuilder strSQL = new StringBuilder(); |
3400 |
strSQL.Append("Select"); |
3401 |
strSQL.Append(" Base.ConstructionCode"); |
3402 |
strSQL.Append(", Ledger.ConstructionStart"); |
3403 |
strSQL.Append(", Ledger.ConstructionEnd"); |
3404 |
strSQL.Append(", LDetail.GroupCount"); |
3405 |
strSQL.Append(", LDetail.SalaryFlg"); |
3406 |
strSQL.Append(", LDetail.SalaryDays"); |
3407 |
strSQL.Append(" From"); |
3408 |
strSQL.Append(" constructionbaseinfo As Base"); |
3409 |
strSQL.Append(" Inner Join constructionledger As Ledger"); |
3410 |
strSQL.Append(" On Ledger.ConstructionCode = Base.ConstructionCode"); |
3411 |
strSQL.AppendFormat(" And DATE('{0}') <= DATE(Ledger.ConstructionEnd)", dtDefaultStart.ToShortDateString()); |
3412 |
strSQL.Append(" Inner Join constructionledgerdetail As LDetail"); |
3413 |
strSQL.Append(" On LDetail.ConstructionCode = Base.ConstructionCode"); |
3414 |
strSQL.AppendFormat(" And LDetail.GroupCount = {0}", (int)ConstructionLedgerDetail.GroupCountDef.Payroll); |
3415 |
strSQL.AppendFormat(" And LDetail.CompanyCode = {0}", PersonCode); |
3416 |
strSQL.AppendFormat(" And LDetail.SalaryFlg = {0}", (int)CommonDefine.SalaryDevision.DaysInput); |
3417 |
strSQL.Append(" Where"); |
3418 |
|
3419 |
if (CommonMotions.BasePeriodYear()) |
3420 |
strSQL.AppendFormat(" Base.ConstructionPeriod = {0}", TargetYear); |
3421 |
else |
3422 |
strSQL.AppendFormat(" Base.ConstructionYear = {0}", TargetYear); |
3423 |
|
3424 |
strSQL.AppendFormat(" And Base.ConstructionPersonCode = {0}", PersonCode); |
3425 |
strSQL.Append(" And ("); |
3426 |
strSQL.AppendFormat("DATE('{0}') <= DATE(Ledger.ConstructionStart)", dtLast.ToShortDateString()); |
3427 |
strSQL.AppendFormat(" And DATE(Ledger.ConstructionEnd) <= DATE('{0}')", dtDefaultEnd.ToShortDateString()); |
3428 |
strSQL.Append(")"); |
3429 |
|
3430 |
ArrayList ArData = new ArrayList(); |
3431 |
if (!SalDB.ExecuteReader(strSQL.ToString(), ref ArData)) return; |
3432 |
|
3433 |
// 半端分の日数を取得する |
3434 |
NextDiffDay = ArData.Cast<object[]>().Sum(x => CommonMotions.cnvInt(x[5])); |
3435 |
|
3436 |
// 先期の半端分の日数を取得する |
3437 |
PrevDiffDay = CalcSpilledPreviusDay(SalDB, TargetYear, dtStart, PersonCode); |
3438 |
|
3439 |
} |
3440 |
catch (Exception ex) |
3441 |
{ |
3442 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3443 |
} |
3444 |
} |
3445 |
#endregion |
3446 |
|
3447 |
#region 先期の終了後零れた日数を取得する |
3448 |
/// <summary> |
3449 |
/// 先期の終了後零れた日数を取得する |
3450 |
/// </summary> |
3451 |
/// <returns></returns> |
3452 |
private static int CalcSpilledPreviusDay(IOMPersonInCharge SalDB |
3453 |
, int TargetYear, DateTime dtStart, int PersonCode) |
3454 |
{ |
3455 |
try |
3456 |
{ |
3457 |
int RetDay = 0; |
3458 |
|
3459 |
// 先期の期末を取得する |
3460 |
int PrevTargetYear = (TargetYear - 1); |
3461 |
if (PrevTargetYear < 1) return 0; |
3462 |
DateTime dtPrevEnd = CommonMotions.GetOpeningEndDate((TargetYear - 1), false); |
3463 |
|
3464 |
// 今期の最初が先期の最後より大きい場合は処理しない |
3465 |
if (dtPrevEnd< dtStart) return 0; |
3466 |
|
3467 |
StringBuilder strSQL = new StringBuilder(); |
3468 |
strSQL.Append("Select"); |
3469 |
strSQL.Append(" Base.ConstructionCode"); |
3470 |
strSQL.Append(", Ledger.ConstructionStart"); |
3471 |
strSQL.Append(", Ledger.ConstructionEnd"); |
3472 |
strSQL.Append(", LDetail.GroupCount"); |
3473 |
strSQL.Append(", LDetail.SalaryFlg"); |
3474 |
strSQL.Append(", LDetail.SalaryDays"); |
3475 |
strSQL.Append(" From"); |
3476 |
strSQL.Append(" constructionbaseinfo As Base"); |
3477 |
strSQL.Append(" Inner Join constructionledger As Ledger"); |
3478 |
strSQL.Append(" On Ledger.ConstructionCode = Base.ConstructionCode"); |
3479 |
strSQL.Append(" Inner Join constructionledgerdetail As LDetail"); |
3480 |
strSQL.Append(" On LDetail.ConstructionCode = Base.ConstructionCode"); |
3481 |
strSQL.AppendFormat(" And LDetail.GroupCount = {0}", (int)ConstructionLedgerDetail.GroupCountDef.Payroll); |
3482 |
strSQL.AppendFormat(" And LDetail.CompanyCode = {0}", PersonCode); |
3483 |
strSQL.AppendFormat(" And LDetail.SalaryFlg = {0}", (int)CommonDefine.SalaryDevision.DaysInput); |
3484 |
strSQL.Append(" Where"); |
3485 |
|
3486 |
if (CommonMotions.BasePeriodYear()) |
3487 |
strSQL.AppendFormat(" Base.ConstructionPeriod = {0}", PrevTargetYear); |
3488 |
else |
3489 |
strSQL.AppendFormat(" Base.ConstructionYear = {0}", PrevTargetYear); |
3490 |
|
3491 |
strSQL.AppendFormat(" And Base.ConstructionPersonCode = {0}", PersonCode); |
3492 |
strSQL.Append(" And("); |
3493 |
strSQL.AppendFormat("DATE('{0}') <= DATE(Ledger.ConstructionStart)", (dtStart.AddDays(-1)).ToShortDateString()); |
3494 |
strSQL.AppendFormat(" And DATE(Ledger.ConstructionEnd) <= DATE('{0}')", dtPrevEnd.ToShortDateString()); |
3495 |
strSQL.Append(")"); |
3496 |
|
3497 |
ArrayList ArData = new ArrayList(); |
3498 |
if (!SalDB.ExecuteReader(strSQL.ToString(), ref ArData)) return 0; |
3499 |
|
3500 |
// 半端分の日数を取得する |
3501 |
RetDay = ArData.Cast<object[]>().Sum(x => CommonMotions.cnvInt(x[5])); |
3502 |
|
3503 |
return RetDay; |
3504 |
} |
3505 |
catch (Exception ex) |
3506 |
{ |
3507 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3508 |
return 0; |
3509 |
} |
3510 |
} |
3511 |
#endregion |
3512 |
|
3513 |
#region 経過給与を一括計算する |
3514 |
/// <summary> |
3515 |
/// 経過給与を一括計算する |
3516 |
/// </summary> |
3517 |
/// <param name="dtStart"></param> |
3518 |
/// <param name="PersonCode"></param> |
3519 |
/// <returns></returns> |
3520 |
public static void CalcElapsedSalaryAll(IOMPersonInCharge SalDB, int TargetYear, ArrayList TargetList, ref List<KeyValuePair<int, long>> SalDataList) |
3521 |
{ |
3522 |
try |
3523 |
{ |
3524 |
if (TargetList.Count < 1) return; |
3525 |
StringBuilder strSQL = new StringBuilder(); |
3526 |
|
3527 |
// 非受注コード |
3528 |
int nNotOrderCode = CommonDefine.ProjectsStatus.First(x => x.Value.Equals("非 受 注")).Key; |
3529 |
|
3530 |
bool bFirst = true; |
3531 |
foreach (object[] ObjRec in TargetList) |
3532 |
{ |
3533 |
int DepartmentCode = CommonMotions.cnvInt(ObjRec[(int)CommonLedgerData.GetPersonTerm.DepartmentCode]); |
3534 |
int PersonCode = CommonMotions.cnvInt(ObjRec[(int)CommonLedgerData.GetPersonTerm.PersonCode]); |
3535 |
int nKeyCode = (DepartmentCode * 100000000) + PersonCode; |
3536 |
DateTime dtStart = CommonMotions.cnvDate(ObjRec[(int)CommonLedgerData.GetPersonTerm.StartDate]); |
3537 |
DateTime dtLast = CommonMotions.cnvDate(ObjRec[(int)CommonLedgerData.GetPersonTerm.CompDate]); |
3538 |
|
3539 |
if (!bFirst) strSQL.Append(" UNION "); |
3540 |
|
3541 |
strSQL.AppendFormat("SELECT {0} As LinkKey, SUM(SAL{0}.SALARY) FROM", nKeyCode); |
3542 |
|
3543 |
strSQL.Append(" (SELECT AX.hiduke"); |
3544 |
strSQL.AppendFormat(" , ROUND((AX.salary * {0}) / 30) AS SALARY", CommonDefine.s_SalaryCorrection); |
3545 |
strSQL.Append(" , MAX(AX.StartD)"); |
3546 |
strSQL.Append(" From (SELECT A.d hiduke, B.MonthlySalary salary, B.STARTDATE StartD FROM"); |
3547 |
|
3548 |
strSQL.Append(" (SELECT A1.years"); |
3549 |
strSQL.Append(" , A2.month"); |
3550 |
strSQL.Append(" , A3.days"); |
3551 |
strSQL.Append(" , DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) AS d"); |
3552 |
strSQL.Append(" FROM yearmaster AS A1, monthmaster AS A2, daymaster AS A3"); |
3553 |
|
3554 |
strSQL.Append(" WHERE"); |
3555 |
if (dtStart.Year == dtLast.Year) |
3556 |
{ |
3557 |
strSQL.AppendFormat(" (A1.years = {0} AND A2.month IN (", dtStart.Year.ToString("0000")); |
3558 |
for (int i = dtStart.Month; i <= dtLast.Month; i++) |
3559 |
{ |
3560 |
if (i != dtStart.Month) strSQL.Append(", "); |
3561 |
strSQL.AppendFormat("{0} ", i); |
3562 |
} |
3563 |
strSQL.Append("))"); |
3564 |
} |
3565 |
else |
3566 |
{ |
3567 |
strSQL.Append(" ("); |
3568 |
|
3569 |
for (int iYear = dtStart.Year; iYear <= dtLast.Year; iYear++) |
3570 |
{ |
3571 |
// 先頭以外はORを追加する |
3572 |
if (iYear != dtStart.Year) strSQL.AppendFormat(" OR"); |
3573 |
|
3574 |
strSQL.AppendFormat(" (A1.years = {0}", iYear.ToString("0000")); |
3575 |
strSQL.Append(" AND A2.month IN ("); |
3576 |
|
3577 |
if (iYear == dtStart.Year) |
3578 |
{ // 先頭年 |
3579 |
for (int i = dtStart.Month; i <= 12; i++) |
3580 |
{ |
3581 |
if (i != dtStart.Month) strSQL.Append(", "); |
3582 |
strSQL.AppendFormat("{0} ", i); |
3583 |
} |
3584 |
} |
3585 |
else if (iYear == dtLast.Year) |
3586 |
{ // 最終年 |
3587 |
for (int i = 1; i <= dtLast.Month; i++) |
3588 |
{ |
3589 |
if (i != 1) strSQL.Append(", "); |
3590 |
strSQL.AppendFormat("{0} ", i); |
3591 |
} |
3592 |
} |
3593 |
else |
3594 |
{ // 以外の年 |
3595 |
for (int i = 1; i <= 12; i++) |
3596 |
{ |
3597 |
if (i != 1) strSQL.Append(", "); |
3598 |
strSQL.AppendFormat("{0} ", i); |
3599 |
} |
3600 |
} |
3601 |
strSQL.Append("))"); |
3602 |
} |
3603 |
strSQL.Append(")"); |
3604 |
} |
3605 |
|
3606 |
strSQL.Append(" AND DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) IS NOT NULL"); |
3607 |
strSQL.AppendFormat(" AND (DATE('{0}') <= DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days))", dtStart.ToShortDateString()); |
3608 |
strSQL.AppendFormat(" AND DATE(CONCAT(A1.years, '/', A2.month, '/', A3.days)) <= DATE('{0}'))", dtLast.ToShortDateString()); |
3609 |
strSQL.Append(" ORDER BY d) A"); |
3610 |
|
3611 |
strSQL.Append(" , PERSONSALARYMASTER AS B"); |
3612 |
strSQL.Append(" Inner Join personinchargemaster As C"); |
3613 |
strSQL.Append(" On C.PersonCode = B.PersonCode"); |
3614 |
strSQL.AppendFormat(" And C.LedgerFlg = {0}", (int)PersonInChargeMaster.LedgerDivNoDef.CalcTarget); |
3615 |
|
3616 |
strSQL.AppendFormat(" WHERE B.PERSONCODE = {0}", PersonCode); |
3617 |
//strSQL.Append(" AND B.STARTDATE <= A.d"); |
3618 |
strSQL.Append(" AND B.STARTDATE = "); |
3619 |
strSQL.Append(" (Select BB.STARTDATE From PERSONSALARYMASTER AS BB"); |
3620 |
strSQL.AppendFormat(" Where BB.PERSONCODE = {0}", PersonCode); |
3621 |
strSQL.Append(" AND BB.STARTDATE <= A.d"); |
3622 |
strSQL.Append(" Order By BB.STARTDATE DESC"); |
3623 |
strSQL.Append(" Limit 1)"); |
3624 |
|
3625 |
strSQL.Append(" ORDER BY A.d, B.STARTDATE DESC) AS AX"); |
3626 |
strSQL.Append(" GROUP BY AX.hiduke"); |
3627 |
strSQL.Append(" ORDER BY AX.hiduke"); |
3628 |
strSQL.AppendFormat(" ) AS SAL{0}", nKeyCode); |
3629 |
|
3630 |
bFirst = false; |
3631 |
} |
3632 |
|
3633 |
ArrayList ArData = new ArrayList(); |
3634 |
if (!SalDB.ExecuteReader(strSQL.ToString(), ref ArData)) return; |
3635 |
|
3636 |
foreach (object[] objRec in ArData) |
3637 |
{ |
3638 |
SalDataList.Add(new KeyValuePair<int, long>(CommonMotions.cnvInt(objRec[0]), CommonMotions.cnvLong(objRec[1]))); |
3639 |
} |
3640 |
|
3641 |
} |
3642 |
catch (Exception ex) |
3643 |
{ |
3644 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3645 |
} |
3646 |
} |
3647 |
#endregion |
3648 |
|
3649 |
#region 期間より零れた経過給与を取得しデータテーブルの開始終了日を変更する |
3650 |
/// <summary> |
3651 |
/// 期間より零れた経過給与を取得しデータテーブルの開始終了日を変更する |
3652 |
/// </summary> |
3653 |
/// <returns></returns> |
3654 |
public static void CalcSpilledSalaryAll(IOMPersonInCharge SalDB |
3655 |
, int TargetYear |
3656 |
, ref ArrayList TargetList) |
3657 |
{ |
3658 |
try |
3659 |
{ |
3660 |
if (TargetList.Count < 1) return; |
3661 |
|
3662 |
// デフォルト開始・終了を取得する |
3663 |
DateTime dtDefaultStart = CommonMotions.GetOpeningEndDate(TargetYear, true); |
3664 |
DateTime dtDefaultEnd = CommonMotions.GetOpeningEndDate(TargetYear, false); |
3665 |
DateTime dtPrevEnd = CommonMotions.GetOpeningEndDate((TargetYear - 1), false); |
3666 |
|
3667 |
// 先期の期末を取得する |
3668 |
int PrevTargetYear = (TargetYear - 1); |
3669 |
if (PrevTargetYear < 1) return; |
3670 |
|
3671 |
List<KeyValuePair<int, int>> wrkManCode = new List<KeyValuePair<int, int>>(); |
3672 |
List<KeyValuePair<DateTime, DateTime>> wrkStEdDate = new List<KeyValuePair<DateTime, DateTime>>(); |
3673 |
bool bFirst = true; |
3674 |
StringBuilder strSQL = new StringBuilder(); |
3675 |
foreach (object[] ObjRec in TargetList) |
3676 |
{ |
3677 |
// 開始・終了日が無い場合はデフォルトの期首・期末を使用する |
3678 |
DateTime stDate = CommonMotions.cnvDate(ObjRec[(int)CommonLedgerData.GetPersonTerm.StartDate]); |
3679 |
DateTime edDate = CommonMotions.cnvDate(ObjRec[(int)CommonLedgerData.GetPersonTerm.CompDate]); |
3680 |
CalcStartCompDate(TargetYear, |
3681 |
dtDefaultStart, dtDefaultEnd, |
3682 |
CommonMotions.cnvDate(ObjRec[(int)CommonLedgerData.GetPersonTerm.HireStartDays]), |
3683 |
CommonMotions.cnvDate(ObjRec[(int)CommonLedgerData.GetPersonTerm.HireCompDays]), |
3684 |
CommonMotions.cnvDate(ObjRec[(int)CommonLedgerData.GetPersonTerm.NextStartDate]), |
3685 |
CommonMotions.cnvDate(ObjRec[(int)CommonLedgerData.GetPersonTerm.NextCompDate]), |
3686 |
CommonMotions.cnvDate(ObjRec[(int)CommonLedgerData.GetPersonTerm.DepHistoryStartDate]), |
3687 |
CommonMotions.cnvDate(ObjRec[(int)CommonLedgerData.GetPersonTerm.DepHistoryCompDate]), |
3688 |
ref stDate, ref edDate); |
3689 |
|
3690 |
int nDepCode = CommonMotions.cnvInt(ObjRec[(int)CommonLedgerData.GetPersonTerm.DepartmentCode]); |
3691 |
int nPersonCode = CommonMotions.cnvInt(ObjRec[(int)CommonLedgerData.GetPersonTerm.PersonCode]); |
3692 |
|
3693 |
wrkManCode.Add(new KeyValuePair<int,int>(nDepCode, nPersonCode)); |
3694 |
wrkStEdDate.Add(new KeyValuePair<DateTime, DateTime>(stDate, edDate)); |
3695 |
|
3696 |
// 今期の最初が先期の最後より大きい場合は処理しない |
3697 |
//if (dtPrevEnd < stDate) continue; |
3698 |
|
3699 |
if (!bFirst) strSQL.Append(" Union "); |
3700 |
|
3701 |
strSQL.Append("Select"); |
3702 |
if (CommonMotions.BasePeriodYear()) |
3703 |
strSQL.Append(" Base.ConstructionPeriod"); |
3704 |
else |
3705 |
strSQL.Append(" Base.ConstructionYear"); |
3706 |
|
3707 |
strSQL.Append(", Base.ConstructionCode"); |
3708 |
strSQL.Append(", LDetail.CompanyCode"); |
3709 |
strSQL.Append(", Ledger.ConstructionStart"); |
3710 |
strSQL.Append(", Ledger.ConstructionEnd"); |
3711 |
strSQL.Append(", LDetail.GroupCount"); |
3712 |
strSQL.Append(", LDetail.SalaryFlg"); |
3713 |
strSQL.Append(", LDetail.SalaryDays"); |
3714 |
strSQL.Append(", LDetail.ComponentCode"); |
3715 |
strSQL.Append(" From"); |
3716 |
strSQL.Append(" constructionbaseinfo As Base"); |
3717 |
strSQL.Append(" Inner Join constructionledger As Ledger"); |
3718 |
strSQL.Append(" On Ledger.ConstructionCode = Base.ConstructionCode"); |
3719 |
strSQL.AppendFormat(" And DATE('{0}') <= DATE(Ledger.ConstructionEnd)", dtDefaultStart.ToShortDateString()); |
3720 |
strSQL.Append(" Inner Join constructionledgerdetail As LDetail"); |
3721 |
strSQL.Append(" On LDetail.ConstructionCode = Base.ConstructionCode"); |
3722 |
strSQL.AppendFormat(" And LDetail.GroupCount = {0}", (int)ConstructionLedgerDetail.GroupCountDef.Payroll); |
3723 |
strSQL.AppendFormat(" And LDetail.ComponentCode = {0}", nDepCode); |
3724 |
strSQL.AppendFormat(" And LDetail.CompanyCode = {0}", nPersonCode); |
3725 |
strSQL.AppendFormat(" And LDetail.SalaryFlg = {0}", (int)CommonDefine.SalaryDevision.DaysInput); |
3726 |
strSQL.Append(" Where"); |
3727 |
|
3728 |
if (CommonMotions.BasePeriodYear()) |
3729 |
strSQL.AppendFormat(" Base.ConstructionPeriod = {0}", TargetYear); |
3730 |
else |
3731 |
strSQL.AppendFormat(" Base.ConstructionYear = {0}", TargetYear); |
3732 |
|
3733 |
strSQL.AppendFormat(" And Base.ConstrDepCode = {0}", nDepCode); |
3734 |
strSQL.AppendFormat(" And Base.ConstructionPersonCode = {0}", nPersonCode); |
3735 |
strSQL.Append(" And("); |
3736 |
strSQL.AppendFormat("DATE('{0}') <= DATE(Ledger.ConstructionStart)", edDate.ToShortDateString()); |
3737 |
strSQL.AppendFormat(" And DATE(Ledger.ConstructionEnd) <= DATE('{0}')", dtDefaultEnd.ToShortDateString()); |
3738 |
strSQL.Append(")"); |
3739 |
strSQL.Append(" Union Select"); |
3740 |
|
3741 |
if (CommonMotions.BasePeriodYear()) |
3742 |
strSQL.Append(" Base.ConstructionPeriod"); |
3743 |
else |
3744 |
strSQL.Append(" Base.ConstructionYear"); |
3745 |
|
3746 |
strSQL.Append(", Base.ConstructionCode"); |
3747 |
strSQL.Append(", LDetail.CompanyCode"); |
3748 |
strSQL.Append(", Ledger.ConstructionStart"); |
3749 |
strSQL.Append(", Ledger.ConstructionEnd"); |
3750 |
strSQL.Append(", LDetail.GroupCount"); |
3751 |
strSQL.Append(", LDetail.SalaryFlg"); |
3752 |
strSQL.Append(", LDetail.SalaryDays"); |
3753 |
strSQL.Append(", LDetail.ComponentCode"); |
3754 |
strSQL.Append(" From"); |
3755 |
strSQL.Append(" constructionbaseinfo As Base"); |
3756 |
strSQL.Append(" Inner Join constructionledger As Ledger"); |
3757 |
strSQL.Append(" On Ledger.ConstructionCode = Base.ConstructionCode"); |
3758 |
strSQL.Append(" Inner Join constructionledgerdetail As LDetail"); |
3759 |
strSQL.Append(" On LDetail.ConstructionCode = Base.ConstructionCode"); |
3760 |
strSQL.AppendFormat(" And LDetail.GroupCount = {0}", (int)ConstructionLedgerDetail.GroupCountDef.Payroll); |
3761 |
strSQL.AppendFormat(" And LDetail.ComponentCode = {0}", nDepCode); |
3762 |
strSQL.AppendFormat(" And LDetail.CompanyCode = {0}", nPersonCode); |
3763 |
strSQL.AppendFormat(" And LDetail.SalaryFlg = {0}", (int)CommonDefine.SalaryDevision.DaysInput); |
3764 |
strSQL.Append(" Where"); |
3765 |
|
3766 |
if (CommonMotions.BasePeriodYear()) |
3767 |
strSQL.AppendFormat(" Base.ConstructionPeriod = {0}", PrevTargetYear); |
3768 |
else |
3769 |
strSQL.AppendFormat(" Base.ConstructionYear = {0}", PrevTargetYear); |
3770 |
|
3771 |
strSQL.AppendFormat(" And Base.ConstrDepCode = {0}", nDepCode); |
3772 |
strSQL.AppendFormat(" And Base.ConstructionPersonCode = {0}", nPersonCode); |
3773 |
strSQL.Append(" And("); |
3774 |
strSQL.AppendFormat("DATE('{0}') <= DATE(Ledger.ConstructionStart)", (stDate.AddDays(-1)).ToShortDateString()); |
3775 |
strSQL.AppendFormat(" And DATE(Ledger.ConstructionEnd) <= DATE('{0}')", dtPrevEnd.ToShortDateString()); |
3776 |
strSQL.Append(")"); |
3777 |
|
3778 |
bFirst = false; |
3779 |
} |
3780 |
// データ取得 |
3781 |
ArrayList ArData = new ArrayList(); |
3782 |
if (!SalDB.ExecuteReader(strSQL.ToString(), ref ArData)) return; |
3783 |
|
3784 |
foreach (object[] ObjRec in TargetList) |
3785 |
{ |
3786 |
int nDepCode = CommonMotions.cnvInt(ObjRec[(int)CommonLedgerData.GetPersonTerm.DepartmentCode]); |
3787 |
int nPersonCode = CommonMotions.cnvInt(ObjRec[(int)CommonLedgerData.GetPersonTerm.PersonCode]); |
3788 |
|
3789 |
// 半端分の日数を取得する |
3790 |
int NextDiffDay = ArData.Cast<object[]>().Where(x => CommonMotions.cnvInt(x[0]) == TargetYear |
3791 |
&& CommonMotions.cnvInt(x[8]) == nDepCode |
3792 |
&& CommonMotions.cnvInt(x[2]) == nPersonCode) |
3793 |
.Sum(y => CommonMotions.cnvInt(y[7])); |
3794 |
|
3795 |
// 先期の半端分の日数を取得する |
3796 |
int PrevDiffDay = ArData.Cast<object[]>().Where(x => CommonMotions.cnvInt(x[0]) == PrevTargetYear |
3797 |
&& CommonMotions.cnvInt(x[8]) == nDepCode |
3798 |
&& CommonMotions.cnvInt(x[2]) == nPersonCode) |
3799 |
.Sum(y => CommonMotions.cnvInt(y[7])); |
3800 |
// 同じデータを探す |
3801 |
int DateCnt = 0; |
3802 |
foreach (KeyValuePair<int, int> CurRec in wrkManCode) |
3803 |
{ |
3804 |
if (CurRec.Key == nDepCode && CurRec.Value == nPersonCode) break; |
3805 |
DateCnt++; |
3806 |
} |
3807 |
KeyValuePair<DateTime, DateTime> CurStEd = wrkStEdDate[DateCnt]; |
3808 |
|
3809 |
DateTime dtDepMove = CommonMotions.cnvDate(ObjRec[(int)CommonLedgerData.GetPersonTerm.DepHistoryStartDate]); |
3810 |
|
3811 |
// 今期終了日変更 |
3812 |
DateTime wrkDate = CurStEd.Value.AddDays(NextDiffDay); |
3813 |
if (dtDefaultEnd.Date < wrkDate.Date) wrkDate = dtDefaultEnd; |
3814 |
ObjRec[(int)CommonLedgerData.GetPersonTerm.CompDate] = wrkDate; |
3815 |
|
3816 |
if (dtDepMove.Date == CurStEd.Key.Date) PrevDiffDay = 0; // 部署移動日がセットされている場合は日付を変えない |
3817 |
// 今期開始日変更 |
3818 |
wrkDate = CurStEd.Key.AddDays(PrevDiffDay); |
3819 |
if (dtDefaultEnd.Date < wrkDate.Date) wrkDate = dtDefaultEnd; |
3820 |
ObjRec[(int)CommonLedgerData.GetPersonTerm.StartDate] = wrkDate; |
3821 |
} |
3822 |
|
3823 |
} |
3824 |
catch (Exception ex) |
3825 |
{ |
3826 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3827 |
} |
3828 |
} |
3829 |
#endregion |
3830 |
|
3831 |
#region 計算開始・終了日のチェック入れ替え |
3832 |
/// <summary> |
3833 |
/// 計算開始・終了日のチェック入れ替え |
3834 |
/// </summary> |
3835 |
public static void CalcStartCompDate(int BusinessPeriod, |
3836 |
DateTime dtDefaultStart, DateTime dtDefaultEnd, |
3837 |
DateTime HireStartDate, DateTime HireCompDate, |
3838 |
DateTime NextStartDate, DateTime NextCompDate, |
3839 |
DateTime DepHisStDate, DateTime DepHisCompDate, |
3840 |
ref DateTime StartDate, ref DateTime CompDate) |
3841 |
{ |
3842 |
try |
3843 |
{ |
3844 |
// ----- 計算開始日セット |
3845 |
if (StartDate.Date == DateTime.MinValue.Date) |
3846 |
{ |
3847 |
// 最小値ならば今期開始をセット |
3848 |
StartDate = dtDefaultStart; |
3849 |
} |
3850 |
//else if (dtDefaultStart.Date <= HireStartDate.Date && HireStartDate.Date <= dtDefaultEnd.Date) |
3851 |
//{ |
3852 |
// // 入社日が期内ならば開始を入社日にする |
3853 |
// StartDate = HireStartDate; |
3854 |
//} |
3855 |
else if (dtDefaultStart.Date < StartDate.Date) |
3856 |
{ |
3857 |
// 今期工事の契約工期が今期の開始より小さい場合は今期開始をセット |
3858 |
StartDate = dtDefaultStart; |
3859 |
} |
3860 |
// 入社日が期内ならば開始を入社日にする |
3861 |
if (dtDefaultStart.Date <= HireStartDate && HireStartDate.Date <= dtDefaultEnd.Date) |
3862 |
{ |
3863 |
StartDate = HireStartDate; |
3864 |
} |
3865 |
// 部署移動開始日が今期ならばセットする |
3866 |
if (dtDefaultStart.Date <= DepHisStDate.Date && DepHisStDate.Date <= dtDefaultEnd.Date) |
3867 |
{ |
3868 |
if (StartDate.Date < DepHisStDate.Date) StartDate = DepHisStDate; |
3869 |
} |
3870 |
|
3871 |
// ----- 計算終了日セット |
3872 |
// Defaultは期末 |
3873 |
CompDate = dtDefaultEnd; |
3874 |
|
3875 |
// 退社日が期内ならば終了を退社日にする |
3876 |
if (dtDefaultStart.Date < HireCompDate.Date && HireCompDate.Date < dtDefaultEnd.Date) |
3877 |
{ |
3878 |
CompDate = HireCompDate; |
3879 |
} |
3880 |
else if (DepHisCompDate.Date == DateTime.MaxValue.Date) |
3881 |
{ |
3882 |
// 終了がマックスは今季終了をセットする |
3883 |
CompDate = dtDefaultEnd; |
3884 |
} |
3885 |
else if (NextStartDate.Date != DateTime.MinValue.Date) |
3886 |
{ |
3887 |
// 来季の開始があって今期の場合は開始日-1に置き換える |
3888 |
if (dtDefaultStart.Date < NextStartDate.Date && NextStartDate.Date < dtDefaultEnd.Date) |
3889 |
{ |
3890 |
CompDate = NextStartDate.AddDays(-1); |
3891 |
} |
3892 |
} |
3893 |
// 部署移動終了日が今期ならばセットする |
3894 |
if (dtDefaultStart.Date <= DepHisCompDate.Date && DepHisCompDate.Date <= dtDefaultEnd.Date) |
3895 |
{ |
3896 |
if (DepHisCompDate.Date < CompDate.Date) CompDate = DepHisCompDate; |
3897 |
} |
3898 |
} |
3899 |
catch (Exception ex) |
3900 |
{ |
3901 |
logger.ErrorFormat("システムエラー:{0}", ex.Message); |
3902 |
} |
3903 |
} |
3904 |
#endregion |
3905 |
|
3906 |
#region グリッド行退避エリア初期化処理 |
3907 |
/// <summary> |
3908 |
/// グリッド行退避エリア初期化処理 |
3909 |
/// </summary> |
3910 |
public static void InitSavrGridRow(ref GridCellStyleMember[] BackUpStyle) |
3911 |
{ |
3912 |
try |
3913 |
{ |
3914 |
for (int i = 0; i < BackUpStyle.Length; i++) |
3915 |
{ |
3916 |
BackUpStyle[i] = new GridCellStyleMember(); |
3917 |
} |
3918 |
} |
3919 |
catch (Exception ex) |
3920 |
{ |
3921 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3922 |
} |
3923 |
} |
3924 |
#endregion |
3925 |
|
3926 |
#region 選択行の色を変更する |
3927 |
/// <summary> |
3928 |
/// 選択行の色を変更する |
3929 |
/// </summary> |
3930 |
public static void ChangeGridRow(DataGridViewEX dgv |
3931 |
, DataGridViewRow CurRow |
3932 |
, ref GridCellStyleMember[] BackUpStyle |
3933 |
, bool bSelect = true) |
3934 |
{ |
3935 |
try |
3936 |
{ |
3937 |
// カレント行バックアップ&対象色セット |
3938 |
for (int i = 0; i < dgv.ColumnCount; i++) |
3939 |
{ |
3940 |
if (bSelect) |
3941 |
{ |
3942 |
BackUpStyle[i].DrowBackColor = CurRow.Cells[i].Style.BackColor; |
3943 |
BackUpStyle[i].DrowFont = CurRow.Cells[i].Style.Font; |
3944 |
BackUpStyle[i].DrowForeColor = CurRow.Cells[i].Style.ForeColor; |
3945 |
CurRow.Cells[i].Style.BackColor = Color.Red; |
3946 |
CurRow.Cells[i].Style.ForeColor = Color.White; |
3947 |
} |
3948 |
else |
3949 |
{ |
3950 |
CurRow.Cells[i].Style.BackColor = BackUpStyle[i].DrowBackColor; |
3951 |
CurRow.Cells[i].Style.Font = BackUpStyle[i].DrowFont; |
3952 |
CurRow.Cells[i].Style.ForeColor = BackUpStyle[i].DrowForeColor; |
3953 |
} |
3954 |
} |
3955 |
} |
3956 |
catch (Exception ex) |
3957 |
{ |
3958 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
3959 |
} |
3960 |
} |
3961 |
#endregion |
3962 |
|
3963 |
#region フォームのコントロールを列挙する |
3964 |
/// <summary> |
3965 |
/// フォームのコントロールを列挙する |
3966 |
/// </summary> |
3967 |
/// <returns></returns> |
3968 |
public static Control[] GetAllControls(Control top) |
3969 |
{ |
3970 |
ArrayList buf = new ArrayList(); |
3971 |
foreach (Control c in top.Controls) |
3972 |
{ |
3973 |
buf.Add(c); |
3974 |
buf.AddRange(GetAllControls(c)); |
3975 |
} |
3976 |
return (Control[])buf.ToArray(typeof(Control)); |
3977 |
} |
3978 |
#endregion |
3979 |
|
3980 |
#region 今期以降の判定を行う |
3981 |
/// <summary> |
3982 |
/// 今期以降の判定を行う |
3983 |
/// </summary> |
3984 |
/// <returns></returns> |
3985 |
public static bool CheckNowSeason(int nTarget) |
3986 |
{ |
3987 |
try |
3988 |
{ |
3989 |
if (CommonMotions.BasePeriodYear()) |
3990 |
{ // 営業期数 |
3991 |
if (nTarget < m_systemMaster.BusinessPeriod) return false; |
3992 |
} |
3993 |
else |
3994 |
{ // 工事年度 |
3995 |
if (nTarget < m_systemMaster.ConstrYear) return false; |
3996 |
} |
3997 |
return true; |
3998 |
} |
3999 |
catch (Exception ex) |
4000 |
{ |
4001 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
4002 |
return false; |
4003 |
} |
4004 |
} |
4005 |
#endregion |
4006 |
|
4007 |
#region 部署コンボボックスデータ取得SQL作成 |
4008 |
/// <summary> |
4009 |
/// 部署コンボボックスデータ取得SQL作成 |
4010 |
/// </summary> |
4011 |
/// <param name="strSQL"></param> |
4012 |
public static void CreateDepCombBoxSQL(ref StringBuilder strSQL |
4013 |
, int nTargetCount |
4014 |
, bool bCompBase = true |
4015 |
, bool bLedgerDivNo = false |
4016 |
, bool bConstrBase = true) |
4017 |
{ |
4018 |
try |
4019 |
{ |
4020 |
if (CommonMotions.LoginUserData.PersonCode == CommonDefine.AdminCode) |
4021 |
{ |
4022 |
strSQL.Append("SELECT"); |
4023 |
strSQL.Append(" A.DEPARTMENTCODE"); |
4024 |
strSQL.Append(", A.DEPARTMENTSTRING"); |
4025 |
strSQL.Append(", A.DISPLAYORDER"); |
4026 |
strSQL.Append(", 1"); |
4027 |
strSQL.Append(" From DEPARTMENTMASTER As A"); |
4028 |
strSQL.AppendFormat(" Where DeleteFlg = {0}", (int)CommonDefine.DataDeleteDef.Exists); |
4029 |
return; |
4030 |
} |
4031 |
|
4032 |
// 今期のデータかどうかを判定する |
4033 |
bool bNowSeason = CheckNowSeason(nTargetCount); |
4034 |
|
4035 |
strSQL.Append("SELECT"); |
4036 |
strSQL.Append(" A.DEPARTMENTCODE"); |
4037 |
strSQL.Append(", A.DEPARTMENTSTRING"); |
4038 |
strSQL.Append(", A.DISPLAYORDER"); |
4039 |
strSQL.Append(", COUNT(*)"); |
4040 |
strSQL.Append(" FROM"); |
4041 |
strSQL.Append(" persondepartmentmaster As AA"); |
4042 |
strSQL.Append(" INNER JOIN ChgChargeDep As AB"); |
4043 |
strSQL.Append(" On AB.PersonCode = AA.PersonCode"); |
4044 |
strSQL.Append(" INNER JOIN DEPARTMENTMASTER As A"); |
4045 |
strSQL.Append(" On A.DepartmentCode = AA.DepartmentCode"); |
4046 |
if (bNowSeason) |
4047 |
{ |
4048 |
// 今期のプライマリテーブルは部署マスタ |
4049 |
//strSQL.AppendFormat(" And A.DELETEFLG = {0}", (int)CommonDefine.DataDeleteDef.Exists); |
4050 |
} |
4051 |
else |
4052 |
{ |
4053 |
if (bConstrBase) |
4054 |
{ |
4055 |
// 過去のデータは工事情報より取得する |
4056 |
strSQL.Append(" INNER JOIN ("); |
4057 |
strSQL.Append("Select"); |
4058 |
strSQL.Append(" A1.SalesDepCode As DEPARTMENTCODE"); |
4059 |
strSQL.Append(", A1.SalesPersonCode As PERSONCODE"); |
4060 |
strSQL.Append(", B1.DetailString As DEPARTMENTSTRING"); |
4061 |
strSQL.Append(", ifnull(C1.DisplayOrder, 10) As DISPLAYORDER"); |
4062 |
strSQL.Append(" From Constructionbaseinfo As A1"); |
4063 |
strSQL.Append(" Inner Join constructionbaseinfodetail As B1"); |
4064 |
strSQL.Append(" On B1.ConstructionCode = A1.ConstructionCode"); |
4065 |
strSQL.AppendFormat(" And B1.DetailNo = {0}", (int)ConstructionBaseInfoDetail.DataNoDef.SalesDepartmentName); |
4066 |
strSQL.Append(" Left Join departmentmaster As C1"); |
4067 |
strSQL.Append(" On C1.DepartmentCode = A1.SalesDepCode"); |
4068 |
|
4069 |
if (CommonMotions.BasePeriodYear()) |
4070 |
strSQL.AppendFormat(" Where A1.ConstructionPeriod = {0}", nTargetCount); |
4071 |
else |
4072 |
strSQL.AppendFormat(" Where A1.ConstructionYear = {0}", nTargetCount); |
4073 |
|
4074 |
strSQL.Append(" And A1.SalesDepCode != 0"); |
4075 |
|
4076 |
strSQL.Append(" Union Select"); |
4077 |
strSQL.Append(" A2.ConstrDepCode As DEPARTMENTCODE"); |
4078 |
strSQL.Append(", A2.ConstructionPersonCode As PERSONCODE"); |
4079 |
strSQL.Append(", B2.DetailString As DEPARTMENTSTRING"); |
4080 |
strSQL.Append(", ifnull(C2.DisplayOrder, 10) As DISPLAYORDER"); |
4081 |
strSQL.Append(" From Constructionbaseinfo As A2"); |
4082 |
strSQL.Append(" Inner Join constructionbaseinfodetail As B2"); |
4083 |
strSQL.Append(" On B2.ConstructionCode = A2.ConstructionCode"); |
4084 |
strSQL.AppendFormat(" And B2.DetailNo = {0}", (int)ConstructionBaseInfoDetail.DataNoDef.ConstrDepartmentName); |
4085 |
strSQL.Append(" Left Join departmentmaster As C2"); |
4086 |
strSQL.Append(" On C2.DepartmentCode = A2.ConstrDepCode"); |
4087 |
|
4088 |
if (CommonMotions.BasePeriodYear()) |
4089 |
strSQL.AppendFormat(" Where A2.ConstructionPeriod = {0}", nTargetCount); |
4090 |
else |
4091 |
strSQL.AppendFormat(" Where A2.ConstructionYear = {0}", nTargetCount); |
4092 |
|
4093 |
strSQL.Append(" And A2.ConstrDepCode != 0"); |
4094 |
|
4095 |
strSQL.Append(" Union Select"); |
4096 |
strSQL.Append(" A3.ConstrSubDepCode As DEPARTMENTCODE"); |
4097 |
strSQL.Append(", A3.ConstrSubPersonCode As PERSONCODE"); |
4098 |
strSQL.Append(", B3.DetailString As DEPARTMENTSTRING"); |
4099 |
strSQL.Append(", ifnull(C3.DisplayOrder, 10) As DISPLAYORDER"); |
4100 |
strSQL.Append(" From Constructionbaseinfo As A3"); |
4101 |
strSQL.Append(" Inner Join constructionbaseinfodetail As B3"); |
4102 |
strSQL.Append(" On B3.ConstructionCode = A3.ConstructionCode"); |
4103 |
strSQL.AppendFormat(" And B3.DetailNo = {0}", (int)ConstructionBaseInfoDetail.DataNoDef.ConstrSubDepartmentName); |
4104 |
strSQL.Append(" Left Join departmentmaster As C3"); |
4105 |
strSQL.Append(" On C3.DepartmentCode = A3.ConstrSubDepCode"); |
4106 |
|
4107 |
if (CommonMotions.BasePeriodYear()) |
4108 |
strSQL.AppendFormat(" Where A3.ConstructionPeriod = {0}", nTargetCount); |
4109 |
else |
4110 |
strSQL.AppendFormat(" Where A3.ConstructionYear = {0}", nTargetCount); |
4111 |
|
4112 |
strSQL.Append(" And A3.ConstrSubDepCode != 0"); |
4113 |
|
4114 |
strSQL.Append(" Union Select"); |
4115 |
strSQL.Append(" A4.ConstrInstrDepCode As DEPARTMENTCODE"); |
4116 |
strSQL.Append(", A4.ConstructionInstructor As PERSONCODE"); |
4117 |
strSQL.Append(", B4.DetailString As DEPARTMENTSTRING"); |
4118 |
strSQL.Append(", ifnull(C4.DisplayOrder, 10) As DISPLAYORDER"); |
4119 |
strSQL.Append(" From Constructionbaseinfo As A4"); |
4120 |
strSQL.Append(" Inner Join constructionbaseinfodetail As B4"); |
4121 |
strSQL.Append(" On B4.ConstructionCode = A4.ConstructionCode"); |
4122 |
strSQL.AppendFormat(" And B4.DetailNo = {0}", (int)ConstructionBaseInfoDetail.DataNoDef.InstrDepartmentName); |
4123 |
strSQL.Append(" Left Join departmentmaster As C4"); |
4124 |
strSQL.Append(" On C4.DepartmentCode = A4.ConstrInstrDepCode"); |
4125 |
|
4126 |
if (CommonMotions.BasePeriodYear()) |
4127 |
strSQL.AppendFormat(" Where A4.ConstructionPeriod = {0}", nTargetCount); |
4128 |
else |
4129 |
strSQL.AppendFormat(" Where A4.ConstructionYear = {0}", nTargetCount); |
4130 |
|
4131 |
strSQL.Append(" And A4.ConstrInstrDepCode != 0"); |
4132 |
|
4133 |
strSQL.Append(" Union Select"); |
4134 |
strSQL.Append(" A5.SalesSubDepCode As DEPARTMENTCODE"); |
4135 |
strSQL.Append(", A5.SalesSubPersonCode As PERSONCODE"); |
4136 |
strSQL.Append(", B5.DetailString As DEPARTMENTSTRING"); |
4137 |
strSQL.Append(", ifnull(C5.DisplayOrder, 10) As DISPLAYORDER"); |
4138 |
strSQL.Append(" From Constructionbaseinfo As A5"); |
4139 |
strSQL.Append(" Inner Join constructionbaseinfodetail As B5"); |
4140 |
strSQL.Append(" On B5.ConstructionCode = A5.ConstructionCode"); |
4141 |
strSQL.AppendFormat(" And B5.DetailNo = {0}", (int)ConstructionBaseInfoDetail.DataNoDef.SalesSubDepartmentName); |
4142 |
strSQL.Append(" Left Join departmentmaster As C5"); |
4143 |
strSQL.Append(" On C5.DepartmentCode = A5.SalesSubDepCode"); |
4144 |
|
4145 |
if (CommonMotions.BasePeriodYear()) |
4146 |
strSQL.AppendFormat(" Where A5.ConstructionPeriod = {0}", nTargetCount); |
4147 |
else |
4148 |
strSQL.AppendFormat(" Where A5.ConstructionYear = {0}", nTargetCount); |
4149 |
|
4150 |
strSQL.Append(" And A5.ConstrInstrDepCode != 0"); |
4151 |
|
4152 |
strSQL.Append(") As D On D.DEPARTMENTCODE = AA.DepartmentCode"); |
4153 |
} |
4154 |
} |
4155 |
|
4156 |
if (bNowSeason && bCompBase) |
4157 |
{ // 対象が今期の場合で工事情報の登録を確認する時 |
4158 |
strSQL.Append(" Inner Join CONSTRUCTIONBASEINFO C"); |
4159 |
strSQL.Append(" On C.ConstrDepCode = A.DepartmentCode"); |
4160 |
} |
4161 |
|
4162 |
// 台帳計算対象外は外す |
4163 |
//if (bLedgerDivNo) strSQL.Append(", PERSONINCHARGEMASTER B"); |
4164 |
|
4165 |
strSQL.Append(" WHERE"); |
4166 |
strSQL.AppendFormat(" AA.PersonCode = {0}", CommonMotions.LoginUserData.PersonCode); |
4167 |
|
4168 |
DateTime dtDefaultStart = CommonMotions.GetOpeningEndDate(nTargetCount, true); |
4169 |
DateTime dtDefaultEnd = CommonMotions.GetOpeningEndDate(nTargetCount, false); |
4170 |
|
4171 |
if (bNowSeason) |
4172 |
{ |
4173 |
// 対象が今期の場合 |
4174 |
//strSQL.AppendFormat(" And DATE(A.StartDate) <= DATE('{0}')", dtDefaultEnd.ToShortDateString()); |
4175 |
// 開始日が今日より小さい |
4176 |
strSQL.AppendFormat(" And DATE(A.StartDate) <= DATE('{0}')", DateTime.Today.ToShortDateString()); |
4177 |
|
4178 |
// システム管理者以外は部署参照マスタよりデータ取得 |
4179 |
if (CommonMotions.LoginUserData.PersonCode != CommonDefine.AdminCode) |
4180 |
{ |
4181 |
// 参照部署マスタより取得する |
4182 |
strSQL.Append(" And A.DEPARTMENTCODE"); |
4183 |
strSQL.Append(" IN (SELECT A1.DEPARTMENTCODE FROM PERSONDEPARTMENTMASTER A1"); |
4184 |
strSQL.AppendFormat(" WHERE A1.PERSONCODE = {0})", CommonMotions.LoginUserData.PersonCode); |
4185 |
} |
4186 |
} |
4187 |
else |
4188 |
{ |
4189 |
strSQL.AppendFormat(" AND DATE('{0}') <= DATE(AB.CompDate)", dtDefaultEnd.ToShortDateString()); |
4190 |
|
4191 |
//strSQL.AppendFormat(" AND ((DATE(AB.STARTDATE) <= DATE('{0}'))", dtDefaultEnd.ToShortDateString()); |
4192 |
//strSQL.AppendFormat(" AND(DATE('{0}') <= DATE(AB.CompDate)", dtDefaultStart.ToShortDateString()); |
4193 |
//strSQL.AppendFormat(" OR DATE('{0}') = DATE(AB.CompDate)))", DateTime.MinValue.ToShortDateString()); |
4194 |
} |
4195 |
|
4196 |
if (bNowSeason) |
4197 |
strSQL.Append(" And ("); |
4198 |
else |
4199 |
strSQL.Append(" And"); |
4200 |
|
4201 |
strSQL.Append(" (0 < (SELECT COUNT(*) FROM constructionbaseinfo AS BX"); |
4202 |
|
4203 |
if (CommonMotions.BasePeriodYear()) |
4204 |
strSQL.AppendFormat(" Where BX.ConstructionPeriod = {0}", nTargetCount); |
4205 |
else |
4206 |
strSQL.AppendFormat(" Where BX.ConstructionYear = {0}", nTargetCount); |
4207 |
strSQL.Append(" AND (BX.SalesDepCode = AA.DepartmentCode"); |
4208 |
strSQL.Append(" Or BX.ConstrDepCode = AA.DepartmentCode"); |
4209 |
strSQL.Append(" Or BX.ConstrSubDepCode = AA.DepartmentCode"); |
4210 |
strSQL.Append(" Or BX.ConstrInstrDepCode = AA.DepartmentCode)))"); |
4211 |
|
4212 |
if (bNowSeason) |
4213 |
{ |
4214 |
strSQL.Append(" Or (0 < (SELECT COUNT(*) FROM PERSONINCHARGEMASTER AS B"); |
4215 |
strSQL.Append(" WHERE B.DepartmentCode = AA.DepartmentCode"); |
4216 |
// 台帳計算対象のみ |
4217 |
if (!bLedgerDivNo) strSQL.AppendFormat(" And B.LedgerFlg = {0}", (int)PersonInChargeMaster.LedgerDivNoDef.CalcTarget); |
4218 |
// 今期は削除されていないもののみ |
4219 |
strSQL.AppendFormat(" And B.DeleteFlg = {0})))", (int)CommonDefine.DataDeleteDef.Exists); |
4220 |
} |
4221 |
|
4222 |
strSQL.Append(" GROUP BY A.DEPARTMENTCODE, A.DEPARTMENTSTRING, A.DISPLAYORDER"); |
4223 |
strSQL.Append(" ORDER BY A.DISPLAYORDER ASC"); |
4224 |
} |
4225 |
catch (Exception ex) |
4226 |
{ |
4227 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
4228 |
} |
4229 |
} |
4230 |
#endregion |
4231 |
|
4232 |
#region 担当者コンボボックスデータ取得SQL作成 |
4233 |
/// <summary> |
4234 |
/// 担当者コンボボックスデータ取得SQL作成 |
4235 |
/// </summary> |
4236 |
/// <param name="strSQL"></param> |
4237 |
/// <param name="nTargetYear"></param> |
4238 |
public static void CreateManCombBoxSQL(ref StringBuilder strSQL |
4239 |
, int nTargetYear |
4240 |
, int nDepCode = 0 |
4241 |
, int nPersonCode = 0 |
4242 |
, bool bNewDataFlg = false |
4243 |
, bool bLedgerDivNo = false |
4244 |
, bool bConstrBase = true) |
4245 |
{ |
4246 |
try |
4247 |
{ |
4248 |
DateTime dtDefaultStart = CommonMotions.GetOpeningEndDate(nTargetYear, true); |
4249 |
DateTime dtDefaultEnd = CommonMotions.GetOpeningEndDate(nTargetYear, false); |
4250 |
|
4251 |
strSQL.AppendFormat("Select {0} From", IOMPersonInCharge.CreateFieldNameList("A.")); |
4252 |
strSQL.Append(" personinchargemaster As A"); |
4253 |
strSQL.Append(" Left Join chgchargedep As B"); |
4254 |
strSQL.Append(" On B.PersonCode = A.PersonCode"); |
4255 |
|
4256 |
strSQL.Append(" WHERE"); |
4257 |
strSQL.AppendFormat(" ((DATE(A.STARTDATE) <= DATE('{0}'))", dtDefaultEnd.ToShortDateString()); |
4258 |
strSQL.AppendFormat(" AND (DATE('{0}') <= DATE(A.ENDDATE)", dtDefaultStart.ToShortDateString()); |
4259 |
strSQL.AppendFormat(" OR DATE('{0}') = DATE(A.ENDDATE)))", DateTime.MinValue.ToShortDateString()); |
4260 |
|
4261 |
strSQL.AppendFormat(" AND ((DATE(B.STARTDATE) <= DATE('{0}'))", dtDefaultEnd.ToShortDateString()); |
4262 |
strSQL.AppendFormat(" AND (DATE('{0}') <= DATE(B.CompDate)", dtDefaultStart.ToShortDateString()); |
4263 |
strSQL.AppendFormat(" OR DATE('{0}') = DATE(B.CompDate)))", DateTime.MinValue.ToShortDateString()); |
4264 |
|
4265 |
if ((nDepCode > 0 && nPersonCode > 0) && nPersonCode != CommonDefine.AdminCode) |
4266 |
{ |
4267 |
if (CheckNowSeason(nTargetYear)) |
4268 |
{ |
4269 |
strSQL.Append(" And (A.DepartmentCode in (Select C.DepartmentCode From persondepartmentmaster As C"); |
4270 |
strSQL.AppendFormat(" Where C.PersonCode = {0})", nPersonCode); |
4271 |
strSQL.AppendFormat(" Or A.DepartmentCode = {0})", nDepCode); |
4272 |
} |
4273 |
else |
4274 |
{ |
4275 |
strSQL.Append(" And A.DepartmentCode in (Select C.DepartmentCode From persondepartmentmaster As C"); |
4276 |
strSQL.AppendFormat(" Where C.PersonCode = {0})", nPersonCode); |
4277 |
} |
4278 |
} |
4279 |
|
4280 |
// 新規のデータは削除者を表示しない |
4281 |
if (bNewDataFlg) |
4282 |
{ |
4283 |
strSQL.AppendFormat(" And A.DELETEFLG = {0}", (int)CommonDefine.DataDeleteDef.Exists); |
4284 |
} |
4285 |
// 開始日が今日より小さい |
4286 |
strSQL.AppendFormat(" And DATE(A.StartDate) <= DATE('{0}')", DateTime.Today.ToShortDateString()); |
4287 |
|
4288 |
if (nDepCode > 0) strSQL.AppendFormat(" AND (B.DEPARTMENTCODE = {0})", nDepCode); |
4289 |
|
4290 |
// 台帳計算対象外 |
4291 |
if (bLedgerDivNo) |
4292 |
{ |
4293 |
strSQL.AppendFormat(" And A.LedgerFlg = {0}", (int)PersonInChargeMaster.LedgerDivNoDef.CalcTarget); |
4294 |
} |
4295 |
|
4296 |
// 今期のデータかどうかを判定する |
4297 |
string FieldName = string.Empty; |
4298 |
if (CommonMotions.BasePeriodYear()) |
4299 |
FieldName = "ConstructionPeriod"; |
4300 |
else |
4301 |
FieldName = "ConstructionYear"; |
4302 |
if (bConstrBase) |
4303 |
{ |
4304 |
if (CheckNowSeason(nTargetYear)) |
4305 |
{ |
4306 |
} |
4307 |
else |
4308 |
{ |
4309 |
strSQL.Append(" AND B.DepartmentCode IN(SELECT InDep.DEPARTMENTCODE FROM ("); |
4310 |
strSQL.Append(" Select A1.SalesDepCode As DEPARTMENTCODE From Constructionbaseinfo As A1"); |
4311 |
strSQL.AppendFormat(" Where A1.{0} = {1}", FieldName, nTargetYear); |
4312 |
strSQL.Append(" Union Select A2.ConstrDepCode As DEPARTMENTCODE From Constructionbaseinfo As A2"); |
4313 |
strSQL.AppendFormat(" Where A2.{0} = {1}", FieldName, nTargetYear); |
4314 |
strSQL.Append(" Union Select A3.ConstrSubDepCode As DEPARTMENTCODE From Constructionbaseinfo As A3"); |
4315 |
strSQL.AppendFormat(" Where A3.{0} = {1}", FieldName, nTargetYear); |
4316 |
strSQL.Append(" Union Select A4.ConstrInstrDepCode As DEPARTMENTCODE From Constructionbaseinfo As A4"); |
4317 |
strSQL.AppendFormat(" Where A4.{0} = {1}", FieldName, nTargetYear); |
4318 |
strSQL.Append(" ) As InDep"); |
4319 |
strSQL.Append(" GROUP BY InDep.DEPARTMENTCODE) "); |
4320 |
} |
4321 |
} |
4322 |
strSQL.Append(" Group By A.PersonCode"); |
4323 |
strSQL.Append(" Order By A.DeleteFlg ASC, A.EmployeeClassFlg ASC, A.DisplayOrder ASC"); |
4324 |
} |
4325 |
catch (Exception ex) |
4326 |
{ |
4327 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
4328 |
} |
4329 |
} |
4330 |
#endregion |
4331 |
|
4332 |
#region 担当者より指定年度の所属情報を取得するSQL作成 |
4333 |
/// <summary> |
4334 |
/// 担当者より指定年度の所属情報を取得するSQL作成 |
4335 |
/// </summary> |
4336 |
public static void CreateMan2DepInfoSQL(ref StringBuilder strSQL, int nTargetYear, int nPersonCode, DateTime dtPettion) |
4337 |
{ |
4338 |
try |
4339 |
{ |
4340 |
DateTime dtDefaultStart = CommonMotions.GetOpeningEndDate(nTargetYear, true); |
4341 |
DateTime dtDefaultEnd = DateTime.Today.Date; |
4342 |
if (!CheckNowSeason(nTargetYear)) |
4343 |
dtDefaultEnd = CommonMotions.GetOpeningEndDate(nTargetYear, false); |
4344 |
|
4345 |
strSQL.Append("Select"); |
4346 |
strSQL.Append(" A.PersonCode"); |
4347 |
strSQL.Append(", A.PersonName"); |
4348 |
strSQL.Append(", B.DepartmentCode"); |
4349 |
strSQL.Append(", B.DepartmentName"); |
4350 |
strSQL.Append(" From personinchargemaster As A"); |
4351 |
strSQL.Append(" Left Join chgchargedep As B"); |
4352 |
strSQL.Append(" On B.PersonCode = A.PersonCode"); |
4353 |
|
4354 |
strSQL.Append(" WHERE"); |
4355 |
strSQL.AppendFormat(" ((DATE(A.STARTDATE) <= DATE('{0}'))", dtDefaultEnd.ToShortDateString()); |
4356 |
strSQL.AppendFormat(" AND (DATE('{0}') <= DATE(A.ENDDATE)", dtDefaultStart.ToShortDateString()); |
4357 |
strSQL.AppendFormat(" OR DATE('{0}') = DATE(A.ENDDATE)))", DateTime.MinValue.ToShortDateString()); |
4358 |
|
4359 |
if (dtPettion.Date == DateTime.MinValue.Date) dtPettion = dtDefaultEnd; |
4360 |
strSQL.AppendFormat(" AND ((DATE(B.STARTDATE) <= DATE('{0}'))", dtPettion.ToShortDateString()); |
4361 |
strSQL.AppendFormat(" AND(DATE('{0}') <= DATE(B.CompDate)", dtPettion.ToShortDateString()); |
4362 |
strSQL.AppendFormat(" OR DATE('{0}') = DATE(B.CompDate)))", DateTime.MaxValue.ToShortDateString()); |
4363 |
|
4364 |
strSQL.AppendFormat(" AND A.PersonCode = {0}", nPersonCode); |
4365 |
strSQL.Append(" Order By B.CompDate desc"); |
4366 |
} |
4367 |
catch (Exception ex) |
4368 |
{ |
4369 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
4370 |
} |
4371 |
} |
4372 |
#endregion |
4373 |
|
4374 |
#region 担当者コードより指定年度の所属部署コードのみを取得するSQL作成 |
4375 |
/// <summary> |
4376 |
/// 担当者コードより指定年度の所属部署コードのみを取得するSQL作成 |
4377 |
/// </summary> |
4378 |
public static void CreateMan2DepSQL(ref StringBuilder strSQL, int nTargetYear, int nPersonCode) |
4379 |
{ |
4380 |
try |
4381 |
{ |
4382 |
DateTime dtDefaultStart = CommonMotions.GetOpeningEndDate(nTargetYear, true); |
4383 |
DateTime dtDefaultEnd = CommonMotions.GetOpeningEndDate(nTargetYear, false); |
4384 |
|
4385 |
strSQL.Append("Select B.DepartmentCode From personinchargemaster As A"); |
4386 |
strSQL.Append(" Inner Join chgchargedep As B"); |
4387 |
strSQL.Append(" On B.PersonCode = A.PersonCode"); |
4388 |
strSQL.AppendFormat(" Where A.PersonCode = {0}", nPersonCode); |
4389 |
strSQL.AppendFormat(" AND ((DATE(B.STARTDATE) <= DATE('{0}'))", dtDefaultEnd.ToShortDateString()); |
4390 |
strSQL.AppendFormat(" AND (DATE('{0}') <= DATE(B.CompDate)", dtDefaultStart.ToShortDateString()); |
4391 |
strSQL.AppendFormat(" OR DATE('{0}') = DATE(B.CompDate)))", DateTime.MinValue.ToShortDateString()); |
4392 |
} |
4393 |
catch (Exception ex) |
4394 |
{ |
4395 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
4396 |
} |
4397 |
} |
4398 |
#endregion |
4399 |
|
4400 |
#region 経費率データ読込み並び |
4401 |
/// <summary> |
4402 |
/// 経費率データ読込み並び |
4403 |
/// </summary> |
4404 |
public enum ExpensesArray |
4405 |
{ |
4406 |
/// <summary> |
4407 |
/// 0:経費名称 |
4408 |
/// </summary> |
4409 |
ExpensesName = 0, |
4410 |
/// <summary> |
4411 |
/// 1:経費率 |
4412 |
/// </summary> |
4413 |
ExpensesRaito, |
4414 |
/// <summary> |
4415 |
/// 2:経費名称コード |
4416 |
/// </summary> |
4417 |
NameCode, |
4418 |
/// <summary> |
4419 |
/// 3:部署コード |
4420 |
/// </summary> |
4421 |
DepCode, |
4422 |
/// <summary> |
4423 |
/// 4:削除フラグ(部署経費マスタ) |
4424 |
/// </summary> |
4425 |
DeleteFlg, |
4426 |
} |
4427 |
#endregion |
4428 |
|
4429 |
#region 経費率リスト取得処理 |
4430 |
/// <summary> |
4431 |
/// 経費率リストを取得する |
4432 |
/// </summary> |
4433 |
/// <returns></returns> |
4434 |
public static bool GetExpensesList(int Preiod, int DepartmentCode, ref ArrayList ExpensesList) |
4435 |
{ |
4436 |
IOMDepartmentExpenses expDB = new IOMDepartmentExpenses(); |
4437 |
try |
4438 |
{ |
4439 |
// 部署経費率マスタ取得 |
4440 |
StringBuilder strSQL = new StringBuilder(); |
4441 |
if (CheckNowSeason(Preiod)) |
4442 |
{ // 今期データ |
4443 |
strSQL.Append("SELECT"); |
4444 |
strSQL.Append(" A.NAMESTRING"); |
4445 |
strSQL.Append(", IFNULL(B.EXPENSESRAITO, 0)"); |
4446 |
strSQL.Append(", A.NAMECODE"); |
4447 |
strSQL.Append(", B.DEPARTMENTCODE"); |
4448 |
strSQL.Append(", A.DeleteFlg"); |
4449 |
strSQL.Append(" FROM DIVISIONMASTER AS A"); |
4450 |
|
4451 |
strSQL.Append(" LEFT JOIN (SELECT"); |
4452 |
strSQL.Append(" BB.NAMECODE"); |
4453 |
strSQL.Append(" , BB.DEPARTMENTCODE"); |
4454 |
strSQL.Append(" , BB.EXPENSESRAITO"); |
4455 |
strSQL.Append(" , BB.EXPENSESPERIOD"); |
4456 |
strSQL.Append(" , BB.DisplayOrder"); |
4457 |
strSQL.Append(" FROM DEPARTMENTEXPENSESMASTER AS BB) AS B"); |
4458 |
strSQL.Append(" ON A.NAMECODE = B.NAMECODE"); |
4459 |
strSQL.AppendFormat(" AND B.EXPENSESPERIOD = {0}", Preiod); |
4460 |
if(DepartmentCode > 0) strSQL.AppendFormat(" AND B.DEPARTMENTCODE = {0}", DepartmentCode); |
4461 |
|
4462 |
strSQL.Append(" LEFT JOIN departmentmaster AS C"); |
4463 |
strSQL.Append(" On C.DepartmentCode = B.DEPARTMENTCODE"); |
4464 |
|
4465 |
strSQL.Append(" WHERE"); |
4466 |
strSQL.AppendFormat(" A.DIVISIONCODE = {0}", (int)DivisionMaster.DivisionMasterCodeDef.ConstructionExpenses); |
4467 |
strSQL.AppendFormat(" AND A.DeleteFlg = {0}", (int)CommonDefine.DataDeleteDef.Exists); |
4468 |
strSQL.Append(" And B.EXPENSESRAITO > 0.00"); |
4469 |
|
4470 |
strSQL.Append(" ORDER BY A.DISPLAYORDER, C.DISPLAYORDER"); |
4471 |
} |
4472 |
else |
4473 |
{ // 以前のデータ |
4474 |
strSQL.Append("SELECT"); |
4475 |
strSQL.Append(" B.NAMESTRING"); |
4476 |
strSQL.Append(", B.EXPENSESRAITO"); |
4477 |
strSQL.Append(", B.NAMECODE"); |
4478 |
strSQL.Append(", B.DEPARTMENTCODE"); |
4479 |
strSQL.Append(", B.DeleteFlg"); |
4480 |
strSQL.Append(" FROM DEPARTMENTEXPENSESMASTER AS B"); |
4481 |
|
4482 |
strSQL.Append(" INNER JOIN departmentmaster AS C"); |
4483 |
strSQL.Append(" On C.DepartmentCode = B.DEPARTMENTCODE"); |
4484 |
|
4485 |
strSQL.Append(" INNER JOIN divisionmaster AS D"); |
4486 |
strSQL.AppendFormat(" ON D.DIVISIONCODE = {0}", (int)DivisionMaster.DivisionMasterCodeDef.ConstructionExpenses); |
4487 |
strSQL.Append(" And D.NameCode = B.NameCode"); |
4488 |
|
4489 |
strSQL.Append(" WHERE"); |
4490 |
strSQL.AppendFormat(" B.EXPENSESPERIOD = {0}", Preiod); |
4491 |
if (DepartmentCode > 0) strSQL.AppendFormat(" AND B.DEPARTMENTCODE = {0}", DepartmentCode); |
4492 |
strSQL.Append(" And B.EXPENSESRAITO > 0.00"); |
4493 |
|
4494 |
strSQL.Append(" ORDER BY D.DeleteFlg, C.DISPLAYORDER, B.DISPLAYORDER"); |
4495 |
} |
4496 |
|
4497 |
ExpensesList.Clear(); |
4498 |
if (!expDB.ExecuteReader(strSQL.ToString(), ref ExpensesList)) return false; |
4499 |
if (ExpensesList.Count == 0) return false; |
4500 |
|
4501 |
return true; |
4502 |
} |
4503 |
catch (Exception ex) |
4504 |
{ |
4505 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
4506 |
return false; |
4507 |
} |
4508 |
finally |
4509 |
{ |
4510 |
expDB.close(); expDB = null; |
4511 |
} |
4512 |
} |
4513 |
#endregion |
4514 |
|
4515 |
#region ベースコントロールコレクションよりボタン取得 |
4516 |
/// <summary> |
4517 |
/// ベースコントロールコレクションよりボタン取得 |
4518 |
/// </summary> |
4519 |
public static Button GetButtton2Collection(Control.ControlCollection BasePnl, string ButtonName) |
4520 |
{ |
4521 |
Button buttonRet = null; |
4522 |
try |
4523 |
{ |
4524 |
foreach (Control CurCtrl in BasePnl) |
4525 |
{ |
4526 |
// 申請ボタン取得 |
4527 |
if (CurCtrl.Name.Equals(ButtonName)) |
4528 |
{ |
4529 |
buttonRet = (Button)CurCtrl; |
4530 |
break; |
4531 |
} |
4532 |
} |
4533 |
return buttonRet; |
4534 |
} |
4535 |
catch (Exception ex) |
4536 |
{ |
4537 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
4538 |
return buttonRet; |
4539 |
} |
4540 |
} |
4541 |
#endregion |
4542 |
|
4543 |
#region 申請パネルより承認数ラベル取得 |
4544 |
/// <summary> |
4545 |
/// 申請パネルより承認数ラベル取得 |
4546 |
/// </summary> |
4547 |
public static Label GetLabel2Collection(Control.ControlCollection BasePnl, string LabelName) |
4548 |
{ |
4549 |
Label LabelRet = null; |
4550 |
try |
4551 |
{ |
4552 |
foreach (Control CurCtrl in BasePnl) |
4553 |
{ |
4554 |
// 申請ボタン取得 |
4555 |
if (CurCtrl.Name.Equals(LabelName)) |
4556 |
{ |
4557 |
LabelRet = (Label)CurCtrl; |
4558 |
break; |
4559 |
} |
4560 |
} |
4561 |
return LabelRet; |
4562 |
} |
4563 |
catch (Exception ex) |
4564 |
{ |
4565 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
4566 |
return LabelRet; |
4567 |
} |
4568 |
} |
4569 |
#endregion |
4570 |
|
4571 |
#region 現在適応消費税を取得する |
4572 |
/// <summary> |
4573 |
/// 現在適応消費税を取得する |
4574 |
/// </summary> |
4575 |
/// <returns></returns> |
4576 |
public static double AdaptationConsumptionTax() |
4577 |
{ |
4578 |
double dRet = CommonMotions.SystemMasterData.ConsumptionTax; |
4579 |
try |
4580 |
{ |
4581 |
// 実装途中 |
4582 |
|
4583 |
return dRet; |
4584 |
} |
4585 |
catch (Exception ex) |
4586 |
{ |
4587 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
4588 |
return dRet; |
4589 |
} |
4590 |
} |
4591 |
/// <summary> |
4592 |
/// 数値のYMDより期間に対応する消費税を取得する |
4593 |
/// </summary> |
4594 |
/// <returns></returns> |
4595 |
public static double AdaptationConsumptionTax(int nYMD) |
4596 |
{ |
4597 |
double dRet = CommonMotions.SystemMasterData.ConsumptionTax; |
4598 |
try |
4599 |
{ |
4600 |
if (nYMD < 1) return dRet; |
4601 |
|
4602 |
int nYear = cnvTruncate(nYMD / 10000); |
4603 |
int nMonth = cnvTruncate((nYMD - (nYear * 10000)) / 100); |
4604 |
int nDay = nYMD - ((nYear * 10000) + (nMonth * 100)); |
4605 |
DateTime dateTime = new DateTime(nYear, nMonth, nDay); |
4606 |
|
4607 |
ConsumptionTax taxes = m_ConsumptionTax.Where(x => (x.StartDate.Date <= dateTime.Date) |
4608 |
&& (dateTime.Date <= x.ComplateDate.Date)) |
4609 |
.First(); |
4610 |
|
4611 |
if (taxes != null) dRet = (double)taxes.TaxRate; |
4612 |
|
4613 |
return dRet; |
4614 |
} |
4615 |
catch (Exception ex) |
4616 |
{ |
4617 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
4618 |
return dRet; |
4619 |
} |
4620 |
} |
4621 |
/// <summary> |
4622 |
/// 年月日より期間に対応する消費税を取得する |
4623 |
/// </summary> |
4624 |
/// <returns></returns> |
4625 |
public static double AdaptationConsumptionTax(DateTime dtYMD) |
4626 |
{ |
4627 |
double dRet = CommonMotions.SystemMasterData.ConsumptionTax; |
4628 |
try |
4629 |
{ |
4630 |
if (dtYMD == DateTime.MaxValue || dtYMD == DateTime.MinValue) return dRet; |
4631 |
|
4632 |
ConsumptionTax taxes = m_ConsumptionTax.Where(x => (x.StartDate.Date <= dtYMD.Date) |
4633 |
&& (dtYMD.Date <= x.ComplateDate.Date)) |
4634 |
.First(); |
4635 |
|
4636 |
if (taxes != null) dRet = (double)taxes.TaxRate; |
4637 |
|
4638 |
return dRet; |
4639 |
} |
4640 |
catch (Exception ex) |
4641 |
{ |
4642 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
4643 |
return dRet; |
4644 |
} |
4645 |
} |
4646 |
#endregion |
4647 |
|
4648 |
#region 担当者のデータにログイン者がアクセスできるかのチェック |
4649 |
/// <summary> |
4650 |
/// 担当者のデータにログイン者がアクセスできるかのチェック |
4651 |
/// </summary> |
4652 |
public static bool DataPermission(int ManNo) |
4653 |
{ |
4654 |
IOMPersonInCharge ManDB = new IOMPersonInCharge(); |
4655 |
try |
4656 |
{ |
4657 |
// 自分自身はOK |
4658 |
if (CommonMotions.LoginUserData.PersonCode == ManNo) return true; |
4659 |
|
4660 |
// 一般者権限では自分以外のデータにアクセスできない |
4661 |
int Rank = CommonDefine.SecurityRankList[(int)CommonDefine.SecurityRankPos.NormalAuthority].Key; |
4662 |
if (Rank == CommonMotions.LoginUserSecurity.SecRank) return false; |
4663 |
|
4664 |
// 対象者の担当者データを取得する |
4665 |
PersonInChargeMaster ManRec = new PersonInChargeMaster(); |
4666 |
if (!ManDB.SelectAction(ManDB.CreatePrimarykeyString(ManNo), ref ManRec)) return false; |
4667 |
|
4668 |
// 参照部署のチェック |
4669 |
bool bRet = false; |
4670 |
foreach(PersonDepartmentMaster CurRec in m_LoginUserRefDepartment) |
4671 |
{ |
4672 |
if(CurRec.DepartmentCode == ManRec.DepartmentCode) |
4673 |
{ |
4674 |
bRet = true; |
4675 |
break; |
4676 |
} |
4677 |
} |
4678 |
|
4679 |
return bRet; |
4680 |
} |
4681 |
catch (Exception ex) |
4682 |
{ |
4683 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
4684 |
return false; |
4685 |
} |
4686 |
finally |
4687 |
{ |
4688 |
ManDB.close(); ManDB = null; |
4689 |
} |
4690 |
} |
4691 |
#endregion |
4692 |
|
4693 |
#region 営業日だけのn日前の日付を取る |
4694 |
/// <summary> |
4695 |
/// 営業日だけのn日前の日付を取る |
4696 |
/// </summary> |
4697 |
public static DateTime GetPrevBusinessDate( DateTime WorktDate, int nCount, int PersonCode = 0) |
4698 |
{ |
4699 |
IOMHolidayCalender CalDB = new IOMHolidayCalender(); |
4700 |
IOAllFreeSQL FreeDB = new IOAllFreeSQL(); |
4701 |
try |
4702 |
{ |
4703 |
// 当月以前は当月1日をセットして抜ける |
4704 |
int nCheckDay = (WorktDate.Year * 100) + WorktDate.Month; |
4705 |
int nToday = (DateTime.Today.Year * 100) + DateTime.Today.Month; |
4706 |
if (nCheckDay < nToday) |
4707 |
{ |
4708 |
DateTime dtTarget = new DateTime(WorktDate.Year, WorktDate.Month, 1); |
4709 |
return dtTarget; |
4710 |
} |
4711 |
|
4712 |
StringBuilder strSQL = new StringBuilder(); |
4713 |
|
4714 |
strSQL.Append("SELECT t1.d"); |
4715 |
strSQL.Append(" , DATE_FORMAT(C.HOLIDAY, '%Y/%m/%d') HOLIDAY"); |
4716 |
strSQL.Append(" , WEEKDAY(t1.d)"); |
4717 |
strSQL.Append(" FROM"); |
4718 |
strSQL.Append(" (SELECT A1.years, A2.month, A3.days"); |
4719 |
strSQL.Append(" , CAST(CONCAT(A1.years, '/', A2.month, '/', A3.days) as DATE) as d"); |
4720 |
strSQL.Append(" FROM yearmaster as A1"); |
4721 |
strSQL.Append(" , monthmaster as A2"); |
4722 |
strSQL.Append(" , daymaster as A3"); |
4723 |
strSQL.AppendFormat(" WHERE A1.years = {0}", WorktDate.Year); |
4724 |
strSQL.AppendFormat(" AND A2.month = {0}", WorktDate.Month); |
4725 |
strSQL.Append(" AND CAST(CONCAT(A1.years, '/', A2.month, '/', A3.days) as DATE) IS NOT NULL) as t1"); |
4726 |
strSQL.Append(" LEFT JOIN HOLIDAYCALENDERMASTER C ON C.HOLIDAY = t1.d"); |
4727 |
strSQL.Append(" Where"); |
4728 |
strSQL.AppendFormat(" DATE(t1.d) <= DATE('{0}')", DateTime.Today.ToShortDateString()); |
4729 |
strSQL.Append(" ORDER BY t1.d Desc"); |
4730 |
|
4731 |
ArrayList arList = new ArrayList(); |
4732 |
CalDB.ExecuteReader(strSQL.ToString(), ref arList); |
4733 |
|
4734 |
// 担当者コードがある場合は勤務シフトの月曜日を0として読み込む |
4735 |
ArrayList WeekList = new ArrayList(); |
4736 |
object[] objWeek = null; |
4737 |
DateTime dtEnd = DateTime.Today; |
4738 |
if (PersonCode > 0) |
4739 |
{ |
4740 |
strSQL.Clear(); |
4741 |
strSQL.Append("Select"); |
4742 |
strSQL.Append(" B.MonValue"); |
4743 |
strSQL.Append(", B.TueValue"); |
4744 |
strSQL.Append(", B.WedValue"); |
4745 |
strSQL.Append(", B.ThuValue"); |
4746 |
strSQL.Append(", B.FriValue"); |
4747 |
strSQL.Append(", B.SatValue"); |
4748 |
strSQL.Append(", B.SunValue"); |
4749 |
strSQL.Append(", A.PersonCode"); |
4750 |
strSQL.Append(", A.PersonName"); |
4751 |
strSQL.Append(", A.EndDate"); |
4752 |
strSQL.Append(" From personinchargemaster As A"); |
4753 |
strSQL.Append(" Inner Join workingtime As B"); |
4754 |
strSQL.Append(" On B.WorkingCode = A.WorkingCode"); |
4755 |
strSQL.Append(" Where"); |
4756 |
strSQL.AppendFormat(" A.Personcode = {0}", PersonCode); |
4757 |
|
4758 |
FreeDB.ExecuteReader(strSQL.ToString(), ref WeekList); |
4759 |
|
4760 |
objWeek = (object[])WeekList[0]; |
4761 |
// 退職日が無い場合は日付をMAXにする |
4762 |
dtEnd = CommonMotions.cnvDate(objWeek[9]).Date == DateTime.MinValue.Date |
4763 |
? DateTime.MaxValue.Date |
4764 |
: CommonMotions.cnvDate(objWeek[9]).Date; |
4765 |
} |
4766 |
|
4767 |
DateTime dtRet = DateTime.MinValue; |
4768 |
int nPrevCount = 0; |
4769 |
foreach(object[] objCalender in arList) |
4770 |
{ |
4771 |
// まず今日を探す |
4772 |
DateTime dtwork = CommonMotions.cnvDate(objCalender[0]); |
4773 |
if (DateTime.Today.Date < dtwork.Date) continue; |
4774 |
|
4775 |
// 休日は除外する |
4776 |
DateTime dtholiday = CommonMotions.cnvDate(objCalender[1]); |
4777 |
if (DateTime.MinValue.Date != dtholiday.Date) continue; |
4778 |
|
4779 |
// 担当者コードがある場合は勤務シフトの比較を行う |
4780 |
if (PersonCode > 0) |
4781 |
{ |
4782 |
if(PersonCode== 20200401) { Debug.WriteLine(""); } |
4783 |
int nWeekFlg = CommonMotions.cnvInt(objCalender[2]); |
4784 |
// 休みの曜日は除外する |
4785 |
if (CommonMotions.cnvInt(objWeek[nWeekFlg]) == 1) continue; |
4786 |
|
4787 |
//退職日以降は除外する |
4788 |
if (dtEnd < dtwork.Date) continue; |
4789 |
} |
4790 |
|
4791 |
nPrevCount++; |
4792 |
if (nCount <= nPrevCount) |
4793 |
{ |
4794 |
dtRet = dtwork; |
4795 |
break; |
4796 |
} |
4797 |
} |
4798 |
|
4799 |
return dtRet; |
4800 |
} |
4801 |
catch (Exception ex) |
4802 |
{ |
4803 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
4804 |
return DateTime.Today; |
4805 |
} |
4806 |
finally |
4807 |
{ |
4808 |
CalDB.close(); CalDB = null; |
4809 |
FreeDB.close(); FreeDB = null; |
4810 |
} |
4811 |
} |
4812 |
#endregion |
4813 |
|
4814 |
#region 文字列の指定毎位置に改行コードを入れる |
4815 |
/// <summary> |
4816 |
/// 文字列の指定毎位置に改行コードを入れる |
4817 |
/// </summary> |
4818 |
/// <param name="InpString"></param> |
4819 |
/// <param name="CutLength"></param> |
4820 |
/// <returns></returns> |
4821 |
public static string StringBuiltInReturn(string InpString, int CutLength) |
4822 |
{ |
4823 |
try |
4824 |
{ |
4825 |
List<string> textList = new List<string>(); |
4826 |
for (int i = 0; i < InpString.Length; i += CutLength) |
4827 |
{ |
4828 |
if ((i + CutLength) < InpString.Length) |
4829 |
textList.Add(InpString.Substring(i, CutLength)); |
4830 |
else |
4831 |
textList.Add(InpString.Substring(i)); |
4832 |
} |
4833 |
|
4834 |
return string.Join("\r\n", textList.ToArray()); |
4835 |
} |
4836 |
catch (Exception ex) |
4837 |
{ |
4838 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
4839 |
return string.Empty; |
4840 |
} |
4841 |
} |
4842 |
#endregion |
4843 |
|
4844 |
#region 日付から曜日を取得してマスタの休みと比較する |
4845 |
/// <summary> |
4846 |
/// 日付から曜日を取得してマスタの休みと比較する |
4847 |
/// </summary> |
4848 |
/// <returns></returns> |
4849 |
public static bool MasterHolidayCheck(DateTime DispDate, WorkingTime WDataRec) |
4850 |
{ |
4851 |
try |
4852 |
{ |
4853 |
// 曜日取得 |
4854 |
DayOfWeek dowWork = DispDate.DayOfWeek; |
4855 |
|
4856 |
int nBreakDayFlg = -1; |
4857 |
switch ((int)dowWork) |
4858 |
{ |
4859 |
case (int)DayOfWeek.Sunday: |
4860 |
nBreakDayFlg = WDataRec.SunValue; |
4861 |
break; |
4862 |
case (int)DayOfWeek.Monday: |
4863 |
nBreakDayFlg = WDataRec.MonValue; |
4864 |
break; |
4865 |
case (int)DayOfWeek.Tuesday: |
4866 |
nBreakDayFlg = WDataRec.TueValue; |
4867 |
break; |
4868 |
case (int)DayOfWeek.Wednesday: |
4869 |
nBreakDayFlg = WDataRec.WedValue; |
4870 |
break; |
4871 |
case (int)DayOfWeek.Thursday: |
4872 |
nBreakDayFlg = WDataRec.ThuValue; |
4873 |
break; |
4874 |
case (int)DayOfWeek.Friday: |
4875 |
nBreakDayFlg = WDataRec.FriValue; |
4876 |
break; |
4877 |
case (int)DayOfWeek.Saturday: |
4878 |
nBreakDayFlg = WDataRec.SatValue; |
4879 |
break; |
4880 |
} |
4881 |
// 休みかを判定する |
4882 |
if (nBreakDayFlg == (int)WorkingTime.DayOfTheWeekDef.Normal) return false; |
4883 |
|
4884 |
return true; |
4885 |
} |
4886 |
catch (Exception ex) |
4887 |
{ |
4888 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
4889 |
return false; |
4890 |
} |
4891 |
} |
4892 |
#endregion |
4893 |
|
4894 |
#endregion |
4895 |
|
4896 |
#region ---------- Excel向け操作メソッド |
4897 |
#region オブジェクト開放 |
4898 |
/// <summary> |
4899 |
/// Com解放 |
4900 |
/// </summary> |
4901 |
/// <param name="o"></param> |
4902 |
public static void ReleaseCom(ref Object objCom) |
4903 |
{ |
4904 |
try |
4905 |
{ |
4906 |
int i = 1; |
4907 |
if (objCom != null && System.Runtime.InteropServices.Marshal.IsComObject(objCom)) |
4908 |
{ |
4909 |
//参照カウントが0より大きい間・・・ |
4910 |
do |
4911 |
{ |
4912 |
//ランタイム呼び出し可能ラッパーの参照カウントをデクリメント |
4913 |
i = System.Runtime.InteropServices.Marshal.ReleaseComObject(objCom); |
4914 |
} while (i > 0); |
4915 |
} |
4916 |
} |
4917 |
catch (Exception ex) |
4918 |
{ |
4919 |
logger.ErrorFormat("システムエラー:{0}:{1}:{2}", GetMethodName(), GetMethodName(2), ex.Message); |
4920 |
} |
4921 |
finally |
4922 |
{ |
4923 |
objCom = null; |
4924 |
} |
4925 |
} |
4926 |
|
4927 |
#endregion |
4928 |
#endregion |
4929 |
|
4930 |
#region デバッグ用メソッド |
4931 |
/// <summary> |
4932 |
/// デバッグ用メソッド |
4933 |
/// </summary> |
4934 |
/// <param name="DebugPrint">表示文字列</param> |
4935 |
public static void DebugWriteLine_TimeNow(string DebugPrint) |
4936 |
{ |
4937 |
string wrkPrint = DateTime.Now.ToLongTimeString() + |
4938 |
((double)DateTime.Now.Millisecond / 1000.0000).ToString("#.0000"); |
4939 |
|
4940 |
Debug.WriteLine(DebugPrint + ":" + wrkPrint); |
4941 |
} |
4942 |
|
4943 |
public static void DebugWriteLine_DateTimeNow(string DebugPrint) |
4944 |
{ |
4945 |
string wrkPrint = DateTime.Now.ToLongDateString() + " " + |
4946 |
DateTime.Now.ToLongTimeString() + "." + |
4947 |
DateTime.Now.Millisecond.ToString(); |
4948 |
|
4949 |
Debug.WriteLine(DebugPrint + ":" + wrkPrint); |
4950 |
} |
4951 |
#endregion |
4952 |
} |
4953 |
} |