📄 kyoukusyologic.java
字号:
package com.dut.logic.logic;
import java.awt.List;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import javax.servlet.http.HttpSession;
import com.dut.dao.BatchDBConnectionUtil;
import com.dut.logic.db.Kyokusyo;
import com.dut.logic.util.StringUtil;
import com.dut.struts.action.ShujuyilanAction;
public class KyoukusyoLogic {
static int page = 1;
static int fiednum;
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public void next() {
page++;
}
public void up() {
page--;
}
public static int getfiednum(String sql, int page, int pageMaxRows) {
int pageMaxRows1;
int maxRows = 0;
pageMaxRows1 = pageMaxRows;
String sql1 = sql;
ArrayList list1 = new ArrayList();
BatchDBConnectionUtil yy = new BatchDBConnectionUtil();
System.out.println("+++++++++++" + sql1);
ResultSet rs = yy.executeQuery(sql1);
try {
while (rs.next()) {
maxRows = Integer.parseInt(rs.getString(1));
System.out.println("maxRows==" + maxRows);
break;
}
} catch (NumberFormatException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return maxRows;
}
public static ArrayList getCurrentPageData(int Page, int pageMaxRows,
int maxRows) {
/** property maxRows ����sql?��?�o"�ő�I�s��" */
int maxRows1 = maxRows;
int frow;
int lrow;
int page1 = page;
int pageMaxRows1 = pageMaxRows;
ArrayList list1 = new ArrayList();
BatchDBConnectionUtil yy = new BatchDBConnectionUtil();
/** property maxPageNum is the biggest of the page nums (�ő�I?��) */
int fiednum = maxRows % pageMaxRows1 == 0 ? maxRows / pageMaxRows1
: maxRows / pageMaxRows + 1;
/**
* judge the current page is from 1 to the maxPageNum
* ���f���O�I?��??��1�a�ő�I?���V?.
*/
System.out.println("page==========" + page1);
System.out.println("fiednum==========" + fiednum);
System.out.println("maxRows==========" + maxRows);
if (page1 <= 1) {
page1 = 1;
}
if (page1 >= fiednum) {
page1 = fiednum;
}
frow = page1 * pageMaxRows1 - 10;
lrow = page1 * 10;
if (lrow > maxRows) {
lrow = maxRows;
}
String w = ShujuyilanAction.W();
System.out.println("w====" + w);
String Sq = "select * from Kyokusyo " + w + " limit " + frow + "," + ""
+ lrow + "";
System.out.println("Sq==>" + Sq);
ResultSet rss = yy.executeQuery(Sq);
System.out.println("sq_frow" + "select * from Kyokusyo limit " + frow
+ "," + "" + lrow + "");
try {
while (rss.next()) {
String ky = StringUtil.trans_date(rss.getString("KYOKU_ID"));
System.out.println(" ky ====" + ky);
String kym = StringUtil.trans_date(rss
.getString("KYOKUSYO_MEI"));
String zm = rss.getString("ZIPCD_MAE");
String za = rss.getString("ZIPCD_ATO");
String ma = zm + za;
String jy = StringUtil.trans_date(rss.getString("JUSYO"));
String tel = StringUtil.trans_date(rss.getString("TEL"));
Kyokusyo kk = new Kyokusyo();
kk.setKyoku_id(StringUtil.trans(ky));
kk.setKyokusyo_mei(kym);
kk.setMa(ma);
kk.setJusyo(jy);
kk.setTel(tel);
list1.add(kk);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list1;
}
public static int getFiednum(int pageMaxRows, int maxRows) {
int pageMaxRows1 = pageMaxRows;
fiednum = maxRows % pageMaxRows1 == 0 ? maxRows / pageMaxRows1
: maxRows / pageMaxRows + 1;
return fiednum;
}
public static boolean delete_kyou(ArrayList list) {
String KYOKU_ID = null;
String KEN_ID = null;
Iterator it = list.iterator();
if (it.hasNext()) {
Kyokusyo temp = (Kyokusyo) it.next();
KYOKU_ID = temp.getKyoku_id();
KEN_ID = String.valueOf(temp.getKen_id());
}
String sql = "DELETE FROM KYOKUSYO WHERE KEN_ID='" + KEN_ID
+ "' AND KYOKU_ID='" + KYOKU_ID + "'";
System.out.println("sql========>"+sql);
String str = new BatchDBConnectionUtil().executeUpdate(sql);
if (str != null) {
return false;
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -