public void SAVE_TREE(string PATTERN_CODE)
    {
        string NODE_CODE = string.Empty;
        if (string.IsNullOrEmpty(PATTERN_CODE))
        {
            if (dt_Show_Tree.Rows.Count > 0)
            {
                PATTERN_CODE = Request.QueryString["PATTERN_CODE"];
            }
        }

        for (int i = 0; i <= dt_default_Tree.Rows.Count - 1; i++)
        {
            NODE_CODE += dt_default_Tree.Rows[i]["NODE_CODE"].ToString() + ",";
        }
        if (dt_default_Tree.Rows.Count > 0)
        {
            NODE_CODE = NODE_CODE.Substring(0, NODE_CODE.Length - 1);
        }
        string sql = "delete from CTLT_TREE_PATTERN where NODE_CODE in (" + NODE_CODE + ")";
        OPM_BL BL = new OPM_BL();
        if (!string.IsNullOrEmpty(NODE_CODE))
        {
            Int16 t = Convert.ToInt16(BL.SQL_TREE_PATTERN(sql));
        }
            for (int i = 0; i <= dt_Show_Tree.Rows.Count - 1; i++)
            {
                sql = "insert into CTLT_TREE_PATTERN (PATTERN_CODE,NODE_CODE,ITEM_CODE,PARENT_NODE_CODE,USER_ID,LAST_DATE,MA_FLAG,PRINT_FLAG,QUERY_FLAG) values ";
                sql += "('" + PATTERN_CODE + "','" + dt_Show_Tree.Rows[i]["NODE_CODE"].ToString() + "','" + dt_Show_Tree.Rows[i]["ITEM_CODE"].ToString() + "',";
                sql += "'" + dt_Show_Tree.Rows[i]["PARENT_NODE_CODE"].ToString() + "','" + OPM_BL._Username + "',GETDATE(),'Y','Y','Y')";
                Int16 t2 = Convert.ToInt16(BL.SQL_TREE_PATTERN(sql));
            }
    }
    public void CountDate_chkDEL(string nodecode)
    {
        string _Sub_nodecode = string.Empty;
        string PATTERN_CODE = Request.QueryString["PATTERN_CODE"];
        DataTable dt = new DataTable();
        SqlParameter[] param = new SqlParameter[1];
        string SQL = "SELECT CTLT_TREE_PATTERN.NODE_CODE, CTLT_ITEM.ITEM_TYPE, CTLT_TREE_PATTERN.ITEM_CODE, CTLT_ITEM.ITEM_NAME, ";
               SQL +="CTLT_TREE_PATTERN.PARENT_NODE_CODE FROM CTLT_TREE_PATTERN INNER JOIN CTLT_ITEM ON CTLT_TREE_PATTERN.ITEM_CODE = CTLT_ITEM.ITEM_CODE";
               SQL +=" WHERE (CTLT_TREE_PATTERN.PATTERN_CODE = @PATTERN_CODE)";

        param[0] = OPM_BL.setParameter("@PATTERN_CODE", SqlDbType.VarChar, PATTERN_CODE);
        dt = OPM_BL.GetDatatable(SQL, param);
        dt.DefaultView.RowFilter = " PARENT_NODE_CODE = '" + nodecode + "'";
        for (int i = 0; i <= dt.DefaultView.Count - 1; i++)
        {
            if (dt.DefaultView[i]["ITEM_TYPE"].ToString() == "M")
            {
                CountDate_chkDEL(dt.DefaultView[i]["NODE_CODE"].ToString());

            }

                _Sub_nodecode += dt.DefaultView[i]["NODE_CODE"].ToString() + ",";
        }

        _Sub_nodecode = _Sub_nodecode.Substring(0, _Sub_nodecode.Length - 1);
        param = new SqlParameter[1];
        string _SQL = "DELETE FROM CTLT_TREE_PATTERN WHERE NODE_CODE in (" + _Sub_nodecode + ")";
        OPM_BL BL = new OPM_BL();
        string Del_chk = Convert.ToString(BL.SQL_TREE_PATTERN(_SQL));
        //param[0] = OPM_BL.setParameter("@nodecode", SqlDbType.VarChar, _Sub_nodecode);
        //string _ret = OPM_BL.ExecuteNoneQuery(_SQL, param);
        //_chk_Delete = _ret;
    }