リビジョン 162
システムマスタ、ホームページURL対応
見積書表示、ホームページURL対応
注文書、法定福利費対応
給与計算、月内日数対応
日時更新処理、サーバー起動対応(サーバー側処理ソース追加)
システムマスタ変更SQL修正版に差し替え
branches/ddl/20170525_SQL.txt | ||
---|---|---|
16 | 16 |
Address3 varchar(60) COMMENT '?Z??3', |
17 | 17 |
PhoneNumber varchar(13) DEFAULT '' NOT NULL COMMENT '?d?b???', |
18 | 18 |
FaxNumber varchar(13) DEFAULT '' COMMENT 'FAX???', |
19 |
HomePageURL varchar(120) DEFAULT '' COMMENT '?z?[???y?[?WURL', |
|
19 | 20 |
ConstructionExpenses decimal(4,2) NOT NULL COMMENT '?H?????o??', |
20 | 21 |
OfficeExpenses decimal(4,2) NOT NULL COMMENT '???????o??', |
21 | 22 |
OperatingExpenses decimal(4,2) NOT NULL COMMENT '?c??o??', |
... | ... | |
49 | 50 |
Address3, |
50 | 51 |
PhoneNumber, |
51 | 52 |
FaxNumber, |
53 |
'', |
|
52 | 54 |
ConstructionExpenses, |
53 | 55 |
OfficeExpenses, |
54 | 56 |
OperatingExpenses, |
branches/src/DataCheckExcute/DataCheckExcute/App.config | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<configuration> |
|
3 |
<startup> |
|
4 |
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> |
|
5 |
</startup> |
|
6 |
</configuration> |
branches/src/DataCheckExcute/DataCheckExcute/Common/CommonVersion.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Threading.Tasks; |
|
6 |
|
|
7 |
namespace ProcessManagement.Common |
|
8 |
{ |
|
9 |
/// <summary> |
|
10 |
/// システムバージョン定義クラス |
|
11 |
/// </summary> |
|
12 |
public static class CommonVersion |
|
13 |
{ |
|
14 |
/// <summary> |
|
15 |
/// 本体バージョン |
|
16 |
/// </summary> |
|
17 |
public static int s_SystemVersion = 0; |
|
18 |
} |
|
19 |
} |
branches/src/DataCheckExcute/DataCheckExcute/Common/Process/ClsChangeLedgerData.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.ComponentModel; |
|
4 |
using System.Data; |
|
5 |
using System.Drawing; |
|
6 |
using System.Linq; |
|
7 |
using System.Text; |
|
8 |
using System.Windows.Forms; |
|
9 |
using System.Collections; |
|
10 |
using System.Diagnostics; |
|
11 |
|
|
12 |
using log4net; |
|
13 |
using log4net.Appender; |
|
14 |
using log4net.Repository.Hierarchy; |
|
15 |
|
|
16 |
using ProcessManagement.Common; |
|
17 |
using ProcessManagement.DB.IOAccess; |
|
18 |
using ProcessManagement.DataModel; |
|
19 |
using ProcessManagement.Forms.DataEntry; |
|
20 |
|
|
21 |
//*----------------------- 工事詳細台帳データ変更クラス -----------------------* |
|
22 |
// 2016/05/31 Ver1.0.0.0 Create Source |
|
23 |
// |
|
24 |
// |
|
25 |
// |
|
26 |
//*----------------------------------------------------------------------------* |
|
27 |
namespace ProcessManagement.Common |
|
28 |
{ |
|
29 |
/// <summary> |
|
30 |
/// 工事詳細台帳データ変更クラス |
|
31 |
/// </summary> |
|
32 |
public static class ClsChangeLedgerData |
|
33 |
{ |
|
34 |
#region ログ定義 |
|
35 |
/// <summary> |
|
36 |
/// log4netログを使用する |
|
37 |
/// </summary> |
|
38 |
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
|
39 |
#endregion |
|
40 |
|
|
41 |
#region 定数 |
|
42 |
|
|
43 |
#endregion |
|
44 |
|
|
45 |
#region 変数 |
|
46 |
/// <summary> |
|
47 |
/// 工事施工台帳支払い実績先頭カラム数 |
|
48 |
/// </summary> |
|
49 |
private static int m_LedgerColumnCount = 0; |
|
50 |
#endregion |
|
51 |
|
|
52 |
#region 工事詳細台帳再計算処理(総支払額・粗利・給与・純利益が対象) |
|
53 |
/// <summary> |
|
54 |
/// 工事詳細台帳再計算処理(総支払額・粗利・給与・純利益が対象) |
|
55 |
/// </summary> |
|
56 |
/// <param name="ConstrCode"></param> |
|
57 |
private static bool LedgerRecalculate(IOConstructionLedgerExcute LedgerExcuteDB, List<int> ConstrCodeList) |
|
58 |
{ |
|
59 |
try |
|
60 |
{ |
|
61 |
string strSQL = string.Empty; |
|
62 |
bool bRet = true; |
|
63 |
foreach (int ConstrCode in ConstrCodeList) |
|
64 |
{ |
|
65 |
// 工事台帳実行データよりグループごとの合計金額を取得する |
|
66 |
strSQL = "SELECT GROUPCOUNT, SUM(PAYMENTAMOUNT)"; |
|
67 |
strSQL += " FROM CONSTRUCTIONLEDGEREXCUTE"; |
|
68 |
strSQL += string.Format(" WHERE CONSTRUCTIONCODE = {0}", ConstrCode); |
|
69 |
strSQL += " GROUP BY GROUPCOUNT"; |
|
70 |
strSQL += " ORDER BY GROUPCOUNT"; |
|
71 |
|
|
72 |
ArrayList InData = new ArrayList(); |
|
73 |
if (!LedgerExcuteDB.ExecuteReader(strSQL, ref InData, false)) continue; |
|
74 |
|
|
75 |
// データ無は次のデータ |
|
76 |
if (InData.Count == 0) continue; |
|
77 |
|
|
78 |
// 対象データ取得 |
|
79 |
List<int> GroupCodeList = new List<int>(); |
|
80 |
GroupCodeList.Add((int)FrmConstructionLedger.DataGroup.Expenses); // 1:経費 |
|
81 |
|
|
82 |
GroupCodeList.Add((int)FrmConstructionLedger.DataGroup.ConstructionCosts); // 2:施工費 |
|
83 |
|
|
84 |
GroupCodeList.Add((int)FrmConstructionLedger.DataGroup.TransportationCosts); // 3:交通費(通行料・電車代) |
|
85 |
GroupCodeList.Add((int)FrmConstructionLedger.DataGroup.PurchaseCosts); // 4:購入品 |
|
86 |
GroupCodeList.Add((int)FrmConstructionLedger.DataGroup.VehicleLeaseFee); // 5:車両リース代 |
|
87 |
GroupCodeList.Add((int)FrmConstructionLedger.DataGroup.ParkingCosts); // 6:駐車場・資材置き場 |
|
88 |
GroupCodeList.Add((int)FrmConstructionLedger.DataGroup.RoomChargeCosts); // 7:宿泊費 |
|
89 |
|
|
90 |
GroupCodeList.Add((int)FrmConstructionLedger.DataGroup.DisposeCosts); // 8:処分費等 |
|
91 |
int Payment = CalcGetTotal(InData, GroupCodeList); // ----- 支払額 |
|
92 |
|
|
93 |
GroupCodeList.Clear(); |
|
94 |
GroupCodeList.Add((int)FrmConstructionLedger.DataGroup.Instructor); // 9:指導員給料行 |
|
95 |
GroupCodeList.Add((int)FrmConstructionLedger.DataGroup.Assistant); // 10:副担当者給料行 |
|
96 |
int PExpenses = CalcGetTotal(InData, GroupCodeList); // ----- 人件費 |
|
97 |
|
|
98 |
GroupCodeList.Clear(); |
|
99 |
GroupCodeList.Add((int)FrmConstructionLedger.DataGroup.Payroll); // 11:担当者給料行 |
|
100 |
int Allowance = CalcGetTotal(InData, GroupCodeList); // ----- 給与 |
|
101 |
|
|
102 |
GroupCodeList.Clear(); |
|
103 |
GroupCodeList.Add((int)FrmConstructionLedger.DataGroup.BillingAmount); // 14:請求金額 |
|
104 |
int Billing = CalcGetTotal(InData, GroupCodeList); // ----- 請求額 |
|
105 |
|
|
106 |
// ----- 工事詳細台帳更新 |
|
107 |
strSQL = "UPDATE CONSTRUCTIONLEDGER SET"; |
|
108 |
strSQL += string.Format(" TOTALPAYMENT = {0}", Payment); |
|
109 |
strSQL += string.Format(" , GROSSPROFIT = {0}", (Billing - Payment)); |
|
110 |
strSQL += string.Format(" , Allowance = {0}", Allowance); |
|
111 |
strSQL += string.Format(" , NETPROFIT = {0}", (Billing - (Payment + Allowance + PExpenses))); |
|
112 |
strSQL += string.Format(" WHERE CONSTRUCTIONCODE = {0}", ConstrCode); |
|
113 |
if (!LedgerExcuteDB.ExecuteNonQuery(strSQL, false)) |
|
114 |
{ |
|
115 |
bRet = false; |
|
116 |
break; |
|
117 |
} |
|
118 |
} |
|
119 |
return bRet; |
|
120 |
} |
|
121 |
catch (System.Exception ex) |
|
122 |
{ |
|
123 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
124 |
return false; |
|
125 |
} |
|
126 |
} |
|
127 |
#endregion |
|
128 |
|
|
129 |
#region 配列リストより指定された合計を取得する |
|
130 |
/// <summary> |
|
131 |
/// 配列リストより指定された合計を取得する |
|
132 |
/// </summary> |
|
133 |
private static int CalcGetTotal(ArrayList InData, List<int> GroupCodeList) |
|
134 |
{ |
|
135 |
try |
|
136 |
{ |
|
137 |
int iRetVal = 0; |
|
138 |
|
|
139 |
int GrpNo = -1; |
|
140 |
foreach (int GroupCode in GroupCodeList) |
|
141 |
{ |
|
142 |
foreach (object[] CurRec in InData) |
|
143 |
{ |
|
144 |
GrpNo = CommonMotions.cnvInt(CurRec[0]); |
|
145 |
|
|
146 |
if (GroupCode != GrpNo) continue; |
|
147 |
|
|
148 |
iRetVal += CommonMotions.cnvInt(CurRec[1]); |
|
149 |
} |
|
150 |
} |
|
151 |
|
|
152 |
return iRetVal; |
|
153 |
} |
|
154 |
catch (System.Exception ex) |
|
155 |
{ |
|
156 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
157 |
return 0; |
|
158 |
} |
|
159 |
} |
|
160 |
#endregion |
|
161 |
|
|
162 |
#region 工事詳細台帳より支払金額グリッドの先頭カラム数を取得する |
|
163 |
/// <summary> |
|
164 |
/// 工事詳細台帳より支払金額グリッドの先頭カラム数を取得する |
|
165 |
/// </summary> |
|
166 |
private static void GetLedgerColumnCount() |
|
167 |
{ |
|
168 |
try |
|
169 |
{ |
|
170 |
m_LedgerColumnCount = Enum.GetNames(typeof(FrmConstructionLedger.GridColumn)).Length - 1; |
|
171 |
} |
|
172 |
catch (System.Exception ex) |
|
173 |
{ |
|
174 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
175 |
} |
|
176 |
} |
|
177 |
#endregion |
|
178 |
|
|
179 |
#region 工事詳細台帳データに対象行の支払い給与を計算する |
|
180 |
/// <summary> |
|
181 |
/// 工事詳細台帳データに対象行の支払い給与を計算する |
|
182 |
/// </summary> |
|
183 |
/// <param name="ConstrCode">工事番号</param> |
|
184 |
/// <param name="TargetDate">対象日</param> |
|
185 |
/// <param name="bSetFlag">月一括セットフラグ</param> |
|
186 |
/// <returns></returns> |
|
187 |
public static bool CalculatePayment(List<ConstructionLedger> LedgerList) |
|
188 |
{ |
|
189 |
IOConstructionLedgerDetail LedgerDeDB = new IOConstructionLedgerDetail(); |
|
190 |
IOConstructionLedgerExcute LedgerExDB = new IOConstructionLedgerExcute(); |
|
191 |
IOMPersonInCharge PersonDB = new IOMPersonInCharge(); |
|
192 |
try |
|
193 |
{ |
|
194 |
bool bret = true; |
|
195 |
List<int> ConstrCodeList = new List<int>(); |
|
196 |
|
|
197 |
LedgerDeDB.connect(); LedgerDeDB.beginTran(); |
|
198 |
LedgerExDB.connect(); LedgerExDB.beginTran(); |
|
199 |
PersonDB.connect(); PersonDB.beginTran(); |
|
200 |
|
|
201 |
foreach (ConstructionLedger LedgerRec in LedgerList) |
|
202 |
{ |
|
203 |
|
|
204 |
// 工事詳細台帳明細データ取得 |
|
205 |
List<ConstructionLedgerDetail> DetailList = new List<ConstructionLedgerDetail>(); |
|
206 |
string DetailSQL = LedgerDeDB.CreatePrimarykeyString(LedgerRec.ConstructionCode); |
|
207 |
DetailSQL += string.Format(" AND OperatingFlg = {0}", (int)CommonDefine.SalaryOperateKind.Oparateing); // 対応中フラグ |
|
208 |
DetailSQL += string.Format(" AND SALARYFLG != {0}", (int)CommonDefine.SalaryDevision.Noting); // 給与振分区分 |
|
209 |
DetailSQL += string.Format(" AND GROUPCOUNT IN ({0},{1},{2})", |
|
210 |
(int)FrmConstructionLedger.DataGroup.Instructor, // 指導員給料 |
|
211 |
(int)FrmConstructionLedger.DataGroup.Assistant, // 副担当者給料 |
|
212 |
(int)FrmConstructionLedger.DataGroup.Payroll); // 担当者給料行 |
|
213 |
|
|
214 |
if (!LedgerDeDB.SelectAction(DetailSQL, ref DetailList, false) || DetailList.Count == 0) continue; |
|
215 |
|
|
216 |
DateTime TargetDate = DateTime.Now.Date; |
|
217 |
// 対象月より書込みカラム位置を取得する |
|
218 |
int ColPoint = CalcTargetMonthToColumn(LedgerRec.ConstructionStart, TargetDate); |
|
219 |
|
|
220 |
foreach (ConstructionLedgerDetail CurRec in DetailList) |
|
221 |
{ |
|
222 |
// コードが担当者ではない場合は処理しない |
|
223 |
if (CurRec.CompanyType != (int)CommonDefine.CodeDataType.Person) continue; |
|
224 |
// コードがない場合は処理しない |
|
225 |
if (CurRec.CompanyCode == 0) continue; |
|
226 |
// 施工管理中担当者ではない場合は処理しない |
|
227 |
if (CurRec.OperatingFlg == (int)CommonDefine.SalaryOperateKind.Complate) continue; |
|
228 |
|
|
229 |
//if (LedgerRec.ConstructionCode == 2016043601) |
|
230 |
//{ |
|
231 |
// Debug.WriteLine("stop"); |
|
232 |
//} |
|
233 |
|
|
234 |
// セットする金額を計算する |
|
235 |
switch (CurRec.SalaryFlg) |
|
236 |
{ |
|
237 |
case (int)CommonDefine.SalaryDevision.All: // 全日振分 |
|
238 |
bret = CalcSalaryDevisionAll(LedgerExDB, PersonDB, LedgerRec, CurRec, TargetDate.Date, ColPoint); |
|
239 |
break; |
|
240 |
case (int)CommonDefine.SalaryDevision.Noting: // 振分無 |
|
241 |
bret = CalcSalaryDevisionNoting(LedgerExDB, CurRec, TargetDate.Date, ColPoint); |
|
242 |
break; |
|
243 |
case (int)CommonDefine.SalaryDevision.DaysInput: // 日数入力 |
|
244 |
bret = CalcSalaryDevisionDaysInput(LedgerExDB, PersonDB, LedgerRec, CurRec); |
|
245 |
break; |
|
246 |
default: |
|
247 |
break; |
|
248 |
} |
|
249 |
} |
|
250 |
ConstrCodeList.Add(LedgerRec.ConstructionCode); |
|
251 |
} |
|
252 |
|
|
253 |
if (bret) |
|
254 |
{ |
|
255 |
// 工事台帳更新 |
|
256 |
bret = LedgerRecalculate(LedgerExDB, ConstrCodeList); |
|
257 |
} |
|
258 |
|
|
259 |
// エラー時ロールバック |
|
260 |
if (!bret) LedgerExDB.rollback(); |
|
261 |
|
|
262 |
// DB Commit |
|
263 |
LedgerExDB.commit(); |
|
264 |
|
|
265 |
return bret; |
|
266 |
} |
|
267 |
catch (Exception ex) |
|
268 |
{ |
|
269 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
270 |
return false; |
|
271 |
} |
|
272 |
finally |
|
273 |
{ |
|
274 |
LedgerDeDB.close(); LedgerDeDB = null; |
|
275 |
LedgerExDB.close(); LedgerExDB = null; |
|
276 |
PersonDB.close(); PersonDB = null; |
|
277 |
} |
|
278 |
} |
|
279 |
#endregion |
|
280 |
|
|
281 |
#region 全日振分時の給与書込み |
|
282 |
/// <summary> |
|
283 |
/// 全日振分時の給与書込み |
|
284 |
/// </summary> |
|
285 |
private static bool CalcSalaryDevisionAll(IOConstructionLedgerExcute LedgerExDB, |
|
286 |
IOMPersonInCharge PersonDB, |
|
287 |
ConstructionLedger LedgerRec, |
|
288 |
ConstructionLedgerDetail CurRec, |
|
289 |
DateTime CalcEndtDate, |
|
290 |
int ColPoint) |
|
291 |
{ |
|
292 |
try |
|
293 |
{ |
|
294 |
DateTime StartDate = DateTime.Now; |
|
295 |
DateTime CompDate = DateTime.Now; |
|
296 |
|
|
297 |
// ----- 計算開始日取得 |
|
298 |
if (LedgerRec.ConstructionStart.Year == CalcEndtDate.Year |
|
299 |
&& LedgerRec.ConstructionStart.Month == CalcEndtDate.Month) |
|
300 |
{ // 対象期間の開始が当月の場合は工事開始日を開始にする |
|
301 |
StartDate = LedgerRec.ConstructionStart; |
|
302 |
} |
|
303 |
else |
|
304 |
{ // 違う場合は月初 |
|
305 |
StartDate = DateTime.Parse(string.Format("{0}/{1}/{2}", CalcEndtDate.Year, CalcEndtDate.Month, 1)); |
|
306 |
} |
|
307 |
// ----- 計算終了日取得 |
|
308 |
if (LedgerRec.ConstructionEnd.Year == CalcEndtDate.Year |
|
309 |
&& LedgerRec.ConstructionEnd.Month == CalcEndtDate.Month) |
|
310 |
{ // 対象期間の終了が当月の場合は工事終了日を終了にする |
|
311 |
CompDate = LedgerRec.ConstructionEnd; |
|
312 |
} |
|
313 |
else |
|
314 |
{ // 違う場合は終了日 |
|
315 |
CompDate = CalcEndtDate; |
|
316 |
} |
|
317 |
|
|
318 |
int SumSaraly = 0; |
|
319 |
|
|
320 |
// 月末日より月日数を取得する |
|
321 |
int MonthDayCnt = DateTimeUtil.EndOfMonth(CalcEndtDate).Day; |
|
322 |
// 経過日数を取得する |
|
323 |
TimeSpan ts = CompDate - StartDate; |
|
324 |
// 支払給与計算 |
|
325 |
switch (CurRec.GroupCount) |
|
326 |
{ |
|
327 |
case (int)FrmConstructionLedger.DataGroup.Instructor: // 指導員給料 |
|
328 |
SumSaraly = CommonMotions.cnvRound((double)CommonDefine.InstructorMonthryCost / MonthDayCnt); |
|
329 |
SumSaraly *= (ts.Days + 1); |
|
330 |
break; |
|
331 |
case (int)FrmConstructionLedger.DataGroup.Assistant: // 副担当者給料 |
|
332 |
SumSaraly = CommonMotions.cnvRound((double)CommonDefine.AssistantMonthryCost / MonthDayCnt); |
|
333 |
SumSaraly *= (ts.Days + 1); |
|
334 |
break; |
|
335 |
case (int)FrmConstructionLedger.DataGroup.Payroll: // 担当者給料行 |
|
336 |
// 範囲給与取得 |
|
337 |
SumSaraly = CommonMotions.CalcElapsedSalary(PersonDB, StartDate, CompDate, CurRec.CompanyCode); |
|
338 |
break; |
|
339 |
} |
|
340 |
|
|
341 |
// 実行データのキー部年月日は対象月の1日 |
|
342 |
DateTime ParaDate = new DateTime(CalcEndtDate.Year, CalcEndtDate.Month, 1); |
|
343 |
// 支払いデータ書込み |
|
344 |
if (!AddOrSetSalary(LedgerExDB |
|
345 |
, CurRec.ConstructionCode, CurRec.GroupCount, CurRec.LineCount, ColPoint, SumSaraly, ParaDate)) |
|
346 |
{ |
|
347 |
return false; |
|
348 |
} |
|
349 |
|
|
350 |
return true; |
|
351 |
} |
|
352 |
catch (Exception ex) |
|
353 |
{ |
|
354 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
355 |
return false; |
|
356 |
} |
|
357 |
} |
|
358 |
#endregion |
|
359 |
|
|
360 |
#region 振分無時の給与書込み |
|
361 |
/// <summary> |
|
362 |
/// 振分無時の給与書込み |
|
363 |
/// </summary> |
|
364 |
private static bool CalcSalaryDevisionNoting(IOConstructionLedgerExcute LedgerExDB, |
|
365 |
ConstructionLedgerDetail CurRec, |
|
366 |
DateTime CalcEndtDate, |
|
367 |
int ColPoint) |
|
368 |
{ |
|
369 |
try |
|
370 |
{ |
|
371 |
// 実行データのキー部年月日は対象月の1日 |
|
372 |
DateTime ParaDate = new DateTime(CalcEndtDate.Year, CalcEndtDate.Month, 1); |
|
373 |
// 支払いデータ書込み |
|
374 |
if (!AddOrSetSalary(LedgerExDB |
|
375 |
, CurRec.ConstructionCode, CurRec.GroupCount, CurRec.LineCount, ColPoint, 0, ParaDate)) |
|
376 |
{ |
|
377 |
return false; |
|
378 |
} |
|
379 |
|
|
380 |
return true; |
|
381 |
} |
|
382 |
catch (Exception ex) |
|
383 |
{ |
|
384 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
385 |
return false; |
|
386 |
} |
|
387 |
} |
|
388 |
#endregion |
|
389 |
|
|
390 |
#region 日付指定時の給与書込み |
|
391 |
/// <summary> |
|
392 |
/// 日付指定時の給与書込み |
|
393 |
/// </summary> |
|
394 |
private static bool CalcSalaryDevisionDaysInput(IOConstructionLedgerExcute LedgerExDB, |
|
395 |
IOMPersonInCharge PersonDB, |
|
396 |
ConstructionLedger LedgerRec, |
|
397 |
ConstructionLedgerDetail CurRec) |
|
398 |
{ |
|
399 |
try |
|
400 |
{ |
|
401 |
int OneDaySalary = 0; |
|
402 |
|
|
403 |
// 月末日より月日数を取得する |
|
404 |
int MonthDayCnt = DateTimeUtil.EndOfMonth(LedgerRec.ConstructionStart).Day; |
|
405 |
// 支払給与計算 |
|
406 |
switch (CurRec.GroupCount) |
|
407 |
{ |
|
408 |
case (int)FrmConstructionLedger.DataGroup.Instructor: // 指導員給料 |
|
409 |
OneDaySalary = CommonMotions.cnvRound((double)CommonDefine.InstructorMonthryCost / MonthDayCnt); |
|
410 |
OneDaySalary *= CurRec.SalaryDays; |
|
411 |
break; |
|
412 |
case (int)FrmConstructionLedger.DataGroup.Assistant: // 副担当者給料 |
|
413 |
OneDaySalary = CommonMotions.cnvRound((double)CommonDefine.AssistantMonthryCost / MonthDayCnt); |
|
414 |
OneDaySalary *= CurRec.SalaryDays; |
|
415 |
break; |
|
416 |
case (int)FrmConstructionLedger.DataGroup.Payroll: // 担当者給料行 |
|
417 |
// 給与取得 |
|
418 |
OneDaySalary = CommonMotions.CalcElapsedSalary(PersonDB, LedgerRec.ConstructionStart, LedgerRec.ConstructionStart, CurRec.CompanyCode); |
|
419 |
OneDaySalary *= CurRec.SalaryDays; |
|
420 |
break; |
|
421 |
} |
|
422 |
|
|
423 |
// 実行データのキー部年月日は開始月の1日 |
|
424 |
DateTime ParaDate = new DateTime(LedgerRec.ConstructionStart.Year, LedgerRec.ConstructionStart.Month, 1); |
|
425 |
// 台帳カラム位置 |
|
426 |
int Columncnt = Enum.GetNames(typeof(FrmConstructionLedger.GridColumn)).Length - 1; |
|
427 |
|
|
428 |
// 支払いデータ書込み |
|
429 |
if (!AddOrSetSalary(LedgerExDB |
|
430 |
, CurRec.ConstructionCode, CurRec.GroupCount, CurRec.LineCount, Columncnt, OneDaySalary, ParaDate)) |
|
431 |
{ |
|
432 |
return false; |
|
433 |
} |
|
434 |
|
|
435 |
return true; |
|
436 |
} |
|
437 |
catch (Exception ex) |
|
438 |
{ |
|
439 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
440 |
return false; |
|
441 |
} |
|
442 |
} |
|
443 |
#endregion |
|
444 |
|
|
445 |
#region 日次処理での日当の加算を判定する |
|
446 |
/// <summary> |
|
447 |
/// 日次処理での日当の加算を判定する |
|
448 |
/// </summary> |
|
449 |
/// <param name="CurRec"></param> |
|
450 |
/// <returns></returns> |
|
451 |
private static bool CheckPaymentValue(ConstructionLedgerDetail CurRec) |
|
452 |
{ |
|
453 |
IOConstructionLedgerExcute ExcuteDB = new IOConstructionLedgerExcute(); |
|
454 |
try |
|
455 |
{ |
|
456 |
// 支払いデータより合計金額を取得する |
|
457 |
ArrayList arList = new ArrayList(); |
|
458 |
string ExcuteSQL = "SELECT SUM(PAYMENTAMOUNT) FROM CONSTRUCTIONLEDGEREXCUTE"; |
|
459 |
ExcuteSQL += string.Format(" WHERE CONSTRUCTIONCODE = {0}", CurRec.ConstructionCode); |
|
460 |
ExcuteSQL += string.Format(" AND GROUPCOUNT = {0}", CurRec.GroupCount); |
|
461 |
ExcuteSQL += string.Format(" AND LINECOUNT = {0}", CurRec.LineCount); |
|
462 |
if (!ExcuteDB.ExecuteReader(ExcuteSQL, ref arList) || arList.Count == 0) return false; |
|
463 |
|
|
464 |
object[] wrkobj = (object[])arList[0]; |
|
465 |
int TotalVal = CommonMotions.cnvInt(wrkobj[0]); |
|
466 |
|
|
467 |
bool bRet = false; |
|
468 |
if (TotalVal < CurRec.ExecutionAmount) bRet = true; |
|
469 |
|
|
470 |
return bRet; |
|
471 |
} |
|
472 |
catch (Exception ex) |
|
473 |
{ |
|
474 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
475 |
return false; |
|
476 |
} |
|
477 |
} |
|
478 |
#endregion |
|
479 |
|
|
480 |
#region 詳細台帳に指定金額を設定するか足しこむ |
|
481 |
/// <summary> |
|
482 |
/// 詳細台帳に指定金額を設定するか足しこむ |
|
483 |
/// </summary> |
|
484 |
private static bool AddOrSetSalary(IOConstructionLedgerExcute LedgerExDB |
|
485 |
, int ConstrCode, int GroupCount, int LineCount, int ColumnCount |
|
486 |
, int DaySalary, DateTime ColumnDate) |
|
487 |
{ |
|
488 |
try |
|
489 |
{ |
|
490 |
// キー作成 |
|
491 |
string strSQL = LedgerExDB.CreatePrimarykeyString(ConstrCode, GroupCount, LineCount, ColumnCount); |
|
492 |
strSQL += string.Format(" AND DATE(TargetMonth) = STR_TO_DATE('{0}','%Y/%m/%d')", ColumnDate.ToShortDateString()); |
|
493 |
|
|
494 |
// データ読込み |
|
495 |
List<ConstructionLedgerExcute> LedgerExDBList = new List<ConstructionLedgerExcute>(); |
|
496 |
ConstructionLedgerExcute LedgerExDBRec = new ConstructionLedgerExcute(); |
|
497 |
bool ReadData = LedgerExDB.SelectAction(strSQL, ref LedgerExDBList, false); |
|
498 |
if (!ReadData || LedgerExDBList.Count == 0) |
|
499 |
{ |
|
500 |
LedgerExDBRec.ConstructionCode = ConstrCode; // 工事コード |
|
501 |
LedgerExDBRec.GroupCount = GroupCount; // グループ番号 |
|
502 |
LedgerExDBRec.LineCount = LineCount; // 行番号 |
|
503 |
LedgerExDBRec.ColumnCount = ColumnCount; // 列番号 |
|
504 |
LedgerExDBRec.PaymentAmount = DaySalary; // 支払金額 |
|
505 |
LedgerExDBRec.TargetMonth = ColumnDate; // 対象年月 |
|
506 |
|
|
507 |
// データ作成 |
|
508 |
if (!LedgerExDB.InsertAction(LedgerExDBRec, false)) return false; |
|
509 |
|
|
510 |
return true; |
|
511 |
} |
|
512 |
|
|
513 |
// データ更新 |
|
514 |
if (!LedgerExDB.UpdateFeild(ConstrCode, GroupCount, LineCount, ColumnCount |
|
515 |
, (int)IOConstructionLedgerExcute.TableColumn.PaymentAmount, DaySalary, false)) return false; |
|
516 |
|
|
517 |
return true; |
|
518 |
} |
|
519 |
catch (Exception ex) |
|
520 |
{ |
|
521 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
522 |
return false; |
|
523 |
} |
|
524 |
} |
|
525 |
#endregion |
|
526 |
|
|
527 |
#region 対象年月から工事詳細台帳のグリッドカラム位置を算出する |
|
528 |
/// <summary> |
|
529 |
/// 対象年月から工事詳細台帳のグリッドカラム位置を算出する |
|
530 |
/// </summary> |
|
531 |
/// <param name="TargetMonth"></param> |
|
532 |
/// <returns></returns> |
|
533 |
public static int CalcTargetMonthToColumn(DateTime StartDate, DateTime TargetMonth) |
|
534 |
{ |
|
535 |
int Columncnt = Enum.GetNames(typeof(FrmConstructionLedger.GridColumn)).Length - 1; |
|
536 |
try |
|
537 |
{ |
|
538 |
// 処理対象年月日を対象月月初日に変換する |
|
539 |
DateTime NowDates = DateTimeUtil.BeginOfMonth(TargetMonth); |
|
540 |
|
|
541 |
// 開始年月日を開始年月月初日に変換する |
|
542 |
DateTime StartMonth = DateTimeUtil.BeginOfMonth(StartDate); |
|
543 |
|
|
544 |
// 経過月数を取得する |
|
545 |
//TimeSpan ts = NowDates - StartDate; |
|
546 |
//int DiffMonth = ts.GetTimeSpanMonths(); |
|
547 |
int DiffMonth = (TargetMonth.Month + (TargetMonth.Year - StartDate.Year) * 12) - StartDate.Month; |
|
548 |
|
|
549 |
// 列番号取得 |
|
550 |
Columncnt += DiffMonth; |
|
551 |
|
|
552 |
return Columncnt; |
|
553 |
} |
|
554 |
catch (Exception ex) |
|
555 |
{ |
|
556 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
557 |
return Columncnt; |
|
558 |
} |
|
559 |
} |
|
560 |
#endregion |
|
561 |
|
|
562 |
} |
|
563 |
} |
branches/src/DataCheckExcute/DataCheckExcute/Common/Process/ClsSystemOnceExecute.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Diagnostics; |
|
4 |
using System.IO; |
|
5 |
using System.Linq; |
|
6 |
using System.Security.Cryptography; |
|
7 |
using System.Text; |
|
8 |
using System.Threading.Tasks; |
|
9 |
using System.Collections; |
|
10 |
|
|
11 |
using log4net; |
|
12 |
using log4net.Appender; |
|
13 |
using log4net.Repository.Hierarchy; |
|
14 |
|
|
15 |
using ProcessManagement.Common; |
|
16 |
using ProcessManagement.DB.IOAccess; |
|
17 |
using ProcessManagement.DataModel; |
|
18 |
|
|
19 |
namespace ProcessManagement.Common |
|
20 |
{ |
|
21 |
/// <summary> |
|
22 |
/// システム初回起動時処理クラス |
|
23 |
/// </summary> |
|
24 |
public class ClsSystemOnceExecute |
|
25 |
{ |
|
26 |
#region 使用定義 |
|
27 |
//log4netログを使用する |
|
28 |
private static readonly log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
|
29 |
#endregion |
|
30 |
|
|
31 |
#region 定数 |
|
32 |
|
|
33 |
/// <summary> |
|
34 |
/// 非受注へ移す期間(受注できずに見積提出日より以下の日数を過ぎれば非受注へ移動) |
|
35 |
/// </summary> |
|
36 |
private const int s_NonOrderDay = 93; |
|
37 |
|
|
38 |
/// <summary> |
|
39 |
/// 非受注時メッセージ |
|
40 |
/// </summary> |
|
41 |
private const string s_NonOrderComment = "受注できずに見積提出日より{0}日を過ぎましたので非受注とします。"; |
|
42 |
#endregion |
|
43 |
|
|
44 |
#region 変数 |
|
45 |
/// <summary> |
|
46 |
/// 初期化処理成否フラグ |
|
47 |
/// </summary> |
|
48 |
private bool m_bExecuteFlg = true; |
|
49 |
|
|
50 |
/// <summary> |
|
51 |
/// 状態毎期限マスタリスト |
|
52 |
/// </summary> |
|
53 |
private List<TermMasterList> SystemOnceExecuteTermMstList = new List<TermMasterList>(); |
|
54 |
|
|
55 |
/// <summary> |
|
56 |
/// 最終起動日 |
|
57 |
/// </summary> |
|
58 |
DateTime m_lastsessionDate = DateTime.MinValue; |
|
59 |
#endregion |
|
60 |
|
|
61 |
#region コンストラクタ |
|
62 |
public ClsSystemOnceExecute() |
|
63 |
{ |
|
64 |
// チェック項目取得 |
|
65 |
if (!GetTermList()) |
|
66 |
{ |
|
67 |
m_bExecuteFlg = false; |
|
68 |
} |
|
69 |
} |
|
70 |
#endregion |
|
71 |
|
|
72 |
#region チェックプロセス |
|
73 |
/// <summary> |
|
74 |
/// 初期起動チェックプロセス |
|
75 |
/// </summary> |
|
76 |
/// <returns></returns> |
|
77 |
public void FirstExecute() |
|
78 |
{ |
|
79 |
bool ProcessFlg = true; |
|
80 |
try |
|
81 |
{ |
|
82 |
// 初期化に失敗したら処理しない |
|
83 |
if (!m_bExecuteFlg) return; |
|
84 |
|
|
85 |
// 本日の初回起動がされている場合は処理しない |
|
86 |
if (!ExecuteCheck(ref m_lastsessionDate)) return; |
|
87 |
|
|
88 |
// 更新済みにするために日付の更新 |
|
89 |
if (!(ProcessFlg = UpDateTargetDate(DateTime.Now))) return; |
|
90 |
|
|
91 |
// ----- データチェック |
|
92 |
// 資材返却期限のチェックを行う |
|
93 |
if (!(ProcessFlg = MaterialLimitCheck(m_lastsessionDate))) return; |
|
94 |
|
|
95 |
// 日付の期限チェックを行う |
|
96 |
if(!(ProcessFlg = SubmittedDateCheck(m_lastsessionDate))) return; |
|
97 |
|
|
98 |
// 見積有効期限切れを非受注へ移行する |
|
99 |
if (!(ProcessFlg = ChangeNonOrdersData())) return; |
|
100 |
|
|
101 |
// 開始期日がきた給与を適用する |
|
102 |
if (!(ProcessFlg = SetNewPayrollCheck())) return; |
|
103 |
|
|
104 |
// 工事詳細台帳の給与を加算する |
|
105 |
if (!(ProcessFlg = CalculateDaysSalary(m_lastsessionDate))) return; |
|
106 |
|
|
107 |
} |
|
108 |
catch (Exception ex) |
|
109 |
{ |
|
110 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
111 |
} |
|
112 |
finally |
|
113 |
{ |
|
114 |
// エラー時は元の日付に更新 |
|
115 |
if (!ProcessFlg) UpDateTargetDate(m_lastsessionDate); |
|
116 |
} |
|
117 |
} |
|
118 |
#endregion |
|
119 |
|
|
120 |
#region 日付チェック |
|
121 |
/// <summary> |
|
122 |
/// 初回起動チェック |
|
123 |
/// </summary> |
|
124 |
/// <returns></returns> |
|
125 |
private bool ExecuteCheck(ref DateTime lastsessionDate) |
|
126 |
{ |
|
127 |
IOSystemExecute seDB = new IOSystemExecute(); |
|
128 |
try |
|
129 |
{ |
|
130 |
// キーを取得する |
|
131 |
int PCode = CommonDefine.ExePrimaryCode.First(x => x.Value.Equals("初回起動日付")).Key; |
|
132 |
// 日付読込 |
|
133 |
string strSQL = seDB.CreatePrimarykeyString(PCode); |
|
134 |
SystemExecute recordRec = new SystemExecute(); |
|
135 |
if (!seDB.SelectAction(strSQL, ref recordRec)) |
|
136 |
{ |
|
137 |
// キーセット |
|
138 |
recordRec.PrimaryCode = PCode; |
|
139 |
// 起動日付 |
|
140 |
recordRec.TargetDate = DateTime.Now; |
|
141 |
// データがないもしくはエラー時はデータ作成 |
|
142 |
if (!seDB.InsertAction(recordRec)) return false; |
|
143 |
// 日付を1日前にする |
|
144 |
recordRec.TargetDate = DateTime.Now.AddDays(-1); |
|
145 |
} |
|
146 |
|
|
147 |
// 前回起動日を取得する |
|
148 |
lastsessionDate = recordRec.TargetDate; |
|
149 |
|
|
150 |
// 日付比較 |
|
151 |
if (DateTime.Today == recordRec.TargetDate.Date) return false; |
|
152 |
|
|
153 |
return true; |
|
154 |
} |
|
155 |
catch (Exception ex) |
|
156 |
{ |
|
157 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
158 |
return false; |
|
159 |
} |
|
160 |
finally |
|
161 |
{ |
|
162 |
seDB.close(); seDB = null; |
|
163 |
} |
|
164 |
} |
|
165 |
#endregion |
|
166 |
|
|
167 |
#region 日付変更 |
|
168 |
/// <summary> |
|
169 |
/// 日付変更 |
|
170 |
/// </summary> |
|
171 |
/// <returns></returns> |
|
172 |
private bool UpDateTargetDate(DateTime TargetDate) |
|
173 |
{ |
|
174 |
IOSystemExecute seDB = new IOSystemExecute(); |
|
175 |
try |
|
176 |
{ |
|
177 |
// キーを取得する |
|
178 |
int PCode = CommonDefine.ExePrimaryCode.First(x => x.Value.Equals("初回起動日付")).Key; |
|
179 |
|
|
180 |
// 日付更新 |
|
181 |
if (!seDB.UpdateFeild(PCode, (int)IOSystemExecute.TableColumn.TargetDate, TargetDate)) return false; |
|
182 |
|
|
183 |
return true; |
|
184 |
} |
|
185 |
catch (Exception ex) |
|
186 |
{ |
|
187 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
188 |
return false; |
|
189 |
} |
|
190 |
finally |
|
191 |
{ |
|
192 |
seDB.close(); seDB = null; |
|
193 |
} |
|
194 |
} |
|
195 |
#endregion |
|
196 |
|
|
197 |
#region 期限マスタ読込 |
|
198 |
/// <summary> |
|
199 |
/// 期限マスタ読込 |
|
200 |
/// </summary> |
|
201 |
/// <returns></returns> |
|
202 |
private bool GetTermList() |
|
203 |
{ |
|
204 |
IOMTerm tmDB = new IOMTerm(); |
|
205 |
try |
|
206 |
{ |
|
207 |
// 期限マスタ読込 |
|
208 |
string strSQL = " Order By ConstructionStatusFlg Asc, DisplayOrder Asc"; |
|
209 |
List<TermMaster> tmList = new List<TermMaster>(); |
|
210 |
if (!tmDB.SelectAction(strSQL, ref tmList)) return false; |
|
211 |
|
|
212 |
// ラストのためにループ外で定義 |
|
213 |
TermMasterList CheckList = null; |
|
214 |
int iTmpStatus = -1; |
|
215 |
// データセット |
|
216 |
foreach (TermMaster tmRec in tmList) |
|
217 |
{ |
|
218 |
// キーが違えばArrayテーブルへ追加する |
|
219 |
if (iTmpStatus != tmRec.ConstructionStatusFlg) |
|
220 |
{ |
|
221 |
// チェックテーブルへ新たな状態テーブルを追加 |
|
222 |
CheckList = new TermMasterList(); |
|
223 |
SystemOnceExecuteTermMstList.Add(CheckList); |
|
224 |
|
|
225 |
// ブレイクキーの更新 |
|
226 |
iTmpStatus = tmRec.ConstructionStatusFlg; |
|
227 |
} |
|
228 |
// 取得データをセットする |
|
229 |
CheckList.TermMstTBL.Add(tmRec); |
|
230 |
} |
|
231 |
|
|
232 |
// バッファテーブルが空ではない場合 |
|
233 |
if (CheckList.TermMstTBL.Count != 0) |
|
234 |
{ |
|
235 |
// マスターテーブルリストより最後のステータスを取得する |
|
236 |
int SetTableStatus = SystemOnceExecuteTermMstList[SystemOnceExecuteTermMstList.Count - 1].TermMstTBL[0].ConstructionStatusFlg; |
|
237 |
// バッファテーブルのステータスを取得する |
|
238 |
int NowStatus = CheckList.TermMstTBL[0].ConstructionStatusFlg; |
|
239 |
// バッファテーブルがすでにセットされていなければセットする |
|
240 |
if (SetTableStatus != NowStatus) SystemOnceExecuteTermMstList.Add(CheckList); |
|
241 |
} |
|
242 |
|
|
243 |
return true; |
|
244 |
} |
|
245 |
catch (Exception ex) |
|
246 |
{ |
|
247 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message); |
|
248 |
return false; |
|
249 |
} |
|
250 |
finally |
|
251 |
{ |
|
252 |
tmDB.close(); tmDB = null; |
|
253 |
} |
|
254 |
} |
|
255 |
#endregion |
|
256 |
|
|
257 |
#region 資材返却ステータス取得処理 |
|
258 |
/// <summary> |
|
259 |
/// 資材返却ステータス取得処理 |
|
260 |
/// </summary> |
|
261 |
/// <returns></returns> |
|
262 |
public void MaterualStatusCheck(MaterialRecordInfo checkRec, DateTime CriteriaDate, ref TermMaster TermRec) |
|
263 |
{ |
|
264 |
try |
|
265 |
{ |
|
266 |
// 対象日付を設定 |
|
267 |
DateTime Target = checkRec.RepayPlanDate; |
|
268 |
|
|
269 |
TermMaster TermMasterData = new TermMaster(); |
|
270 |
|
|
271 |
// 当日のチェック 今日を基準に対象日と比較する |
|
272 |
if (Target.Date == CriteriaDate.Date) |
|
273 |
{ |
|
274 |
TermMasterData.CheckSchdule = (int)CommonDefine.TermDateCheckTiming.CheckSchdule1; |
|
275 |
TermMasterData.TermDays = CommonDefine.MaterualStatusCheckList[0].Value; |
|
276 |
TermMasterData.SendTitle = CommonDefine.MaterualLimitItem[0, 0]; |
|
277 |
TermMasterData.SendMessage = CommonDefine.MaterualLimitItem[0, 1]; |
|
278 |
TermMasterData.BackColor = CommonDefine.MaterualLimitItem[0, 2]; |
|
279 |
TermMasterData.ForeColor = CommonDefine.MaterualLimitItem[0, 3]; |
|
280 |
} |
|
281 |
// 後日以降継続のチェック 今日を基準に経過日(1日)が過ぎているか比較する |
|
282 |
if (Target.AddDays(1).Date <= CriteriaDate.Date) |
|
283 |
{ |
|
284 |
TermMasterData.CheckSchdule = (int)CommonDefine.TermDateCheckTiming.CheckSchdule3; |
|
285 |
TermMasterData.TermDays = CommonDefine.MaterualStatusCheckList[1].Value; |
|
286 |
TermMasterData.SendTitle = CommonDefine.MaterualLimitItem[1, 0]; |
|
287 |
TermMasterData.SendMessage = CommonDefine.MaterualLimitItem[1, 1]; |
|
288 |
TermMasterData.BackColor = CommonDefine.MaterualLimitItem[1, 2]; |
|
289 |
TermMasterData.ForeColor = CommonDefine.MaterualLimitItem[1, 3]; |
|
290 |
} |
|
291 |
|
|
292 |
TermRec = TermMasterData; |
|
293 |
} |
|
294 |
catch (Exception ex) |
|
295 |
{ |
|
296 |
logger.ErrorFormat("システムエラー:{0}", ex.Message); |
|
297 |
} |
|
298 |
} |
|
299 |
#endregion |
|
300 |
|
|
301 |
#region 秘書からのメッセージ作成 |
|
302 |
/// <summary> |
|
303 |
/// 秘書からのメッセージ作成 |
|
304 |
/// </summary> |
|
305 |
private bool MakeSecretaryMassageData(IOMessageBoardData mbdDB, |
|
306 |
IOMessageBoardTerget mbtDB, |
|
307 |
IOConstructionBaseInfoDetail cbiDB, |
|
308 |
MaterialRecordInfo wrkRec, TermMaster CheckRec, DateTime CriteriaDate) |
|
309 |
{ |
|
310 |
try |
|
311 |
{ |
|
312 |
// 工事名称・担当者取得 |
|
313 |
string strSQL = "SELECT A.DETAILSTRING, C.PERSONCODE CCODE, C.PERSONNAME CNAME"; |
|
314 |
strSQL += " FROM ConstructionBaseInfo P"; |
|
315 |
strSQL += string.Format(" LEFT JOIN PERSONINCHARGEMASTER C ON C.PERSONCODE = {0}", wrkRec.PersonCode); |
|
316 |
strSQL += " , CONSTRUCTIONBASEINFODETAIL A"; |
|
317 |
strSQL += string.Format(" WHERE P.CONSTRUCTIONCODE = {0}", wrkRec.ConstructionCode); |
|
318 |
strSQL += string.Format(" AND A.CONSTRUCTIONCODE = P.CONSTRUCTIONCODE AND A.DETAILNO = {0}", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName); |
|
319 |
ArrayList arList = new ArrayList(); |
|
320 |
if (!cbiDB.ExecuteReader(strSQL, ref arList)) return false; |
|
321 |
|
|
322 |
string DetailString = string.Empty; |
|
323 |
//int SalesPersonCode = 0; |
|
324 |
string SalesPersonName = string.Empty; |
|
325 |
int ConstructionPersonCode = 0; |
|
326 |
string ConstructionPersonName = string.Empty; |
|
327 |
foreach (object[] onjwrk in arList) |
|
328 |
{ |
|
329 |
DetailString = CommonMotions.cnvString(onjwrk[0]); |
|
330 |
ConstructionPersonCode = CommonMotions.cnvInt(onjwrk[1]); |
|
331 |
ConstructionPersonName = CommonMotions.cnvString(onjwrk[2]); |
|
332 |
break; |
|
333 |
} |
|
334 |
|
|
335 |
// 新規メッセージ作成 |
|
336 |
MessageBoardData WriteData = new MessageBoardData(); |
|
337 |
List<MessageBoardTerget> WriteDetail = new List<MessageBoardTerget>(); |
|
338 |
|
|
339 |
// 掲示板メッセージ |
|
340 |
WriteData.FromCode = CommonDefine.s_MsgBoardSystemCode; // 書込み者コード |
|
341 |
WriteData.FromName = string.Format(CommonDefine.s_MsgBoardSystemNameFormat, "秘書"); // 書込み者名 |
|
342 |
|
|
343 |
WriteData.MessageTitle = CheckRec.SendTitle; // 伝言タイトル |
|
344 |
|
|
345 |
// リンク情報 |
|
346 |
WriteData.LinkType = (int)CommonDefine.LinkType.ConstructionInfo; |
|
347 |
WriteData.LinkMessage = string.Format("工事番号:{0} 工事名称:{1}" |
|
348 |
, CommonMotions.cnvStringCodeFromInt(wrkRec.ConstructionCode, "-", 8) |
|
349 |
, DetailString); |
|
350 |
WriteData.LinkCode = string.Format("{0}", CommonMotions.cnvStringCodeFromInt(wrkRec.ConstructionCode, "-", 8)); |
|
351 |
|
|
352 |
// 伝言内容 |
|
353 |
WriteData.MessageContent = CheckRec.SendMessage; |
|
354 |
|
|
355 |
|
|
356 |
//WriteData.WritingDate = DateTime.Now; // 書込み日付 |
|
357 |
WriteData.WritingDate = CriteriaDate.Date + DateTime.Now.TimeOfDay; // 書込み日付 |
|
358 |
WriteData.PersonCode = CommonDefine.s_MsgBoardSystemCode; // 書込み担当者コード |
|
359 |
WriteData.ShareFlag = 1; // 管理者対象フラグ |
|
360 |
|
|
361 |
WriteData.BackColor = CheckRec.BackColor; // 背景色セット |
|
362 |
WriteData.MessageColor = CheckRec.ForeColor; // 背景色セット |
|
363 |
|
|
364 |
// 掲示板対象者テーブル |
|
365 |
MessageBoardTerget DetailTbl = new MessageBoardTerget(); |
|
366 |
DetailTbl.ToCode = ConstructionPersonCode; // 対象者コード |
|
367 |
DetailTbl.ToName = ConstructionPersonName; // 対象者 |
|
368 |
WriteDetail.Add(DetailTbl); |
|
369 |
|
|
370 |
// メッセージフラグを自動に設定する |
|
371 |
WriteData.MessageFlag = (int)CommonDefine.MessageFlg.Secretary; |
|
372 |
|
|
373 |
// 掲示板へメッセージを載せる |
|
374 |
if (!ClsMessageBoradAccess.CreateMessage(mbdDB, mbtDB, WriteData, WriteDetail)) return false; |
|
375 |
|
|
376 |
return true; |
|
377 |
} |
|
378 |
catch (Exception ex) |
|
379 |
{ |
|
380 |
logger.ErrorFormat("システムエラー:{0}", ex.Message); |
|
381 |
return false; |
|
382 |
} |
|
383 |
} |
|
384 |
#endregion |
|
385 |
|
|
386 |
#region 資材返却期限チェック処理 |
|
387 |
/// <summary> |
|
388 |
/// チェック処理 |
|
389 |
/// </summary> |
|
390 |
/// <returns></returns> |
|
391 |
public bool MaterialLimitCheck(DateTime StartDate) |
|
392 |
{ |
|
393 |
IOConstructionBaseInfo cbiDB = new IOConstructionBaseInfo(); |
|
394 |
IOConstructionBaseInfoDetail cbiDDB = new IOConstructionBaseInfoDetail(); |
|
395 |
IOMessageBoardData mbdDB = new IOMessageBoardData(); |
|
396 |
IOMessageBoardTerget mbtDB = new IOMessageBoardTerget(); |
|
397 |
|
|
398 |
string strSQL = "SELECT"; |
|
399 |
strSQL += " t1.MaterialItemCode"; |
|
400 |
strSQL += ", t1.ProcessDate"; |
|
401 |
strSQL += ", t1.SeqNo"; |
|
402 |
strSQL += ", t1.RecKind"; |
|
403 |
strSQL += ", t1.ConstructionCode"; |
|
404 |
strSQL += ", t1.PersonCode"; |
|
405 |
strSQL += ", t1.MaterialCount"; |
|
406 |
strSQL += ", MAX(t1.REPAYPLANDATE) AS RepayPlanDate"; |
|
407 |
strSQL += ", t1.CommentText"; |
|
408 |
strSQL += ", t1.EntryDate"; |
|
409 |
strSQL += ", t1.UpdateDate"; |
|
410 |
strSQL += " FROM"; |
|
411 |
strSQL += " MATERIALRECORDINFO AS t1"; |
|
412 |
strSQL += " INNER JOIN CONSTRUCTIONMATERIALINFO AS t2"; |
|
413 |
strSQL += " ON t1.CONSTRUCTIONCODE = t2.CONSTRUCTIONCODE"; |
|
414 |
strSQL += " AND t1.MATERIALITEMCODE = t2.MATERIALITEMCODE"; |
|
415 |
strSQL += " AND t2.COMPLETEFLG = 0"; |
|
416 |
strSQL += " WHERE"; |
|
417 |
strSQL += " t1.CONSTRUCTIONCODE > 0"; |
|
418 |
strSQL += " AND t1.CONSTRUCTIONCODE IS NOT NULL"; |
|
419 |
strSQL += " AND t1.RECKIND = 0"; |
|
420 |
strSQL += " AND t1.REPAYPLANDATE <= DATE_FORMAT(NOW(), '%Y/%m/%d')"; |
|
421 |
strSQL += " GROUP BY"; |
|
422 |
strSQL += " t1.CONSTRUCTIONCODE"; |
|
423 |
strSQL += ", t1.PERSONCODE"; |
|
424 |
strSQL += " ORDER BY"; |
|
425 |
strSQL += " t1.CONSTRUCTIONCODE"; |
|
426 |
strSQL += " , t1.REPAYPLANDATE"; |
|
427 |
|
|
428 |
try |
|
429 |
{ |
|
430 |
cbiDB.connect(); cbiDB.beginTran(); |
|
431 |
cbiDDB.connect(); cbiDDB.beginTran(); |
|
432 |
mbdDB.connect(); mbdDB.beginTran(); |
|
433 |
mbtDB.connect(); mbtDB.beginTran(); |
|
434 |
|
|
435 |
bool procflg = true; |
|
436 |
|
|
437 |
// 資材履歴情報の返却未完了の貸出データを取得する |
|
438 |
IOMaterialRecordInfo mrDB = new IOMaterialRecordInfo(); |
|
439 |
ArrayList mrData = new ArrayList(); |
|
440 |
List<MaterialRecordInfo> data = new List<MaterialRecordInfo>(); |
|
441 |
|
|
442 |
if (mrDB.ExecuteReader(strSQL, ref mrData)) |
|
443 |
{ |
|
444 |
foreach (object[] objwrk in mrData) |
|
445 |
{ |
|
446 |
MaterialRecordInfo wrkRec = new MaterialRecordInfo(); |
|
447 |
mrDB.Reader2Struct(objwrk, ref wrkRec); |
|
448 |
// チェック |
|
449 |
TermMaster term = new TermMaster(); |
|
450 |
MaterualStatusCheck(wrkRec, StartDate, ref term); |
|
451 |
|
|
452 |
// メッセージ作成 掲示板にメッセージを載せる処理 |
|
453 |
if (!MakeSecretaryMassageData(mbdDB, mbtDB, cbiDDB, wrkRec, term, StartDate)) |
|
454 |
{ |
|
455 |
procflg = false; |
|
456 |
break; |
|
457 |
} |
|
458 |
} |
|
459 |
|
|
460 |
if (procflg) |
|
461 |
{ |
|
462 |
cbiDB.commit(); |
|
463 |
cbiDDB.commit(); |
|
464 |
mbdDB.commit(); |
|
465 |
mbtDB.commit(); |
|
466 |
} |
|
467 |
else |
|
468 |
{ |
|
469 |
cbiDB.rollback(); |
|
470 |
cbiDDB.rollback(); |
|
471 |
mbdDB.rollback(); |
|
472 |
mbtDB.rollback(); |
|
473 |
} |
|
474 |
|
|
475 |
return procflg; |
|
476 |
} |
|
477 |
} |
|
478 |
catch (Exception ex) |
|
479 |
{ |
|
480 |
logger.ErrorFormat("システムエラー:{0}", ex.Message); |
|
481 |
return false; |
|
482 |
} |
|
483 |
finally |
|
484 |
{ |
|
485 |
cbiDB.close(); cbiDB = null; |
|
486 |
cbiDDB.close(); cbiDDB = null; |
|
487 |
mbdDB.close(); mbdDB = null; |
|
488 |
mbtDB.close(); mbtDB = null; |
|
489 |
} |
|
490 |
return true; |
|
491 |
} |
|
492 |
#endregion |
|
493 |
|
|
494 |
#region 工事情報チェック処理 |
|
495 |
/// <summary> |
|
496 |
/// 日付の期限チェックを行う |
|
497 |
/// </summary> |
|
498 |
private bool SubmittedDateCheck(DateTime StartDate) |
|
499 |
{ |
|
500 |
IOConstructionBaseInfo cbiDB = new IOConstructionBaseInfo(); |
|
501 |
IOConstructionBaseInfoDetail cbiDDB = new IOConstructionBaseInfoDetail(); |
|
502 |
IOMessageBoardData mbdDB = new IOMessageBoardData(); |
|
503 |
IOMessageBoardTerget mbtDB = new IOMessageBoardTerget(); |
|
504 |
try |
|
505 |
{ |
|
506 |
// 工事基本情報を期限テーブルに設定している状態分取得する |
|
507 |
string strSQL = " WHERE CONSTRUCTIONSTATUSFLG IN (SELECT DISTINCT A1.CONSTRUCTIONSTATUSFLG FROM TERMMASTER A1)"; |
|
508 |
strSQL = " ORDER BY CONSTRUCTIONSTATUSFLG ASC, CONSTRUCTIONCODE ASC"; |
|
509 |
List<ConstructionBaseInfo> cbiList = new List<ConstructionBaseInfo>(); |
|
510 |
if (!cbiDB.SelectAction(strSQL, ref cbiList)) return true; |
|
511 |
|
|
512 |
// 経過日数を取得する |
|
513 |
TimeSpan ts = DateTime.Now - StartDate; |
|
514 |
int diffDays = ts.Days; |
|
515 |
// チェック範囲が10日を超えたら当日だけチェックする |
|
516 |
if (diffDays > 10) |
|
517 |
{ |
|
518 |
diffDays = 1; |
|
519 |
StartDate = DateTime.Now.AddDays(-1); |
|
520 |
} |
|
521 |
|
|
522 |
cbiDB.connect(); cbiDB.beginTran(); |
|
523 |
cbiDDB.connect(); cbiDDB.beginTran(); |
|
524 |
mbdDB.connect(); mbdDB.beginTran(); |
|
525 |
mbtDB.connect(); mbtDB.beginTran(); |
|
526 |
|
|
527 |
bool procflg = true; |
|
528 |
// 経過日数分処理を行う |
|
529 |
for (int ix = 0; ix < diffDays; ix++) |
|
530 |
{ |
|
531 |
DateTime CriteriaDate = StartDate.AddDays((ix + 1)); |
|
532 |
foreach (ConstructionBaseInfo wrkRec in cbiList) |
|
533 |
{ |
|
534 |
List<TermMaster> term = new List<TermMaster>(); |
|
535 |
// 増減工事の子は処理しない |
|
536 |
if (wrkRec.TyingFlg == (int)CommonDefine.BaseInfoTyingFlg.Tying) continue; |
|
537 |
// 結合工事の親は処理しない |
|
538 |
if (wrkRec.JoinFlg == (int)CommonDefine.BaseInfoJoinFlg.JoinParent) continue; |
|
539 |
// 結合工事の子は処理しない |
|
540 |
if (wrkRec.JoinFlg == (int)CommonDefine.BaseInfoJoinFlg.JoinChildren) continue; |
|
541 |
// チェックOKならば次のデータ |
|
542 |
if (ConstructionStatusCheck(wrkRec, CriteriaDate, ref term)) continue; |
|
543 |
|
|
544 |
// 掲示板にメッセージを載せるためにループ処理 |
|
545 |
foreach (TermMaster CurTerm in term) |
|
546 |
{ |
|
547 |
// メッセージ作成 |
|
548 |
if (!MakeMassageData(mbdDB, mbtDB, cbiDDB, wrkRec, CurTerm, CriteriaDate)) |
|
549 |
{ // エラー時に抜ける |
|
550 |
procflg = false; |
|
551 |
break; |
|
552 |
} |
|
553 |
} |
|
554 |
if (!procflg) break; |
|
555 |
} |
|
556 |
if (!procflg) break; |
|
557 |
} |
|
558 |
|
|
559 |
if (!procflg) |
|
560 |
{ |
|
561 |
cbiDB.rollback(); |
|
562 |
cbiDDB.rollback(); |
|
563 |
mbdDB.rollback(); |
|
564 |
mbtDB.rollback(); |
|
565 |
} |
|
566 |
|
|
567 |
return procflg; |
|
568 |
} |
|
569 |
catch (Exception ex) |
|
570 |
{ |
|
571 |
logger.ErrorFormat("システムエラー:{0}", ex.Message); |
|
572 |
return false; |
|
573 |
} |
|
574 |
finally |
|
575 |
{ |
|
576 |
cbiDB.commit(); |
|
577 |
cbiDDB.commit(); |
|
578 |
mbdDB.commit(); |
|
579 |
mbtDB.commit(); |
|
580 |
|
|
581 |
cbiDB.close(); cbiDB = null; |
|
582 |
cbiDDB.close(); cbiDDB = null; |
|
583 |
mbdDB.close(); mbdDB = null; |
|
584 |
mbtDB.close(); mbtDB = null; |
|
585 |
} |
|
586 |
} |
|
587 |
#endregion |
|
588 |
|
|
589 |
#region チェック処理 |
|
590 |
/// <summary> |
|
591 |
/// チェック処理 |
|
592 |
/// </summary> |
|
593 |
/// <returns></returns> |
|
594 |
public bool ConstructionStatusCheck(ConstructionBaseInfo checkRec, DateTime CriteriaDate, ref List<TermMaster> TermRec) |
|
595 |
{ |
|
596 |
try |
|
597 |
{ |
|
598 |
// 初期化に失敗していたら処理しない |
|
599 |
if (!m_bExecuteFlg) return true; |
|
600 |
|
|
601 |
// 取得データの進捗状態がチェック判定テーブルにあるかの存在チェック |
|
602 |
bool exestFlg = false; |
|
603 |
int itblCnt = 0; |
|
604 |
for (int i = 0; i < SystemOnceExecuteTermMstList.Count; i++) |
|
605 |
{ |
|
606 |
// 判定対象データの状態がチェック判定テーブルにあれば処理をおこなう |
|
607 |
if (SystemOnceExecuteTermMstList[i].TermMstTBL[0].ConstructionStatusFlg == checkRec.ConstructionStatusFlg) |
|
608 |
{ |
|
609 |
exestFlg = true; |
|
610 |
itblCnt = i; |
|
611 |
break; |
|
612 |
} |
|
613 |
} |
|
614 |
// 取得データがチェック判定以外は処理しない |
|
615 |
if (!exestFlg) return true; |
|
616 |
|
|
617 |
// 戻り値 |
|
618 |
bool bCheckNoError = true; |
|
619 |
|
|
620 |
List<TermMaster> Termtbl = SystemOnceExecuteTermMstList[itblCnt].TermMstTBL; |
|
621 |
// エラーチェック |
|
622 |
foreach (TermMaster wrkCheck in Termtbl) |
|
623 |
{ |
|
624 |
// 対象日付をクリア |
|
625 |
DateTime Target = DateTime.MinValue; |
|
626 |
|
|
627 |
switch (wrkCheck.FieldNo) |
|
628 |
{ |
|
629 |
case (int)CommonDefine.ConstructionBaseInfo_DateNo.RequestedDate: // 依頼受け日 |
|
630 |
Target = checkRec.RequestedDate; |
|
631 |
break; |
|
632 |
case (int)CommonDefine.ConstructionBaseInfo_DateNo.EstimatesSubmitDeadline: // 見積提出期限 |
|
633 |
Target = checkRec.EstimatesSubmitDeadline; |
|
634 |
break; |
|
635 |
case (int)CommonDefine.ConstructionBaseInfo_DateNo.EstimatesSubmittedDate: // 見積提出日 |
|
636 |
Target = checkRec.EstimatesSubmittedDate; |
|
637 |
break; |
|
638 |
case (int)CommonDefine.ConstructionBaseInfo_DateNo.OrderDate: // 受注日 |
|
639 |
Target = checkRec.OrderDate; |
|
640 |
break; |
|
641 |
case (int)CommonDefine.ConstructionBaseInfo_DateNo.OrderStartingDate: // 開始予定日 |
|
642 |
Target = checkRec.OrderStartingDate; |
|
643 |
break; |
|
644 |
case (int)CommonDefine.ConstructionBaseInfo_DateNo.OrderCompletionDate: // 完了予定日 |
|
645 |
Target = checkRec.OrderCompletionDate; |
|
646 |
break; |
|
647 |
case (int)CommonDefine.ConstructionBaseInfo_DateNo.ConstrPreparationDate: // 施工開始準備日 |
|
648 |
Target = checkRec.PreparationStartDate; |
|
649 |
break; |
|
650 |
case (int)CommonDefine.ConstructionBaseInfo_DateNo.ConstructionStartingDate: // 施工開始日 |
|
651 |
Target = checkRec.ConstructionStartingDate; |
|
652 |
break; |
|
653 |
case (int)CommonDefine.ConstructionBaseInfo_DateNo.ConstructionCompletionDate: // 施工完了日 |
|
654 |
Target = checkRec.ConstructionCompletionDate; |
|
655 |
break; |
|
656 |
case (int)CommonDefine.ConstructionBaseInfo_DateNo.TransferConstructionDate: // 工事移管日 |
|
657 |
Target = checkRec.TransferConstructionDate; |
|
658 |
break; |
|
659 |
case (int)CommonDefine.ConstructionBaseInfo_DateNo.EstimatesExpirationDate: // 見積有効期限 |
|
660 |
Target = checkRec.EstimatesExpirationDate; |
|
661 |
break; |
|
662 |
case (int)CommonDefine.ConstructionBaseInfo_DateNo.ConstructionPeriodStart: // 契約工期開始 |
|
663 |
Target = checkRec.ConstructionPeriodStart; |
|
664 |
break; |
|
665 |
case (int)CommonDefine.ConstructionBaseInfo_DateNo.ConstructionPeriodEnd: // 契約工期完了 |
|
666 |
Target = checkRec.ConstructionPeriodEnd; |
|
667 |
// 延長工期があれば延長工期を入れる |
|
668 |
if (checkRec.ConstructionPeriodEnd2 != DateTime.MinValue) Target = checkRec.ConstructionPeriodEnd2; |
|
669 |
break; |
|
670 |
case (int)CommonDefine.ConstructionBaseInfo_DateNo.BillingStartDate: // 請求準備開始日 |
|
671 |
Target = checkRec.BillingStartDate; |
|
672 |
break; |
|
673 |
case (int)CommonDefine.ConstructionBaseInfo_DateNo.BillingDate: // 請求日 |
|
674 |
Target = checkRec.BillingDate; |
|
675 |
// 2016/10/06 台帳入力完了日があればチェックをしない |
|
676 |
if (checkRec.LedgerComplateDate != DateTime.MinValue) Target = DateTime.MinValue.Date; |
|
677 |
break; |
|
678 |
} |
|
679 |
// 未定の日付はチェックしない |
|
680 |
if (Target.Date == DateTime.MinValue.Date) continue; |
|
681 |
|
|
682 |
|
|
683 |
// エラーフラグクリア |
|
684 |
bool ErrFlg = false; |
|
685 |
|
|
686 |
switch (wrkCheck.CheckSchdule) |
|
687 |
{ |
|
688 |
case (int)CommonDefine.TermDateCheckTiming.CheckSchdule0: // 前日以前のチェック |
|
689 |
// 今日を基準に経過日を加算して対象日と比較する |
|
690 |
//if (Target.Date == DateTime.Now.AddDays(wrkCheck.TermDays).Date) |
|
691 |
if (Target.Date == CriteriaDate.AddDays(wrkCheck.TermDays).Date) |
|
692 |
{ |
|
693 |
ErrFlg = true; |
|
694 |
} |
|
695 |
break; |
|
696 |
case (int)CommonDefine.TermDateCheckTiming.CheckSchdule1: // 当日のチェック |
|
697 |
// 今日を基準に対象日と比較する |
|
698 |
//if (Target.Date == DateTime.Now.Date) |
|
699 |
if (Target.Date == CriteriaDate.Date) |
|
700 |
{ |
|
701 |
ErrFlg = true; |
|
702 |
} |
|
703 |
break; |
|
704 |
case (int)CommonDefine.TermDateCheckTiming.CheckSchdule2: // 後日以降のチェック |
|
705 |
// 今日を基準に対象日と比較する |
|
706 |
//if (Target.AddDays(wrkCheck.TermDays).Date == DateTime.Now.Date) |
|
707 |
if (Target.AddDays(wrkCheck.TermDays).Date == CriteriaDate.Date) |
|
708 |
{ |
|
709 |
ErrFlg = true; |
|
710 |
} |
|
711 |
break; |
|
712 |
case (int)CommonDefine.TermDateCheckTiming.CheckSchdule3: // 後日以降継続のチェック |
|
713 |
// 今日を基準に経過日が過ぎているとエラー |
|
714 |
//if (Target.AddDays(wrkCheck.TermDays).Date <= DateTime.Now.Date) |
|
715 |
if (Target.AddDays(wrkCheck.TermDays).Date <= CriteriaDate.Date) |
|
716 |
{ |
|
717 |
ErrFlg = true; |
|
718 |
} |
|
719 |
break; |
|
720 |
} |
|
721 |
// チェック項目に該当すればメッセージ・色をセットする |
|
722 |
if (ErrFlg) |
|
723 |
{ |
|
724 |
TermRec.Add(wrkCheck); |
|
725 |
bCheckNoError = false; |
|
726 |
} |
|
727 |
} |
|
728 |
return bCheckNoError; |
|
729 |
} |
|
730 |
catch (Exception ex) |
|
731 |
{ |
|
732 |
logger.ErrorFormat("システムエラー:{0}", ex.Message); |
|
733 |
return false; |
|
734 |
} |
|
735 |
} |
|
736 |
#endregion |
|
737 |
|
|
738 |
#region 掲示板メッセージ作成 |
|
739 |
/// <summary> |
|
740 |
/// メッセージ作成 |
|
741 |
/// </summary> |
|
742 |
private bool MakeMassageData(IOMessageBoardData mbdDB, |
|
743 |
IOMessageBoardTerget mbtDB, |
|
744 |
IOConstructionBaseInfoDetail cbiDB, |
|
745 |
ConstructionBaseInfo wrkRec, TermMaster CheckRec, DateTime CriteriaDate) |
|
746 |
{ |
|
747 |
try |
|
748 |
{ |
|
749 |
// 工事名称・営業担当者・工事担当者取得 |
|
750 |
string strSQL = "SELECT A.DETAILSTRING, B.PERSONCODE SCODE, B.PERSONNAME SNAME, C.PERSONCODE CCODE, C.PERSONNAME CNAME"; |
|
751 |
strSQL += " FROM CONSTRUCTIONBASEINFO P"; |
|
752 |
strSQL += " LEFT JOIN PERSONINCHARGEMASTER B ON B.PERSONCODE = P.SALESPERSONCODE"; |
|
753 |
strSQL += " LEFT JOIN PERSONINCHARGEMASTER C ON C.PERSONCODE = P.CONSTRUCTIONPERSONCODE"; |
|
754 |
strSQL += " , CONSTRUCTIONBASEINFODETAIL A"; |
|
755 |
strSQL += string.Format(" WHERE P.CONSTRUCTIONCODE = {0}",wrkRec.ConstructionCode); |
|
756 |
strSQL += string.Format(" AND A.CONSTRUCTIONCODE = P.CONSTRUCTIONCODE AND A.DETAILNO = {0}", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName); |
|
757 |
ArrayList arList = new ArrayList(); |
|
758 |
if (!cbiDB.ExecuteReader(strSQL, ref arList)) return false; |
|
759 |
|
|
760 |
string DetailString = string.Empty; |
|
761 |
int SalesPersonCode = 0; |
|
762 |
string SalesPersonName = string.Empty; |
|
763 |
int ConstructionPersonCode = 0; |
|
764 |
string ConstructionPersonName = string.Empty; |
|
765 |
foreach (object[] onjwrk in arList) |
|
766 |
{ |
|
767 |
DetailString = CommonMotions.cnvString(onjwrk[0]); |
|
768 |
SalesPersonCode = CommonMotions.cnvInt(onjwrk[1]); |
|
769 |
SalesPersonName = CommonMotions.cnvString(onjwrk[2]); |
|
770 |
ConstructionPersonCode = CommonMotions.cnvInt(onjwrk[3]); |
|
771 |
ConstructionPersonName = CommonMotions.cnvString(onjwrk[4]); |
|
772 |
break; |
|
773 |
} |
|
774 |
|
|
775 |
// 新規メッセージ作成 |
|
776 |
MessageBoardData WriteData = new MessageBoardData(); |
|
777 |
List<MessageBoardTerget> WriteDetail = new List<MessageBoardTerget>(); |
|
778 |
|
|
779 |
// 掲示板メッセージ |
|
780 |
WriteData.FromCode = CommonDefine.s_MsgBoardSystemCode; // 書込み者コード |
|
781 |
WriteData.FromName = string.Format(CommonDefine.s_MsgBoardSystemNameFormat, "秘書"); // 書込み者名 |
|
782 |
|
|
783 |
WriteData.MessageTitle = CheckRec.SendTitle; // 伝言タイトル |
|
784 |
|
|
785 |
// リンク情報 |
|
786 |
WriteData.LinkType = (int)CommonDefine.LinkType.ConstructionInfo; |
|
787 |
WriteData.LinkMessage = string.Format("工事番号:{0} 工事名称:{1}" |
|
788 |
, CommonMotions.cnvStringCodeFromInt(wrkRec.ConstructionCode, "-", 8) |
|
789 |
, DetailString); |
|
790 |
WriteData.LinkCode = string.Format("{0}", CommonMotions.cnvStringCodeFromInt(wrkRec.ConstructionCode, "-", 8)); |
|
791 |
|
|
792 |
// 伝言内容 |
|
793 |
WriteData.MessageContent = CheckRec.SendMessage; |
|
794 |
|
|
795 |
|
|
796 |
//WriteData.WritingDate = DateTime.Now; // 書込み日付 |
|
797 |
WriteData.WritingDate = CriteriaDate.Date + DateTime.Now.TimeOfDay; // 書込み日付 |
|
798 |
WriteData.PersonCode = CommonDefine.s_MsgBoardSystemCode; // 書込み担当者コード |
|
799 |
WriteData.ShareFlag = 1; // 管理者対象フラグ |
|
800 |
|
|
801 |
WriteData.BackColor = CheckRec.BackColor; // 背景色セット |
|
802 |
WriteData.MessageColor = CheckRec.ForeColor; // 背景色セット |
|
803 |
|
|
804 |
// 掲示板対象者テーブル |
|
805 |
MessageBoardTerget DetailTbl = new MessageBoardTerget(); |
|
806 |
DetailTbl.ToCode = SalesPersonCode; // 対象者コード |
|
807 |
DetailTbl.ToName = SalesPersonName; // 対象者 |
|
808 |
if (ConstructionPersonCode != 0) |
|
809 |
{ |
|
810 |
DetailTbl.ToCode = ConstructionPersonCode; // 対象者コード |
|
811 |
DetailTbl.ToName = ConstructionPersonName; // 対象者 |
|
812 |
} |
|
813 |
WriteDetail.Add(DetailTbl); |
|
814 |
|
|
815 |
// メッセージフラグを自動に設定する |
|
816 |
WriteData.MessageFlag = (int)CommonDefine.MessageFlg.Secretary; |
|
817 |
|
|
818 |
// 掲示板へメッセージを載せる |
|
819 |
if (!ClsMessageBoradAccess.CreateMessage(mbdDB, mbtDB, WriteData, WriteDetail)) return false; |
|
820 |
|
|
821 |
return true; |
|
822 |
} |
|
823 |
catch (Exception ex) |
|
824 |
{ |
|
825 |
logger.ErrorFormat("システムエラー:{0}", ex.Message); |
|
826 |
return false; |
|
827 |
} |
|
828 |
} |
|
829 |
#endregion |
|
830 |
|
|
831 |
#region 見積有効期限が経過したデータを非受注へ変更する |
|
832 |
/// <summary> |
|
833 |
/// 見積有効期限が経過したデータを非受注へ変更する |
|
834 |
/// </summary> |
|
835 |
private bool ChangeNonOrdersData() |
|
836 |
{ |
|
837 |
IOConstructionBaseInfo BaseDB = new IOConstructionBaseInfo(); |
|
838 |
IOConstructionBaseInfoDetail DetailDB = new IOConstructionBaseInfoDetail(); |
|
839 |
try |
|
840 |
{ |
|
841 |
int iCode1 = CommonDefine.ProjectsStatus.First(x => x.Value.Equals("非 受 注")).Key; |
|
842 |
int iCode2 = CommonDefine.ProjectsStatus.First(x => x.Value.Equals("依頼受け中")).Key; |
|
843 |
int iCode3 = CommonDefine.ProjectsStatus.First(x => x.Value.Equals("見積提出")).Key; |
|
844 |
|
|
845 |
// 対象データが存在するかを確認する |
|
846 |
string strSQL = "SELECT A.CONSTRUCTIONCODE, B.DETAILSTRING FROM CONSTRUCTIONBASEINFO A"; |
|
847 |
strSQL += " LEFT JOIN CONSTRUCTIONBASEINFODETAIL B ON B.CONSTRUCTIONCODE = A.CONSTRUCTIONCODE"; |
|
848 |
strSQL += string.Format(" AND B.DETAILNO = {0}", (int)ConstructionBaseInfoDetail.DetailDataNo.OrdersDecisionComment); |
|
849 |
|
|
850 |
string strWHERE = " WHERE DATE(A.ESTIMATESSUBMITTEDDATE) != STR_TO_DATE('0001/01/01', '%Y/%m/%d')"; |
|
851 |
strWHERE += string.Format(" AND DATE(DATE_ADD(ESTIMATESSUBMITTEDDATE, INTERVAL '{0}' DAY))", s_NonOrderDay); |
|
852 |
strWHERE += string.Format(" < STR_TO_DATE('{0}','%Y/%m/%d')", DateTime.Now.ToShortDateString()); |
|
853 |
strWHERE += string.Format(" AND A.CONSTRUCTIONSTATUSFLG IN({0}, {1})", iCode2, iCode3); |
|
854 |
strWHERE += string.Format(" AND A.ESTIMATETYPE IN ({0}, {1})", (int)CommonDefine.BaseInfoEstimateType.Normal, (int)CommonDefine.BaseInfoEstimateType.GetBudget); |
|
855 |
strSQL += strWHERE; |
|
856 |
ArrayList arList = new ArrayList(); |
|
857 |
if (!BaseDB.ExecuteReader(strSQL, ref arList)) |
|
858 |
{ |
|
859 |
logger.ErrorFormat("工事基本情報読込エラー 非受注案件移行処理失敗:{0}:{1}", CommonMotions.GetMethodName(), strSQL); |
|
860 |
return false; |
|
861 |
} |
|
862 |
// ----- 対象データが存在しなければ抜ける |
|
863 |
if (arList.Count == 0) return true; |
|
864 |
|
|
865 |
// ----- 対象データが存在すれば更新する |
|
866 |
BaseDB.connect(); BaseDB.beginTran(); |
|
867 |
DetailDB.connect(); DetailDB.beginTran(); |
|
868 |
|
|
869 |
// 工事基本情報データ |
|
870 |
strSQL = string.Format("UPDATE CONSTRUCTIONBASEINFO A SET A.CONSTRUCTIONSTATUSFLG = {0},", iCode1); |
|
871 |
strSQL += string.Format(" A.NONORDERDATE = STR_TO_DATE('{0}','%Y/%m/%d')", DateTime.Today.ToShortDateString()); |
|
872 |
strSQL += strWHERE; |
他の形式にエクスポート: Unified diff