📄 delmodifyaction.java
字号:
String str1 = str.substring(0, t);
String str2 = str.substring(t, str.length());
str = str1 + "%" + str2;
System.out.println(str);
sql += " fcity like \"" + str + "\"";
count2[0] = 1;
}
/**
* 如果起点不是空而终点为空的话加如% 并设定以后需要加如"and"
*/
if ((count[3] == 1) && (count[4] == 0)) {
str = str + "%";
sql += " fcity like \"" + str + "\"";
count2[0] = 1;
}
/**
* 如果终点不是空而起点为空的话加如% 并设定以后需要加如"and"
*/
if ((count[3] == 0) && (count[4] == 1)) {
str = "%" + str;
sql += " fcity like \"" + str + "\"";
count2[0] = 1;
}
/** 判断航空号是否为空,并判断是否需要加如 "and" */
if (count[0] == 1) {
if (count2[0] == 1) {
sql = sql + " and fno='" + m_ViewForm.getSelect()
+ "'";
count2[1] = 1;
}
if (count2[0] == 0) {
sql = sql + " fno='" + m_ViewForm.getSelect() + "'";
count2[1] = 1;
}
}
/** 判断航班国籍是否为空,并判断是否需要加如 "and" */
if (count[1] == 1) {
if ((count2[0] == 1) || (count2[1] == 1))
sql = sql + " and fcountry='"
+ toChinese(m_ViewForm.getSelect2()) + "'";
else
sql = sql + " fcountry='"
+ toChinese(m_ViewForm.getSelect2()) + "'";
count2[2] = 1;
}
/** 判断航班是出境还是入境还是为空,并判断是否需要加如 "and" */
if (count[2] == 1) {
if ((count2[0] == 1) || (count2[1] == 1)
|| (count2[2] == 1))
sql = sql + " and iout='"
+ toChinese(m_ViewForm.getSelect3()) + "'";
else
sql = sql + " iout='"
+ toChinese(m_ViewForm.getSelect3()) + "'";
count2[3] = 1;
}
/** 判断航空公司是否为空,并判断是否需要加如 "and" */
if (count[5] == 1) {
if ((count2[0] == 1) || (count2[1] == 1)
|| (count2[2] == 1) || (count2[3] == 1)) {
sql = sql + " and fcom='"
+ toChinese(m_ViewForm.getSelect6()) + "'";
} else
sql = sql + " fcom='"
+ toChinese(m_ViewForm.getSelect6()) + "'";
}
} else {
/** 判断是否指定了关键字 */
sql += expression + "'";
}
System.out.println(sql);
}
/**
* 权限
*
* @param userTableName
* 对表进行操作的权限
*/
String userTableName = (String) request.getSession().getAttribute(
"userTableName");
String str1 = "";
int temp1 = 0;
int temp2 = 0;
boolean flag2 = false;
for (int m = 0; m < userTableName.length(); m++) {
str1 = userTableName.substring(m, m + 1);
if (";".equals(str1)) {
if ("flight".equals(userTableName.substring(temp1, m)))
temp2++;
if ("city".equals(userTableName.substring(temp1, m)))
temp2++;
temp1 = m + 1;
}
}
/**
* 权限
*
* @param userUpdateGrant
* 对表进行更新操作的权限
*/
String userUpdateGrant = (String) request.getSession()
.getAttribute("userUpdateGrant");
/** 删除记录操作 */
/**
* 权限
*
* @param userDeleteGrant
* 对表进行删除操作的权限
*/
String userDeleteGrant = (String) request.getSession()
.getAttribute("userDeleteGrant");
/** 判断是否只是做动作来进行跳转,是的话则跳转到delmodify.jsp */
if ((userDeleteGrant == "Y") || (userUpdateGrant == "Y")) {
flag2 = true;
}
if (("find".equals(action)) && (temp2 == 2) && (flag2 == true)) {
return mapping.findForward("success");
}
if ((temp2 != 2) || (flag2 == false))
return mapping.findForward("filter");
/** 设置每页显示的记录数 */
m_ViewDAO.setLength(6);
/** 当前显示页 */
int ipage;
try {
/** 分页参数,读取请求的当前页 */
String page = request.getParameter("page");
ipage = java.lang.Integer.parseInt(page, 10);
} catch (Exception e) {
ipage = m_ViewForm.getPage();
}
/** 如果没有找到数据显示为0个数据时则页面显示为1页 */
if (ipage < 1)
ipage = 1;
/** 通过DAO对象查询数据 */
Collection col = m_ViewDAO.findSQL(sql, ipage);
/** 保存数据 */
request.setAttribute("View", col);
/** 分页字符串,分页内容 */
String pagestr = m_ViewDAO.getPagestr(ipage);
String s_find, str;
/**
* 查找和全部显示两个不同的操作,其分页字符串不同,在此进行处理。
* 如果是全部显示则去掉"search=search&"
*/
if (!"search".equals(search)) {
s_find = "search=search&";
while (pagestr.indexOf(s_find) != -1) {
str = pagestr.substring(0, pagestr.indexOf(s_find));
str += pagestr.substring(pagestr.indexOf(s_find)
+ s_find.length(), pagestr.length());
pagestr = str;
}
}
/** 将分页内容,动作类型传递给m_ViewForm */
m_ViewForm.setPagestr(pagestr);
m_ViewForm.setAction(action);
request.setAttribute("DelModifyForm", m_ViewForm);
/** 当下拉框有值被选择,而不都为空时flag为真 */
for (int j = 0; j < 6; j++) {
if (count[j] == 1)
flag = true;
}
/** 当进行了动作并且有下拉框被选择则跳转到delmodifyout.jsp页 */
if ((!"find".equals(action)) && (flag == true) && (temp2 == 2)
&& (flag2 == true)) {
return mapping.findForward("delmodify");
}
/** 否则则跳转到出错的页面 */
else
return mapping.findForward("error");
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Unable to get connection.");
} finally {
try {
/** 关闭数据库连接 */
if (con != null)
con.close();
} catch (SQLException e) {
throw new RuntimeException(e.getMessage());
}
}
}
/** 处理中文问题,实现编码转换 */
public String toChinese(String ss) {
if (ss != null) {
try {
String temp_p = ss;
byte[] temp_t = temp_p.getBytes("ISO-8859-1");
ss = new String(temp_t);
} catch (Exception e) {
System.err.println("toChinese exception:" + e.getMessage());
System.err.println("The String is:" + ss);
}
}
return ss;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -