⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zscom_func.java

📁 实现oracle查询数据集分页
💻 JAVA
📖 第 1 页 / 共 3 页
字号:

        return strRslt;
      }


      // 获取经度(给出四个文本域)
      public static String getLongitude(JTextField textFieldD, JTextField textFieldM, JTextField textFieldS, JTextField textFieldCentiS)
      {
        if(textFieldD.getText().equals("") || textFieldM.getText().equals("") || textFieldS.getText().equals("") ||
        textFieldCentiS.getText().equals(""))
        {
          return "";
        }
        return getLogitude(textFieldD.getText().trim(),
                           textFieldM.getText().trim(),
                           textFieldS.getText().trim(),
                           textFieldCentiS.getText().trim());
      }

      // 获取经度(给出四个DB域)
      public static String getLongitude(JdbTextField textFieldD, JdbTextField textFieldM, JdbTextField textFieldS, JdbTextField textFieldCentiS)
      {
        if(textFieldD.getText().equals("") || textFieldM.getText().equals("") || textFieldS.getText().equals("") ||
        textFieldCentiS.getText().equals(""))
        {
          return "";
        }

        return getLogitude(textFieldD.getText().trim(),
                           textFieldM.getText().trim(),
                           textFieldS.getText().trim(),
                           textFieldCentiS.getText().trim());
      }

      //获取纬度(给出字符串)
      public static String getLatitude(String strD, String strM, String strS, String strCentiS)
      {
        if(strD.equals("") || strM.equals("") || strS.equals("") || strCentiS.equals(""))
        {
          return "";
        }

        String strRslt =
            getLatitudeDegree(strD.trim()) +
            getMinute(strM.trim()) +
            getSecond(strS.trim()) +
            getCentiSecond(strCentiS.trim());

        if(strRslt.length() != 9)
        {
          return "";
        }

        return strRslt;
      }

      // 获取纬度(给出文本域)
      public static String getLatitude(JTextField textFieldD, JTextField textFieldM, JTextField textFieldS, JTextField textFieldCentiS)
      {
        if(textFieldD.getText().equals("") || textFieldM.getText().equals("") || textFieldS.getText().equals("") ||
        textFieldCentiS.getText().equals(""))
        {
          return "";
        }

        return getLatitude(textFieldD.getText().trim(),
                           textFieldM.getText().trim(),
                           textFieldS.getText().trim(),
                           textFieldCentiS.getText().trim());
      }



      // 获取纬度(给出db文本域)
      public static String getLatitude(JdbTextField textFieldD, JdbTextField textFieldM, JdbTextField textFieldS, JdbTextField textFieldCentiS)
      {
        if(textFieldD.getText().equals("") || textFieldM.getText().equals("") || textFieldS.getText().equals("") ||
           textFieldCentiS.getText().equals(""))
        {
          return "";
        }

        return getLatitude(textFieldD.getText().trim(),
                           textFieldM.getText().trim(),
                           textFieldS.getText().trim(),
                           textFieldCentiS.getText().trim());
      }
      /**选择消息框*/
      public static boolean  showConfirmDlg(JDialog dlgParent,String sNote)
            {
              if (JOptionPane.showConfirmDialog(dlgParent, sNote, "提示!",
                                                JOptionPane.OK_CANCEL_OPTION)==JOptionPane.OK_OPTION)
              {
                return true;
              }
              else return false ;
            }




     /**删除失败对话框*/
     public static void showDeleteErrorDlg(JDialog dlgParent)
      {
        showInformationMessageDlg(dlgParent,"删除失败", "删除提示");
      }

      /** 存储成功对话框*/
      public static void showSaveSuccessDlg(JDialog dlgParent)
      {
        showInformationMessageDlg(dlgParent,"保存成功", "保存提示");
      }

      /** 存储失败对话框*/
      public static void  showSaveErrorDlg(JDialog dlgParent)
      {
        showInformationMessageDlg(dlgParent,"保存失败", "保存提示");
      }

       /**清空成功对话框*/
      public static void  showClearSuccessDlg(JDialog dlgParent)
      {
        showInformationMessageDlg(dlgParent,"清空成功", "清空提示");
      }
       /**清空失败对话框*/
      public static void  showClearErrorDlg(JDialog dlgParent)
      {
        showInformationMessageDlg(dlgParent,"清空失败", "清空提示");
      }
      /** 退出确认对话框*/
      public static boolean  showExitDlg(JDialog dlgParent)
      {
        if (JOptionPane.showConfirmDialog(dlgParent, "数据尚未保存,是否确定退出?", "提示!",
                                          JOptionPane.OK_CANCEL_OPTION)==JOptionPane.OK_OPTION)
        {
          return true;
        }
        else return false ;
      }
/**显示消息框*/
      public static  void showErrorMessageDlg(JFrame parent, String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(parent, strError, strTitle, JOptionPane.ERROR_MESSAGE);
      }
/**显示消息框*/
      public static  void showErrorMessageDlg(JDialog parent, String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(parent, strError, strTitle, JOptionPane.ERROR_MESSAGE);
      }
/**显示消息框*/
      public static  void showErrorMessageDlg(String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(C_Parent_Frame, strError, strTitle, JOptionPane.ERROR_MESSAGE);
      }
/**显示消息框*/
      public static  void showErrorMessageDlg(JComponent m_Parent,String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(m_Parent, strError, strTitle, JOptionPane.ERROR_MESSAGE);
      }
/**显示消息框*/
      public static  void showInformationMessageDlg(JFrame parent, String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(parent, strError, strTitle, JOptionPane.INFORMATION_MESSAGE);
      }
/**显示消息框*/
      public static  void showInformationMessageDlg(JDialog parent, String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(parent, strError, strTitle, JOptionPane.INFORMATION_MESSAGE);
      }
/**显示消息框*/
      public static  void showInformationMessageDlg(String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(C_Parent_Frame, strError, strTitle, JOptionPane.INFORMATION_MESSAGE);
      }
/**显示消息框*/
      public static  void showWarningMessageDlg(JFrame parent, String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(parent, strError, strTitle, JOptionPane.WARNING_MESSAGE);
      }
/**显示消息框*/
      public static  void showWarningMessageDlg(JDialog parent, String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(parent, strError, strTitle, JOptionPane.WARNING_MESSAGE);
      }
/**显示消息框*/
      public static  void showWarningMessageDlg(String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(C_Parent_Frame, strError, strTitle, JOptionPane.WARNING_MESSAGE);
      }
/**显示消息框*/
      public static  void showQuestionMessageDlg(JFrame parent, String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(parent, strError, strTitle, JOptionPane.QUESTION_MESSAGE);
      }
/**显示消息框*/
      public static  void showQuestionMessageDlg(JDialog parent, String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(parent, strError, strTitle, JOptionPane.QUESTION_MESSAGE);
      }
/**显示消息框*/
      public static  void showQuestionMessageDlg(String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(C_Parent_Frame, strError, strTitle, JOptionPane.QUESTION_MESSAGE);
      }
/**显示消息框*/
      public static  void showPlainMessageDlg(JFrame parent, String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(parent, strError, strTitle, JOptionPane.PLAIN_MESSAGE);
      }
/**显示消息框*/
      public static  void showPlainMessageDlg(JDialog parent, String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(parent, strError, strTitle, JOptionPane.PLAIN_MESSAGE);
      }
/**显示消息框*/
      public static  void showPlainMessageDlg(String strError, String strTitle)
      {
        JOptionPane.showMessageDialog(C_Parent_Frame, strError, strTitle, JOptionPane.PLAIN_MESSAGE);
      }

////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////bearking新增共用函数////////////////////////////////////////////////////
      /**数据类型转换*/
    public static String IntToString (int i)
     {
        Variant m_variant=new Variant();
        m_variant.setInt(i);
        return m_variant.toString();
     }
/**数据类型转换*/
     public static int StringToInt (String i)
      {
         if ((i.trim().equals(""))||(i==null))
         {
             i = "0";
         }
         Integer m_int= new Integer(i.trim());
         return  m_int.intValue();
      }
/**数据类型转换*/
      public static short StringToShort (String i)
      {
         Short m_short= new Short(i);
         return  m_short.shortValue();
      }
/**数据类型转换*/
      public static  byte  StringTobyte (String i)
      {
         Byte m_byte= new Byte(i);
         return  m_byte.byteValue();
      }

      /**显示对话框*/
      public static void showDlgCenter(JDialog dlg)
      {
        Dimension dimScreen = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension dimDlg = dlg.getSize();
        int nX = (dimScreen.width - dimDlg.width)/2;
        int nY = (dimScreen.height - dimDlg.height)/2;
        dlg.setLocation(nX, nY);
        dlg.pack();
        dlg.setModal(true);
        dlg.show();
      }
      /**数据类型转换*/
      public static BigDecimal StringToBigdecimal (String str)
      {
        int n = StringToInt(str);
        return IntToBigdecimal(n);
      }
      /**数据类型空值判断*/
     public static boolean  isNull(Object mobj)  //判定结构对象是否为空
     {
       if (mobj==null)
       return true;
       else return false;
     }


