299 |
299 |
}
|
300 |
300 |
#endregion
|
301 |
301 |
|
|
302 |
#region グリッド空行チェック
|
|
303 |
/// <summary>
|
|
304 |
/// グリッド空行チェック
|
|
305 |
/// </summary>
|
|
306 |
/// <param name="row"></param>
|
|
307 |
/// <returns></returns>
|
|
308 |
private bool BlanckRowCheck(DataGridViewRow row)
|
|
309 |
{
|
|
310 |
try
|
|
311 |
{
|
|
312 |
// 空欄チェック
|
|
313 |
if (CommonMotions.chkObjectIsNull(row.Cells[(int)DispGridColumn.ConstructionCode].Value)) return false;
|
|
314 |
if (CommonMotions.cnvString(row.Cells[(int)DispGridColumn.ConstructionName].Value).Length == 0) return false;
|
|
315 |
|
|
316 |
return true;
|
|
317 |
}
|
|
318 |
catch (Exception ex)
|
|
319 |
{
|
|
320 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
321 |
return false;
|
|
322 |
}
|
|
323 |
}
|
|
324 |
#endregion
|
|
325 |
|
302 |
326 |
#region 選択データセット処理
|
303 |
327 |
/// <summary>
|
304 |
328 |
/// 選択データセット処理
|
... | ... | |
365 |
389 |
dgvMaster.Rows.Clear();
|
366 |
390 |
|
367 |
391 |
StringBuilder strSQL = new StringBuilder();
|
368 |
|
// string strSQL = string.Empty;
|
369 |
392 |
|
370 |
|
//// if (m_ProcessNo == (int)ClsExcute.ProcessExecuteNo.TAndPCosts) Del BIT 2017/02/22
|
371 |
|
if (m_SelectType == (int)SelectConstructionType.Ongoing) // 検索タイプが進行中 Add BIT 2017/02/22
|
372 |
|
{ // ----- 購入品選択の場合
|
373 |
|
// 進行中案件を検索する
|
374 |
|
strSQL.Append("SELECT A.CONSTRUCTIONCODE, B.DETAILSTRING");
|
375 |
|
strSQL.Append(" FROM CONSTRUCTIONBASEINFO A, CONSTRUCTIONBASEINFODETAIL B, CONSTRUCTIONLEDGER C");
|
376 |
|
strSQL.AppendFormat(" WHERE (A.CONSTRUCTIONCODE = B.CONSTRUCTIONCODE AND B.DETAILNO = {0})", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName);
|
377 |
|
strSQL.Append(" AND A.CONSTRUCTIONCODE = C.CONSTRUCTIONCODE AND C.COMPLATEFLG = 0");
|
|
393 |
switch (m_SelectType)
|
|
394 |
{
|
|
395 |
case (int)SelectConstructionType.Ongoing: // 検索タイプが進行中 Add BIT 2017/02/22
|
|
396 |
// 進行中案件を検索する
|
|
397 |
SetSelectTypeOngoing(ref strSQL);
|
|
398 |
break;
|
|
399 |
case (int)SelectConstructionType.CombinedOrder: // 検索タイプが一括請求 Add BIT 2017/02/22
|
|
400 |
// ----- 請求入力(一括請求)の場合
|
|
401 |
SetSelectTypeCombinedOrder(ref strSQL);
|
|
402 |
break;
|
378 |
403 |
|
379 |
|
switch (m_PersonCharge)
|
380 |
|
{
|
381 |
|
case (int)PersonChargePoint.Sales:
|
382 |
|
/// 営業担当検索
|
383 |
|
strSQL.AppendFormat(" AND A.SalesPersonCode = {0}", m_PersonCode);
|
384 |
|
break;
|
385 |
|
case (int)PersonChargePoint.Construction:
|
386 |
|
/// 工事担当者
|
387 |
|
strSQL.AppendFormat(" AND (A.ConstructionPersonCode = {0} OR A.ConstrSubPersonCode = {0} OR A.ConstructionInstructor = {0})", m_PersonCode);
|
388 |
|
break;
|
389 |
|
}
|
390 |
|
strSQL.Append(" ORDER BY A.ConstructionPeriodStart DESC");
|
391 |
|
}
|
392 |
|
else if (m_SelectType == (int)SelectConstructionType.CombinedOrder) // 検索タイプが一括請求 Add BIT 2017/02/22
|
393 |
|
{ // ----- 請求入力(一括請求)の場合
|
394 |
|
// 進行中+一括請求を検索する
|
395 |
|
strSQL.Append("SELECT");
|
396 |
|
strSQL.Append(" UNI.CONSTRUCTIONCODE");
|
397 |
|
strSQL.Append(" , UNI.DETAILSTRING");
|
398 |
|
strSQL.Append(" FROM (");
|
399 |
|
strSQL.Append(" SELECT");
|
400 |
|
strSQL.Append(" A1.CONSTRUCTIONCODE AS CONSTRUCTIONCODE");
|
401 |
|
strSQL.Append(" , B1.DETAILSTRING AS DETAILSTRING");
|
402 |
|
strSQL.Append(" , A1.CONSTRUCTIONPERIODSTART AS CONSTRUCTIONPERIODSTART");
|
403 |
|
strSQL.Append(" FROM");
|
404 |
|
strSQL.Append(" CONSTRUCTIONBASEINFO A1");
|
405 |
|
strSQL.Append(" INNER JOIN CONSTRUCTIONBASEINFODETAIL B1 ON ");
|
406 |
|
strSQL.Append(" A1.CONSTRUCTIONCODE = B1.CONSTRUCTIONCODE");
|
407 |
|
strSQL.AppendFormat(" AND B1.DETAILNO = {0}", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName);
|
408 |
|
strSQL.Append(" INNER JOIN CONSTRUCTIONLEDGER C1 ON ");
|
409 |
|
strSQL.Append(" A1.CONSTRUCTIONCODE = C1.CONSTRUCTIONCODE");
|
410 |
|
strSQL.Append(" AND C1.COMPLATEFLG = 0 ");
|
411 |
|
strSQL.Append(" WHERE ");
|
412 |
|
strSQL.AppendFormat(" A1.BILLINGSPLITFLG = {0}", (int)CommonDefine.BaseInfoBillingSplitFlg.AllOnBilling);
|
413 |
|
strSQL.AppendFormat(" AND A1.JOINFLG <> {0}", (int)CommonDefine.BaseInfoJoinFlg.JoinChildren);
|
|
404 |
case (int)SelectConstructionType.SeparateBilling: // 検索タイプが分割請求 Add BIT 2017/02/22
|
|
405 |
// ----- 請求入力(分割請求)の場合
|
|
406 |
SetSelectTypeSeparateBilling(ref strSQL);
|
|
407 |
break;
|
414 |
408 |
|
415 |
|
switch (m_PersonCharge)
|
416 |
|
{
|
417 |
|
case (int)PersonChargePoint.Sales:
|
418 |
|
/// 営業担当検索
|
419 |
|
strSQL.AppendFormat(" AND A1.SALESPERSONCODE = {0}", m_PersonCode);
|
420 |
|
break;
|
421 |
|
case (int)PersonChargePoint.Construction:
|
422 |
|
/// 工事担当者
|
423 |
|
strSQL.AppendFormat(" AND (A1.CONSTRUCTIONPERSONCODE = {0} OR A1.CONSTRSUBPERSONCODE = {0} OR A1.CONSTRUCTIONINSTRUCTOR = {0})", m_PersonCode);
|
424 |
|
break;
|
425 |
|
}
|
426 |
|
|
427 |
|
strSQL.Append(" UNION ALL");
|
428 |
|
strSQL.Append(" SELECT");
|
429 |
|
strSQL.Append(" A2.CONSTRUCTIONCODE AS CONSTRUCTIONCODE");
|
430 |
|
strSQL.Append(" , B2.DETAILSTRING AS DETAILSTRING");
|
431 |
|
strSQL.Append(" , A2.CONSTRUCTIONPERIODSTART AS CONSTRUCTIONPERIODSTART");
|
432 |
|
strSQL.Append(" FROM");
|
433 |
|
strSQL.Append(" CONSTRUCTIONBASEINFO A2");
|
434 |
|
strSQL.Append(" INNER JOIN CONSTRUCTIONBASEINFODETAIL B2 ON ");
|
435 |
|
strSQL.Append(" A2.CONSTRUCTIONCODE = B2.CONSTRUCTIONCODE");
|
436 |
|
strSQL.AppendFormat(" AND B2.DETAILNO = {0}", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName);
|
437 |
|
strSQL.Append(" INNER JOIN CONSTRUCTIONLINK D2 ON ");
|
438 |
|
strSQL.Append(" A2.CONSTRUCTIONCODE = D2.FLUCTUATIONCODE");
|
439 |
|
strSQL.AppendFormat(" AND D2.LINKTYPE = {0}",(int)CommonDefine.LinkDataType.JoinType);
|
440 |
|
strSQL.Append(" INNER JOIN CONSTRUCTIONLEDGER C2 ON ");
|
441 |
|
strSQL.Append(" D2.CONSTRUCTIONCODE = C2.CONSTRUCTIONCODE");
|
442 |
|
strSQL.Append(" AND C2.COMPLATEFLG = 0 ");
|
443 |
|
strSQL.Append(" WHERE ");
|
444 |
|
strSQL.AppendFormat(" A2.BILLINGSPLITFLG = {0}", (int)CommonDefine.BaseInfoBillingSplitFlg.AllOnBilling);
|
445 |
|
strSQL.AppendFormat(" AND A2.JOINFLG = {0}", (int)CommonDefine.BaseInfoJoinFlg.JoinChildren);
|
446 |
|
|
447 |
|
switch (m_PersonCharge)
|
448 |
|
{
|
449 |
|
case (int)PersonChargePoint.Sales:
|
450 |
|
/// 営業担当検索
|
451 |
|
strSQL.AppendFormat(" AND A2.SALESPERSONCODE = {0}", m_PersonCode);
|
452 |
|
break;
|
453 |
|
case (int)PersonChargePoint.Construction:
|
454 |
|
/// 工事担当者
|
455 |
|
strSQL.AppendFormat(" AND (A2.CONSTRUCTIONPERSONCODE = {0} OR A2.CONSTRSUBPERSONCODE = {0} OR A2.CONSTRUCTIONINSTRUCTOR = {0})", m_PersonCode);
|
456 |
|
break;
|
457 |
|
}
|
458 |
|
strSQL.Append(" ) UNI ORDER BY UNI.CONSTRUCTIONPERIODSTART DESC");
|
459 |
|
|
|
409 |
case (int)SelectConstructionType.All: // 結合工事検索
|
|
410 |
// ----- 工事結合の場合
|
|
411 |
// 対象全ての案件を検索する
|
|
412 |
SetSelectTypeAll(ref strSQL);
|
|
413 |
break;
|
460 |
414 |
}
|
461 |
|
else if (m_SelectType == (int)SelectConstructionType.SeparateBilling) // 検索タイプが分割請求 Add BIT 2017/02/22
|
462 |
|
{ // ----- 請求入力(分割請求)の場合
|
463 |
|
// 進行中+分割請求を検索する
|
464 |
|
strSQL.Append("SELECT");
|
465 |
|
strSQL.Append(" UNI.CONSTRUCTIONCODE");
|
466 |
|
strSQL.Append(" , UNI.DETAILSTRING");
|
467 |
|
strSQL.Append(" FROM (");
|
468 |
|
strSQL.Append(" SELECT");
|
469 |
|
strSQL.Append(" A1.CONSTRUCTIONCODE AS CONSTRUCTIONCODE");
|
470 |
|
strSQL.Append(" , B1.DETAILSTRING AS DETAILSTRING");
|
471 |
|
strSQL.Append(" , A1.CONSTRUCTIONPERIODSTART AS CONSTRUCTIONPERIODSTART");
|
472 |
|
strSQL.Append(" FROM");
|
473 |
|
strSQL.Append(" CONSTRUCTIONBASEINFO A1");
|
474 |
|
strSQL.Append(" INNER JOIN CONSTRUCTIONBASEINFODETAIL B1 ON ");
|
475 |
|
strSQL.Append(" A1.CONSTRUCTIONCODE = B1.CONSTRUCTIONCODE");
|
476 |
|
strSQL.AppendFormat(" AND B1.DETAILNO = {0}", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName);
|
477 |
|
strSQL.Append(" INNER JOIN CONSTRUCTIONLEDGER C1 ON ");
|
478 |
|
strSQL.Append(" A1.CONSTRUCTIONCODE = C1.CONSTRUCTIONCODE");
|
479 |
|
strSQL.Append(" AND C1.COMPLATEFLG = 0 ");
|
480 |
|
strSQL.Append(" WHERE ");
|
481 |
|
strSQL.AppendFormat(" A1.BILLINGSPLITFLG = {0}", (int)CommonDefine.BaseInfoBillingSplitFlg.SplitBilling);
|
482 |
|
strSQL.AppendFormat(" AND A1.JOINFLG <> {0}", (int)CommonDefine.BaseInfoJoinFlg.JoinChildren);
|
483 |
415 |
|
484 |
|
switch (m_PersonCharge)
|
485 |
|
{
|
486 |
|
case (int)PersonChargePoint.Sales:
|
487 |
|
/// 営業担当検索
|
488 |
|
strSQL.AppendFormat(" AND A1.SALESPERSONCODE = {0}", m_PersonCode);
|
489 |
|
break;
|
490 |
|
case (int)PersonChargePoint.Construction:
|
491 |
|
/// 工事担当者
|
492 |
|
strSQL.AppendFormat(" AND (A1.CONSTRUCTIONPERSONCODE = {0} OR A1.CONSTRSUBPERSONCODE = {0} OR A1.CONSTRUCTIONINSTRUCTOR = {0})", m_PersonCode);
|
493 |
|
break;
|
494 |
|
}
|
495 |
|
|
496 |
|
strSQL.Append(" UNION ALL");
|
497 |
|
strSQL.Append(" SELECT");
|
498 |
|
strSQL.Append(" A2.CONSTRUCTIONCODE AS CONSTRUCTIONCODE");
|
499 |
|
strSQL.Append(" , B2.DETAILSTRING AS DETAILSTRING");
|
500 |
|
strSQL.Append(" , A2.CONSTRUCTIONPERIODSTART AS CONSTRUCTIONPERIODSTART");
|
501 |
|
strSQL.Append(" FROM");
|
502 |
|
strSQL.Append(" CONSTRUCTIONBASEINFO A2");
|
503 |
|
strSQL.Append(" INNER JOIN CONSTRUCTIONBASEINFODETAIL B2 ON ");
|
504 |
|
strSQL.Append(" A2.CONSTRUCTIONCODE = B2.CONSTRUCTIONCODE");
|
505 |
|
strSQL.AppendFormat(" AND B2.DETAILNO = {0}", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName);
|
506 |
|
strSQL.Append(" INNER JOIN CONSTRUCTIONLINK D2 ON ");
|
507 |
|
strSQL.Append(" A2.CONSTRUCTIONCODE = D2.FLUCTUATIONCODE");
|
508 |
|
strSQL.AppendFormat(" AND D2.LINKTYPE = {0}", (int)CommonDefine.LinkDataType.JoinType);
|
509 |
|
strSQL.Append(" INNER JOIN CONSTRUCTIONLEDGER C2 ON ");
|
510 |
|
strSQL.Append(" D2.CONSTRUCTIONCODE = C2.CONSTRUCTIONCODE");
|
511 |
|
strSQL.Append(" AND C2.COMPLATEFLG = 0 ");
|
512 |
|
strSQL.Append(" WHERE ");
|
513 |
|
strSQL.AppendFormat(" A2.BILLINGSPLITFLG = {0}", (int)CommonDefine.BaseInfoBillingSplitFlg.SplitBilling);
|
514 |
|
strSQL.AppendFormat(" AND A2.JOINFLG = {0}", (int)CommonDefine.BaseInfoJoinFlg.JoinChildren);
|
515 |
|
|
516 |
|
switch (m_PersonCharge)
|
517 |
|
{
|
518 |
|
case (int)PersonChargePoint.Sales:
|
519 |
|
/// 営業担当検索
|
520 |
|
strSQL.AppendFormat(" AND A2.SALESPERSONCODE = {0}", m_PersonCode);
|
521 |
|
break;
|
522 |
|
case (int)PersonChargePoint.Construction:
|
523 |
|
/// 工事担当者
|
524 |
|
strSQL.AppendFormat(" AND (A2.CONSTRUCTIONPERSONCODE = {0} OR A2.CONSTRSUBPERSONCODE = {0} OR A2.CONSTRUCTIONINSTRUCTOR = {0})", m_PersonCode);
|
525 |
|
break;
|
526 |
|
}
|
527 |
|
strSQL.Append(" ) UNI ORDER BY UNI.CONSTRUCTIONPERIODSTART DESC");
|
528 |
|
}
|
529 |
|
///// else if (m_ProcessNo == (int)ClsExcute.ProcessExecuteNo.OrderJoin) Del BIT 2017/02/22
|
530 |
|
//else // Add BIT 2017/02/22
|
531 |
|
//{ // ※※※※※なぜ検索条件が違うSQLを一つにしたのか? 2017/05/13
|
532 |
|
// // 対象全ての案件を検索する
|
533 |
|
// strSQL.Append("SELECT DISTINCT A.CONSTRUCTIONCODE, B.DETAILSTRING, A.OrderersDivision, A.OrderersCode");
|
534 |
|
// strSQL.Append(" FROM CONSTRUCTIONBASEINFO A, CONSTRUCTIONBASEINFODETAIL B, PERSONINCHARGEMASTER C");
|
535 |
|
// strSQL.AppendFormat(" WHERE (A.CONSTRUCTIONCODE = B.CONSTRUCTIONCODE AND B.DETAILNO = {0})", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName);
|
536 |
|
// strSQL.AppendFormat(" AND A.JOINFLG = {0} ", (int)CommonDefine.BaseInfoJoinFlg.JoinParent);
|
537 |
|
// switch (m_PersonCharge)
|
538 |
|
// {
|
539 |
|
// case (int)PersonChargePoint.Sales:
|
540 |
|
// /// 営業担当検索
|
541 |
|
// strSQL.AppendFormat(" AND A.SALESPERSONCODE = {0}", m_PersonCode);
|
542 |
|
// break;
|
543 |
|
// case (int)PersonChargePoint.Construction:
|
544 |
|
// /// 工事担当者
|
545 |
|
// strSQL.AppendFormat(" AND (A.CONSTRUCTIONPERSONCODE = {0} OR A.CONSTRSUBPERSONCODE = {0} OR A.CONSTRUCTIONINSTRUCTOR = {0})", m_PersonCode);
|
546 |
|
// break;
|
547 |
|
// }
|
548 |
|
// strSQL.Append(" AND (C.PERSONCODE = A.SALESPERSONCODE");
|
549 |
|
// strSQL.Append(" OR C.PERSONCODE = A.CONSTRUCTIONPERSONCODE");
|
550 |
|
// strSQL.Append(" OR C.PERSONCODE = A.CONSTRSUBPERSONCODE");
|
551 |
|
// strSQL.Append(" OR C.PERSONCODE = A.CONSTRUCTIONINSTRUCTOR)");
|
552 |
|
// strSQL.Append(" ORDER BY B.DETAILSTRING ASC, A.CONSTRUCTIONCODE DESC");
|
553 |
|
//}
|
554 |
|
else if (m_ProcessNo == (int)ClsExcute.ProcessExecuteNo.TAndPCosts)
|
555 |
|
{ // ----- 購入品選択の場合
|
556 |
|
// 進行中案件を検索する
|
557 |
|
strSQL.Append("SELECT A.CONSTRUCTIONCODE, B.DETAILSTRING");
|
558 |
|
strSQL.Append(" FROM CONSTRUCTIONBASEINFO A, CONSTRUCTIONBASEINFODETAIL B, CONSTRUCTIONLEDGER C");
|
559 |
|
strSQL.AppendFormat(" WHERE (A.CONSTRUCTIONCODE = B.CONSTRUCTIONCODE AND B.DETAILNO = {0})", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName);
|
560 |
|
strSQL.Append(" AND A.CONSTRUCTIONCODE = C.CONSTRUCTIONCODE AND C.COMPLATEFLG = 0");
|
561 |
|
|
562 |
|
switch (m_PersonCharge)
|
563 |
|
{
|
564 |
|
case (int)PersonChargePoint.Sales:
|
565 |
|
/// 営業担当検索
|
566 |
|
strSQL.AppendFormat(" AND A.SalesPersonCode = {0}", m_PersonCode);
|
567 |
|
break;
|
568 |
|
case (int)PersonChargePoint.Construction:
|
569 |
|
/// 工事担当者
|
570 |
|
strSQL.AppendFormat(" AND (A.ConstructionPersonCode = {0} OR A.ConstrSubPersonCode = {0} OR A.ConstructionInstructor = {0})", m_PersonCode);
|
571 |
|
break;
|
572 |
|
}
|
573 |
|
strSQL.Append(" ORDER BY A.ConstructionPeriodStart DESC");
|
574 |
|
}
|
575 |
|
else if (m_ProcessNo == (int)ClsExcute.ProcessExecuteNo.OrderJoin)
|
576 |
|
{ // ----- 工事結合の場合
|
577 |
|
// 対象全ての案件を検索する
|
578 |
|
strSQL.Append("SELECT DISTINCT A.CONSTRUCTIONCODE, B.DETAILSTRING, A.OrderersDivision, A.OrderersCode");
|
579 |
|
strSQL.Append(" FROM CONSTRUCTIONBASEINFO A, CONSTRUCTIONBASEINFODETAIL B, PERSONINCHARGEMASTER C");
|
580 |
|
strSQL.AppendFormat(" WHERE (A.CONSTRUCTIONCODE = B.CONSTRUCTIONCODE AND B.DETAILNO = {0})", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName);
|
581 |
|
strSQL.AppendFormat(" AND A.JOINFLG = {0} ", (int)CommonDefine.BaseInfoJoinFlg.JoinParent);
|
582 |
|
switch (m_PersonCharge)
|
583 |
|
{
|
584 |
|
case (int)PersonChargePoint.Sales:
|
585 |
|
/// 営業担当検索
|
586 |
|
strSQL.AppendFormat(" AND A.SalesPersonCode = {0}", m_PersonCode);
|
587 |
|
break;
|
588 |
|
case (int)PersonChargePoint.Construction:
|
589 |
|
/// 工事担当者
|
590 |
|
strSQL.AppendFormat(" AND (A.ConstructionPersonCode = {0} OR A.ConstrSubPersonCode = {0} OR A.ConstructionInstructor = {0})", m_PersonCode);
|
591 |
|
break;
|
592 |
|
}
|
593 |
|
strSQL.Append(" AND (C.PERSONCODE = A.SALESPERSONCODE");
|
594 |
|
strSQL.Append(" Or C.PERSONCODE = A.CONSTRUCTIONPERSONCODE");
|
595 |
|
strSQL.Append(" Or C.PERSONCODE = A.CONSTRSUBPERSONCODE");
|
596 |
|
strSQL.Append(" Or C.PERSONCODE = A.CONSTRUCTIONINSTRUCTOR)");
|
597 |
|
strSQL.Append(" ORDER BY B.DETAILSTRING ASC, A.CONSTRUCTIONCODE DESC");
|
598 |
|
}
|
599 |
|
|
600 |
416 |
ArrayList BaseList = new ArrayList();
|
601 |
417 |
if (!BaseDB.ExecuteReader(strSQL.ToString(), ref BaseList)) return;
|
602 |
418 |
if (BaseList.Count == 0) return;
|
... | ... | |
621 |
437 |
dgvMaster.Rows.Add((i + 1),
|
622 |
438 |
EditConstructionCode,
|
623 |
439 |
CommonMotions.cnvString(wrk[1]),
|
|
440 |
CommonMotions.cnvString(wrk[4]),
|
624 |
441 |
ConstructionCode,
|
625 |
442 |
iData[0],
|
626 |
443 |
iData[1]);
|
... | ... | |
635 |
452 |
{
|
636 |
453 |
BaseDB.close(); BaseDB = null;
|
637 |
454 |
dgvMaster.RowCount += (CommonDefine.s_MaxInitLineCount - dgvMaster.Rows.Count);
|
|
455 |
}
|
|
456 |
}
|
|
457 |
#endregion
|
638 |
458 |
|
|
459 |
#region 進行中(購入品選択、資材貸出、資材返却)SQL作成
|
|
460 |
/// <summary>
|
|
461 |
/// 進行中(購入品選択、資材貸出、資材返却)SQL作成
|
|
462 |
/// </summary>
|
|
463 |
/// <param name="strSQL"></param>
|
|
464 |
private void SetSelectTypeOngoing(ref StringBuilder strSQL)
|
|
465 |
{
|
|
466 |
try
|
|
467 |
{
|
|
468 |
// 進行中案件を検索する
|
|
469 |
strSQL.Append("SELECT A.CONSTRUCTIONCODE, B.DETAILSTRING, '', '' , D.PERSONNAME");
|
|
470 |
strSQL.Append(" FROM CONSTRUCTIONBASEINFO A, CONSTRUCTIONBASEINFODETAIL B, CONSTRUCTIONLEDGER C, PERSONINCHARGEMASTER D");
|
|
471 |
strSQL.AppendFormat(" WHERE (A.CONSTRUCTIONCODE = B.CONSTRUCTIONCODE AND B.DETAILNO = {0})", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName);
|
|
472 |
strSQL.Append(" AND A.CONSTRUCTIONCODE = C.CONSTRUCTIONCODE AND C.COMPLATEFLG = 0");
|
|
473 |
|
|
474 |
switch (m_PersonCharge)
|
|
475 |
{
|
|
476 |
case (int)PersonChargePoint.Sales:
|
|
477 |
/// 営業担当検索
|
|
478 |
strSQL.AppendFormat(" AND A.SalesPersonCode = {0}", m_PersonCode);
|
|
479 |
break;
|
|
480 |
case (int)PersonChargePoint.Construction:
|
|
481 |
/// 工事担当者
|
|
482 |
strSQL.AppendFormat(" AND (A.ConstructionPersonCode = {0} OR A.ConstrSubPersonCode = {0} OR A.ConstructionInstructor = {0})", m_PersonCode);
|
|
483 |
break;
|
|
484 |
}
|
|
485 |
strSQL.Append(" AND D.PERSONCODE = A.ConstructionPersonCode");
|
|
486 |
|
|
487 |
strSQL.Append(" ORDER BY A.ConstructionPeriodStart DESC");
|
639 |
488 |
}
|
|
489 |
catch (Exception ex)
|
|
490 |
{
|
|
491 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
492 |
}
|
640 |
493 |
}
|
|
494 |
#endregion
|
|
495 |
|
|
496 |
#region 請求入力(一括請求)SQL作成
|
641 |
497 |
/// <summary>
|
642 |
|
/// グリッド空行チェック
|
|
498 |
/// 請求入力(一括請求)SQL作成
|
643 |
499 |
/// </summary>
|
644 |
|
/// <param name="row"></param>
|
645 |
|
/// <returns></returns>
|
646 |
|
private bool BlanckRowCheck(DataGridViewRow row)
|
|
500 |
/// <param name="strSQL"></param>
|
|
501 |
private void SetSelectTypeCombinedOrder(ref StringBuilder strSQL)
|
647 |
502 |
{
|
648 |
503 |
try
|
649 |
504 |
{
|
650 |
|
// 空欄チェック
|
651 |
|
if (CommonMotions.chkObjectIsNull(row.Cells[(int)DispGridColumn.ConstructionCode].Value)) return false;
|
652 |
|
if (CommonMotions.cnvString(row.Cells[(int)DispGridColumn.ConstructionName].Value).Length == 0) return false;
|
|
505 |
// 進行中+一括請求を検索する
|
|
506 |
strSQL.Append("SELECT");
|
|
507 |
strSQL.Append(" UNI.CONSTRUCTIONCODE");
|
|
508 |
strSQL.Append(" , UNI.DETAILSTRING");
|
|
509 |
strSQL.Append(" , '', '', UNI.PERSONNAME");
|
|
510 |
strSQL.Append(" FROM (");
|
|
511 |
strSQL.Append(" SELECT");
|
|
512 |
strSQL.Append(" A1.CONSTRUCTIONCODE AS CONSTRUCTIONCODE");
|
|
513 |
strSQL.Append(" , B1.DETAILSTRING AS DETAILSTRING");
|
|
514 |
strSQL.Append(" , A1.CONSTRUCTIONPERIODSTART AS CONSTRUCTIONPERIODSTART");
|
|
515 |
strSQL.Append(" , P1.PERSONNAME AS PERSONNAME");
|
|
516 |
strSQL.Append(" FROM");
|
|
517 |
strSQL.Append(" CONSTRUCTIONBASEINFO A1");
|
|
518 |
strSQL.Append(" INNER JOIN CONSTRUCTIONBASEINFODETAIL B1 ON ");
|
|
519 |
strSQL.Append(" A1.CONSTRUCTIONCODE = B1.CONSTRUCTIONCODE");
|
|
520 |
strSQL.AppendFormat(" AND B1.DETAILNO = {0}", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName);
|
|
521 |
strSQL.Append(" INNER JOIN CONSTRUCTIONLEDGER C1 ON ");
|
|
522 |
strSQL.Append(" A1.CONSTRUCTIONCODE = C1.CONSTRUCTIONCODE");
|
|
523 |
strSQL.Append(" AND C1.COMPLATEFLG = 0 ");
|
|
524 |
strSQL.Append(" LEFT JOIN PERSONINCHARGEMASTER P1 ON P1.PERSONCODE = A1.CONSTRUCTIONPERSONCODE");
|
|
525 |
strSQL.Append(" WHERE ");
|
|
526 |
strSQL.AppendFormat(" A1.BILLINGSPLITFLG = {0}", (int)CommonDefine.BaseInfoBillingSplitFlg.AllOnBilling);
|
|
527 |
strSQL.AppendFormat(" AND A1.JOINFLG <> {0}", (int)CommonDefine.BaseInfoJoinFlg.JoinChildren);
|
653 |
528 |
|
654 |
|
return true;
|
|
529 |
switch (m_PersonCharge)
|
|
530 |
{
|
|
531 |
case (int)PersonChargePoint.Sales:
|
|
532 |
/// 営業担当検索
|
|
533 |
strSQL.AppendFormat(" AND A1.SALESPERSONCODE = {0}", m_PersonCode);
|
|
534 |
break;
|
|
535 |
case (int)PersonChargePoint.Construction:
|
|
536 |
/// 工事担当者
|
|
537 |
strSQL.AppendFormat(" AND (A1.CONSTRUCTIONPERSONCODE = {0} OR A1.CONSTRSUBPERSONCODE = {0} OR A1.CONSTRUCTIONINSTRUCTOR = {0})", m_PersonCode);
|
|
538 |
break;
|
|
539 |
}
|
|
540 |
|
|
541 |
strSQL.Append(" UNION ALL");
|
|
542 |
strSQL.Append(" SELECT");
|
|
543 |
strSQL.Append(" A2.CONSTRUCTIONCODE AS CONSTRUCTIONCODE");
|
|
544 |
strSQL.Append(" , B2.DETAILSTRING AS DETAILSTRING");
|
|
545 |
strSQL.Append(" , A2.CONSTRUCTIONPERIODSTART AS CONSTRUCTIONPERIODSTART");
|
|
546 |
strSQL.Append(" , P2.PERSONNAME AS PERSONNAME");
|
|
547 |
strSQL.Append(" FROM");
|
|
548 |
strSQL.Append(" CONSTRUCTIONBASEINFO A2");
|
|
549 |
strSQL.Append(" INNER JOIN CONSTRUCTIONBASEINFODETAIL B2 ON ");
|
|
550 |
strSQL.Append(" A2.CONSTRUCTIONCODE = B2.CONSTRUCTIONCODE");
|
|
551 |
strSQL.AppendFormat(" AND B2.DETAILNO = {0}", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName);
|
|
552 |
strSQL.Append(" INNER JOIN CONSTRUCTIONLINK D2 ON ");
|
|
553 |
strSQL.Append(" A2.CONSTRUCTIONCODE = D2.FLUCTUATIONCODE");
|
|
554 |
strSQL.AppendFormat(" AND D2.LINKTYPE = {0}", (int)CommonDefine.LinkDataType.JoinType);
|
|
555 |
strSQL.Append(" INNER JOIN CONSTRUCTIONLEDGER C2 ON ");
|
|
556 |
strSQL.Append(" D2.CONSTRUCTIONCODE = C2.CONSTRUCTIONCODE");
|
|
557 |
strSQL.Append(" AND C2.COMPLATEFLG = 0 ");
|
|
558 |
strSQL.Append(" LEFT JOIN PERSONINCHARGEMASTER P2 ON P2.PERSONCODE = A2.CONSTRUCTIONPERSONCODE");
|
|
559 |
strSQL.Append(" WHERE ");
|
|
560 |
strSQL.AppendFormat(" A2.BILLINGSPLITFLG = {0}", (int)CommonDefine.BaseInfoBillingSplitFlg.AllOnBilling);
|
|
561 |
strSQL.AppendFormat(" AND A2.JOINFLG = {0}", (int)CommonDefine.BaseInfoJoinFlg.JoinChildren);
|
|
562 |
|
|
563 |
switch (m_PersonCharge)
|
|
564 |
{
|
|
565 |
case (int)PersonChargePoint.Sales:
|
|
566 |
/// 営業担当検索
|
|
567 |
strSQL.AppendFormat(" AND A2.SALESPERSONCODE = {0}", m_PersonCode);
|
|
568 |
break;
|
|
569 |
case (int)PersonChargePoint.Construction:
|
|
570 |
/// 工事担当者
|
|
571 |
strSQL.AppendFormat(" AND (A2.CONSTRUCTIONPERSONCODE = {0} OR A2.CONSTRSUBPERSONCODE = {0} OR A2.CONSTRUCTIONINSTRUCTOR = {0})", m_PersonCode);
|
|
572 |
break;
|
|
573 |
}
|
|
574 |
strSQL.Append(" ) UNI ORDER BY UNI.CONSTRUCTIONPERIODSTART DESC");
|
655 |
575 |
}
|
656 |
576 |
catch (Exception ex)
|
657 |
577 |
{
|
658 |
578 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
659 |
|
return false;
|
660 |
579 |
}
|
661 |
580 |
}
|
662 |
581 |
#endregion
|
|
582 |
|
|
583 |
#region 請求入力(分割請求)SQL作成
|
|
584 |
/// <summary>
|
|
585 |
/// 請求入力(分割請求)SQL作成
|
|
586 |
/// </summary>
|
|
587 |
/// <param name="strSQL"></param>
|
|
588 |
private void SetSelectTypeSeparateBilling(ref StringBuilder strSQL)
|
|
589 |
{
|
|
590 |
try
|
|
591 |
{ // ----- 請求入力(分割請求)の場合
|
|
592 |
// 進行中+分割請求を検索する
|
|
593 |
strSQL.Append("SELECT");
|
|
594 |
strSQL.Append(" UNI.CONSTRUCTIONCODE");
|
|
595 |
strSQL.Append(" , UNI.DETAILSTRING");
|
|
596 |
strSQL.Append(" , '', '', UNI.PERSONNAME");
|
|
597 |
strSQL.Append(" FROM (");
|
|
598 |
strSQL.Append(" SELECT");
|
|
599 |
strSQL.Append(" A1.CONSTRUCTIONCODE AS CONSTRUCTIONCODE");
|
|
600 |
strSQL.Append(" , B1.DETAILSTRING AS DETAILSTRING");
|
|
601 |
strSQL.Append(" , A1.CONSTRUCTIONPERIODSTART AS CONSTRUCTIONPERIODSTART");
|
|
602 |
strSQL.Append(" , P1.PersonName AS PERSONNAME");
|
|
603 |
strSQL.Append(" FROM");
|
|
604 |
strSQL.Append(" CONSTRUCTIONBASEINFO A1");
|
|
605 |
strSQL.Append(" INNER JOIN CONSTRUCTIONBASEINFODETAIL B1 ON ");
|
|
606 |
strSQL.Append(" A1.CONSTRUCTIONCODE = B1.CONSTRUCTIONCODE");
|
|
607 |
strSQL.AppendFormat(" AND B1.DETAILNO = {0}", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName);
|
|
608 |
strSQL.Append(" INNER JOIN CONSTRUCTIONLEDGER C1 ON ");
|
|
609 |
strSQL.Append(" A1.CONSTRUCTIONCODE = C1.CONSTRUCTIONCODE");
|
|
610 |
strSQL.Append(" AND C1.COMPLATEFLG = 0 ");
|
|
611 |
strSQL.Append(" LEFT JOIN PERSONINCHARGEMASTER P1 ON P1.PERSONCODE = A1.CONSTRUCTIONPERSONCODE");
|
|
612 |
strSQL.Append(" WHERE ");
|
|
613 |
strSQL.AppendFormat(" A1.BILLINGSPLITFLG = {0}", (int)CommonDefine.BaseInfoBillingSplitFlg.SplitBilling);
|
|
614 |
strSQL.AppendFormat(" AND A1.JOINFLG <> {0}", (int)CommonDefine.BaseInfoJoinFlg.JoinChildren);
|
|
615 |
|
|
616 |
switch (m_PersonCharge)
|
|
617 |
{
|
|
618 |
case (int)PersonChargePoint.Sales:
|
|
619 |
/// 営業担当検索
|
|
620 |
strSQL.AppendFormat(" AND A1.SALESPERSONCODE = {0}", m_PersonCode);
|
|
621 |
break;
|
|
622 |
case (int)PersonChargePoint.Construction:
|
|
623 |
/// 工事担当者
|
|
624 |
strSQL.AppendFormat(" AND (A1.CONSTRUCTIONPERSONCODE = {0} OR A1.CONSTRSUBPERSONCODE = {0} OR A1.CONSTRUCTIONINSTRUCTOR = {0})", m_PersonCode);
|
|
625 |
break;
|
|
626 |
}
|
|
627 |
|
|
628 |
strSQL.Append(" UNION ALL");
|
|
629 |
strSQL.Append(" SELECT");
|
|
630 |
strSQL.Append(" A2.CONSTRUCTIONCODE AS CONSTRUCTIONCODE");
|
|
631 |
strSQL.Append(" , B2.DETAILSTRING AS DETAILSTRING");
|
|
632 |
strSQL.Append(" , A2.CONSTRUCTIONPERIODSTART AS CONSTRUCTIONPERIODSTART");
|
|
633 |
strSQL.Append(" , P2.PERSONNAME AS PERSONNAME");
|
|
634 |
strSQL.Append(" FROM");
|
|
635 |
strSQL.Append(" CONSTRUCTIONBASEINFO A2");
|
|
636 |
strSQL.Append(" INNER JOIN CONSTRUCTIONBASEINFODETAIL B2 ON ");
|
|
637 |
strSQL.Append(" A2.CONSTRUCTIONCODE = B2.CONSTRUCTIONCODE");
|
|
638 |
strSQL.AppendFormat(" AND B2.DETAILNO = {0}", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName);
|
|
639 |
strSQL.Append(" INNER JOIN CONSTRUCTIONLINK D2 ON ");
|
|
640 |
strSQL.Append(" A2.CONSTRUCTIONCODE = D2.FLUCTUATIONCODE");
|
|
641 |
strSQL.AppendFormat(" AND D2.LINKTYPE = {0}", (int)CommonDefine.LinkDataType.JoinType);
|
|
642 |
strSQL.Append(" INNER JOIN CONSTRUCTIONLEDGER C2 ON ");
|
|
643 |
strSQL.Append(" D2.CONSTRUCTIONCODE = C2.CONSTRUCTIONCODE");
|
|
644 |
strSQL.Append(" AND C2.COMPLATEFLG = 0 ");
|
|
645 |
strSQL.Append(" LEFT JOIN PERSONINCHARGEMASTER P2 ON P2.PERSONCODE = A2.CONSTRUCTIONPERSONCODE");
|
|
646 |
strSQL.Append(" WHERE ");
|
|
647 |
strSQL.AppendFormat(" A2.BILLINGSPLITFLG = {0}", (int)CommonDefine.BaseInfoBillingSplitFlg.SplitBilling);
|
|
648 |
strSQL.AppendFormat(" AND A2.JOINFLG = {0}", (int)CommonDefine.BaseInfoJoinFlg.JoinChildren);
|
|
649 |
|
|
650 |
switch (m_PersonCharge)
|
|
651 |
{
|
|
652 |
case (int)PersonChargePoint.Sales:
|
|
653 |
/// 営業担当検索
|
|
654 |
strSQL.AppendFormat(" AND A2.SALESPERSONCODE = {0}", m_PersonCode);
|
|
655 |
break;
|
|
656 |
case (int)PersonChargePoint.Construction:
|
|
657 |
/// 工事担当者
|
|
658 |
strSQL.AppendFormat(" AND (A2.CONSTRUCTIONPERSONCODE = {0} OR A2.CONSTRSUBPERSONCODE = {0} OR A2.CONSTRUCTIONINSTRUCTOR = {0})", m_PersonCode);
|
|
659 |
break;
|
|
660 |
}
|
|
661 |
strSQL.Append(" ) UNI ORDER BY UNI.CONSTRUCTIONPERIODSTART DESC");
|
|
662 |
}
|
|
663 |
catch (Exception ex)
|
|
664 |
{
|
|
665 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
666 |
}
|
|
667 |
}
|
|
668 |
#endregion
|
|
669 |
|
|
670 |
#region 工事結合SQL作成
|
|
671 |
/// <summary>
|
|
672 |
/// 工事結合SQL作成
|
|
673 |
/// </summary>
|
|
674 |
/// <param name="strSQL"></param>
|
|
675 |
private void SetSelectTypeAll(ref StringBuilder strSQL)
|
|
676 |
{
|
|
677 |
try
|
|
678 |
{
|
|
679 |
// ----- 工事結合の場合
|
|
680 |
// 対象全ての案件を検索する
|
|
681 |
strSQL.Append("SELECT DISTINCT A.CONSTRUCTIONCODE, B.DETAILSTRING, A.OrderersDivision, A.OrderersCode, C.PERSONNAME");
|
|
682 |
strSQL.Append(" FROM CONSTRUCTIONBASEINFO A, CONSTRUCTIONBASEINFODETAIL B, PERSONINCHARGEMASTER C");
|
|
683 |
strSQL.AppendFormat(" WHERE (A.CONSTRUCTIONCODE = B.CONSTRUCTIONCODE AND B.DETAILNO = {0})", (int)ConstructionBaseInfoDetail.DetailDataNo.ConstructionName);
|
|
684 |
strSQL.AppendFormat(" AND A.JOINFLG = {0} ", (int)CommonDefine.BaseInfoJoinFlg.JoinParent);
|
|
685 |
switch (m_PersonCharge)
|
|
686 |
{
|
|
687 |
case (int)PersonChargePoint.Sales:
|
|
688 |
/// 営業担当検索
|
|
689 |
strSQL.AppendFormat(" AND A.SalesPersonCode = {0}", m_PersonCode);
|
|
690 |
break;
|
|
691 |
case (int)PersonChargePoint.Construction:
|
|
692 |
/// 工事担当者
|
|
693 |
strSQL.AppendFormat(" AND (A.ConstructionPersonCode = {0} OR A.ConstrSubPersonCode = {0} OR A.ConstructionInstructor = {0})", m_PersonCode);
|
|
694 |
break;
|
|
695 |
}
|
|
696 |
strSQL.Append(" AND (C.PERSONCODE = A.SALESPERSONCODE");
|
|
697 |
strSQL.Append(" Or C.PERSONCODE = A.CONSTRUCTIONPERSONCODE");
|
|
698 |
strSQL.Append(" Or C.PERSONCODE = A.CONSTRSUBPERSONCODE");
|
|
699 |
strSQL.Append(" Or C.PERSONCODE = A.CONSTRUCTIONINSTRUCTOR)");
|
|
700 |
strSQL.Append(" ORDER BY B.DETAILSTRING ASC, A.CONSTRUCTIONCODE DESC");
|
|
701 |
}
|
|
702 |
catch (Exception ex)
|
|
703 |
{
|
|
704 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
705 |
}
|
|
706 |
}
|
|
707 |
#endregion
|
663 |
708 |
}
|
664 |
709 |
}
|