etElementsByTagName("name").item(0).getFirstChild().getNodeValue()).equals(strName) && Integer.parseInt(restaurant.getAttributeNode("id").getNodeValue())!=modiId ){ out.print(showDialog("餐馆名称重复!")); return; }else{ if(((String)restaurant.getElementsByTagName("name").item(0).getFirstChild().getNodeValue()).equals(strPhone) && Integer.parseInt(restaurant.getAttributeNode("id").getNodeValue())!=modiId ){ out.print(showDialog("餐馆电话重复!")); return; } } } if(!recordExist){ out.print(showDialog("你要修改餐馆的记录不存在!")); return; }else{ //进行记录更改的操作 try{ Element modiRestaurant=(Element) restaurants.item(intI); modiRestaurant.getElementsByTagName("name").item(0).getFirstChild().setNodeValue(strName); modiRestaurant.getElementsByTagName("phone").item(0).getFirstChild().setNodeValue(strPhone); modiRestaurant.getElementsByTagName("address").item(0).getFirstChild().setNodeValue(strAddress); //调用bean 写入相应的xml文件 writeXmlBean.writeXml(doc,"webapps/canyin/data/restaurants.xml"); response.sendRedirect(request.getRequestURI()); return; }catch(Exception e){} } } //进行删除操作 if(strAct.equals("del")){ int delId; //记录要修改的记录是item(i)的哪一项 int intI=0; delId=Integer.parseInt(request.getParameter("recordId").trim()); if(delId==0){ out.print(showDialog("你要修改餐馆的记录不存在!")); return; } file://标志显示记录存在 boolean recordExist=false; //校验数据的唯一性 for(int i=0;i<restaurants.getLength();i++){ Element restaurant=(Element) restaurants.item(i); if(Integer.parseInt(restaurant.getAttributeNode("id").getNodeValue())==delId){ recordExist=true; intI=i; } } if(!recordExist){ out.print(showDialog("你要删除餐馆的记录不存在!")); return; }else{ //进行记录删除的操作 try{ Node delNode=(Node)restaurants.item(intI); doc.getElementsByTagName("restaurants").item(0).removeChild(delNode); //调用bean 写入相应的xml文件 writeXmlBean.writeXml(doc,"webapps/canyin/data/restaurants.xml"); response.sendRedirect(request.getRequestURI()); return; }catch(Exception e){} } } } //由外部传入参数决定页面相应的处理状态 if (strAct==null){ strOperation="show"; }else{ if (strAct.equals("modi")){ strOperation="modi"; intId=Integer.parseInt(request.getParameter("recordId")); }else{ if(strAct.equals("addnew")){ strOperation="addnew"; }else{ strOperation="show"; } } } //如果为空记录,则变更页面状态为“新增” if (restaurants.getLength()==0){ strOperation="addnew"; } %> <html> <head> <title>oddWorld 餐饮系统</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <meta http-equiv="expires" content="0"> <link rel="stylesheet" href="../../include/itsp.css" type="text/css"> </head> <body > <div align="center"> <table width="100%" border="0" cellspacing="0" cellpadding="0" height="22"> <tr> <td width="1"><img src="../../images/top_r1.GIF" width="62" height="22"></td> <td width=150 align="center"> 餐饮系统管理--餐馆管理</td> <td><img src="../../images/top_r2.GIF" width="294" height="22"></td> <td width=100 align="center"><a href="/index.html">[ 退出系统 ]</a></td> </tr> </table> <br> <br> <table bgcolor="#999999" align=center border=0 cellpadding=1 cellspacing=1 width="90%"> <tbody> <tr bgcolor="#efefef" align="center" valign="middle"> <td class=ttTable height=30 width="20"> </td> <td class=ttTable height=30 width="0">餐馆名称</td> <td class=ttTable height=30 width="0">餐馆电话</td> <td class=ttTable height=30 width="0"> <div align="center">餐馆地址</div> </td> <td class=ttTable height=30 width="30"> <div align="center">修改</div> </td> <td class=ttTable height=30 width="30"> <div align="center">删除</div> </td> </tr> <% for(int i=0;i<restaurants.getLength();i++) { Element restaurant=(Element) restaurants.item(i); if (strOperation=="modi" && Integer.parseInt(restaurant.getAttributeNode("id").getNodeValue())==intId){ %> <%//显示修改的格式%> <tr align="center" bgcolor="#ffffff" valign="middle"> <form name=dataform action="<%=request.getRequestURI()%>?act=modiDo" method="post" onSubmit='return checkform(this);' > <td class=tdsmall height=25 width="20"> <input type="hidden" name="recordId" value="<%=restaurant.getAttributeNode("id").getNodeValue()%>"> <%=(i+1)%></td> <td class=tdsmall height=25> <input name="name" class=stedit style="HEIGHT: 22px; WIDTH: 150px" value="<%if(restaurant.getElementsByTagName("name").item(0).hasChildNodes()){ out.print(restaurant.getElementsByTagName("name").item(0).getFirstChild().getNodeValue()); }%> " maxlength="40" > </td> <td class=tdsmall height=25> <input name="phone" class=stedit & 上一页 [1] [2] [3] [4] [5] [6] 下一页
|