////////////////////////////////////////////////////////////////////////////////////////////////////
/**数据类型转换*/
     // 把'0'或'1'转换成布尔型true or false
  public static boolean StringToBoolean(char ch)
  {
    if(ch == '1')
    {
      return true;
    }
    else if(ch == '0')
    {
      return false;
    }
    else
    {
      showErrorMessageDlg("传入了错误的字符", "字符到布尔值的转换");
      return false;
     }
   }
   /**数据类型转换*/
   public static double  StringToDouble (String s){
      Double dNum = new Double(s);
      return  dNum.doubleValue();
   }
  /**数据类型转换*/
   public static float  StringTofloat (String s){
      Float fNum = new Float(s);
      return  fNum.floatValue();
   }
   /*得到系统日期*/
   public static String  getSystemDate(){
     Calendar calendar = Calendar.getInstance();
     int y, m, d;
     String sdate;
     y = calendar.get(Calendar.YEAR);
     m = calendar.get(Calendar.MONTH)+1;
     d = calendar.get(Calendar.DAY_OF_MONTH);
     sdate = y + "-" + m + "-" + d;
     return sdate;
   }


 public static void setComponentBackColor(JComponent component)
 {
   int nComponent = component.getComponentCount();
   if (!component.getBackground().equals(Color.white) &&
       !component.getBackground().equals(SystemColor.info))
   {
      component.setBackground(m_backcolor);
      component.setForeground(SystemColor.black);

   }

   if(nComponent == 0)
   {
     return;
   }
   for(int i=0; i<nComponent; i++)
   {
     try
     {

       setComponentBackColor( (JComponent) component.getComponent(i));
     }
     catch(Exception ex)
     {

     }
   }

 }
////////////////////////////////判定点是否在圆内

 /**执行外部程序*/
 public static void exe_command(String command) {
   try {
        //String command = "/path/to/command";
        Process child = Runtime.getRuntime().exec(command);
        }
        catch (IOException e) {
       }
}
/**给字符串加够长度,按任意字符补位*/
public static String addleftchar(String sString,int iLength,char cChar)
{
     String tmpstr=sString.trim();
     int sLength=tmpstr.length();
     if (sLength>iLength)
     {
       return tmpstr.substring(0,iLength);
     }
     else
     {
       for (int i = 0; i < iLength -sLength;i++)
       {
         tmpstr=cChar+tmpstr;
       }
       return tmpstr;
     }
  }

/**
   JAVA字符转换成Oracle字符编码的长度
*/
static public int lengthStrOra(String str) { //JAVA字符转换成Oracle字符编码的长度

    int i = 0,ilength=0;
    byte[] strA = str.getBytes();
    if (strA == null) { //Com_Func.Showmessage("数组为空","");
      return ilength;
    }
    while (i < strA.length) {
      if ( ( (int) strA[i]) < 0) { //若值小于0,则代表是中文字符,因此取两个字节转换成一个字符
        //String h = new String(strA, i, 2);
        //k = k + h;
        ilength=ilength+2;
        i = i + 2;
      }
      else {
        String h = new String(strA, i, 1); //反之,则代表是英文字符,因此取一个字节转换成一个字符
        ilength++;
        i++;
      }
    }
    return ilength;
  }
  /** 适合返回一个值的数据查询*/
  public static String getSqlValue(String sqlstr,Database db, String colname,
                                    String defaultvalue) //传入SQL语句,得到某列的值,


 {
   //Showmessage(sqlstr,"");
   QueryDataSet m_qry=new QueryDataSet();
   if (!db.isOpen()) {
      db.openConnection();
    }
    QueryDescriptor m_QD = new QueryDescriptor(db, sqlstr);
    m_qry.setQuery(m_QD);
    if (!m_qry.isOpen()) {
      m_qry.open();
    }
   if (m_qry.getRowCount() == 0) {
     return defaultvalue;
   }
   else {
     Variant m_variant = new Variant();
     m_qry.getVariant(colname, m_variant);
     return m_variant.toString();
   }
 }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -