changehw.jsp
上传用户:helenhuo66
上传日期:2007-06-01
资源大小:865k
文件大小:7k
源码类别:

百货/超市行业

开发平台:

Java

  1. <%@ page contentType="text/html;charset=GBK" language="java" import="java.sql.*,java.util.Date" errorPage="" %>
  2. <%@ include file="conn.jsp"%>
  3. <%
  4. if(session.getAttribute("admin_name")!=null){
  5. //--------------------------------------logged------------------------------------------------------------------
  6. %>
  7. <html><head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  9. <link href=../css.css rel=STYLESHEET type=text/css>
  10. </head>
  11. <%!
  12. String encode(String str)
  13.  {
  14.     String result;
  15.     int l;
  16.     if(str=="")
  17. {
  18.        result="";
  19. }
  20.     else
  21.     {
  22.     l=str.length();
  23. char[] chr=new char[l];
  24. str.getChars(0,l,chr,0);
  25.     result="";
  26. int i;
  27. for(i=0;i<=l-1;i++)
  28.   {
  29.     
  30.                switch(chr[i])
  31.     {
  32.     
  33.            case '<':
  34.                 result=result+"&lt;";
  35. break;
  36.            case '>':
  37.                 result=result+"&gt;";
  38.    break;
  39.               case 10:
  40.                 result=result+"<br>";
  41.   break;
  42.  
  43.            case 34:
  44.                 result=result+"&quot;";
  45.    break;
  46.            case '&':
  47.                 result=result+"&amp;";
  48.    break;
  49.               case ' ':
  50.         result=result+"&nbsp;";
  51.   break;
  52.                
  53.           case 9:
  54.                 result=result+"    ";
  55.    break;
  56.            default:
  57.                 result=result+String.valueOf(chr[i]);
  58. }
  59.   } 
  60. }
  61.     return result;
  62.   }
  63.  %>
  64. <%
  65. int hw_id ,hw_cash,sort_id,hw_views,hw_buys,pifa,daili,Nsort_id;
  66. String hw_name,hw_pic,hw_content,hw_content2,hw_sn,company,isbn,chubsh,zhuang,yeshu,action,kaiben;
  67. boolean tuijian=false;
  68. Date data,date;
  69. data=new Date();
  70. action=request.getParameter("action");
  71. if(action!=null)//---------------------------action!=null-------------------------------------
  72.  {   if(action.trim().equals("save"))
  73.       {//--------------------------------action=save---------------------------------
  74.    boolean founderr=false;
  75.    String hw_ids ,hw_cashs,sort_ids,pifas,dailis,errmsg,datas,tuijians,Nsort_ids;
  76.    errmsg="错误信息:";
  77.         hw_name=request.getParameter("hw_name");
  78.        hw_content=request.getParameter("hw_content");
  79.    hw_content2=request.getParameter("hw_content2");
  80.        hw_cashs=request.getParameter("hw_cash");
  81.        hw_pic=request.getParameter("hw_pic");
  82.    chubsh=request.getParameter("chubsh");
  83.    zhuang=request.getParameter("zhuang");
  84.    yeshu=request.getParameter("yeshu");
  85.    isbn=request.getParameter("isbn");
  86.        sort_ids=request.getParameter("sort_id");
  87.        Nsort_ids=request.getParameter("Nsort_id");
  88.        tuijians=request.getParameter("tuijian");
  89.        company=request.getParameter("company");
  90.        pifas=request.getParameter("pifa");
  91.        dailis=request.getParameter("daili");
  92.        hw_sn=request.getParameter("hw_sn");
  93.        datas=request.getParameter("data");
  94.        kaiben=request.getParameter("kaiben");
  95.    hw_ids=request.getParameter("hw_id");
  96.        if (hw_cashs.equals(""))
  97.        {   errmsg="<br>"+"<li>图书的价格不能为空";
  98.         founderr=true;
  99.         }
  100.     else{
  101.          hw_cash=Cint(hw_cashs);
  102.          if(hw_cash==0){
  103.              errmsg="<br>"+"<li>图书的价格为数字";
  104.                   founderr=true;
  105.          }
  106.    }
  107.  if (pifas.equals(""))
  108.       {   errmsg="<br>"+"<li>图书的价格不能为空";
  109.         founderr=true;
  110.       }
  111.  else{
  112.       pifa=Cint(pifas);
  113.        if(pifa==0){
  114.       errmsg="<br>"+"<li>图书的价格为数字";
  115.           founderr=true;
  116.        }
  117.  }
  118.  if (dailis.equals(""))
  119.      {   errmsg="<br>"+"<li>图书的价格不能为空";
  120.         founderr=true;
  121.      }
  122.  else{
  123.  daili=Cint(dailis);
  124.    if(daili==0){
  125.       errmsg="<br>"+"<li>图书的价格为数字";
  126.           founderr=true;
  127.    }
  128.  }
  129.     if(hw_name.equals(""))
  130. {
  131.         errmsg=errmsg+"<br>"+"<li>图书名称不能为空";
  132.         founderr=true;
  133.     }
  134.     if(hw_content.equals(""))
  135. {
  136.         errmsg=errmsg+"<Br>"+"<li>图书介绍不能为空";
  137.         founderr=true;
  138.     }
  139.     if(sort_ids.equals(""))
  140. {
  141.         errmsg=errmsg+"<br>"+"<li>图书类别不能为空";
  142.         founderr=true;
  143.     }
  144.     if(datas.length()!=10){
  145.     errmsg=errmsg+"<br>"+"<li>产品生产日期格式不正确";
  146.         founderr=true;
  147.   }else
  148.  {
  149.     if(datas.indexOf('-')!=4||datas.lastIndexOf('-')!=7){
  150.   errmsg=errmsg+"<br>"+"<li>产品生产日期格式不正确";
  151.           founderr=true;
  152. }
  153. else
  154. {
  155. int year=Cint(datas.substring(0,4));
  156. int month=Cint(datas.substring(5,7));
  157. int day=Cint(datas.substring(8));
  158.   if(month>12||day>31||month<=0||day<=0){
  159.       errmsg=errmsg+"<br>"+"<li>产品生产日期格式不正确";
  160.              founderr=true;
  161.    }else{
  162.     data=new Date(year-1900,month-1,day);
  163.    }
  164. }
  165.   }
  166.     
  167.     if (hw_pic.equals("")){ hw_pic="img/noimage.gif";}
  168. if (hw_ids.equals(""))
  169. {   errmsg=errmsg+"<br>ID参数丢失";
  170.     founderr=true;
  171. }
  172.      if (tuijians.equals(""))
  173. {   errmsg=errmsg+"<br>推荐与否参数丢失";
  174.     founderr=true;
  175. }
  176.    /* check to decide whether to carry the work                            */
  177.      if(founderr==true)
  178.  {
  179.         out.print(errmsg);
  180.         out.print("<br>");
  181.         out.print("<a href=addhw.jsp>返回</a>");
  182.         
  183. }
  184.     else
  185. {   
  186.     hw_id=Cint(hw_ids);
  187. sort_id=Cint(sort_ids);
  188. hw_cash=Cint(hw_cashs);
  189. daili=Cint(dailis);
  190. pifa=Cint(pifas);
  191. Nsort_id=Cint(Nsort_ids);
  192.         hw_name=getStr(hw_name);
  193.         hw_content=getStr(hw_content);
  194.         hw_content=encode(hw_content);
  195. hw_content=getStr(hw_content);
  196.         hw_content2=encode(hw_content2);            
  197.         hw_pic=getStr(hw_pic);
  198. if(tuijians.equals("1")){
  199.   tuijian=true;
  200. }   
  201.      
  202. sql="update hw set hw_name='"+hw_name+"',hw_content='"+hw_content+"',hw_content2='"+hw_content2;
  203. sql=sql+"',hw_cash="+hw_cash+",sort_id="+sort_id+",company='"+company+"',daili="+daili+",pifa="+pifa;
  204. sql=sql+",hw_sn='"+hw_sn+"',chubsh='"+chubsh+"',kaiben='"+kaiben+"',yeshu='"+yeshu+"',data='"+data.toLocaleString()+"',isbn='"+isbn;
  205. sql=sql+"',zhuang='"+zhuang+"',hw_pic='"+hw_pic+"',Nsort_id="+Nsort_id+",tuijian="+tuijian+" where hw_id="+hw_id;
  206.         mdb.executeUpdate(sql);
  207.   out.print("商品修改成功!");
  208.         out.print("<br>");
  209.        out.print("<a href=delhw.jsp>返回</a>");
  210.      }
  211.   
  212.     }//----------------------------------end save---------------------------------------------------
  213.     
  214.    }
  215.     else
  216.   {//------------------------------------------ action==null--------------------------------------------------------------
  217.      %>
  218.  <%@ include file="in-changehw.jsp" %>
  219.  <%
  220.   }//----------------------------action== null end--------------------------------------------------------------
  221. }
  222. else
  223. {
  224. //--------------------------------------not logged------------------------------------------------------------------
  225. response.sendRedirect("index.jsp");
  226. }%>