/// <summary>
/// 자율관리-품질지적 일때
/// </summary>
/// <param name="curr_page">현제 페이지</param>
/// <param name="page_size">페이지당 갯수</param>
public DataSet Select_CMM_INDI_MST_ddlSearch_QUALITY_1(string pjt_cd, string mdul_cd, string nod_cd, string subc_idx, string str, string RegNm, string ComNm, string GjongNm, string GbnNm, string DocStatus, int curr_page, int page_size)
{
// 페이지 항목
string strPage = "";
// 검색항목
string strWhere = " WHERE (C1.PJT_CD = @pjt_cd) AND (C1.MDUL_CD = @mdul_cd) AND (C1.NOD_CD LIKE @nod_cd) ";
if (str == "C")
{
strWhere += @" AND (C1.SUBC_IDX = " + subc_idx.Replace("'", "''") + ") ";
}
else
{
strWhere += "";
}
if (RegNm != null && RegNm != "")
{
strWhere += " AND C1.REG_ID LIKE '%" + RegNm.Replace("'", "''") + "%' ";
}
if (ComNm != null && ComNm != "")
{
strWhere += " AND C1.SUBC_IDX LIKE '%" + ComNm.Replace("'", "''") + "%' ";
}
if (GjongNm != null && GjongNm != "")
{
strWhere += " AND C1.SAFTY_GJONG_CD LIKE '%" + GjongNm.Replace("'", "''") + "%' ";
}
if (GbnNm != null && GbnNm != "")
{
strWhere += " AND C1.SAFTY_GBN_CD LIKE '%" + GbnNm.Replace("'", "''") + "%' ";
}
if (DocStatus != null && DocStatus != "")
{
strWhere += " AND C1.DOC_STATUS LIKE '%" + DocStatus.Replace("'", "''") + "%' ";
}
// 페이지 조건
if (page_size > 0)
{
strPage = " ROW_NO BETWEEN " + (curr_page * page_size + 1) + " AND " + ((curr_page + 1) * page_size) + " ";
}
// 기본 정의 SQL
string strBaseSql = @" FROM CMM_INDI_MST AS C1
INNER JOIN SYS_ENTCD_MST S1
ON C1.SAFTY_GJONG_CD = S1.ENTCD
AND S1.PJT_CD = C1.PJT_CD
AND S1.CLS_CD = 'QGON'
INNER JOIN SYS_ENTCD_MST S2
ON C1.SAFTY_GBN_CD = S2.ENTCD
AND S2.PJT_CD = C1.PJT_CD
AND S2.CLS_CD = 'QTYP'
";
// 넘겨줄 SQL
string SQL = @"
-- 페이지항목만 임시테이블변수로 저장
SELECT C1.ORI_ROW_NO AS ROW_NO, C1.INDI_IDX
INTO #T_SEARCH
FROM
(
SELECT
ROW_NUMBER() OVER(ORDER BY C1.INDI_IDX) AS ORI_ROW_NO -- 반환할 Row_no
, ROW_NUMBER() OVER(ORDER BY C1.INDI_IDX DESC) AS ROW_NO -- 페이지 비교할 Row_No.
, C1.INDI_IDX
"
+ strBaseSql + strWhere +
" ) AS C1 WHERE "
+ strPage+
@"
-- 조회값 Table[0]
SELECT TS.ROW_NO, C2.COM_NM, SUBSTRING(CONVERT(VARCHAR, C1.INDI_DD, 121), 1, 10) AS INDI_DD, C1.REG_ID, C1.SUBC_IDX, C1.TTL, SUBSTRING(CONVERT(VARCHAR,
C1.DISP_RR, 121), 1, 10) AS DISP_RR, C1.DOC_STATUS, C1.INDI_IDX, C1.MDUL_CD, C1.NOD_CD, C3.MSURE_IDX, U1.USER_NM, C1.PJT_CD,
C1.SAFTY_GJONG_CD, C1.SAFTY_GBN_CD, S1.CD_NM AS SAFTY_GJONG_NM, S2.CD_NM AS SAFETY_GBN_NM,
(CASE WHEN C1.SAFTY_GJONG_CD = '1' THEN '품질'
WHEN C1.SAFTY_GJONG_CD = '2' THEN '안전'
WHEN C1.SAFTY_GJONG_CD = '3' THEN '환경' ELSE '' END) AS GJONG_NM
FROM CMM_INDI_MST AS C1
INNER JOIN #T_SEARCH AS TS
ON C1.INDI_IDX = TS.INDI_IDX
LEFT OUTER JOIN CDR_SUBC_MST AS C2
ON C1.SUBC_IDX = C2.SUBC_IDX
AND C2.DEL_YN = 'N'
LEFT OUTER JOIN CMM_INDI_RSPN AS C3
ON C3.INDI_IDX = C1.INDI_IDX
LEFT OUTER JOIN SYS_USER_MST AS U1
ON C1.REG_ID = U1.USER_ID
INNER JOIN SYS_ENTCD_MST S1
ON C1.SAFTY_GJONG_CD = S1.ENTCD
AND S1.PJT_CD = C1.PJT_CD
AND S1.CLS_CD = 'QGON'
INNER JOIN SYS_ENTCD_MST S2
ON C1.SAFTY_GBN_CD = S2.ENTCD
AND S2.PJT_CD = C1.PJT_CD
AND S2.CLS_CD = 'QTYP'
ORDER BY ROW_NO DESC
";
SQL += @"
-- 총카운터 Table[1]
SELECT COUNT(*) AS CNT
"