1 <%
 2                                long lOfficeIDAbstract = sessionMng.m_lOfficeID;
 3                                long lCurrencyIDAbstract = sessionMng.m_lCurrencyID;
 4                                long NclientID=sessionMng.m_lClientID;
 5                                String strFormNameAbstract = "frmzjhb";
 6                                String strCtrlNameAbstract = "sNote";
 7                                String strTitleAbstract = "摘要";
 8                                
 9                                //long lAbstractIDAbstract = -1;
10                                String strAbstractDescAbstract = (financeInfo.getNote()==null)?"":financeInfo.getNote();
11                                String strFirstTDAbstract = "";
12                                String strSecondTDAbstract = "";
13                                String[] strNextControlsAbstract = null;
14                                strNextControlsAbstract = new String[] "add1" };
15                                //if (Config.getBoolean(ConfigConstant.SETT_TRANSCOMMISSION,
16                                //false)) {
17                                //    strNextControlsAbstract = new String[] { "commissionAmount" };
18                                //} else {
19                                //    strNextControlsAbstract = new String[] { "save" };
20                                //}*/
21
22                                OBMagnifier.createAbstractCtrl(out, lOfficeIDAbstract,
23                                lCurrencyIDAbstract,NclientID, strFormNameAbstract,
24                                strCtrlNameAbstract, strTitleAbstract,
25                                -1, strAbstractDescAbstract,
26                                strFirstTDAbstract, strSecondTDAbstract,
27                                strNextControlsAbstract);
28                        %>

 1/**
 2     * 检测数组中的控件名称 和 对应的数据库字段 的数目 是否匹配
 3     * @param strNames
 4     * @param strValues
 5     * @param bIsAllowNull
 6     * @throws SecException
 7     */

 8    private static void checkValue(String[] strNames, String[] strValues, boolean bIsAllowNull) throws IException
 9    {
10        if (!bIsAllowNull)
11        {
12            if (strNames != null && strValues != null)
13            {
14                if (strNames.length != strValues.length)
15                {
16                    throw new IException(ZOOMERRORMSG);
17                }

18            }

19            return;
20        }

21        if (strNames == null || strValues == null)
22        {
23            throw new IException(ZOOMERRORMSG);
24        }

25        if (strNames.length == 0 || strValues.length == 0)
26        {
27            throw new IException(ZOOMERRORMSG);
28        }

29        if (strNames.length != strValues.length)
30        {
31            throw new IException(ZOOMERRORMSG);
32        }

33    }

34    /**
35     * 检测数组中的控件名称 和 对应的数据库字段 的数目 是否匹配
36     * @param strNames 控件名称
37     * @param strFields 对应数据库字段
38     * @param strValues 对应初始值
39     * @param bIsAllowNull 是否允许为空
40     * @throws SecException
41     */

42    private static void checkValue(String[] strNames, String[] strFields, String[] strValues, boolean bIsAllowNull) throws IException
43    {
44        if (!bIsAllowNull)
45        {
46            if (strNames != null && strFields != null && strValues != null)
47            {
48                if (strNames.length != strFields.length || strNames.length != strValues.length || strFields.length != strValues.length)
49                {
50                    throw new IException(ZOOMERRORMSG);
51                }

52            }

53        }

54        else
55        {
56            if (strNames == null || strFields == null || strValues == null)
57            {
58                throw new IException(ZOOMERRORMSG);
59            }

60            if (strNames.length == 0 || strFields.length == 0 || strValues.length == 0)
61            {
62                throw new IException(ZOOMERRORMSG);
63            }

64            if (strNames.length != strFields.length || strNames.length != strValues.length || strFields.length != strValues.length)
65            {
66                throw new IException(ZOOMERRORMSG);
67            }

68        }

69    }



这是页面上的显示
  1/**
  2     * 创建摘要放大镜
  3     * @param out
  4     * @param lOfficeID 办事处ID
  5     * @param lCurrencyID 币种ID
  6     * @param strFormName 表单域名称
  7     * @param strCtrlName 放大镜主控件名称
  8     * @param strTitle 放大镜描述
  9     * @param lAbstractID 摘要ID(初识值)
 10     * @param strAbstractDesc 摘要描述(初识值)
 11     * @param strFirstTD 第一个TD的属性
 12     * @param strSecondTD 第二个TD的属性
 13     * @param strNextControls 下一个(或多个)获得焦点的控件
 14     */

 15    public static void createAbstractCtrl(
 16        JspWriter out,
 17        long lOfficeID,
 18        long lCurrencyID,
 19        long nclientID,
 20        String strFormName,
 21        String strCtrlName,
 22        String strTitle,
 23        long lAbstractID,
 24        String strAbstractDesc,
 25        String strFirstTD,
 26        String strSecondTD,
 27        String[] strNextControls)
 28    {
 29        String strMagnifierName = "摘要";
 30        String AbstractCode = "摘要代号";
 31        String AbstractDesc = "摘要描述";
 32        try
 33        {
 34            strMagnifierName = URLEncoder.encode(strMagnifierName, "utf-8");
 35            AbstractCode = URLEncoder.encode(AbstractCode, "utf-8");
 36            AbstractDesc = URLEncoder.encode(AbstractDesc, "utf-8");
 37        }

 38        catch (UnsupportedEncodingException uxe)
 39        {
 40            Log.print("摘要放大镜[" + strCtrlName + "]异常:" + uxe.toString());
 41        }

 42        
 43        String strMainProperty = " size='32' value='" + strAbstractDesc + "'";
 44        if (strNextControls != null && strNextControls.length > 0)
 45        {
 46            strMainProperty = strMainProperty + " onfocus=\"nextfield='" + strNextControls[0] + "'\"";
 47        }

 48        String strPrefix = "";
 49        String[] strMainNames = { strCtrlName + "Ctrl" };
 50        String[] strMainFields = "AbstractDesc" };
 51        String[] strReturnNames = { strCtrlName };
 52        String[] strReturnFields = "AbstractID" };
 53        String[] strReturnValues = { String.valueOf(lAbstractID)};
 54        //String[] strDisplayNames = { URLEncoder.encode("摘要代号"), URLEncoder.encode("摘要描述")};
 55        String[] strDisplayNames = { AbstractCode, AbstractDesc};
 56        String[] strDisplayFields = "AbstractCode""AbstractDesc" };
 57        int nIndex = 1;
 58        String strSQL = "getAbstractSQL(" + lOfficeID + "," + nclientID+ "," + strCtrlName + "Ctrl.value)";
 59        boolean blnIsOptional = false;
 60        try
 61        {
 62            showZoomCtrl(
 63                out,
 64                strMagnifierName,
 65                strFormName,
 66                strPrefix,
 67                strMainNames,
 68                strMainFields,
 69                strReturnNames,
 70                strReturnFields,
 71                strReturnValues,
 72                strDisplayNames,
 73                strDisplayFields,
 74                nIndex,
 75                strMainProperty,
 76                strSQL,
 77                strNextControls,
 78                strTitle,
 79                strFirstTD,
 80                strSecondTD,
 81                blnIsOptional);
 82        }

 83        catch (Exception e)
 84        {
 85             e.printStackTrace();
 86            Log.print("摘要放大镜[" + strCtrlName + "]异常:" + e.toString());
 87        }

 88    }

 89    /**
 90     * 显示普通放大镜
 91     * @param out
 92     * @param strMagnifierName 放大镜的名称
 93     * @param strFormName 主页面表单名称
 94     * @param strPrefix 控件名称前缀
 95     * @param strMainNames 放大镜回显栏位值列表
 96     * @param strMainFields 放大镜回显栏位对应的表格字段
 97     * @param strReturnNames 放大镜返回值列表(隐含值)
 98     * @param strReturnFields 放大镜返回值(隐含值)对应的表格字段列表
 99     * @param strReturnValues 放大镜返回值(隐含值)对应的初始值
100     * @param strDisplayNames 放大镜小窗口显示的栏位名称
101     * @param strDisplayFields 放大镜小窗口显示栏位对应的表格字段
102     * @param nIndex 确定选择项,从0开始,如果小于0,则默认所有栏位都可选择,如果大于或等于strDisplayNames.length,则没有选择项
103     * @param strMainProperty 放大镜栏位属性
104     * @param strSQL 放大镜查询SQL语句
105     * @param strNextControls 设置下一个焦点
106     * @param strTitle 栏位标题
107     * @param strFirstTD 第一个TD的属性
108     * @param strSecondTD 第二个TD的属性 
109     * @throws Exception
110     */

111    public static void showZoomCtrl(
112        JspWriter out,
113        String strMagnifierName,
114        String strFormName,
115        String strPrefix,
116        String[] strMainNames,
117        String[] strMainFields,
118        String[] strReturnNames,
119        String[] strReturnFields,
120        String[] strReturnValues,
121        String[] strDisplayNames,
122        String[] strDisplayFields,
123        int nIndex,
124        String strMainProperty,
125        String strSQL,
126        String[] strNextControls,
127        String strTitle,
128        String strFirstTD,
129        String strSecondTD)
130        throws Exception
131    {
132        boolean blnIsOptional = false;
133        showZoomCtrl(
134            out,
135            strMagnifierName,
136            strFormName,
137            strPrefix,
138            strMainNames,
139            strMainFields,
140            strReturnNames,
141            strReturnFields,
142            strReturnValues,
143            strDisplayNames,
144            strDisplayFields,
145            nIndex,
146            strMainProperty,
147            strSQL,
148            strNextControls,
149            strTitle,
150            strFirstTD,
151            strSecondTD,
152            blnIsOptional);
153    }

154    /**
155     * 显示普通放大镜
156     * @param out
157     * @param strMagnifierName 放大镜的名称
158     * @param strFormName 主页面表单名称
159     * @param strPrefix 控件名称前缀
160     * @param strMainNames 放大镜回显栏位值列表
161     * @param strMainFields 放大镜回显栏位对应的表格字段
162     * @param strReturnNames 放大镜返回值列表(隐含值)
163     * @param strReturnFields 放大镜返回值(隐含值)对应的表格字段列表
164     * @param strReturnValues 放大镜返回值(隐含值)对应的初始值
165     * @param strDisplayNames 放大镜小窗口显示的栏位名称
166     * @param strDisplayFields 放大镜小窗口显示栏位对应的表格字段
167     * @param nIndex 确定选择项,从0开始,如果小于0,则默认所有栏位都可选择,如果大于或等于strDisplayNames.length,则没有选择项
168     * @param strMainProperty 放大镜栏位属性
169     * @param strSQL 放大镜查询SQL语句
170     * @param strNextControls 设置下一个焦点
171     * @param strTitle 栏位标题
172     * @param strFirstTD 第一个TD的属性
173     * @param strSecondTD 第二个TD的属性 
174     * @param blnIsOptional 是否是可选项(目前仅对摘要、现金流向放大镜有用)
175     * @throws Exception
176     */

177    public static void showZoomCtrl(
178        JspWriter out,
179        String strMagnifierName,
180        String strFormName,
181        String strPrefix,
182        String[] strMainNames,
183        String[] strMainFields,
184        String[] strReturnNames,
185        String[] strReturnFields,
186        String[] strReturnValues,
187        String[] strDisplayNames,
188        String[] strDisplayFields,
189        int nIndex,
190        String strMainProperty,
191        String strSQL,
192        String[] strNextControls,
193        String strTitle,
194        String strFirstTD,
195        String strSecondTD,
196        boolean blnIsOptional)
197        throws Exception
198    {
199        showZoomCtrl(
200            out,
201            strMagnifierName,
202            strFormName,
203            strPrefix,
204            strMainNames,
205            strMainFields,
206            strReturnNames,
207            strReturnFields,
208            strReturnValues,
209            strDisplayNames,
210            strDisplayFields,
211            nIndex,
212            strMainProperty,
213            strSQL,
214            strNextControls,
215            strTitle,
216            strFirstTD,
217            strSecondTD,
218            blnIsOptional,
219            "");
220    }

221    /**
222     * 显示普通放大镜
223     * @param out
224     * @param strMagnifierName 放大镜的名称
225     * @param strFormName 主页面表单名称
226     * @param strPrefix 控件名称前缀
227     * @param strMainNames 放大镜回显栏位值列表
228     * @param strMainFields 放大镜回显栏位对应的表格字段
229     * @param strReturnNames 放大镜返回值列表(隐含值)
230     * @param strReturnFields 放大镜返回值(隐含值)对应的表格字段列表
231     * @param strReturnValues 放大镜返回值(隐含值)对应的初始值
232     * @param strDisplayNames 放大镜小窗口显示的栏位名称
233     * @param strDisplayFields 放大镜小窗口显示栏位对应的表格字段
234     * @param nIndex 确定选择项,从0开始,如果小于0,则默认所有栏位都可选择,如果大于或等于strDisplayNames.length,则没有选择项
235     * @param strMainProperty 放大镜栏位属性
236     * @param strSQL 放大镜查询SQL语句
237     * @param strNextControls 设置下一个焦点
238     * @param strTitle 栏位标题
239     * @param strFirstTD 第一个TD的属性
240     * @param strSecondTD 第二个TD的属性 
241     * @param blnIsOptional 是否是可选项(目前仅对摘要、现金流向放大镜有用)
242     * @param strCtrlType 控件类型(特殊处理)
243     *  rate 利率控件(可以格式化利率)
244     *  branch 开户行控件(控件为textarea)
245     * @throws Exception
246     */

247    public static void showZoomCtrl(
248        JspWriter out,
249        String strMagnifierName,
250        String strFormName,
251        String strPrefix,
252        String[] strMainNames,
253        String[] strMainFields,
254        String[] strReturnNames,
255        String[] strReturnFields,
256        String[] strReturnValues,
257        String[] strDisplayNames,
258        String[] strDisplayFields,
259        int nIndex,
260        String strMainProperty,
261        String strSQL,
262        String[] strNextControls,
263        String strTitle,
264        String strFirstTD,
265        String strSecondTD,
266        boolean blnIsOptional,
267        String strCtrlType)
268        throws Exception
269    {
270        
271        String strButtonName = "button";
272        try
273        {
274            //检查放大镜参数
275            
276            checkValue(strMainNames, strMainFields, true);
277            checkValue(strReturnNames, strReturnFields, strReturnValues, false);
278            checkValue(strDisplayNames, strDisplayFields, true);
279            if (strMagnifierName == null || strFormName == null || strFormName.equals(""|| strSQL == null || strSQL.equals(""))
280            {
281                throw new IException(ZOOMERRORMSG);
282            }

283            if (strNextControls == null)
284            {
285                throw new IException(ZOOMERRORMSG);
286            }

287            if (strFirstTD == null)
288            {
289                strFirstTD = "";
290            }

291            if (strSecondTD == null)
292            {
293                strSecondTD = "";
294            }

295            //检查完毕
296            //设置前缀
297            if (strPrefix != null && !strPrefix.trim().equals(""))
298            {
299                for (int i = 0; i < strMainNames.length; i++)
300                {
301                    strMainNames[i] = strPrefix + strMainNames[i];
302                }

303                for (int i = 0; i < strReturnNames.length; i++)
304                {
305                    strReturnNames[i] = strPrefix + strReturnNames[i];
306                }

307            }

308            //弹出窗口的属性
309            String sFeatures = null;
310            if (strDisplayNames.length < 3)
311            {
312                sFeatures = "toolbar=no,menubar=no,resizable=no,location=no,width=520,height=450,scrollbars=yes";
313            }

314            else
315            {
316                sFeatures = "toolbar=no,menubar=no,resizable=no,location=no,width=624,height=540,scrollbars=yes";
317            }

318            //生成传递给弹出窗口的参数字符串
319            String strParam = "";
320            strParam = "strFormName=" + strFormName;
321            strParam += "&strMagnifierName=" + strMagnifierName;
322            strParam += "&nIndex=" + nIndex;
323            if (!isSQL(strSQL))
324            {
325                strParam += "&strSQL='+" + strSQL + "+'";
326            }

327            else
328            {
329                strParam += "&strSQL=" + getSQL(strSQL);
330                System.out.println( strSQL );
331            }

332            for (int i = 0; i < strNextControls.length; i++)
333            {
334                strParam += "&strNextControls=" + strNextControls[i];
335            }

336            for (int i = 0; i < strMainNames.length; i++)
337            {
338                strParam += "&strMainNames=" + strMainNames[i];
339                strParam += "&strMainFields=" + strMainFields[i];
340            }

341            if (strReturnNames != null)
342            {
343                boolean bValue = false;
344                if (strReturnValues != null && strReturnValues.length == strReturnNames.length)
345                {
346                    bValue = true;
347                }

348                for (int i = 0; i < strReturnNames.length; i++)
349                {
350                    //生成数组参数
351                    strParam += "&strReturnNames=" + strReturnNames[i];
352                    strParam += "&strReturnFields=" + strReturnFields[i];
353                    if (bValue)
354                    {
355                        out.println("<input type=\"hidden\" name=\"" + strReturnNames[i] + "\" value=\"" + strReturnValues[i] + "\">");
356                    }

357                    else
358                    {
359                        out.println("<input type=\"hidden\" name=\"" + strReturnNames[i] + "\">");
360                    }

361                }

362            }

363            
364            for (int i = 0; i < strDisplayNames.length; i++)
365            {
366                //生成数组参数
367                strParam += "&strDisplayNames=" + strDisplayNames[i];
368                strParam += "&strDisplayFields=" + strDisplayFields[i];
369            }

370            
371            //生成查询按钮的事件字符串
372            String sOnKeydown =
373                "if(checkMagnifierInput("+ strFormName +"."+ strMainNames[0+",'')){"
374                    + "if("
375                    + strFormName
376                    + "."
377                    + strMainNames[0]
378                    + ".disabled == false) {gnIsSelectCtrl=1;window.open('"
379                    + Env.URL_PREFIX
380                    + "/iTreasury-settlement/magnifier/ShowMagnifierZoom.jsp?"
381                    + strParam
382                    + "', 'SelectAnything', '"
383                    + sFeatures
384                    + "', false);}}";
385            //
386            String sOnKeyUp = "";
387            if (strReturnNames != null)
388            {
389                for (int i = 0; i < strReturnNames.length; i++)
390                {
391                    sOnKeyUp += strReturnNames[i] + ".value = -1; ";
392                }

393            }

394            //int iPos = strMainProperty.toLowerCase().indexOf("disabled");
395            int iPos = -1;
396            //显示控件
397            if (iPos == -1)
398            {
399                out.println(
400                    "<td "
401                        + strFirstTD
402                        + "width=\"130\" height=\"25\" class=\"MsoNormal\" colspan=\"2\" align=\"left\" >"
403                        + "&nbsp;&nbsp;"
404                        + strTitle
405                        + ":&nbsp;"
406                        + "<a href=#><img name=\""
407                        + strButtonName
408                        + "\" src='/websett/image/icon.gif' border=0 onclick=\""
409                        + sOnKeydown
410                        + "\"></a></td>");
411                //image
412            }

413            else
414            {
415                out.println("<td " + strFirstTD + ">" + strTitle + ":&nbsp;" + "<a href=#><img name=\"" + strButtonName + "\" src='/websett/image/icon.gif' border=0 ></a></td>");
416                //image
417            }

418            //blnIsOptional,是否可选项(仅对摘要、现金流向放大镜有效)
419            if (blnIsOptional == true)
420            {
421                /*
422                if (strNextControls != null && strNextControls.length > 0)
423                {
424                    strMainProperty = " onfocus=\"nextfield='" + strNextControls[0] + "'\" "+strMainProperty;
425                }
426                */

427                if (strCtrlType.equals("rate"))
428                {
429                    out.println("<td" + strSecondTD + "><input type=\"text\" name=\"" + strMainNames[0] + "\" class=\"tar\" " + strMainProperty + "> %</td>");
430                }

431                else
432                    if (strCtrlType.equals("branch"))
433                    {
434                        out.println(
435                            "<td"
436                                + strSecondTD
437                                + "><textarea name=\""
438                                + strMainNames[0]
439                                + "\"  class=\"box\" bgcolor=\"#FF00\"  rows=2 cols=30>"
440                                + strMainProperty
441                                + "</textarea></td>");
442                    }

443                    else
444                    {
445                        out.println("<td" + strSecondTD + "><input type=\"text\" name=\"" + strMainNames[0] + "\" class=\"box\" " + strMainProperty + "></td>");
446                    }

447            }

448            else
449            {
450                if (strCtrlType.equals("rate"))
451                {
452                    out.println(
453                        "<td"
454                            + strSecondTD
455                            + "><input type=\"text\" name=\""
456                            + strMainNames[0]
457                            + "\" class=\"tar\" "
458                            + strMainProperty
459                            + " onKeyDown=\"if(event.keyCode==13{"
460                            + sOnKeydown
461                            + "}\" onKeyUp=\""
462                            + sOnKeyUp
463                            + "\"> %</td>");
464                }

465                else
466                    if (strCtrlType.equals("branch"))
467                    {
468                        out.println(
469                            "<td"
470                                + strSecondTD
471                                + "><textarea name=\""
472                                + strMainNames[0]
473                                + "\"  class=\"box\" bgcolor=\"#FF00\"  rows=2 cols=30 onKeyDown=\"if(event.keyCode==13) "
474                                + sOnKeydown
475                                + "\" onKeyUp=\""
476                                + sOnKeyUp
477                                + "\" >"
478                                + strMainProperty
479                                + "</textarea></td>");
480                    }

481                    else
482                    {
483                        System.out.println("-------------单据放大种类:"+strMainNames[0]);
484                        out.println(
485                            "<td"
486                                + strSecondTD
487                                + "><input type=\"text\" name=\""
488                                + strMainNames[0]
489                                + "\" class=\"box\" "
490                                + strMainProperty
491                                + " onKeyDown=\"if(event.keyCode==13"
492                                + sOnKeydown
493                                + "\" onKeyUp=\""
494                                + sOnKeyUp
495                                + "\"></td>");
496                    }

497            }

498        }

499        catch (Exception exp)
500        {
501            throw exp;
502        }

503    }

用于显示

js拼sql
   1
   2/**===========账户放大镜===============
   3* lType  查找类型
   4* lOfficeID 办事处标识
   5* lCurrencyID 货币标识
   6* lClientID 客户标识
   7* lAccountType 账户类型
   8*=====================================*/

   9function getAccountSQL(lOfficeID,lCurrencyID,lClientID,lType,lAccountGroupType)
  10{
  11    var strSQL ="";
  12    var strAccount="";
  13    strSQL = " select a.SACCOUNTNO,c.sName,a.id from SETT_Account a,client c,sett_AccountType sat where a.nClientID=c.ID and 1=1 and a.nAccountTypeID=sat.id";
  14    if(lOfficeID > 0)
  15    {
  16        strSQL += " and a.nOfficeID = " + lOfficeID;
  17    }

  18    if(lCurrencyID > 0)
  19    {
  20        strSQL += " and a.nCurrencyID = " + lCurrencyID;
  21    }

  22    if(lClientID > 0)
  23    {
  24        strSQL += " and a.nClientID = " + lClientID;
  25    }

  26    if(lType = 100)//放款通知单中所使用的活期账户只能是正常(1)和封存(3)状态
  27    {
  28        strSQL += " and a.NSTATUSID in(1,3) ";
  29    }

  30    if(lAccountGroupType > 0)
  31    {
  32            strSQL += " and sat.naccountGroupid = "+ lAccountGroupType;
  33    }

  34    strSQL += " order by a.sAccountNo ";
  35    return strSQL;
  36}

  37
  38/**
  39 * 下属单位客户放大镜
  40 * nOfficeID 办事处ID
  41 * sClientNo 客户编号
  42 */

  43function getChildClientSQL(nOfficeID,lParentClientID,sClientNo)
  44{
  45    var sql = "select distinct  a.sCode as ClientNo, a.ID as ClientID,a.sname as ClientName,b.ID as OfficeID, b.sCode as OfficeNo, b.sName as OfficeName,1 as FromClient ";
  46    sql += " from client a, office b ";
  47    sql += " where a.nofficeid = b.id and a.nStatusID > 0";
  48
  49    if (lParentClientID > 0)
  50    {
  51        sql += " and a.id in (select CHILDCLIENTID from childclientprivilege where CLIENTID= "
  52        + lParentClientID; 
  53        sql += " and decode(PRIVILEGETYPE,1,PRIVILEGEVALUE,-1)=1";
  54        sql += " union select "+lParentClientID+" from dual )"
  55    }

  56    if (nOfficeID > 0)
  57    {
  58        sql += " and a.nofficeid = " + nOfficeID; 
  59    }

  60    if (sClientNo != null && sClientNo != ""
  61    {
  62        sql += " and (a.sCode like '%25" + sClientNo + "%25' or a.sName like '%25" + sClientNo + "%25')";
  63    }

  64    sql += " order by a.sCode";
  65    
  66    return sql;
  67}

  68
  69
  70    /**==========付款方银行账户编号放大镜====================*/
  71    function getPayerAccountNoSQL(sBankAccountCode,lUserID,lClientID,lCurrencyID,lInstructionID)
  72    {
  73        var sql = " select distinct "+ lCurrencyID +" as CurrencyID, "+lInstructionID
  74                 +" as InstructionID, a.sbankaccountno accountBankNo,b.saccountno displayAccountNo, a.sbankaccountno,b.saccountno||decode(baf.SBANKACCOUNTNO,null,'',' -- '||baf.SBANKACCOUNTNO) as saccountno ,b.ID as nAccountID,b.sname "
  75                 + " from SETT_ACCOUNTBANK  a,SETT_account b ,SETT_accounttype c,OB_AccountOwnedByUser oba,Sett_bankAccountOfFiliale baf"
  76                 + " where oba.sAccountNo=b.sAccountNo and a.naccountid(%2B)=b.id and b.nAccountTypeID=c.id(%2B) and c.nAccountGroupID=1 "
  77                 + " and b.id = baf.NWITHINACCOUNTID(%2B)"
  78                 + " and b.nStatusID=1 "
  79                 + " and b.nCheckStatusID =4 " ;
  80        if (sBankAccountCode!=null && sBankAccountCode!="")
  81        {
  82            sql = sql + " and replace(b.saccountno,'-','') like '%25" + sBankAccountCode + "%25' ";
  83        }

  84        sql = sql+" and oba.nUserID="+lUserID+" and b.nclientid ="+lClientID+"  and b.ncurrencyid ="+lCurrencyID;
  85        sql += " order by saccountno  ";
  86        
  87        return sql;
  88    }

  89    
  90    function getPayerAccountNoSQL1(sBankAccountCode,lUserID,lClientID,lCurrencyID,lInstructionID)
  91    
  92        var sql = " select distinct "+ lCurrencyID +" CurrencyID,"+lInstructionID
  93                 +" as InstructionID, a.sbankaccountno accountBankNo,b.saccountno dANo, a.sbankaccountno,b.saccountno||decode(baf.SBANKACCOUNTNO,null,'',' -- '||baf.SBANKACCOUNTNO) sactno ,b.ID nActID,b.sname"
  94                 + ",bs.outAcctNo o1,bs.outAcctName o2,bs.province p,bs.city c,bs.openBankName o3"                
  95                 + " from SETT_ACCOUNTBANK  a,SETT_account b ,SETT_accounttype c,OB_AccountOwnedByUser oba,Sett_bankAccountOfFiliale baf,"
  96                 
  97                 + " (select ba.N_SUBJECTID,ba.S_ACCOUNTNO outAcctNo,"
  98                 + " ba.S_ACCOUNTNAME outAcctName,bb.S_BRANCHAREASEG1 province,bb.S_BRANCHAREASEG2 city,bb.S_NAME openBankName"
  99                 + " from bs_bankaccountinfo ba,bs_banksetting bb"
 100                 + " where bb.n_id(%2B)=ba.N_BANKID "
 101                 + " and ba.n_inputoroutput=2"                 
 102                 + ") bs "                                  
 103                 + " where oba.sAccountNo=b.sAccountNo and a.naccountid(%2B)=b.id and b.nAccountTypeID=c.id(%2B) and c.nAccountGroupID=1 "
 104                                  + " and b.id = baf.NWITHINACCOUNTID(%2B)"
 105                 + " and b.nStatusID=1 "
 106                 + " and b.nCheckStatusID =4 " ;
 107        if (sBankAccountCode!=null && sBankAccountCode!="")
 108        {
 109            sql = sql + " and replace(b.saccountno,'-','') like '%25" + sBankAccountCode + "%25' ";
 110        }

 111        sql = sql+" and oba.nUserID="+lUserID+" and b.nclientid ="+lClientID+"  and b.ncurrencyid ="+lCurrencyID;
 112        sql += " and bs.N_SUBJECTID(%2B)=b.id";
 113        sql += " order by sactno  ";
 114        
 115        return sql;
 116    }

 117
 118    /**==========收款方银行账户编号放大镜(内部转账)====================*/
 119    function getInternalPayeeAccountNoSQL(sBankAccountCode,lUserID,lClientID,lCurrencyID,lInstructionID)
 120    {
 121        var sql = " select distinct "+ lCurrencyID +" as CurrencyID, "+lInstructionID
 122                 +" as InstructionID,a.sbankaccountno accountBankNo,b.saccountno displayAccountNo, a.sbankaccountno ,b.saccountno||decode(baf.SBANKACCOUNTNO,null,'',' -- '||baf.SBANKACCOUNTNO) as saccountno ,b.ID as nAccountID,b.sname "
 123                 + " from SETT_ACCOUNTBANK  a,SETT_account b ,SETT_accounttype c,OB_AccountOwnedByUser oba,Sett_bankAccountOfFiliale baf"
 124                 + " where oba.sAccountNo=b.sAccountNo and a.naccountid(%2B)=b.id and b.nAccountTypeID=c.id(%2B) and c.nAccountGroupID=1 and c.ID!=97"
 125                 + " and b.id = baf.NWITHINACCOUNTID(%2B)"
 126                 + " and b.nStatusID=1 "
 127                 + " and b.nCheckStatusID =4 " ;
 128        if (sBankAccountCode!=null && sBankAccountCode!="")
 129        {
 130            sql = sql + " and replace(b.saccountno,'-','') like '%25" + sBankAccountCode + "%25' ";
 131        }

 132        sql = sql+" and oba.nUserID="+lUserID+" and b.nclientid ="+lClientID+"  and b.ncurrencyid ="+lCurrencyID;
 133        sql += " order by saccountno  ";
 134        
 135        return sql;
 136    }

 137    
 138    /**==========收款方银行账户编号放大镜(本转)====================*/
 139    function getPayeeBankNOSQL(bisBlurQuery,lClientID,lCurrencyID,sPayeeBankNo,sPayeeName)
 140    {
 141        var sql = " select seacct.id id, sPayeeName,sPayeeBankName,SPAYEEPROV,SPAYEECITY,sab.sbankaccountno accountBankNo,spayeeacctno displayAccountNo,"
 142                +"spayeeacctno||decode(baf.SBANKACCOUNTNO,null,'',' -- '||baf.SBANKACCOUNTNO) as spayeeacctno  "
 143                +"from OB_PAYEEINFO obacct,SETT_ACCOUNT seacct,SETT_ACCOUNTBANK sab "
 144                +",(select aa.SBANKACCOUNTNO,aa.NWITHINACCOUNTID id from Sett_bankAccountOfFiliale aa,SETT_accounttype bb where aa.naccounttype=bb.id(%2B) ) baf"
 145                +" where sPayeeName is not null "
 146                + " and seacct.id = baf.id(%2B)"
 147                + "  and sab.naccountid(%2B)=seacct.id "
 148                + " and obacct.niscpfacct= 1 and obacct.NSTATUSID = 1 and obacct.spayeeacctno=seacct.saccountno "
 149                + " and obacct.nclientid ="+lClientID+" and obacct.ncurrencyid ="+lCurrencyID;
 150        
 151        if (sPayeeBankNo!=null && sPayeeBankNo!="")
 152        {
 153            sql = sql + " and replace(obacct.spayeeacctno,'-','') like '%25" + sPayeeBankNo +"%25' ";
 154        }

 155        sql += " order by obacct.spayeeacctno ";
 156        
 157        return sql;
 158    }

 159    
 160   /**==========收款方银行账户编号放大镜(本转+内部转账)===========为长春一汽所增=========*/
 161   function getPayeeInternalBankAccountNoSQL(sBankAccountCode,lUserID,lClientID,lCurrencyID,lInstructionID)
 162   {
 163   
 164   
 165      
 166      var sql= " select distinct "+ lCurrencyID +" as CurrencyID, "+lInstructionID
 167                +" as InstructionID,a.sbankaccountno accountBankNo,b.sname snametest, a.sbankaccountno ,b.saccountno||decode(baf.SBANKACCOUNTNO,null,'',' -- '||baf.SBANKACCOUNTNO) as saccountno ,b.ID as nPayeeAccountID, b.saccountno spayeeacctno, b.saccountno displayAccountNo, b.sname sPayeeName,b.ID as id "
 168                + " from SETT_ACCOUNTBANK  a,SETT_account b ,SETT_accounttype c,OB_AccountOwnedByUser oba,Sett_bankAccountOfFiliale baf"
 169                + " where oba.sAccountNo=b.sAccountNo and a.naccountid(%2B)=b.id and b.nAccountTypeID=c.id(%2B) and c.nAccountGroupID=1 and c.ID!=97"
 170                + " and b.id = baf.NWITHINACCOUNTID(%2B)"
 171                + " and b.nStatusID=1 "
 172                + " and b.nCheckStatusID =4 " ;
 173        if (sBankAccountCode!=null && sBankAccountCode!="")
 174        {
 175            sql+=" and b.saccountno like '%25" + sBankAccountCode + "%25' ";
 176        }

 177        sql+= " and oba.nUserID="+lUserID+" and b.nclientid ="+lClientID+"  and b.ncurrencyid ="+lCurrencyID;
 178        sql+=" union ";
 179        sql+=" select distinct ob.nCurrencyid, -1 as InstructionID , '' accountBankNo ,'' displayAccountNo ,'' sbankaccountno ,";
 180        sql+="'' saccountno,-1 nAccountID,ob.spayeeacctno saccountno , ob.spayeeacctno spayeeacctno , ob.spayeename sname,s.id ";
 181        sql+="from OB_PayeeInfo ob, SETT_account s where ob.nclientid ="+lClientID+" and ob.nStatusid = 1 and ob.NISCPFACCT=1 and ob.spayeeacctno=s.saccountno";
 182     
 183        return sql;
 184   }

 185
 186    /**==========收款方银行账户编号放大镜(汇)====================*/
 187    function getPayeeAccountNOSQL(bisBlurQuery,lClientID,lCurrencyID,sPayeeAccountNo,sPayeeName)
 188    {
 189        var sql = " select id, sPayeeName,spayeeacctno,sPayeeBankName,SPAYEEPROV,SPAYEECITY from OB_PAYEEINFO  where sPayeeName is not null "
 190                + " and niscpfacct= 2 and NSTATUSID = 1 and nclientid ="+lClientID+" and ncurrencyid ="+lCurrencyID ;
 191        if (bisBlurQuery == true)
 192        {
 193            if (sPayeeName!=null && sPayeeName!="")
 194            {
 195                sql = sql + " and sPayeeName like '%25" + sPayeeName +"%25'";
 196            }

 197        }

 198        
 199        if (sPayeeAccountNo!=null && sPayeeAccountNo!="")
 200        {
 201            sql = sql + " and spayeeacctno like '%25" + sPayeeAccountNo +"%25'";
 202        }

 203        
 204        sql += " order by spayeeacctno";
 205        
 206        return sql;
 207    }

 208    
 209/**
 210 * 定期(通知)存款单据号
 211 * nOfficeID 办事处ID
 212 * sClientNo 客户编号
 213 * lDepositTypeID 存单类型:1,定期;2,通知。
 214 * nAccountID 主账户ID
 215 * nUserID 当前用户
 216 * sDepositNo 存单号
 217 * nTypeID 类型
 218 *     1,定期(通知)开立--复核匹配时使用
 219 *     21,定期(通知)支取--业务处理时使用
 220 *     22,定期(通知)支取--业务复核时使用
 221 *     3、定期续期转存--业务处理时使用(仅显示已到期的存单)
 222 * sSystemDate 开机日期
 223 */

 224
 225function getFixedDepositNoSQL(nOfficeID,nCurrencyID,lDepositTypeID,nAccountID,nUserID,sDepositNo,nTypeID,sSystemDate)
 226{
 227    //定期存单
 228    if (nTypeID == 1)
 229    {
 230        //定期(通知)开立--复核匹配时使用
 231        var sql = "select -1 SubAccountID,a.sDepositNo DepositNo,to_char(a.dtEnd,'yyyy-mm-dd') EndDate,'' OpenDate,0 Capital,0 Balance,nAccountID AccountID,0 Rate,0 Interval,'' StartDate ";
 232        sql += " from sett_TransOpenFixedDeposit a ";
 233        sql += " where a.nStatusID=2 ";
 234         
 235        if (lDepositTypeID == 1)
 236        {
 237            //定期开立
 238            sql += " and a.nTransactionTypeID=12"
 239        }

 240        else if (lDepositTypeID == 2)
 241        {
 242            //通知开立
 243            sql += " and a.nTransactionTypeID=15";             
 244        }

 245        if (nOfficeID > 0)
 246        {
 247            sql += " and a.nofficeid = " + nOfficeID; 
 248        }

 249        if (nCurrencyID > 0)
 250        {
 251            sql += " and a.nCurrencyID = " + nCurrencyID; 
 252        }

 253        if (nAccountID > 0)
 254        {
 255            sql += " and a.nAccountID = " + nAccountID; 
 256        }

 257        if (nUserID > 0)
 258        {
 259            sql += " and a.nInputUserID <> " + nUserID; 
 260        }

 261        if (sDepositNo != null && sDepositNo != ""
 262        {
 263            sql += " and a.sDepositNo like '%25" + sDepositNo + "%25'";
 264        }

 265        sql += " order by a.sDepositNo";
 266        
 267        return sql;
 268    }

 269    else if (nTypeID == 22 || nTypeID == 21)
 270    {
 271        //定期(通知)支取--业务处理 或 复核时使用
 272        var sql ="";
 273        if(lDepositTypeID == 1)
 274        {
 275            sql += "select a.ID SubAccountID,a.af_sDepositNo DepositNo,to_char(a.af_dtEnd,'yyyy-mm-dd') EndDate,to_char(a.dtOpen,'yyyy-mm-dd') OpenDate,a.mOpenAmount Capital,(a.mBalance-a.mUncheckPaymentAmount) Balance,ma.ID AccountID,round(AF_mRate,6) Rate,AF_nDepositTerm Interval,to_char(AF_dtStart,'yyyy-mm-dd') StartDate ";    
 276        }

 277        else if (lDepositTypeID == 2)
 278        {
 279            sql += "select a.ID SubAccountID,a.af_sDepositNo DepositNo,to_char(a.af_dtEnd,'yyyy-mm-dd') EndDate,to_char(a.dtOpen,'yyyy-mm-dd') OpenDate,a.mOpenAmount Capital,(a.mBalance-a.mUncheckPaymentAmount) Balance,ma.ID AccountID,round(AF_mRate,6) Rate,AF_NNOTICEDAY Interval,to_char(AF_dtStart,'yyyy-mm-dd') StartDate ";    
 280        }

 281        
 282        sql += " from sett_SubAccount a,sett_Account ma ";
 283        sql += " where a.nAccountID=ma.ID and a.nStatusID=1 ";
 284         
 285        if (nTypeID == 21)
 286        {
 287            sql += " and (a.mBalance - a.mUncheckPaymentAmount) > 0";
 288        }

 289        else if (nTypeID == 22)
 290        {
 291            //复核只显示已保存过的。
 292            //sql += " and a.ID in (select distinct nSubAccountID from SETT_TRANSFIXEDWITHDRAW where nStatusID=2)";
 293            sql += " and a.mUncheckPaymentAmount>0 ";
 294        }

 295        if (lDepositTypeID == 1)
 296        {
 297            //定期存款
 298            sql += " and ma.nAccountTypeID in( select id from sett_accounttype where naccountgroupid = 2 ) "
 299        }

 300        else if (lDepositTypeID == 2)
 301        {
 302            //通知存款
 303            sql += " and ma.nAccountTypeID in( select id from sett_accounttype where naccountgroupid = 3 ) ";             
 304        }

 305        else
 306        {
 307            sql += " and ma.nAccountTypeID in ( select id from sett_accounttype where naccountgroupid in(2,3) )";
 308        }

 309        if (nOfficeID > 0)
 310        {
 311            sql += " and ma.nofficeid = " + nOfficeID; 
 312        }

 313        if (nCurrencyID > 0)
 314        {
 315            sql += " and ma.nCurrencyID = " + nCurrencyID; 
 316        }

 317        if (nAccountID > 0)
 318        {
 319            sql += " and a.nAccountID = " + nAccountID; 
 320        }

 321        if (nUserID > 0)
 322        {
 323            //sql += " and a.nInputUserID <> " + nUserID; 
 324        }

 325        
 326        if (sDepositNo != null && sDepositNo != ""
 327        {
 328            sql += " and a.af_sDepositNo like '%25" + sDepositNo + "%25'";
 329        }

 330        sql += " order by a.af_sDepositNo ";
 331        
 332        return sql;            
 333    }

 334    else if (nTypeID == 3)
 335    {
 336        //定期续期转存--业务处理时使用
 337        var sql = "select a.ID SubAccountID,a.af_sDepositNo DepositNo,to_char(a.af_dtEnd,'yyyy-mm-dd') EndDate,to_char(a.dtOpen,'yyyy-mm-dd') OpenDate,a.mOpenAmount Capital,a.mBalance Balance,ma.ID AccountID,round(AF_mRate,6) Rate,AF_nDepositTerm Interval,to_char(AF_dtStart,'yyyy-mm-dd') StartDate ";
 338        sql += " from sett_SubAccount a,sett_Account ma ";
 339        sql += " where a.nAccountID=ma.ID and a.nStatusID=1 and ma.nAccountTypeID in( select id from sett_accounttype where naccountgroupid = 2 ) ";
 340         
 341        if (nOfficeID > 0)
 342        {
 343            sql += " and ma.nofficeid = " + nOfficeID; 
 344        }

 345        if (nCurrencyID > 0)
 346        {
 347            sql += " and ma.nCurrencyID = " + nCurrencyID; 
 348        }

 349        if (nAccountID > 0)
 350        {
 351            sql += " and a.nAccountID = " + nAccountID; 
 352        }

 353        if (nUserID > 0)
 354        {
 355            //sql += " and a.nInputUserID <> " + nUserID; 
 356        }

 357        if(sSystemDate != null && sSystemDate != "")
 358        {
 359            sql += " and a.af_dtEnd <= to_date('" + sSystemDate +"','yyyy-mm-dd')"
 360        }

 361        if (sDepositNo != null && sDepositNo != ""
 362        {
 363            sql += " and a.af_sDepositNo like '%25" + sDepositNo + "%25'";
 364        }

 365        sql += " order by a.af_sDepositNo ";
 366        
 367        return sql;            
 368    }

 369    else
 370    {
 371        //显示全部
 372        var sql = "select a.ID SubAccountID,a.af_sDepositNo DepositNo,to_char(a.af_dtEnd,'yyyy-mm-dd') EndDate,to_char(a.dtOpen,'yyyy-mm-dd') OpenDate,a.mOpenAmount Capital,a.mBalance Balance,ma.ID AccountID,round(AF_mRate,6) Rate,AF_nDepositTerm Interval,to_char(AF_dtStart,'yyyy-mm-dd') StartDate ";
 373        sql += " from sett_SubAccount a,sett_Account ma ";
 374        sql += " where a.nAccountID=ma.ID and a.nStatusID>0 ";
 375         
 376        if (nOfficeID > 0)
 377        {
 378            sql += " and ma.nofficeid = " + nOfficeID; 
 379        }

 380        if (nCurrencyID > 0)
 381        {
 382            sql += " and ma.nCurrencyID = " + nCurrencyID; 
 383        }

 384        if (lDepositTypeID == 1)
 385        {
 386            //定期存款
 387            sql += " and ma.nAccountTypeID  in ( select id from sett_accounttype where naccountgroupid = 2 )"
 388        }

 389        else if (lDepositTypeID == 2)
 390        {
 391            //通知存款
 392            sql += " and ma.nAccountTypeID in ( select id from sett_accounttype where naccountgroupid = 3 )";             
 393        }

 394        else
 395        {
 396            sql += " and ma.nAccountTypeID in ( select id from sett_accounttype where naccountgroupid in (2,3) )";
 397        }

 398        if (nAccountID > 0)
 399        {
 400            sql += " and a.nAccountID = " + nAccountID; 
 401        }

 402        if (sDepositNo != null && sDepositNo != ""
 403        {
 404            sql += " and a.af_sDepositNo like '%25" + sDepositNo + "%25'";
 405        }

 406        sql += " order by a.af_sDepositNo ";
 407        
 408        return sql;            
 409    }
    
 410
 411}

 412    
 413/**
 414 * 合同放大镜
 415 * nOfficeID 办事处ID
 416 * nCurrencyID 币种ID
 417 * nTypeIDArray 合同类型(信托,委托,贴现)
 418 * nStatusIDArray 合同状态
 419 * sContractCode 合同编号
 420 */

 421 
 422function getContractSQL(nOfficeID,nCurrencyID,sTypeIDArray,sStatusIDArray,sContractCode,nClientID)
 423{      
 424    var sql = "select contract.ID ContractID,contract.sContractCode ContractCode,contract.nBorrowClientID ClientID, client.sname ClientName from loan_contractform contract, client ";
 425    sql += " where contract.nborrowclientid=client.id and contract.nOfficeID is not null ";
 426    if (nOfficeID > 0)
 427    {
 428        sql += " and contract.nOfficeID = " + nOfficeID;
 429    }

 430    if (nCurrencyID > 0)
 431    {
 432        sql += " and contract.ncurrencyid = " + nCurrencyID;
 433    }

 434    if (sTypeIDArray != null && sTypeIDArray.length > 0)
 435    {
 436        sql += " and contract.nTypeID in ("+sTypeIDArray+")";
 437    }

 438    if (sStatusIDArray != null && sStatusIDArray.length > 0)
 439    {
 440        sql += " and contract.nStatusID in ("+sStatusIDArray+")";
 441    }

 442    if (sContractCode != null && sContractCode.length > 0)
 443    {
 444        sql += " and contract.sContractCode like '" + sContractCode + "%25'";
 445    }

 446    if (nClientID > 0)
 447    {
 448        sql += " and contract.nborrowclientid = " + nClientID;
 449    }

 450    sql += " order by contract.sContractCode";
 451    return sql;
 452    
 453}

 454
 455/**
 456 * 放款日期放大镜
 457 * nOfficeID 办事处ID
 458 * nCurrencyID 币种ID
 459 * nContractID 合同ID
 460 * sTypeIDArray 通知单类型
 461 * sStatusIDArray 通知单状态
 462 * sPayFormNo 放款通知单号
 463 */
 
 464function getPayFormSQL(nOfficeID,nCurrencyID,nClientID,nContractID,sTypeIDArray,sStatusIDArray,sPayFormNo)
 465{   
 466    var sql = "";   
 467    if (sStatusIDArray != null && (sStatusIDArray == '-100' || sStatusIDArray == '-200'))
 468    {//信托/委托收回,从子账户取值
 469        sql = "select a.id PayFormID,a.scode PayFormCode,b.ID ContractID,to_char(a.dtOutDate,'yyyy-mm-dd') PayDate,to_char(a.dtOutDate,'yyyy-mm-dd') InterestStartDate,to_char(a.dtStart,'yyyy-mm-dd') StartDate,to_char(a.dtEnd,'yyyy-mm-dd') EndDate,sa.ID SubAccountID,(sa.MBalance-sa.MUNCHECKPAYMENTAMOUNT) LoanBalance,sa.NAccountId LoanAccountID,sa.AL_nLoanNoteID LoanNoteID ";
 470        sql += " ,a.mInterestrate*(1 %2B b.mAdjustrate/100) as rate ";
 471        sql += " from LOAN_PAYFORM a,loan_contractform b,Client c,sett_SubAccount sa ";
 472        sql += " where a.nContractID = b.id and b.nBorrowClientID=c.ID and a.ID=sa.al_nLoanNoteID ";
 473        
 474        if (sStatusIDArray == '-100')
 475        {
 476            //收回——业务处理
 477            sql += " and sa.nstatusid=1 and (sa.mbalance-sa.mUncheckPaymentAmount) > 0 ";        
 478        }

 479        else
 480        {
 481            //收回——业务复核
 482            //sql += " and sa.nstatusid=1 and sa.al_nLoanNoteID in (select distinct nLoanNoteID from sett_TransRepaymentLoan where nStatusID=2) ";
 483            //sql += " and sa.nstatusid=1 and sa.mUncheckPaymentAmount>0 ";
 484        }

 485        
 486        if (nOfficeID > 0)
 487        {
 488            sql += " and b.nOfficeID = " + nOfficeID;
 489        }

 490        if (nCurrencyID > 0)
 491        {
 492            sql += " and b.nCurrencyID = " + nCurrencyID;
 493        }

 494        if (nClientID > 0)
 495        {
 496            sql += " and b.nBorrowClientID = " + nClientID;
 497        }

 498        if (nContractID > 0)
 499        {
 500            sql += " and a.nContractID = " + nContractID;
 501        }

 502        if (sTypeIDArray != null && sTypeIDArray.length > 0)
 503        {
 504            sql += " and b.nTypeID in ("+sTypeIDArray+")";
 505        }
    
 506        if (sPayFormNo != null && sPayFormNo.length > 0)
 507        {
 508            sql += " and a.scode like '" + sPayFormNo + "%25'";
 509        }

 510        sql += " order by a.scode";
 511    }

 512    else
 513    {//信托/委托发放,从信贷取值
 514        sql = "select a.id PayFormID,a.scode PayFormCode,b.ID ContractID,to_char(a.dtOutDate,'yyyy-mm-dd') PayDate,to_char(a.dtOutDate,'yyyy-mm-dd') InterestStartDate,to_char(a.dtStart,'yyyy-mm-dd') StartDate,to_char(a.dtEnd,'yyyy-mm-dd') EndDate,-1 SubAccountID ";
 515        sql += " ,a.mInterestrate*(1 %2B b.mAdjustrate/100) as rate ";
 516        sql += " from LOAN_PAYFORM a,loan_contractform b,Client c ";
 517        sql += " where a.nContractID = b.id and b.nBorrowClientID=c.ID ";
 518        
 519        if (nOfficeID > 0)
 520        {
 521            sql += " and b.nOfficeID = " + nOfficeID;
 522        }

 523        if (nCurrencyID > 0)
 524        {
 525            sql += " and b.nCurrencyID = " + nCurrencyID;
 526        }

 527        if (nClientID > 0)
 528        {
 529            sql += " and b.nBorrowClientID = " + nClientID;
 530        }

 531        if (nContractID > 0)
 532        {
 533            sql += " and a.nContractID = " + nContractID;
 534        }

 535        if (sTypeIDArray != null && sTypeIDArray.length > 0)
 536        {
 537            sql += " and b.nTypeID in ("+sTypeIDArray+")";
 538        }
    
 539        if (sStatusIDArray != null && sStatusIDArray.length > 0)
 540        {
 541            sql += " and a.nStatusID in ("+sStatusIDArray+")";
 542        }

 543        if (sPayFormNo != null && sPayFormNo.length > 0)
 544        {
 545            sql += " and a.scode like '" + sPayFormNo + "%25'";
 546        }

 547        sql += " order by a.scode";
 548    }

 549    
 550    return sql;
 551}

 552/**
 553 * 放款通知单放大镜
 554 * nOfficeID 办事处ID
 555 * nCurrencyID 币种ID
 556 * nContractID 合同ID
 557 * sTypeIDArray 通知单类型
 558 * sStatusIDArray 通知单状态
 559 * sPayFormNo 放款通知单号
 560 */
 
 561function getPayFormNOSQL(nClientID,nOfficeID,nCurrencyID,nContractID,sTypeIDArray,sStatusIDArray,sPayFormNo)
 562{   
 563    var sql = "";   
 564    if (sStatusIDArray != null && (sStatusIDArray == '-100' || sStatusIDArray == '-200' || sStatusIDArray == '-500' || sStatusIDArray == '-600'))
 565    {//信托/委托收回,从子账户取值
 566        sql = "select a.id PayFormID,a.scode PayFormCode,b.ID ContractID,to_char(a.dtOutDate,'yyyy-mm-dd') PayDate,to_char(a.dtOutDate,'yyyy-mm-dd') InterestStartDate,to_char(a.dtStart,'yyyy-mm-dd') StartDate,to_char(a.dtEnd,'yyyy-mm-dd') EndDate,sa.ID SubAccountID,(sa.mBalance-sa.mUncheckPaymentAmount) Balance, ";
 567        sql += " (select decode(count(*),0,0,1) from loan_FreeForm where nPayFormID=a.ID and nStatusID=2) IsHasFree ";
 568        sql += " from LOAN_PAYFORM a,loan_contractform b,Client c,sett_SubAccount sa,sett_Account account,loan_FreeForm ff ";
 569        sql += " where a.nContractID = b.id and b.nBorrowClientID=c.ID and a.ID=sa.al_nLoanNoteID and sa.nAccountID=account.ID and a.ID=ff.nPayFormID(%2B) ";
 570        sql += " and account.nAccountTypeID in ( select id from sett_accounttype where naccountgroupid in(4,5) ) ";
 571
 572        if (sStatusIDArray == '-100')
 573        {
 574            //贷款收回——业务处理
 575            sql += " and sa.nstatusid=1 and (sa.mbalance-sa.mUncheckPaymentAmount) > 0 ";        
 576        }

 577        else if (sStatusIDArray == '-500')
 578        {
 579            //利息费用/特殊业务——业务处理
 580            sql += " and sa.nstatusid=1  ";
 581        }

 582        else if (sStatusIDArray == '-200')
 583        {
 584            //贷款收回——业务复核
 585            sql += " and sa.nstatusid=1 and (sa.mUncheckPaymentAmount>0) ";
 586        }

 587        else if (sStatusIDArray == '-600')
 588        {
 589            //利息费用/特殊业务——业务复核
 590            sql += " and sa.nstatusid=1 ";
 591        }

 592        if (nClientID > 0)
 593        {
 594            sql += "and c.ID = " + nClientID;    
 595        }

 596        if (nOfficeID > 0)
 597        {
 598            sql += " and b.nOfficeID = " + nOfficeID;
 599        }

 600        if (nCurrencyID > 0)
 601        {
 602            sql += " and b.nCurrencyID = " + nCurrencyID;
 603        }

 604        if (nContractID > 0)
 605        {
 606            sql += " and a.nContractID = " + nContractID;
 607        }

 608        if (sTypeIDArray != null && sTypeIDArray.length > 0)
 609        {
 610            sql += " and b.nTypeID in ("+sTypeIDArray+")";
 611        }
    
 612        if (sPayFormNo != null && sPayFormNo.length > 0)
 613        {
 614            sql += " and a.scode like '" + sPayFormNo + "%25'";
 615        }

 616        sql += " order by a.scode";
 617    }

 618    else
 619    {//信托/委托发放,从信贷取值
 620        sql = "select a.id PayFormID,a.scode PayFormCode,b.ID ContractID,to_char(a.dtOutDate,'yyyy-mm-dd') PayDate,to_char(a.dtOutDate,'yyyy-mm-dd') InterestStartDate,to_char(a.dtStart,'yyyy-mm-dd') StartDate,to_char(a.dtEnd,'yyyy-mm-dd') EndDate,-1 SubAccountID,0.0 Balance,-1 IsHasFree ";
 621        sql += " from LOAN_PAYFORM a,loan_contractform b,Client c ";
 622        sql += " where a.nContractID = b.id and b.nBorrowClientID=c.ID ";
 623        
 624        if (nClientID > 0)
 625        {
 626            sql += "and c.ID = " + nClientID;    
 627        }

 628        if (nOfficeID > 0)
 629        {
 630            sql += " and b.nOfficeID = " + nOfficeID;
 631        }

 632        if (nCurrencyID > 0)
 633        {
 634            sql += " and b.nCurrencyID = " + nCurrencyID;
 635        }

 636        if (nContractID > 0)
 637        {
 638            sql += " and a.nContractID = " + nContractID;
 639        }

 640        if (sTypeIDArray != null && sTypeIDArray.length > 0)
 641        {
 642            sql += " and b.nTypeID in ("+sTypeIDArray+")";
 643        }
    
 644        if (sStatusIDArray != null && sStatusIDArray.length > 0)
 645        {
 646            sql += " and a.nStatusID in ("+sStatusIDArray+")";
 647        }

 648        if (sPayFormNo != null && sPayFormNo.length > 0)
 649        {
 650            sql += " and a.scode like '" + sPayFormNo + "%25'";
 651        }

 652        sql += " order by a.scode";
 653    }

 654    
 655    return sql;
 656}

 657
 658
 659/**===========利率放大镜(带出改动后的利率)===============*/
 660function getRateSQL(lCurrencyID,changeRate)
 661{
 662    var lTmpRate = 1+changeRate/100;
 663 var strSQL = " select RateID,RateCode,mRate,RateName,RateValue,dtValiDate,adjustRate from ("  
 664     strSQL += "  select b.id RateID,a.SINTERESTRATENO RateCode,round(b.mRate,6) mRate, a.sinterestratename as RateName,";
 665    strSQL  += " round(b.mRate,6) RateValue,to_char(b.dtValiDate,'yyyy-mm-dd') as dtValiDate ";
 666    if(changeRate!=null&&changeRate!="")
 667    {
 668        strSQL += ",(b.mRate <%=URLEncoder.encode("*")%>"+lTmpRate+") as adjustRate ";
 669    }
else
 670    {
 671        strSQL += ",0 as adjustRate ";
 672    }

 673    strSQL  += " from LOAN_INTERESTRATETYPEINFO a,LOAN_INTERESTRATE  b ";
 674    strSQL  += " where a.id = b.nBankInterestTypeID and b.dtValiDate <= sysdate ";
 675  /*if (strCode != null && strCode != "") 
 676  {
 677       strSQL += " and a.sInterestRateNo like '<%=URLEncoder.encode("%")%>"+strCode+"<%=URLEncoder.encode("%")%>' ";
 678  }*/

 679  if (lCurrencyID > 0)
 680  {
 681       strSQL=strSQL+ " and a.nCurrencyID = "+lCurrencyID;
 682  }

 683    strSQL+=" and (a.id,b.dtvalidate) in ";
 684    strSQL+=" (   select a.id,max(b.dtvalidate) from loan_INTERESTRATETYPEINFO a,loan_InterestRate b ";
 685    strSQL+=" WHERE ";
 686    strSQL+=" a.ID=b.NBANKINTERESTTYPEID ";
 687    strSQL+=" and  to_char(b.DTVALIDATE,'yyyymmdd')<=to_char(sysdate,'yyyymmdd') ";
 688    strSQL+=" group by a.id ) ";
 689
 690    strSQL = strSQL + " union ";
 691    strSQL = strSQL + " select b.id RateID,a.sInterestRateNo RateCode,round(b.mRate,6) mRate,a.sInterestRateName as RateName,";
 692    strSQL  += " round(b.mRate,6) RateValue,to_char(b.dtValiDate,'yyyy-mm-dd') as dtValiDate "
 693    if(changeRate!=null&&changeRate!="")
 694    {
 695        strSQL += ",(b.mRate <%=URLEncoder.encode("*")%>"+lTmpRate+") as adjustRate ";
 696    }
else
 697    {
 698        strSQL += ",0 as adjustRate ";
 699    }

 700    strSQL  += " from loan_INTERESTRATETYPEINFO a,loan_InterestRate  b ";
 701    strSQL = strSQL + " where a.id = b.nBankInterestTypeID and b.dtvalidate > sysdate ";
 702     /*if (strCode != null && strCode != "") 
 703      {
 704           strSQL += " and a.sInterestRateNo like '<%=URLEncoder.encode("%")%>"+strCode+"<%=URLEncoder.encode("%")%>' ";
 705      }*/

 706      if (lCurrencyID > 0)
 707      {
 708           strSQL=strSQL+ " and a.nCurrencyID = "+lCurrencyID;
 709      }

 710        //strSQL = strSQL + " order by sCode,dtValidate";
 711      strSQL = strSQL + ") order by mRate ";
 712      return strSQL;
 713}

 714
 715/**
 716 * 外部账户放大镜
 717 * nOfficeID 办事处ID
 718 * sExtAcctNo 外部账户编号
 719 */

 720function getExtAcctSQL(nOfficeID,sExtAcctNo)
 721{      
 722    var sql = "select ID ExtAcctID,sExtAcctNo ExtAcctNo,sExtAcctName ExtAcctName,sProvince ExtProvince,sCity ExtCity,sBankName ExtBankName ";
 723    sql += " from sett_ExternalAccount where nOfficeID is not null ";
 724    if (nOfficeID > 0)
 725    {
 726        sql += " and nOfficeID = " + nOfficeID;
 727    }

 728    if (sExtAcctNo != null && sExtAcctNo.length > 0)
 729    {
 730        sql += " and sExtAcctNo like '%25" + sExtAcctNo + "%25'";
 731    }

 732    sql += " order by sExtAcctNo";
 733    
 734    return sql;
 735}

 736
 737/**
 738 * 开户行放大镜的SQL语句
 739 * nOfficeID 办事处ID
 740 * nCurrencyID 币种ID
 741 * nIsSingleBank 是否单边账银行(1,是;其它,不是)
 742 * nAccountID 账户ID
 743 * sBranchNoOrName 开户行编号或名称
 744 */

 745function getBranchSQL(nOfficeID, nCurrencyID,nIsSingleBank,nAccountID,sBranchNoOrName)
 746{
 747    var sql = "";
 748    if (nAccountID > 0)
 749    {
 750        sql = "select distinct b.ID BranchID,b.sCode BranchNo,b.sName BranchName,ab.sBankAccountNo BranchAccountNo";
 751        sql += " from sett_Branch b,sett_AccountBank ab ";
 752        sql += " where b.nStatusID=1 and ab.nBankID(%2B)=b.ID";
 753        
 754        sql += " and ab.nAccountID = " + nAccountID;
 755    }

 756    else
 757    {
 758        sql = "select distinct b.ID BranchID,b.sCode BranchNo,b.sName BranchName,'' BranchAccountNo";
 759        sql += " from sett_Branch b ";
 760        sql += " where b.nStatusID=1 ";
 761    }

 762    if (nOfficeID > 0)
 763    {
 764        sql += " and b.nOfficeID = " + nOfficeID;
 765    }

 766    if (nCurrencyID > 0)
 767    {
 768        sql += " and b.nCurrencyID = " + nCurrencyID;
 769    }
        
 770    if (nIsSingleBank = 1)
 771    {
 772        //目前还没有用
 773    }
    
 774    if (sBranchNoOrName != null && sBranchNoOrName.length > 0)
 775    {
 776        sql += " and (b.sCode like '%25" + sBranchNoOrName + "%25' or b.sName like '%25"+sBranchNoOrName+"%25')";
 777    }
    
 778    sql += " order by b.sCode";
 779    
 780    return sql;
 781}

 782/**==========合同放大镜SQL语句===========
 783* nconsignclientid 登陆单位
 784*=====================================*/

 785function getContractSQL1(clientid,currencyid)
 786{
 787
 788    var strSQL = " select a.sContractCode as ContractCode, a.id as ID ";
 789        strSQL +=" ,b.ID as ClientID,b.sName as ClientName ";
 790        strSQL += " ,-1 as NullID,'' as NullName ";//NullID NullName 是用来清空由合同ID决定的放款单编号等等
 791        strSQL +=" from LOAN_ContractForm a,Client b where 1=1 ";
 792        strSQL +=" and a.NBORROWCLIENTID=b.ID(%2B) ";
 793        strSQL += " and a.nTypeID in (2)";//委托免还,委托统借统还
 794        strSQL += " and a.NSTATUSID in (5,6)"//状态为执行中,一展期
 795        if(currencyid>0)
 796        {
 797            strSQL += " and a.ncurrencyid = "+currencyid; 
 798        }

 799        if(clientid>0)
 800        {
 801            strSQL += " and a.nconsignclientid = "+clientid; //委托单位是登陆单位
 802        }

 803
 804        strSQL += " order by a.sContractCode ";//按合同编号排序
 805    return strSQL;
 806}

 807
 808function getContractSQL2(clientid,currency)
 809{
 810    var strSQL = " select a.sContractCode as ContractCode, a.id as ID ";
 811        strSQL +=" ,b.ID as ClientID,b.sName as ClientName ";
 812        strSQL += " ,-1 as NullID,'' as NullName ";//NullID NullName 是用来清空由合同ID决定的放款单编号等等
 813        strSQL +=" from LOAN_ContractForm a,Client b where 1=1 ";
 814        strSQL +=" and a.NBORROWCLIENTID=b.ID(%2B) ";
 815        strSQL += " and a.nTypeID in (8)";//银团
 816        strSQL += " and a.NSTATUSID in (4,5,6)"//状态为未执行,执行中,以展期
 817        strSQL += " and a.NCURRENCYID = "+currency
 818        if(clientid>0)
 819        {
 820        strSQL += " and a.NBORROWCLIENTID = "+clientid ; //委托单位是登陆单位
 821        }

 822        
 823        strSQL += " order by a.sContractCode ";//按合同编号排序
 824
 825    return strSQL;
 826}

 827
 828function getContractSQL3(clientid,currency)
 829{
 830    var strSQL = " select a.sContractCode as ContractCode, a.id as ID ";
 831        strSQL +=" ,b.ID as ClientID,b.sName as ClientName ";
 832        strSQL += " ,-1 as NullID,'' as NullName ";//NullID NullName 是用来清空由合同ID决定的放款单编号等等
 833        strSQL +=" from LOAN_ContractForm a,Client b where 1=1 ";
 834        strSQL +=" and a.NBORROWCLIENTID=b.ID(%2B) ";
 835        strSQL += " and a.NSTATUSID in (4,5,6)"//状态为未执行,执行中,以展期
 836        strSQL += " and a.nTypeID !=3";//不是贴现
 837        //strSQL += " and a.nTypeID !=8";
 838        strSQL += " and a.NCURRENCYID = "+currency;
 839        if(clientid>0)
 840        {
 841        strSQL += " and a.NBORROWCLIENTID = "+clientid ; //委托单位是登陆单位
 842        }

 843        
 844        strSQL += " order by a.sContractCode ";//按合同编号排序
 845
 846    return strSQL;
 847}

 848/**==================客户放大镜==================
 849* lType  查找类型
 850* lOfficeID 办事处标识
 851*=====================================*/

 852function getClientSQL()
 853{
 854    var strSQL  = " select distinct a.sCode ClientCode, a.ID, a.sName ClientName, ";
 855        strSQL += " a.sLicenceCode LicenceCode, b.ID OfficeID, b.sCode OfficeCode, b.sName OfficeName ";
 856        strSQL += " ,a.sLoanCardNo as CardNo,a.sLoanCardPwd as PassWord ";
 857        strSQL += " ,-1 as NullID,'' as NullName ";//NullID NullName 是用来清空由与其关联的控件ID和txt
 858        strSQL += " from Client a, Office b ";
 859        strSQL += " where a.nOfficeID =b.ID and a.nStatusID= 1"//有效
 860        strSQL += " order by a.sCode ";
 861        return strSQL;
 862}
    
 863
 864function getClient()
 865{
 866    var sql = "SELECT id,sCode,sName,SLOANCARDNO,SLOANCARDPWD FROM client where nStatusID=<%=Constant.RecordStatus.VALID%> order by sCode";
 867    return sql ;
 868}

 869
 870/**===========放款通知单放大镜===============/
 871* lType  查找类型  1:委托免还;  2:逾期  3:
 872* lLoanType 贷款种类
 873* lContractID 合同id
 874* lInputUserID 用户标识
 875* lContractInputUserID 合同输入人
 876*=====================================*/

 877function getLoanPaySQL(lContractID,lCurrencyID,lClientID)
 878{
 879    var strSQL ="";
 880    strSQL = " select a.sCode as LoanPayCode,a.id as id,b.sContractCode as ContractCode,b.ID as ContractID ";
 881    strSQL +=" ,c.ID as ClientID,c.sName as ClientName ";
 882    strSQL +=" ,SA.mBalance as Balance  ";
 883    strSQL +=" from LOAN_PayForm a,loan_contractform b,Client c ";
 884    strSQL +=" ,sett_subaccount SA ";
 885    strSQL +=" where 1=1 ";
 886    strSQL +=" and a.ID = SA.Al_NloanNoteid(%2B) ";
 887    strSQL +=" and a.nContractID=b.ID and c.ID=b.NBORROWCLIENTID ";
 888    strSQL += " and b.nTypeID in (2)";//委托免还,委托统借统还
 889    strSQL += " and a.nstatusid in (4)";//使用used
 890    //var  = 0;
 891    if(lCurrencyID > 0)
 892    {
 893        strSQL += " and b.ncurrencyid = " + lCurrencyID ;
 894    }

 895    if(lContractID > 0)
 896    {
 897        strSQL += " and b.ID = " + lContractID ;
 898    }

 899    if(lClientID > 0)
 900    {
 901        strSQL += " and b.nConsignClientId = " + lClientID ;
 902    }

 903    strSQL += " order by b.sContractCode,a.SCODE ";//按照合同编号大排序, 再按照放款单编号排序
 904    return strSQL;
 905}

 906
 907function getClient()
 908{
 909    var strSQL  = " select distinct a.sCode ClientCode, a.ID, a.sName ClientName";
 910        strSQL += "  from Client a where  a.nStatusID= 1 order by a.sCode ";
 911        return strSQL;
 912}
    
 913
 914/**==========用户放大镜===============*/
 915function getUserSQL(nOfficeID,nCurrencyID,nClinetID,sUserName)
 916{
 917    var sql = "select u.ID UserID,u.sName UserName ,c.sname ClinetName";
 918    sql += " from ob_user u ,client c";
 919    sql += " where u.nStatus=1 and u.nClientID = c.id";
 920    if (nOfficeID > 0)
 921    {
 922        sql += " and u.nOfficeID = " + nOfficeID;
 923    }

 924    if (nClinetID > 0)
 925    {
 926        sql += " and c.id = " + nClinetID;
 927    }

 928    if(sUserName != null && sUserName.length > 0)
 929    {
 930      sql += " and u.sName like '%25" + sUserName + "%25'";
 931    }

 932    sql += " order by u.sName";
 933    
 934    return sql;
 935}

 936
 937function getApprovalSettingSQL(OfficeID,CurrencyID)
 938{
 939    var strSQL  =" select rownum,ID,sName ";        
 940        strSQL +=" from ob_approvalsetting where 1=1 ";
 941        strSQL +=" and nStatusID = 2 ";//激活状态
 942        strSQL +=" and nOfficeID = " + OfficeID;
 943        strSQL +=" and nCurrencyID = " + CurrencyID;   
 944    //strSQL += "  order by ID ";
 945    return strSQL;
 946}

 947
 948function getApprovalSettingSQL(nOfficeID,lApprovalID,nClientID)
 949{
 950    var sql = "select a.ID, a.sName,rownum ";
 951    sql += " from ob_approvalSetting a,ob_user b ";
 952    sql += " where a.nInputUserID=b.id and a.nStatusID = 2 ";
 953 
 954   if (nOfficeID > 0)
 955    {
 956        sql += " and a.nOfficeID = " + nOfficeID; 
 957    }

 958   if (nClientID > 0)
 959    {
 960        sql += " and b.nClientID = " + nClientID; 
 961    }

 962   if (lApprovalID > 0)
 963    {
 964        sql += " and a.ID = " + lApprovalID; 
 965    }

 966    return sql;
 967}

 968
 969function getPeriodSetting()
 970{
 971    var sql = "select id,PERIOD,PERIODNAME,STARTDATE from SETT_PERIODSETTING";
 972    return sql;
 973}

 974
 975/**
 976 * 账户放大镜的SQL语句
 977 * nOfficeID 办事处ID
 978 * nCurrencyID 币种ID
 979 * nAccountGroupType 账户组类型
 980 * nAccountTypeID 账户类型
 981 * lReceiveOrPay 收或付
 982 * nClientID 客户ID
 983 * sAccountNo 账户编号
 984 */

 985function getAccountSQL1(nOfficeID,nCurrencyID,nAccountGroupType,nAccountTypeID,lReceiveOrPay,nClientID,sAccountNo)
 986{      
 987    /*-----------Modify By Gqfang 04-03-02
 988    var sql = "select a.ID as AccountID,a.sAccountNo AccountNo,a.sName AccountName,c.ID as ClientID,c.sCode as ClientNo,c.sName as ClientName ";
 989    sql += " from sett_Account a, Client c,sett_AccountType at ";
 990    sql += " where a.nClientID=c.ID and a.nAccountTypeID=at.ID ";
 991    */

 992    //edit by rxie for nhcw
 993    var sql = "select a.ID as AccountID,a.sAccountNo AccountNo,a.sName AccountName,c.ID as ClientID,c.sCode as ClientNo,c.sName as ClientName ,decode((ss.mbalance - ss.muncheckpaymentamount),0,'0.00',TO_CHAR((ss.mbalance - ss.muncheckpaymentamount),'999,999,999,999,999,999,999.99') ) mBalance";
 994    sql += " from sett_Account a, Client c,sett_AccountType at ,";
 995    sql += " (select sub.* from sett_account acc,sett_subaccount sub,sett_accounttype acctype where acc.id=sub.naccountid and acc.naccounttypeid=acctype.id and acctype.naccountgroupid = 1 and sub.nStatusID > 0) ss ";
 996    sql += " where a.nClientID=c.ID and a.nAccountTypeID=at.ID and    a.id = ss.naccountid(%2B)";
 997
 998    if (lReceiveOrPay == -1000)
 999    {
1000        //账户信息查询专用,可以查出所有状态的账户
1001        sql += " and a.nCheckStatusID=4 ";
1002    }

1003    else
1004    {
1005        sql += " and a.nStatusID in (1,2,3,7,8) and a.nCheckStatusID=4 ";
1006    }

1007    
1008    if (nOfficeID > 0)
1009    {
1010        sql += " and a.nOfficeID = " + nOfficeID;
1011    }

1012    if (nCurrencyID > 0)
1013    {
1014        sql += " and a.nCurrencyID = " + nCurrencyID;
1015    }

1016    if (nAccountGroupType == 1)
1017    {
1018        sql += " and at.nAccountGroupID in (1,7)";
1019    }

1020    else if (nAccountGroupType > 1)
1021    {
1022        sql += " and at.nAccountGroupID = " + nAccountGroupType;
1023    }

1024    else if(nAccountGroupType==-12)//所有存款账户
1025    {
1026        sql += " and at.nAccountGroupID in (1,2,3,7)";
1027    }

1028    else if(nAccountGroupType==-1000)//所有贷款账户
1029    {
1030        sql += " and at.nAccountGroupID in (4,5,6,8)";
1031    }

1032    if (nAccountTypeID > 0)
1033    {
1034        sql += " and a.nAccountTypeID = " + nAccountTypeID;
1035    }

1036    else if (nAccountTypeID == -100)
1037    {
1038        sql += " and at.nAccountGroupID in (4,5) ";
1039    }

1040    if (lReceiveOrPay > 0)
1041    {
1042        //收或付(目前没有用)
1043    }
    
1044    if (nClientID > 0)
1045    {
1046        sql += " and a.nClientID = " + nClientID;
1047    }

1048    if (sAccountNo != null && sAccountNo.length > 0)
1049    {
1050        sql += " and a.sAccountNo like '%25" + sAccountNo + "%25'";
1051    }

1052    sql += " order by a.sAccountNo";
1053    
1054    return sql;
1055}

1056/**
1057 * 摘要放大镜
1058 * nOfficeID 办事处ID
1059 * sCodeOrDesc 摘要代码或描述
1060 */

1061function getAbstractSQL(nOfficeID,nClientID,sCodeOrDesc)
1062{   
1063    sCodeOrDesc = encodeURI(sCodeOrDesc);//转码成 utf-8
1064    var sql = "select ID AbstractID,sCode AbstractCode,sDesc AbstractDesc from ob_StandardAbstract ";
1065    sql += " where nStatusID > 0";
1066    if (nOfficeID > 0)
1067    {
1068        sql += " and nOfficeid = " + nOfficeID;
1069    }

1070     if (nClientID > 0)
1071    {
1072        sql += " and nclientid = " + nClientID;
1073    }

1074    if (sCodeOrDesc != null && sCodeOrDesc.length > 0)
1075    {
1076        sql += " and (sCode like '%25" + sCodeOrDesc + "%25' or sDesc like '%25" + sCodeOrDesc + "%25')";
1077    }

1078     if (nClientID > 0)
1079    {
1080        sql += " and nclientid = " + nClientID;
1081    }

1082    sql += " order by sCode";
1083    
1084    return sql;
1085}