package zr.zrpower.ejb.sys;

import zr.zrpower.common.util.Log;
import zr.zrpower.common.db.*;
import zr.zrpower.common.util.SysPreperty;
import java.util.Hashtable;

 /**
 * 界面公共函数库
 * <p>Title: 界面公共函数库</p>
 * <p>public String LoadMainUP            //生成主框架上面页面的菜单</p>
 * <p>public String LoadMenuItem          //生成主框架左边页面的一级菜单</p>
 * <p>public String LoadSubItem           //生成主框架左边页面的二级菜单</p>
 * <p>public String ShowHeadHtml          //显示（表单脚/表格/窗体）头部HTML</p>
 * <p>public String ShowHeadHtml          //显示（表单脚/表格/窗体）头部HTML(带自定义图标)</p>
 * <p>public String ShowTitleHtml         //显示(功能标题)HTML</p>
 * <p>public String ShowTitleEndHtml      //显示(功能标题)结束HTML</p>
 * <p>public String ShowMenuHtml          //显示表单上的菜单（功能按钮）原样式</p>
 * <p>public String ShowButtonHtml        //显示功能按钮</p>
 * <p>public String ClickButton           //显示点击或链接按钮</p>
 * <p>public String ClickButton1          //显示点击按钮</p>
 * <p>public String ShowBodyStartHtml     //显示（表单脚/表格/窗体）中间开始部分HTML</p>
 * <p>public String ShowBodyEndHtml       //显示（表单脚/表格/窗体）中间结束部分HTML</p>
 * <p>public String ShowPageMenuHtml      //显示翻页HTML（全选、翻页）</p>
 * <p>public String ShowPageMenuHtml      //显示翻页HTML（全选、翻页不一定存）</p>
 * <p>public String ShowPageMenuHtml      //显示脚注菜单</p>
 * <p>public String ShowFootHtml          //显示（表单脚/表格/窗体）页脚(原样式)</p>
 * <p>public String ShowFootHtml()        //显示表单结束部分</p>
 * <p>public String CreatePageMenu        //实现记录集分页显示</p>
 * <p>public String ShowNullRecord        //显示不满一页时的空记录数</p>
 **/
public class UIService
  {
  static private Log log;
  dbEngine dbengine;
  static private int clients=0;

  public int intCurrentPage;
  public int intRecordCount;
  public UIService()
  {
    dbengine = new dbEngine(SysPreperty.getProperty().MainDataSource,SysPreperty.getProperty().IsConvert);
    dbengine.initialize();

    if (clients<1)
    {
      log = new Log();
      log.SetLogForClass("UIService");
      log.SetLogFile("UIEjb.log");

    }
    clients++;
  }

  /**
   * Html5新框架菜单,左边菜单为一体
   * @param strUser_No  登陆用户ID
   * @return
   */
  public String LoadMenuNew(String strUser_No){
	  StringBuffer returnStr=new StringBuffer();
	  String strSql="",MenId="",Name="",url="javascript:;";
	  strSql = "select MENUNO,MENUNAME,URL,ISOPEN  from BPIP_MENU where FLAG='1' and  MENUNO like '___' and  "
		       +"MENUNO in (select distinct substr(MENUNO,1,3) from BPIP_ROLE_RERMISSISSON where ROLEID "
		       +"in (select ROLEID from BPIP_USER_ROLE where USERID='"+strUser_No+"')) order by MNCODE,MENUNO";
	  dbSet ds = dbengine.QuerySQL(strSql);//第一级菜单
	  if(ds!=null&&ds.RowCount()>0){
		  for(int i=0;i<ds.RowCount();i++){
			  MenId=ds.Row(i).Column("MENUNO").getString();
			  Name=ds.Row(i).Column("MENUNAME").getString();
			  if(ds.Row(i).Column("URL").getString()!=null&&ds.Row(i).Column("URL").getString().length()>1){
				  url=ds.Row(i).Column("URL").getString();
			  }else{
				  url="javascript:;";
			  }

			  //查询第二季菜单class="dropdown-toggle"
			  strSql = "select URL,MENUNO,ISOPEN,MENUNAME from BPIP_MENU where FLAG='1' and "
				  +"MENUNO like '"+MenId+"___'  and MENUNO in (select distinct substr(MENUNO,1,6) from BPIP_ROLE_RERMISSISSON where ROLEID in "
				  +"(select ROLEID from BPIP_USER_ROLE where USERID='"+strUser_No+"'))  order by MNCODE,MENUNO";
			  dbSet ds2 = dbengine.QuerySQL(strSql);
			  //第二级菜单
			  if(ds2!=null&&ds2.RowCount()>0){//存在
				  if(i==0){
					  returnStr.append("<li ><a href=\""+url+"\" class=\"dropdown-toggle\"><i class=\"icon-dashboard\"></i><span class=\"menu-text\">"+Name+"</span>\t\n");
				  }else{
					  returnStr.append("<li><a href=\""+url+"\" class=\"dropdown-toggle\"><i class=\"icon-desktop\" ></i><span class=\"menu-text\">"+Name+"</span>\t\n");
				  }
				  returnStr.append("<b class=\"arrow icon-angle-down\"></b></a>\t\n");
				  returnStr.append("<ul class=\"submenu\">\t\n");
				  for(int j=0;j<ds2.RowCount();j++){
					  MenId=ds2.Row(j).Column("MENUNO").getString();
					  Name=ds2.Row(j).Column("MENUNAME").getString();
					  if(ds2.Row(j).Column("URL").getString()!=null&&ds2.Row(j).Column("URL").getString().length()>1){
						  if(!ds2.Row(j).Column("URL").getString().equals("1")){//本地窗口打开
							  url="onClick=\"Javascript:setMenu('"+Name+"','"+ds2.Row(j).Column("URL").getString()+"');\"";
						  }else{//新窗口打开
							  //url="onClick=\"Javascript:setMenu('"+Name+"','"+ds2.Row(j).Column("URL").getString()+"');\"";
							  url="onClick=\"javascript:OpenFullUrl('"+ds2.Row(j).Column("URL").getString()+"',,'800','600');\"";
						  }
					  }else{
						  url="";
					  }

					  //查询第三级菜单
					  strSql = "select  URL,MENUNO,ISOPEN,MENUNAME from BPIP_MENU where FLAG='1' and ISPOWER='1' "
						  +"and MENUNO like '"+MenId+"___' and MENUNO in (select MENUNO from BPIP_ROLE_RERMISSISSON where ROLEID in "
						  +"(select ROLEID from BPIP_USER_ROLE where USERID='"+ strUser_No+"')) order by MNCODE,MENUNO";
					  dbSet ds3 = dbengine.QuerySQL(strSql);
					  if(ds3!=null&&ds3.RowCount()>0){//存在第三届菜单
						  returnStr.append("<li><a href=\"javascript:;\" class=\"dropdown-toggle\" "+url+"><i class=\"icon-double-angle-right\"></i>"+Name+"\t\n");
						  returnStr.append("<b class=\"arrow icon-angle-down\"></b></a>\t\n");
						  returnStr.append("<ul class=\"submenu\">\t\n");
						  for(int k=0;k<ds3.RowCount();k++){
							  Name=ds3.Row(k).Column("MENUNAME").getString();
							  if(ds3.Row(k).Column("URL").getString()!=null&&ds3.Row(k).Column("URL").getString().length()>1){

								  if(!ds3.Row(k).Column("ISOPEN").getString().equals("1")){//本地窗口打开
									  url="onClick=\"Javascript:setMenu('"+Name+"','"+ds3.Row(k).Column("URL").getString()+"');\"";
								  }else{//新窗口打开
									  //url="onClick=\"Javascript:setMenu('"+Name+"','"+ds2.Row(j).Column("URL").getString()+"');\"";
									  url="onClick=\"javascript:OpenFullUrl('"+ds3.Row(k).Column("URL").getString()+"','800','600');\"";
								  }
							  }else{
								  url="";
							  }
							  returnStr.append("<li><a href=\"javascript:;\" "+url+"><i class=\"icon-leaf\"></i>"+Name+"</a></li>\t\n");
						  }
						  returnStr.append("</ul>\t\n");
					  }else{
						  returnStr.append("<li><a href=\"javascript:;\" "+url+"><i class=\"icon-double-angle-right\"></i>"+Name+"\t\n");
						  returnStr.append("</a>");
					  }
					  returnStr.append("</li>\t\n");
					  ds3 = null;
				  }
				  returnStr.append("</ul>\t\n");
			  }else{//不存在
				  if(i==0){
					  returnStr.append("<li ><a href=\""+url+"\"><i class=\"icon-dashboard\"></i><span class=\"menu-text\">"+Name+"</span>\t\n");
				  }else{
					  returnStr.append("<li><a href=\""+url+"\"><i class=\"icon-desktop\"></i><span class=\"menu-text\">"+Name+"</span>\t\n");
				  }
				  returnStr.append("</a>\t\n");
			  }
			  returnStr.append("</li>\t\n");
			  ds2 = null;
		  }
	  }
	  ds=null;
	  return returnStr.toString();
  }








//qq三级菜单---
public String LoadMenuItem(String strUser_No) {
    String  strSql = "";
    String  strSqlA = "";
    String  strSqlB = "";
    String  strResult = "";
    String  strTmp = "";
    String  strPARENTNO = "";
    String  strYPARENTNO = "";
    String  strMENUNO = "";
    String  strMENUNAME = "";
    String  strURL = "";
    String  strISOPEN = "";
    int num=0;
    int znum=0;

    Hashtable Hashtable1 = new Hashtable();//一级菜单对应的二级菜单表
    Hashtable Hashtable2 = new Hashtable();//二级菜单对应的三级菜单表

    try {

        //---一级菜单------------
        if (strUser_No.equals("0000000000000000"))
        {
           strSql = "select MENUNO,MENUNAME,URL,ISOPEN from BPIP_MENU where FLAG='1' and MENUNO like '___' order by MNCODE,MENUNO";
        }else
        {
           strSql = "select MENUNO,MENUNAME,URL,ISOPEN from BPIP_MENU where FLAG='1' and  MENUNO like '___' and  MENUNO in (select distinct substr(MENUNO,1,3) from BPIP_ROLE_RERMISSISSON where ROLEID in (select ROLEID from BPIP_USER_ROLE where USERID='"+strUser_No+"')) order by MNCODE,MENUNO";
        }

        //二级菜单----------------
        if (strUser_No.equals("0000000000000000")) {
            strSqlA = "select URL,MENUNO,ISOPEN,MENUNAME from BPIP_MENU where FLAG='1' and  MENUNO like '______'  order by MNCODE,MENUNO";
        }else
        {
            strSqlA = "select URL,MENUNO,ISOPEN,MENUNAME from BPIP_MENU where FLAG='1' and   MENUNO like '______'  and MENUNO in (select distinct substr(MENUNO,1,6) from BPIP_ROLE_RERMISSISSON where ROLEID in (select ROLEID from BPIP_USER_ROLE where USERID='"+strUser_No+"'))  order by MNCODE,MENUNO";
        }
        //三级菜单----------------
        if (strUser_No.equals("0000000000000000"))
        {
           strSqlB = "select URL,MENUNO,ISOPEN,MENUNAME from BPIP_MENU where FLAG='1' and ISPOWER='1'  and MENUNO like '_________'  order by MNCODE,MENUNO";
        }else
        {
           strSqlB = "select  URL,MENUNO,ISOPEN,MENUNAME from BPIP_MENU where FLAG='1'  and ISPOWER='1'  and MENUNO like '_________' and MENUNO in (select MENUNO from BPIP_ROLE_RERMISSISSON where ROLEID in (select ROLEID from BPIP_USER_ROLE where USERID='"+ strUser_No+"')) order by MNCODE,MENUNO";
        }

        //二级菜单装入对照表
        dbSet ds = dbengine.QuerySQL(strSqlA);
        if (ds != null && ds.RowCount() > 0) {
          for (int i = 0; i < ds.RowCount(); i++) {
               strMENUNO = ds.Row(i).Column("MENUNO").getString();
               strPARENTNO = strMENUNO.substring(0,3);
               strMENUNAME = ds.Row(i).Column("MENUNAME").getString();
               strURL = ds.Row(i).Column("URL").getString();
               if (strURL==null){strURL="";}
               strISOPEN = ds.Row(i).Column("ISOPEN").getString();
               if (strISOPEN==null || strISOPEN.length()==0)
               {strISOPEN="0";}

               if (!strPARENTNO.equals(strYPARENTNO) && strYPARENTNO.length()>0)
               {
                   Hashtable1.put(strYPARENTNO,strTmp);
                   strTmp = "";
               }
               if (strTmp.length()==0)
               {strTmp = strTmp + strMENUNO+"@"+strMENUNAME+"@"+strURL+"@"+strISOPEN;}
               else
               {strTmp = strTmp + "#"+strMENUNO+"@"+strMENUNAME+"@"+strURL+"@"+strISOPEN;}

               strYPARENTNO = strPARENTNO;

          }
          if (ds.RowCount()>1)
          {
              Hashtable1.put(strYPARENTNO,strTmp);
          }
        }
        //三级菜单装入对照表
        strYPARENTNO = "";
        strTmp = "";
        ds = dbengine.QuerySQL(strSqlB);
        if (ds != null && ds.RowCount() > 0) {
          for (int i = 0; i < ds.RowCount(); i++) {
               strMENUNO = ds.Row(i).Column("MENUNO").getString();
               strPARENTNO = strMENUNO.substring(0,6);
               strMENUNAME = ds.Row(i).Column("MENUNAME").getString();
               strURL = ds.Row(i).Column("URL").getString();
               if (strURL==null){strURL="";}
               strISOPEN = ds.Row(i).Column("ISOPEN").getString();
               if (strISOPEN==null || strISOPEN.length()==0)
               {strISOPEN="0";}

               if (!strPARENTNO.equals(strYPARENTNO) && strYPARENTNO.length()>0)
               {
                   Hashtable2.put(strYPARENTNO,strTmp);
                   strTmp = "";
               }
               if (strTmp.length()==0)
               {strTmp = strTmp + strMENUNO+"@"+strMENUNAME+"@"+strURL+"@"+strISOPEN;}
               else
               {strTmp = strTmp + "#"+strMENUNO+"@"+strMENUNAME+"@"+strURL+"@"+strISOPEN;}

               strYPARENTNO = strPARENTNO;
          }
          if (ds.RowCount()>1)
          {
              Hashtable2.put(strYPARENTNO,strTmp);
          }

        }



      //从一级菜单开始分层生成三级菜单
      ds = dbengine.QuerySQL(strSql);
      if (ds != null && ds.RowCount() > 0) {
        znum=ds.RowCount();
        for (int i = 0; i < ds.RowCount(); i++) {

        log.WriteLog("i:"+i);

          strMENUNO = ds.Row(i).Column("MENUNO").getString();
          strMENUNAME = ds.Row(i).Column("MENUNAME").getString();
          strURL =ds.Row(i).Column("URL").getString();
          if (strURL==null){strURL="";}
          strISOPEN =ds.Row(i).Column("ISOPEN").getString();
          if (strISOPEN==null || strISOPEN.length()==0)
          {strISOPEN="0";}

          if (i==0)
          {
              if (strURL.length()>0)
              {
                  strResult = strResult + "<div class='lmenua' id='treePic"+String.valueOf(i+1)+"' onClick=\"javascript:ShowFLT("+String.valueOf(i+1)+");OpenUrl('"+strURL+"','"+strISOPEN+"');\">"+strMENUNAME+"</div>\r\n";

              }else
              {
                  strResult = strResult + "<div class='lmenua' id='treePic"+String.valueOf(i+1)+"' onClick=\"javascript:ShowFLT("+String.valueOf(i+1)+");\">"+strMENUNAME+"</div>\r\n";

              }
          }else
          {
              if (strURL.length()>0)
              {
                  strResult = strResult + "<div class='lmenub'  id='treePic"+String.valueOf(i+1)+"' onClick=\"javascript:ShowFLT("+String.valueOf(i+1)+");OpenUrl('"+strURL+"','"+strISOPEN+"');\">"+strMENUNAME+"</div>\r\n";

              }else
              {
                  strResult = strResult + "<div class='lmenub'  id='treePic"+String.valueOf(i+1)+"' onClick=\"javascript:ShowFLT("+String.valueOf(i+1)+");\">"+strMENUNAME+"</div>\r\n";

              }
          }
          if (i==0)
          {
             strResult = strResult + "<div id='LM"+String.valueOf(i+1)+"'>\r\n";
          }
          else
          {
             strResult = strResult + "<div  style='display:none' id='LM"+String.valueOf(i+1)+"'>\r\n";
          }

          //--得到当前菜单下的二级菜单-----------------------
          strTmp= (String)Hashtable1.get(strMENUNO);
          if (strTmp!=null)
          {
          String[] sList1 = strTmp.split("#");//得到记录数
          for (int k = 0; k < sList1.length; k++) {
              String[] sList2 = sList1[k].split("@");
              strMENUNO =sList2[0];
              strMENUNAME =sList2[1];
              strURL =sList2[2];
              strISOPEN =sList2[3];

              num++;

              if (strURL.length()>0)
              {
                  strResult = strResult + "<div class='lmenuc' id='treePicb"+String.valueOf(num)+"' onClick=\"javascript:ShowFLTb("+String.valueOf(num)+");OpenUrl('"+strURL+"','"+strISOPEN+"');\">"+strMENUNAME+"</div>\r\n";

              }else
              {
                  strResult = strResult + "<div class='lmenuc' id='treePicb"+String.valueOf(num)+"' onClick=\"javascript:ShowFLTb("+String.valueOf(num)+");\">"+strMENUNAME+"</div>\r\n";

              }

              if (k==0)
              {
                 strResult = strResult + "<div id='LMb"+String.valueOf(num)+"' class='pclist'>\r\n";
              }
              else
              {
                 strResult = strResult + "<div id='LMb"+String.valueOf(num)+"'  style='display:none'  class='pclist'>\r\n";
              }

              strResult = strResult + "<ul>\r\n";
              //--得到当前菜单下的三级菜单--------------------------

              strTmp= (String)Hashtable2.get(strMENUNO);
              if (strTmp!=null)
              {
              String[] sListA1 = strTmp.split("#");//得到记录数
              for (int j = 0; j < sListA1.length; j++){

                  String[] sListA2 = sListA1[j].split("@");
                  strMENUNO =sListA2[0];
                  strMENUNAME =sListA2[1];
                  strURL =sListA2[2];
                  strISOPEN =sListA2[3];

                  if (i==0 && k==0 && j==0)
                  {
                       strResult = strResult + "<li><span onclick='checkTdBg(this);' class='active'><a href=\"javascript:OpenUrl('"+strURL+"','"+strISOPEN+"')\">"+strMENUNAME+"</a></span></li>\r\n";
                  }else
                  {
                       strResult = strResult + "<li><span onclick='checkTdBg(this);'><a href=\"javascript:OpenUrl('"+strURL+"','"+strISOPEN+"')\">"+strMENUNAME+"</a></span></li>\r\n";
                  }
              }}
              //--得到当前菜单下的三级菜单结束-----------------------
              strResult = strResult + "</ul>\r\n";
              strResult = strResult + "</div>\r\n";
          }}
          //--得到当前菜单下的二级菜单结束--------------------
          strResult = strResult + "</div>\r\n";


        }
        ds = null;
      }
    }
    catch (Exception ex) {
           log.WriteLog("错误："+ex.toString());
           return "error";

    }

    if (strResult.length()>0)
    {strResult = String.valueOf(znum)+"/"+String.valueOf(num)+"       "+strResult;}

    return strResult;
}


   /**
   * 作用或功能：显示（表单脚/表格/窗体）头部HTML
   * @param strTitle 标题名称
   * @param strUser_ImagePath 用户图片路径
   * @return HTML
   */
    public String ShowHeadHtml(String strTitle,String strUser_ImagePath){
      StringBuffer strResult = new StringBuffer();
      if(strUser_ImagePath.equals("6")){

  		strResult.append("<table border='0' width='100%' height='100%' cellSpacing='0' cellPadding='0'>"+"\r\n");
          //strResult.append("  <TR>"+"\r\n");
  	  }else{
  		strResult.append("<TABLE border='0' width='100%' height='100%' cellSpacing='0' cellPadding='0'>"+"\r\n");
        strResult.append("  <TR>"+"\r\n");
        strResult.append("     <TD width='100%' height='100%' valign='center' align='center'>"+"\r\n");
        strResult.append("       <TABLE width='100%' height='100%' class='Window' cellSpacing='0' cellPadding='0' align='center' border='0'>"+"\r\n");
        strResult.append("         <TR>"+"\r\n");
        strResult.append("           <TD height='22' width='100%'>"+"\r\n");
        strResult.append("             <TABLE border='0' width='100%' height='100%' cellspacing='0' cellpadding='0'>"+"\r\n");
        strResult.append("               <TR>"+"\r\n");
        strResult.append("                 <TD align='left' background='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/WindowTitle.gif' align=center>&nbsp;<img align='absmiddle' src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/IcoTitle.gif'>&nbsp;<font class='titleFont'>"+strTitle+"</font></TD>"+"\r\n");
        strResult.append("               </TR>"+"\r\n");
        strResult.append("             </TABLE>"+"\r\n");
        strResult.append("           </TD>"+"\r\n");
        strResult.append("         </TR>"+"\r\n");
  	  }
      return strResult.toString();
    }
    /**
       * 作用或功能：显示（表单脚/表格/窗体）头部HTML
       * @param strTitle 标题名称
       * @param strTitle_Image 标题图标
       * @param strUser_ImagePath 用户图片路径
       * @return HTML
       */
        public String ShowHeadHtml(String strTitle,String strTitle_Image,String strUser_ImagePath){
        	StringBuffer strResult = new StringBuffer();
        	if(strUser_ImagePath.equals("6")){
        		strResult.append("<TABLE border='0' width='100%' height='100%' cellSpacing='0' cellPadding='0'>"+"\r\n");
                //strResult.append("  <TR>"+"\r\n");
        	}else{
        		strResult.append("<TABLE border='0' width='100%' height='100%' cellSpacing='0' cellPadding='0'>"+"\r\n");
                strResult.append("  <TR>"+"\r\n");
                strResult.append("     <TD width='100%' height='100%' valign='center' align='center'>"+"\r\n");
                strResult.append("       <TABLE width='100%' height='100%'  cellSpacing='0' cellPadding='0' align='center' border='0'>"+"\r\n");//class='Window'
                strResult.append("         <TR>"+"\r\n");
                strResult.append("           <TD height='22' width='100%'>"+"\r\n");
                strResult.append("             <TABLE border='0' width='100%' height='100%' cellspacing='0' cellpadding='0'>"+"\r\n");
                strResult.append("               <TR>"+"\r\n");
                strResult.append("                 <TD align='left' background='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/WindowTitle.gif' align=center>&nbsp;<img align='absmiddle' src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/"+strTitle_Image+"'>&nbsp;<font class='titleFont'>"+strTitle+"</font></TD>"+"\r\n");
                strResult.append("               </TR>"+"\r\n");
                strResult.append("             </TABLE>"+"\r\n");
                strResult.append("           </TD>"+"\r\n");
                strResult.append("         </TR>"+"\r\n");
        	}


          return strResult.toString();
    }

    /**
       * 作用或功能：显示（功能标题）HTML
       * @param strTitle 标题名称
       * @param strTitle_Image 标题图标
       * @param strTitle_Width 标题宽度
       * @param strUser_ImagePath 用户图片路径
       * @return HTML
       */
        public String ShowTitleHtml(String strTitle,String strTitle_Image,String strTitle_Width,String strUser_ImagePath){
          StringBuffer strResult = new StringBuffer();
          if("6".equals(strUser_ImagePath)){

        	  strResult.append("<table  cellSpacing='0' cellPadding='0' border='0'>");
        	  strResult.append("<TR>");
          }else{
        	  strResult.append("  <TR>"+"\r\n");
              strResult.append("     <TD background='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/ShowTitle4.gif' width='100%' height='31' valign='left'>\r\n");
              strResult.append("       <TABLE height='31' cellSpacing='0' cellPadding='0' border='0'>\r\n");
              strResult.append("         <TR>\r\n");
              if (strTitle.length()>0){
              strResult.append("           <TD height='31' width='28' background='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/ShowTitle1.gif'></td>\r\n");
              strResult.append("           <TD height='31' width='"+strTitle_Width+"' background='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/ShowTitle2.gif'>&nbsp;<img align='absmiddle' src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/"+strTitle_Image+"'>&nbsp;"+strTitle+"</td>\r\n");
              strResult.append("           <TD height='31' width='30' background='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/ShowTitle3.gif'></td>\r\n");
              }
          }
          return strResult.toString();
     }
     /**
        * 作用或功能：显示（功能标题）结束HTML
        * @return HTML
        */
         public String ShowTitleEndHtml(){
           StringBuffer strResult = new StringBuffer();
           strResult.append("</tr></table></td></tr>");
           return strResult.toString();
      }


       /**
       * 作用或功能：显示表单的菜单（功能按钮）
       * @param strMenuName 功能按钮名称 如：增加
       * @param strMenuUrl 连接URL 如：AddFrm.jsp
       * @param intMenuIco 图标 （增加0、修改1、删除2、查询3、浏览4、统计5、打印6、帮助7、审批8、返回9）
       * @param strMenuWidth 功能按钮长度
       * @param strMark 子项标识   S表示开始Start   E表示结果End   B表示只有一个按钮(表示两者)  空值表示中间
       * @param strUser_ImagePath 用户图片路径
       * @return 返回HTML
       */
      public String ShowMenuHtml(String strMenuName,String strMenuUrl,int intMenuIco,String strMenuWidth,String strMark,String strUser_ImagePath){
        String strTdWidth="";
        StringBuffer strResult = new StringBuffer();
        StringBuffer strImage = new StringBuffer();
        if (strMenuWidth!=""){
          strTdWidth = "width='"+strMenuWidth+"'";
        }
        switch(intMenuIco){
          case 0:
            strImage.append("<img src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/IcoAdd.gif' border='0'>");
            break;
          case 1 :
            strImage.append("<img src='"+SysPreperty.getProperty().AppUrl +"zrsysmanage/images/"+strUser_ImagePath+"/IcoEdit.gif' border='0'>");
            break;
          case 2 :
            strImage.append("<img src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/IcoDel.gif' border='0'>");
            break;
          case 3 :
            strImage.append("<img src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/IcoQuery.gif' border='0'>");
            break;
          case 4 :
            strImage.append("<img src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/IcoBrowse.gif' border='0'>");
            break;
          case 5 :
            strImage.append("<img src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/IcoStat.gif' border='0'>");
            break;
          case 6 :
            strImage.append("<img src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/IcoPrint.gif' border='0'>");
            break;
          case 7 :
            strImage.append("<img src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/IcoHelp.gif' border='0'>");
            break;
          case 8 :
            strImage.append("<img src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/IcoApprove.gif' border='0'>");
            break;
          case 9 :
            strImage.append("<img src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/IcoBack.gif' border='0'>");
            break;
          case 10 :
            strImage.append("<img src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/IcoBack.gif' border='0'>");
            break;
          case 11 :
             strImage.append("<img src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/IcoApprove.gif' border='0'>");
           break;
         case 12 :
             strImage.append("<img src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/IcoApprove.gif' border='0'>");
         break;

        }

        if ((strMark.equalsIgnoreCase("S"))||(strMark.equalsIgnoreCase("B"))){
          strResult.append("<TR>"+"\r\n");
          strResult.append("  <TD class='Window_Menubar'>"+"\r\n");
          strResult.append("    <TABLE border='0' width='100%' height='24' cellspacing='2' cellpadding='2' class='Menu'>"+"\r\n");
          strResult.append( "     <TR>"+"\r\n");
        }

        strResult.append("         <TD class=Menud nowrap "+strTdWidth+" onMouseover=SetWinMenu(this) onMouseout=SetWinMenu(this) onclick=RecordOption('"+strMenuUrl+"','"+intMenuIco+"')>&nbsp;"+strImage.toString()+" "+strMenuName+"&nbsp;</TD>"+"\r\n");

        if ((strMark.equalsIgnoreCase("E"))||(strMark.equalsIgnoreCase("B"))){
          strResult.append("       <TD class=Menut width='90%'>&nbsp;</TD>"+"\r\n");
          strResult.append("     </TR>"+"\r\n");
          strResult.append("    </TABLE>"+"\r\n");
          strResult.append("  </TD>"+"\r\n");
          strResult.append("</TR>"+"\r\n");
        }


        if (strMark.equalsIgnoreCase("A")){
         strResult.delete(0,strResult.length());//清空
         strResult.append("       <TD class=Menut width='90%'>&nbsp;</TD>"+"\r\n");
         strResult.append("     </TR>"+"\r\n");
         strResult.append("    </TABLE>"+"\r\n");
         strResult.append("  </TD>"+"\r\n");
         strResult.append("</TR>"+"\r\n");
       }

        return strResult.toString();
      }
      /**
      * 作用或功能：显示功能按钮
      * @param strName 功能按钮名称 如：增加
      * @param strUrl 连接URL 如：AddFrm.jsp
      * @param intType 类型 （增加0、修改1、删除2、查询3、浏览4、统计5、打印6、帮助7、审批8、返回9,等等,在javascript中要用到）
      * @param strWidth 功能按钮长度
      * @param str_Image 图标文件
      * @param strUser_ImagePath 用户图片路径
      * @return 返回HTML
      */
     public String ShowButtonHtml(String strName,String strUrl,int intType,String str_Image,String strUser_ImagePath){
       StringBuffer strResult = new StringBuffer();
       strResult.append("<td width='5'></td><td><table height='22' border='0' cellspacing='0' cellpadding='0'><tr><td background='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/buttonleft.gif' width='4'></td><td background='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/buttonback.gif' height='22'><a href=javascript:RecordOption('"+strUrl+"','"+intType+"'); title='"+strName+"'><img border='0' align='absmiddle' src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/"+str_Image+"'>&nbsp;"+strName+"</a></td><td background='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/buttonright.gif' width='4'></td></tr></table></td>\r\n");
       return strResult.toString();
     }
     /**
     * 作用或功能：点击或链接按钮
     * @param strName 按钮名称 如：增加
     * @param strScript 点击时执行的javascript
     * @param strWidth 功能按钮长度
     * @param str_Image 图标文件
     * @param strUser_ImagePath 用户图片路径
     * @return 返回HTML
     */
    public String ClickButton(String strName,String strScript,String str_Image,String strUser_ImagePath){
       StringBuffer strResult = new StringBuffer();
       if("6".equals(strUser_ImagePath)){
    	   if(strScript.indexOf("JavaScript")<0&&strScript.indexOf("(")>-1&&strScript.indexOf("layer")<0){
    		   strScript="JavaScript:"+strScript;
    	   }else if(strScript.indexOf("JavaScript")<0&&strScript.indexOf("layer")>-1){
    		   strScript="JavaScript:"+strScript;
    	   }
    	   strResult.append("<td ><a class=\"btn1 btn-medium btn-blue btn-radius\" href=\""+strScript+"\" >"+strName+"</a></td>");
       }else{
    	   strResult.append("<td width='5'></td><td><table height='22' border='0' cellspacing='0' cellpadding='0'><tr><td background='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/buttonleft.gif' width='4'></td><td background='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/buttonback.gif' height='22'><a href="+strScript+" title='"+strName+"'><img border='0' align='absmiddle' src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/"+str_Image+"'>&nbsp;"+strName+"</a></td><td background='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/buttonright.gif' width='4'></td></tr></table></td>\r\n");
       }
       return strResult.toString();
     }
     /**
     * 作用或功能：点击按钮
     * @param strName 按钮名称 如：增加
     * @param strScript 点击时执行的javascript
     * @param strWidth 功能按钮长度
     * @param str_Image 图标文件
     * @param strUser_ImagePath 用户图片路径
     * @return 返回HTML
     */
    public String ClickButton1(String strName,String strScript,String str_Image,String strUser_ImagePath){
       StringBuffer strResult = new StringBuffer();
       if("6".equals(strUser_ImagePath)){
    	   if(strScript.indexOf("JavaScript")<0&&strScript.indexOf("(")>-1&&strScript.indexOf("layer")<0){
    		   strScript="JavaScript:"+strScript;
    	   }else if(strScript.indexOf("JavaScript")<0&&strScript.indexOf("layer")>-1){
    		   strScript="JavaScript:"+strScript;
    	   }
    	   strResult.append("<td><a class=\"btn1 btn-medium btn-blue btn-radius\" href=\""+strScript+"\" >"+strName+"</a></td>");
       }else{
           strResult.append("<td width='5'></td><td><table height='22' border='0' cellspacing='0' cellpadding='0'><tr><td background='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/buttonleft.gif' width='4'></td><td style='cursor:pointer' onclick=\""+strScript+"\" background='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/buttonback.gif' height='22'><img border='0' align='absmiddle' src='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/"+str_Image+"'>&nbsp;"+strName+"</td><td background='"+SysPreperty.getProperty().AppUrl+"zrsysmanage/images/"+strUser_ImagePath+"/buttonright.gif' width='4'></td></tr></table></td>\r\n");
       }
       return strResult.toString();
     }
         /**
         * 作用或功能：显示（表单脚/表格/窗体）中间开始部分HTML
         * @return BodyStartHTML
         */
        public String ShowBodyStartHtml(){
          StringBuffer strResult = new StringBuffer();
          strResult.append("<TR>\r\n");
          strResult.append("  <TD width='100%' height='100%' class='Window_Body' valign='top'>\r\n");
          return strResult.toString();
        }
        /**
        * 作用或功能：显示（表单脚/表格/窗体）中间结束部分HTML
        * @return BodyEndHTML
        */
        public String ShowBodyEndHtml(){
          StringBuffer strResult = new StringBuffer();
          strResult.append("  </TD>"+"\r\n");
          strResult.append("</TR>"+"\r\n");
          return strResult.toString();
         }

         /**
            * 功能或作用：显示翻页HTML（全选、翻页）
            * @param strPageMenu 翻页列表HTML
            * @return 显示全选和翻页功能
            */
           public String ShowPageMenuHtml(String strPageMenu){
             StringBuffer strResult = new StringBuffer();
             strResult.append("<TR>"+"\r\n");
             strResult.append("  <TD class='Window_TbE'>"+"\r\n");
             strResult.append("    <TABLE border='0' width='100%' cellspacing='0' cellpadding='0'>"+"\r\n");
             strResult.append("      <TR>"+"\r\n");
             strResult.append("        <TD width='20%'><input type='checkbox' name='selectall' onclick=SelectAll();>全选</TD>"+"\r\n");
             strResult.append("        <TD align='right'>"+strPageMenu+"</TD>"+"\r\n");
             strResult.append("      </TR>"+"\r\n");
             strResult.append("     </TABLE>"+"\r\n");
             strResult.append("  </TD>"+"\r\n");
             strResult.append("</TR>"+"\r\n");
             return strResult.toString();
           }

           /**
            * 功能或作用：显示翻页HTML（全选、翻页不一定存在）
            * @param strPageMenu strPageMenu 翻页列表HTML
            * @param intFlag 0表示只有全选功能   1表示只有翻页功能   2表示都没有
            * @return 显示全选和翻页功能
            */
            public String ShowPageMenuHtml(String strPageMenu,int intFlag){
             StringBuffer strResult = new StringBuffer();
             strResult.append("<TR>"+"\r\n");
             strResult.append("  <TD class='Window_TbE'>"+"\r\n");
             strResult.append("    <TABLE border='0' width='100%' cellspacing='0' cellpadding='0'>"+"\r\n");
             strResult.append("      <TR>"+"\r\n");
             switch(intFlag){
               case 0 :
                 strResult.append("        <TD width='20%'><input type='checkbox' name='selectall' onclick=SelectAll();>全选</TD>"+"\r\n");
                 break;
               case 1 :
                 strResult.append("        <TD align='right'>"+strPageMenu+"</TD>"+"\r\n");
                 break;
               case 2 :
                 strResult.append("        <TD>&nbsp;</TD>"+"\r\n");
                 break;
             }
             strResult.append("      </TR>"+"\r\n");
             strResult.append("     </TABLE>"+"\r\n");
             strResult.append("  </TD>"+"\r\n");
             strResult.append("</TR>"+"\r\n");
             return strResult.toString();
            }


           /**
            * 功能或作用：显示脚注菜单
            * @param strPageMenu strPageMenu 翻页列表HTML
            * @param strMenuFlag 00000多位  第一位表示是否有翻页   第一位表示是否有全选
            *   第三位是否有隐藏左边   第四位是否有隐藏上边    第五位是否有打印
            * 1表示有，0表示否
            * @return 显示脚注菜单
            */
           public String ShowPageMenuHtml(String strPageMenu,String strMenuFlag){
             String strFlag,strTmpResult="";
             StringBuffer strResult = new StringBuffer();
             int i = 0,intLen=0;
             intLen = strMenuFlag.length();

             strResult.append("<TR>"+"\r\n");
             strResult.append("  <TD class='Window_TbE'>"+"\r\n");
             strResult.append("    <TABLE border='0' width='100%' cellspacing='0' cellpadding='0'>"+"\r\n");
             strResult.append("      <TR>"+"\r\n");

             if (intLen>0){
               for (i=0;i<intLen;i++){
                 strFlag = strMenuFlag.substring(i,i+1);
                 if (i==0){
                   if (strFlag.equalsIgnoreCase("1")){
                     strTmpResult = strTmpResult + "        <TD nowrap width='90%' valign='bottom' align='right'>"+strPageMenu+"</TD>"+"\r\n";
                   }else{
                     strTmpResult = strTmpResult + "        <TD nowrap width='90%'>&nbsp;</TD>"+"\r\n";
                   }
                 }
                 if ((i==1)&&(strFlag.equalsIgnoreCase("1"))){
                   strResult.append("        <TD nowrap width='50' valign='absmiddle'><input type='checkbox' name='selectall' onclick=SelectAll(); class='CheckBoxCss'><a href='javascript:ClickAll()';>全选</a></TD>"+"\r\n");
                 }
                 if ((i==2)&&(strFlag.equalsIgnoreCase("1"))){
                   strResult.append("        <TD nowrap width='30' align='center' valign='bottom'><a href='javascript:top.window.parent.Move_Left();'>左边</a></TD>"+"\r\n");
                 }
                 if ((i==3)&&(strFlag.equalsIgnoreCase("1"))){
                   strResult.append("        <TD nowrap width='30' align='center' valign='bottom'><a href='javascript:top.window.parent.Move_Top();'>上边</a></TD>"+"\r\n");
                 }
                 if ((i==4)&&(strFlag.equalsIgnoreCase("1"))){
                   strResult.append("        <TD nowrap width='30' align='center' valign='bottom'><a href=javascript:OpenUrl('"+SysPreperty.getProperty().AppUrl+"messageprint.jsp','1')>打印</a></TD>"+"\r\n");
                 }
               }
             }else{
               strResult.append("        <TD>&nbsp;</TD>"+"\r\n");
             }
             strResult.append(strTmpResult);

             strResult.append("      </TR>"+"\r\n");
             strResult.append("     </TABLE>"+"\r\n");
             strResult.append("  </TD>"+"\r\n");
             strResult.append("</TR>"+"\r\n");
             return strResult.toString();
           }

           /**
              * 功能或作用：显示（表单脚/表格/窗体）页脚
              * @param  strTitle  显示内容
              * @param  strUser_ImagePath  用户图片路径
              * @return Foot HTML
              */
             public String ShowFootHtml(String strTitle,String strUser_ImagePath){
               StringBuffer strResult = new StringBuffer();
               strResult.append("      </TABLE>\r\n");
               strResult.append("    </TD>\r\n");
               strResult.append("  </TR>\r\n");
               strResult.append("</TABLE>\r\n");
               return strResult.toString();
             }
             /**
                * 功能或作用：显示表单脚结束部分
                * @return Foot HTML
                */
               public String ShowFootHtml(){
                 StringBuffer strResult = new StringBuffer();

                 strResult.append("  </TD>\r\n");
                 strResult.append("  </TR>\r\n");
                 strResult.append("      </TABLE>\r\n");
                 strResult.append("    </TD>\r\n");
                 strResult.append("  </TR>\r\n");
                 strResult.append("</TABLE>\r\n");
                 return strResult.toString();
             }

                  /**
                  * 功能或作用：实现翻页
                  * @param PageSize 一页的记录数
                  * @param FileUrl 文件名
                  * @param intRowCount 总的记录数
                  * @param intPage 当前页
                  * @param StrAll 是否分页显示
                  * @Return PageMenu 执行后返回一个PageMenu字符串
                  */
                 public String CreatePageMenu(int intPageSize,String strFileUrl,int intRowCount,int intPage,String strAll){
                   String PageMenu1="";
                   StringBuffer  PageMenu = new   StringBuffer();
                   PageMenu.append("&nbsp;");
                   int intPageCount=0,i,sum1=0,sum2=0,sum3=intRowCount;
                   int curRowCount = intRowCount;
                   while (((intRowCount-intPageSize)>0) || (intRowCount>0)){
                     intPageCount++;
                     intRowCount=intRowCount-intPageSize;
                   }
                   if(intPage>intPageCount){
                     intPage = intPageCount;
                   }
                   if (intPageCount>1){
                     sum1=intPage-1;
                     if (sum1<1){sum1=1;}
                     sum2=intPage+1;
                     if (sum2>intPageCount){sum2=intPageCount;}
                     PageMenu.append("<a href='"+strFileUrl+"page=1'>首页</a>");
                     PageMenu.append("&nbsp;&nbsp;<a href='"+strFileUrl+"page="+sum1+"'>上一页</a>");
                     PageMenu.append("&nbsp;&nbsp;<a href='"+strFileUrl+"page="+sum2+"'>下一页</a>");
                     PageMenu.append("&nbsp;&nbsp;<a href='"+strFileUrl+"page="+intPageCount+"'>末页</a>&nbsp;&nbsp;");

                     PageMenu.append("<select size='1' class='PageStyle'  Onchange='DoMenu(this.value)'>");
                     for (i=1;i<=intPageCount;i++){
                       if (intPage==i){
                         PageMenu.append("<option value='"+strFileUrl+"page="+i+"' selected >第"+i+"页</option>");
                       }
                       else{
                         PageMenu.append("<option value='"+strFileUrl+"page="+i+"' >第"+i+"页</option>");
                       }
                     }
                     PageMenu.append("</select>");

                     PageMenu.append("&nbsp;&nbsp;页次："+intPage+"/"+intPageCount+"&nbsp;&nbsp;共"+sum3+"条");
                   }
                   else
                   {PageMenu.append("&nbsp;&nbsp;共"+sum3+"条");}

                   if (strAll.equals("yes"))
                   {
                     PageMenu1 =PageMenu.toString();
                     PageMenu.delete(0,PageMenu.length());//清空
                     PageMenu.append("<a href='"+strFileUrl+"all=no&page=1'>分页显示</a>&nbsp;&nbsp;"+PageMenu1);}
                   else
                   {
                   if (intPageSize<curRowCount)
                   { PageMenu1 =PageMenu.toString();
                     PageMenu.delete(0,PageMenu.length());//清空
                     PageMenu.append("<a href='"+strFileUrl+"all=yes&page=1'>单页显示</a>&nbsp;&nbsp;"+PageMenu1);
                    }
                   else
                   {
                     PageMenu1 =PageMenu.toString();
                     PageMenu.delete(0,PageMenu.length());//清空
                     PageMenu.append("<a href='"+strFileUrl+"all=no&page=1'></a>&nbsp;&nbsp;"+PageMenu1);}
                   }
                   return PageMenu.toString();
                 }

               /**
                * 功能或作用：显示空记录数
                * @param mshowRecord 列数
                * @param mCountRecord 已有记录数
                * @param mPageSize 一页总的记录数
                * @Return mResult 执行后返回一个mResult字符串
                */
               public String ShowNullRecord(int mShowRecord,int mCountRecord,int mPageSize){
                 StringBuffer  mResult = new   StringBuffer();
                 boolean mFlag;
                 int n;
                 while (mCountRecord < mPageSize){
                   mFlag = true;
                   mCountRecord = mCountRecord + 1;
                   mResult.append("<tr>");
                   for (n=1;n<=mShowRecord;n++){
                     if (mFlag){
                       mResult.append("<td class=Window_TbB>&nbsp;</td> ");
                       mFlag = false;
                     }
                     else
                     {
                       mResult.append("<td class=Window_TbB>&nbsp;</td> ");
                     }
                   }
                   mResult.append("</tr>");
                 }
                 return (mResult.toString());
               }


               /**
              * 功能或作用：生成主框架上面页面的菜单  //第二种菜单1
              * @param strUser_No用户编号
              * @strUser_ImagePath用户图片路径
              * @return 返回HTML值
              */
              public String LoadMainUP(String strUser_No,String strUser_ImagePath){
                log.WriteLog("LoadMainUP", "开始调用");
                String strResult = "";

                strResult = "<table height=\"85\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
                strResult = strResult + "<td width=\"5\" bgcolor=\"#EDF3FF\" style=\"filter: Alpha(Opacity=85)\"></td>";

                try {
                  String scode = "";
                  String sname = "";
                  String surl = "";
                  String  strSql = "";
                  int num_row = 0;
                  if (strUser_No.equals("0000000000000000"))
                 {
                    strSql = "select MENUNO,MENUNAME,URL,ISOPEN from BPIP_MENU where FLAG='1' and MENUNO like '___' order by MNCODE,MENUNO";
                 }else
                 {
                     strSql = "select MENUNO,MENUNAME,URL,ISOPEN from BPIP_MENU where FLAG='1' and  MENUNO like '___' and  MENUNO in (select distinct substr(MENUNO,1,3) from BPIP_ROLE_RERMISSISSON where ROLEID in (select ROLEID from BPIP_USER_ROLE where USERID='"+strUser_No+"')) order by MNCODE,MENUNO";
                 }

                  dbSet ds = dbengine.QuerySQL(strSql);
                  if (ds != null && ds.RowCount() > 0) {
                    for (int i = 0; i < ds.RowCount(); i++) {
                            scode = ds.Row(i).Column("MENUNO").getString();
                            sname = ds.Row(i).Column("MENUNAME").getString();
                            surl = ds.Row(i).Column("URL").getString();
                            if (surl == null){surl = "";}
                            num_row = num_row + 1;

                            strResult = strResult + "<td width=\"80\"  bgcolor=\"#EDF3FF\" align=center  style=\"filter: Alpha(Opacity=80)\">";
                            strResult = strResult + "<a href=\"javascript:chgFontStyle('"+scode+"','"+surl+"');\"><img  border=\"0\" src="+SysPreperty.getProperty().AppUrl +"zrsysmanage/images/"+strUser_ImagePath+"/dt"+String.valueOf(num_row)+".gif align=\"absmiddle\"><br><br><b>"+sname+"</b></a></td>";


                    }
                    ds = null;
                  }
                }
                catch (Exception ex){
                  strResult ="error";
                }
                strResult = strResult + "<td width=\"5\"></td></tr></table>";
                return strResult.toString();
            }


            //第二种菜单2
            public String LoadMenu_two(String strUser_No,String strcode) {
                String  strSql = "";
                String  strSqlA = "";
                String  strResult = "";
                String  strTmp = "";
                String  strPARENTNO = "";
                String  strYPARENTNO = "";
                String  strMENUNO = "";
                String  strMENUNAME = "";
                String  strURL = "";
                String  strISOPEN = "";
                int num=0;
                int znum=0;

                Hashtable Hashtable1 = new Hashtable();//一级菜单对应的二级菜单表

                try {

                    //---一级菜单------------
                    if (strUser_No.equals("0000000000000000"))
                    {
                       strSql = "select MENUNO,MENUNAME,URL,ISOPEN from BPIP_MENU where FLAG='1' and MENUNO like '______'  and MENUNO like '"+strcode+"%' order by MNCODE,MENUNO";
                    }else
                    {
                       strSql = "select MENUNO,MENUNAME,URL,ISOPEN from BPIP_MENU where FLAG='1' and  MENUNO like '______' and MENUNO like '"+strcode+"%' and  MENUNO in (select distinct substr(MENUNO,1,6) from BPIP_ROLE_RERMISSISSON where ROLEID in (select ROLEID from BPIP_USER_ROLE where USERID='"+strUser_No+"')) order by MNCODE,MENUNO";
                    }

                    //二级菜单----------------
                    if (strUser_No.equals("0000000000000000"))
                   {
                      strSqlA = "select URL,MENUNO,ISOPEN,MENUNAME from BPIP_MENU where FLAG='1' and ISPOWER='1'  and MENUNO like '_________'  order by MNCODE,MENUNO";
                   }else
                   {
                      strSqlA = "select  URL,MENUNO,ISOPEN,MENUNAME from BPIP_MENU where FLAG='1'  and ISPOWER='1'  and MENUNO like '_________' and MENUNO in (select MENUNO from BPIP_ROLE_RERMISSISSON where ROLEID in (select ROLEID from BPIP_USER_ROLE where USERID='"+ strUser_No+"')) order by MNCODE,MENUNO";
                   }



                    //二级菜单装入对照表
                    dbSet ds = dbengine.QuerySQL(strSqlA);
                    if (ds != null && ds.RowCount() > 0) {
                      for (int i = 0; i < ds.RowCount(); i++) {
                           strMENUNO = ds.Row(i).Column("MENUNO").getString();
                           strPARENTNO = strMENUNO.substring(0,6);
                           strMENUNAME = ds.Row(i).Column("MENUNAME").getString();
                           strURL = ds.Row(i).Column("URL").getString();
                           if (strURL==null){strURL="";}
                           strISOPEN = ds.Row(i).Column("ISOPEN").getString();
                           if (strISOPEN==null || strISOPEN.length()==0)
                           {strISOPEN="0";}

                           if (!strPARENTNO.equals(strYPARENTNO) && strYPARENTNO.length()>0)
                           {
                               Hashtable1.put(strYPARENTNO,strTmp);
                               strTmp = "";
                           }
                           if (strTmp.length()==0)
                           {strTmp = strTmp + strMENUNO+"@"+strMENUNAME+"@"+strURL+"@"+strISOPEN;}
                           else
                           {strTmp = strTmp + "#"+strMENUNO+"@"+strMENUNAME+"@"+strURL+"@"+strISOPEN;}

                           strYPARENTNO = strPARENTNO;

                      }
                      if (ds.RowCount()>1)
                      {
                          Hashtable1.put(strYPARENTNO,strTmp);
                      }
                    }




                  //从一级菜单开始分层生成二级菜单
                  ds = dbengine.QuerySQL(strSql);
                  if (ds != null && ds.RowCount() > 0) {
                    znum=ds.RowCount();
                    for (int i = 0; i < ds.RowCount(); i++) {

                    log.WriteLog("i:"+i);

                      strMENUNO = ds.Row(i).Column("MENUNO").getString();
                      strMENUNAME = ds.Row(i).Column("MENUNAME").getString();
                      strURL =ds.Row(i).Column("URL").getString();
                      if (strURL==null){strURL="";}
                      strISOPEN =ds.Row(i).Column("ISOPEN").getString();
                      if (strISOPEN==null || strISOPEN.length()==0)
                      {strISOPEN="0";}

                      if (i==0)
                      {
                          if (strURL.length()>0)
                          {
                              strResult = strResult + "<div class='lmenua' id='treePic"+String.valueOf(i+1)+"' onClick=\"javascript:ShowFLT("+String.valueOf(i+1)+");OpenUrl('"+strURL+"','"+strISOPEN+"');\">"+strMENUNAME+"</div>\r\n";

                          }else
                          {
                              strResult = strResult + "<div class='lmenua' id='treePic"+String.valueOf(i+1)+"' onClick=\"javascript:ShowFLT("+String.valueOf(i+1)+");\">"+strMENUNAME+"</div>\r\n";

                          }
                      }else
                      {
                          if (strURL.length()>0)
                          {
                              strResult = strResult + "<div class='lmenub'  id='treePic"+String.valueOf(i+1)+"' onClick=\"javascript:ShowFLT("+String.valueOf(i+1)+");OpenUrl('"+strURL+"','"+strISOPEN+"');\">"+strMENUNAME+"</div>\r\n";

                          }else
                          {
                              strResult = strResult + "<div class='lmenub'  id='treePic"+String.valueOf(i+1)+"' onClick=\"javascript:ShowFLT("+String.valueOf(i+1)+");\">"+strMENUNAME+"</div>\r\n";

                          }
                      }
                      if (i==0)
                      {
                         strResult = strResult + "<div id='LM"+String.valueOf(i+1)+"'>\r\n";
                      }
                      else
                      {
                         strResult = strResult + "<div  style='display:none' id='LM"+String.valueOf(i+1)+"'>\r\n";
                      }

                      //--得到当前菜单下的二级菜单-----------------------
                      strTmp= (String)Hashtable1.get(strMENUNO);
                      if (strTmp!=null)
                      {
                      String[] sList1 = strTmp.split("#");//得到记录数
                      for (int k = 0; k < sList1.length; k++) {
                          String[] sList2 = sList1[k].split("@");
                          strMENUNO =sList2[0];
                          strMENUNAME =sList2[1];
                          strURL =sList2[2];
                          strISOPEN =sList2[3];

                          num++;

                          if (strURL.length()>0)
                          {
                              strResult = strResult + "<div class='lmenuc' id='treePicb"+String.valueOf(num)+"' onClick=\"javascript:ShowFLTb("+String.valueOf(num)+");OpenUrl('"+strURL+"','"+strISOPEN+"');\">"+strMENUNAME+"</div>\r\n";

                          }else
                          {
                              strResult = strResult + "<div class='lmenuc' id='treePicb"+String.valueOf(num)+"' onClick=\"javascript:ShowFLTb("+String.valueOf(num)+");\">"+strMENUNAME+"</div>\r\n";

                          }


                         strResult = strResult + "<div id='LMb"+String.valueOf(num)+"'  style='display:none'  class='pclist'>\r\n";


                          strResult = strResult + "<ul>\r\n";

                          strResult = strResult + "</ul>\r\n";
                          strResult = strResult + "</div>\r\n";
                      }}
                      //--得到当前菜单下的二级菜单结束--------------------
                      strResult = strResult + "</div>\r\n";


                    }
                    ds = null;
                  }
                }
                catch (Exception ex) {
                       log.WriteLog("错误："+ex.toString());
                       return "error";

                }

                if (strResult.length()>0)
                {strResult = String.valueOf(znum)+"/"+String.valueOf(num)+"       "+strResult;}

                return strResult;
            }

            //第二种菜单2-1
            public String LoadMenu_two_a(String strUser_No,String strcode) {
                            String  strSql = "";
                            String  strSqlA = "";
                            String  strResult = "";
                            String  strTmp = "";
                            String  strPARENTNO = "";
                            String  strYPARENTNO = "";
                            String  strMENUNO = "";
                            String  strMENUNAME = "";
                            String  strURL = "";
                            String  strISOPEN = "";
                            int num=0;
                            int znum=0;
                            strResult = strResult + "<table width='149' border='0' cellpadding='0' cellspacing='0'>\r\n";

                            Hashtable Hashtable1 = new Hashtable();//一级菜单对应的二级菜单表

                            try {

                                //---一级菜单------------
                                if (strUser_No.equals("0000000000000000"))
                                {
                                   strSql = "select MENUNO,MENUNAME,URL,ISOPEN from BPIP_MENU where FLAG='1' and MENUNO like '______'  and MENUNO like '"+strcode+"%' order by MNCODE,MENUNO";
                                }else
                                {
                                   strSql = "select MENUNO,MENUNAME,URL,ISOPEN from BPIP_MENU where FLAG='1' and  MENUNO like '______' and MENUNO like '"+strcode+"%' and  MENUNO in (select distinct substr(MENUNO,1,6) from BPIP_ROLE_RERMISSISSON where ROLEID in (select ROLEID from BPIP_USER_ROLE where USERID='"+strUser_No+"')) order by MNCODE,MENUNO";
                                }

                                //二级菜单----------------
                                if (strUser_No.equals("0000000000000000"))
                               {
                                  strSqlA = "select URL,MENUNO,ISOPEN,MENUNAME from BPIP_MENU where FLAG='1' and ISPOWER='1'  and MENUNO like '_________'  order by MNCODE,MENUNO";
                               }else
                               {
                                  strSqlA = "select  URL,MENUNO,ISOPEN,MENUNAME from BPIP_MENU where FLAG='1'  and ISPOWER='1'  and MENUNO like '_________' and MENUNO in (select MENUNO from BPIP_ROLE_RERMISSISSON where ROLEID in (select ROLEID from BPIP_USER_ROLE where USERID='"+ strUser_No+"')) order by MNCODE,MENUNO";
                               }



                                //二级菜单装入对照表
                                dbSet ds = dbengine.QuerySQL(strSqlA);
                                if (ds != null && ds.RowCount() > 0) {
                                  for (int i = 0; i < ds.RowCount(); i++) {
                                       strMENUNO = ds.Row(i).Column("MENUNO").getString();
                                       strPARENTNO = strMENUNO.substring(0,6);
                                       strMENUNAME = ds.Row(i).Column("MENUNAME").getString();
                                       strURL = ds.Row(i).Column("URL").getString();
                                       if (strURL==null){strURL="";}
                                       strISOPEN = ds.Row(i).Column("ISOPEN").getString();
                                       if (strISOPEN==null || strISOPEN.length()==0)
                                       {strISOPEN="0";}

                                       if (!strPARENTNO.equals(strYPARENTNO) && strYPARENTNO.length()>0)
                                       {
                                           Hashtable1.put(strYPARENTNO,strTmp);
                                           strTmp = "";
                                       }
                                       if (strTmp.length()==0)
                                       {strTmp = strTmp + strMENUNO+"@"+strMENUNAME+"@"+strURL+"@"+strISOPEN;}
                                       else
                                       {strTmp = strTmp + "#"+strMENUNO+"@"+strMENUNAME+"@"+strURL+"@"+strISOPEN;}

                                       strYPARENTNO = strPARENTNO;

                                  }
                                  if (ds.RowCount()>1)
                                  {
                                      Hashtable1.put(strYPARENTNO,strTmp);
                                  }
                                }




                              //从一级菜单开始分层生成二级菜单
                              ds = dbengine.QuerySQL(strSql);
                              if (ds != null && ds.RowCount() > 0) {
                                znum=ds.RowCount();
                                for (int i = 0; i < ds.RowCount(); i++) {

                                log.WriteLog("i:"+i);

                                  strMENUNO = ds.Row(i).Column("MENUNO").getString();
                                  strMENUNAME = ds.Row(i).Column("MENUNAME").getString();
                                  strURL =ds.Row(i).Column("URL").getString();
                                  if (strURL==null){strURL="";}
                                  strISOPEN =ds.Row(i).Column("ISOPEN").getString();
                                  if (strISOPEN==null || strISOPEN.length()==0)
                                  {strISOPEN="0";}



                                  //--得到当前菜单下的二级菜单-----------------------
                                  strTmp= (String)Hashtable1.get(strMENUNO);
                                  if (strTmp!=null)
                                  {
                                  String[] sList1 = strTmp.split("#");//得到记录数

                                  for (int k = 0; k < sList1.length; k++) {
                                      String[] sList2 = sList1[k].split("@");
                                      strMENUNO =sList2[0];
                                      strMENUNAME =sList2[1];
                                      strURL =sList2[2];
                                      strISOPEN =sList2[3];

                                      num++;

                                      if (num>10){num=10;}

                                      strResult = strResult + "<tr>\r\n";
                                      strResult = strResult +"<td  align=center>\r\n";
                                      strResult = strResult +"<a href=\"javascript:OpenUrl('"+strURL+"','"+strISOPEN+"');\"><img  border='0' src="+SysPreperty.getProperty().AppUrl +"zrsysmanage/images/blueimg/dtw"+String.valueOf(num)+".gif align='absmiddle'><br><b>"+strMENUNAME+"</b></a>\r\n";
                                      strResult = strResult + "<br><br></td></tr>\r\n";




                                  }}
                                  //--得到当前菜单下的二级菜单结束--------------------



                                }
                                ds = null;
                              }
                            }
                            catch (Exception ex) {
                                   log.WriteLog("错误："+ex.toString());
                                   return "error";

                            }

                            strResult = strResult + "</table>\r\n";

                            if (strResult.length()>0)
                            {strResult = String.valueOf(znum)+"/"+String.valueOf(num)+"       "+strResult;}

                            return strResult;
            }

  public String get_menuName(String strcode) {
      String strRe = "";
      String  strSql = "";
      strSql = "select MENUNAME from BPIP_MENU where MENUNO = '"+strcode+"'";
      dbSet ds = dbengine.QuerySQL(strSql);
      if (ds != null && ds.RowCount() > 0) {
          strRe = ds.Row(0).Column("MENUNAME").getString();
      }
      ds = null;
      return strRe;
  }
}
