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

📄 updatecuredata.jsp

📁 利用JAVA语言实现
💻 JSP
字号:
<!--添加/修改语料库页面-->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page contentType="text/html; charset=gb2312" pageEncoding="gb2312" language="java" %>
<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page import="com.CureData"%>
<jsp:useBean id="cureDataManage" class="com.CureDataManage" scope="request"/>
<%  
	if(session.getAttribute("adminName") == null)
		response.sendRedirect("null.htm");

	//操作类型 "ADD":添加记录 ,"UPDATE":修改记录
	String operationType = request.getParameter("operationType");
	String msg = "";
	String symptom = ""; //症状
	String treatment = ""; //治疗方法
	String addDate = ""; //添加日期
	int id = 0;
	if(operationType.equals("UPDATE")){
		msg = "修改";
		id = new Integer(request.getParameter("updateID")).intValue(); //记录ID
		CureData cureData = cureDataManage.getDataById(id);
		if(cureData != null){
			symptom = cureData.getSymptom();
			treatment = cureData.getTreatment();
			addDate = cureData.getAddDate().split(" ")[0];
		}
	}else if(operationType.equals("ADD")){
		msg = "新增";
		Calendar cal = Calendar.getInstance();
  		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
  		addDate = sf.format(cal.getTime()); //获取当前日期(字符串)
	}
	
%>
<html><head>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0"><title></title>
<script language="JavaScript" src="js/calendar.js"></script>
<!-- js for dwr -->
<script src="<%=request.getContextPath()%>/dwr/engine.js"></script>
<script src="<%=request.getContextPath()%>/dwr/util.js"></script>
<script src="<%=request.getContextPath()%>/dwr/interface/DWRCureData.js"></script>
<link href="css/common.css" rel="stylesheet" type="text/css">
</head>

<script language="JavaScript">    
function checkForm(form, type){
	var symptom = trim(form.symptom.value);
	if(symptom == ""){
		alert("症状不能为空!");	
		return;
	}
	var treatment = trim(form.treatment.value);
	if(treatment == ""){
		alert("治疗方法不能为空!");	
		return;
	}
	
	var cureDataMap = {}; //语料信息对象
	cureDataMap.id = form.id.value;
	cureDataMap.symptom = symptom; 
	cureDataMap.treatment = treatment;
	cureDataMap.addDate = form.addDate.value;

	if(type == "ADD"){ //添加记录
		DWRCureData.add(cureDataMap, addCallback);
		
	}else if(type == "UPDATE"){ //修改记录
		DWRCureData.update(cureDataMap, updateCallback);
	}
}

//添加语料对象的反馈函数
function addCallback(data){
	if(data){
		alert("添加成功!");
		window.location.href="cureDataList.jsp";
		
	}else{
		alert("添加失败!");
	}
}

//修改语料对象的反馈函数
function updateCallback(data){
	if(data){
		alert("修改成功!");
		history.go(-1);
		
	}else{
		alert("修改失败!");
	}
}

//去掉字符串两端空格
function trim(val){
	var str = val+"";
	if (str.length == 0) return str;
	var re = /^\s*/;
	str = str.replace(re,'');
	re = /\s*$/;
	return str.replace(re,'');
}

</script>

<BODY>
<form name="updateCureDataform" method="post">
<input type="hidden" name="id" value="<%=id%>" />
<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
      <td height=25 id=location ><div align="left"><img src="images/location_arrow.gif" width="8" height="11" align="absmiddle"> 语料库管理&gt;&gt;<%=msg%></div></td>
    </tr>
    <tr>
      <td height=12 id=operation><div align="left">
        <input type="button" class="input-button" name="Submit" value="保 存" onClick="javascript:checkForm(updateCureDataform, '<%=operationType%>')">
		<input type="button" class="input-button" value="返 回" onClick="history.go(-1)">

</div></td>
    </tr></table>
<table width="95%" border="0" align="center" cellpadding="4" cellspacing="1" class="tbcolor">
  <tbody>
    <tr id="tbcolor">
       <th align="center" id="list"><%=msg%>语料库信息</th>
    </tr>
    <tr>
    <td bgcolor="#FFFFFF">
<table width="100%" border="0" cellpadding="2" cellspacing="1">
  <tbody>
	<tr>
	<td width="10%"><div align="right">症状 :</div></td>
      <td width="40%"><div align="left">
	  <input type="text" maxLength=100 name="symptom" style="width:600px;" class="input-text" value="<%=symptom%>"/>
      </div></td>
	</tr>
	<tr>
	<td width="10%"><div align="right">治疗方法 :</div></td>
      <td width="40%"><div align="left">
	      <textarea rows="10" cols="10" style="height:300px; width:600px; overflow:auto;" name="treatment" class="input-text"><%=treatment%></textarea>
      </div></td>
	</tr>
	<tr>
	<td width="10%"><div align="right">添加日期 :</div></td>
      <td width="40%"><div align="left">
	  <input type="text" name="addDate" style="width:100px;" onBlur="" styleClass="input-text" maxlength="30" readonly="true" value="<%=addDate%>" onFocus="showcal(this)" />
      </div></td>
	</tr>
</table>
    </td>   
  </tbody>
</table>
</form>
</body></html>

⌨️ 快捷键说明

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