fanxin

 

anbieter_DB_Test.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page import = "java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="de.tum.sep.*" %>

<%@ page contentType="text/html; charset=UTF-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> Anbieter</title>
</head>
<%
    String anzahlPersonenStr = (String)request.getParameter("n_person");    
    //out.println("anzahlPersonenStr:  " + anzahlPersonenStr);
    String nameAnbieter = (String)request.getParameter("nameAnbieter" );
    String adresse = (String)request.getParameter("adresse");
    String plz = (String)request.getParameter("plz");
    String ort = (String)request.getParameter("ort");
    String land = (String)request.getParameter("land");
    String url = (String)request.getParameter("url");
    String emailAnbieter = (String)request.getParameter("emailAnbieter");

    int anzahlZuruecken = 0;

    String showNachnameStr = (String)request.getParameter("showNachname");
    String showTelPerStr = (String)request.getParameter("showTelPer");   
    
    String anzahlZurueckenStr = (String)request.getParameter("nZuruecken");
    String submit_db = (String)request.getAttribute("submit_db");    
%>  
<body bgcolor="#DDDDDD">
<%    
      if ( anzahlZurueckenStr == null)
         { anzahlZuruecken = 0 ;
%>
   <table width="700" border="0">
        <h3><font color="#0000FF">Anbieter:</font></h3>  
   </table>
      <table width="700" border="0">
        <tr>
          <td width="86"> Name: </td>
          <td width="348">
          <%= nameAnbieter %></td>
          <td width="252">        
          </td>
        </tr>
        <tr>
          <td width="86"> Adresse: </td>
          <td width="348">
          <%= adresse %></td>
          <td width="252">        
          </td>
        </tr>
        <tr>
          <td width="86"> PLZ: </td>
          <td width="348">
          <%= plz %></td>
          <td width="252">        
          </td>
        </tr>
        <tr>
          <td width="86"> Ort: </td>
          <td width="348">
          <%= ort %></td>
          <td width="252">        
          </td>
        </tr>
        <tr>
          <td width="86"> Land: </td>
          <td width="348">
          <%= land %></td>
          <td width="252">        
          </td>
        </tr>
        <tr>
          <td width="86"> URL: </td>
          <td width="348">
          <%= url %></td>
          <td width="252">        
          </td>
        </tr>
        <tr>
          <td width="86"> Email: </td>
          <td width="348">
          <%= emailAnbieter %></td>
          <td width="252">        
          </td>
        </tr>
      </table>
<!--Personal Bereich################################################################################-->    
<%   
     RandomGUID my_anbieter_guid = new RandomGUID();
     String anbieter_guid = my_anbieter_guid.toString();
     try {
         Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");      
         Connection con_anbieter =java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost;1433;databaseName=RFID;","boxer", "boxer");
                          
         Statement st_anbieter = con_anbieter.createStatement();
         String  sql_anbieter = "INSERT INTO Anbieter (AnbieterGUID, AnbieterName, Adresse, PLZ, Ort, Land, Website, AbfragEmail)                        VALUES ('"+anbieter_guid+" ','"+nameAnbieter+"','"+adresse+"','"+plz+"','"+ort+"','"+land+"','"+url+"','"+emailAnbieter+"')";
         //st_anbieter.executeUpdate(sql_anbieter);
         st_anbieter.close();
         con_anbieter.close();
         }catch (ClassNotFoundException e1) {
         //JDBC driver class not found, print error message to the console
         out.println(e1.toString());
         }
          catch (SQLException e2) {
          // Exception when executing java.sql related commands, print error message to the console
          out.println(e2.toString());
          //out.println("Es gibt ein Ueberschreit der String");
          }
          catch (Exception e3) {
          // other unexpected exception, print error message to the console
          out.println(e3.toString());
          }
%>    
<%    
  int anzahlPersonen ;
 
  if ((anzahlPersonenStr == null) || anzahlPersonenStr.equals("0"))
     {anzahlPersonen = 0;
      } else {    
          anzahlPersonen = Integer.parseInt(anzahlPersonenStr, 10);                      
          int count = anzahlPersonen;               
          for (int i = 1, j = 1; i <= count; ++i)                                
          {
           String nachname = (String)request.getParameter("nachname" + i);
           String vorname = (String)request.getParameter("vorname" +i);
           String abteilung = (String)request.getParameter("abteilung" +i);
           String emailPer = (String)request.getParameter("emailPer" +i);

//         String telPer = (String)request.getParameter("telPer" +i);
    
           if (nachname == null) nachname = "";
//           if (telPer == null) telPer = "";    
%>
      <table width="700" border="0">
        <h4><font color="#0000FF">Kontaktpersonen_<%= i %>:</font></h4>  
<%
           RandomGUID my_person_guid = new RandomGUID();
           String person_guid = my_person_guid.toString();                           
           //out.println("person_guid_"+i+ "="+person_guid);   
%>             
      </table>    
      <table width="700" border="0">
        <tr>
          <td width="86"> Nachname: </td>
          <td width="48"><%= nachname %></td>
          <td width="552"></td>
        </tr>
        <tr>
          <td width="126"> Vorname: </td>
          <td width="148"><%= vorname %></td>
          <td width="412"></td>
        </tr>
        <tr>
          <td width="126"> Abteilung: </td>
          <td width="148"><%= abteilung %></td>
          <td width="412"></td>
        </tr>
        <tr>
          <td width="126">Email: </td>
          <td width="448"><%= emailPer %></td>            
          <td width="112"></td>
        </tr>
      </table>
      <%
          String tel_count_str = (String)request.getParameter("telPer_num_"+ j );                
        int tel_count ;    
                    
        if(tel_count_str == null)
        {
            //out.println(request.getParameter("telPer_num_"+ j ));
            //out.println("Ablauf1");
            tel_count = 1;
        }
        else
        {
            //out.println("tel_count_str = Tel von Person ="+ tel_count_str);
            String tel_count_db = request.getParameter("telPer_num_"+ j );                        
            tel_count = Integer.parseInt(tel_count_db, 10);
        }
                        
        for(int ii = 0; ii < tel_count; ii++)
        {
          RandomGUID my_tel_guid = new RandomGUID();
          String tel_guid = my_tel_guid.toString();                                       
          out.println("tel_guid ="+ tel_guid);
          String tel_per_str = (String)request.getParameter("telPer"+j+"_"+ii);
          if (tel_per_str == null) tel_per_str="";
          
          String tel_type_str = (String)request.getParameter("telPer_type_" + i + "_" + ii);
          //Entscheidung von Telepon ########################################################
          String tel1 = new String();
          String tel2 = new String();
          String tel3 = new String();
          String tel_type = new String();
          if(tel_type_str != null)
          {
             if (tel_type_str.equals("telPer1") )
              {  
               tel1 = "selected";
               tel_type = "Festnetz";   
               }
                else if (tel_type_str.equals("telPer2") )
              {
                 tel2 = "selected";
               tel_type = "Mobil";
               }
               else if (tel_type_str.equals("telPer3") )
                 {
               tel3 = "selected";
               tel_type = "Fax";
               }   
           }
//#################################################################################
      %>
      <table width="700" border="0">
        <tr>
          <td width="104">TelNr._<%= j %>_<%= ii %>: </td>                           
          <td width="48"><%= tel_per_str%></td>        
          <td width="528"><!--<select name="telPer_type_<%//= j %>_<%//= ii %>" value=""style="WIDTH: 100px" size="">              
              <option value="telPer1" <%//= tel1 %>>Festnetz</option>
              <option value="telPer2" <%//= tel2 %>>Mobil</option>
              <option value="telPer3" <%//= tel3 %>>Fax</option></select>-->
              <%= tel_type %>
              </td>        
          </tr>
        <input type="hidden" name="telPer_num_<%= j %>" value="<%= tel_count %>" />
        </table>
        <%
          }
        %>      
<!--in Datenbank speichern##########################################################################-->          
<%        
try {     
         Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
         Connection con_person =java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost;1433;databaseName=RFID;","boxer", "boxer");                             
         Statement st_person = con_person.createStatement();
                 
         String  sql_person = "INSERT INTO Kontaktperson (KontaktpersonGUID, AnbieterGUID, Vorname, Nachname, Abteilung, Email)                        VALUES ('"+person_guid+" ','"+anbieter_guid+"','"+vorname+"','"+nachname+"','"+abteilung+"','"+emailPer+"')";
//       st_person.executeUpdate(sql_person);
         st_person.close();
         con_person.close();
         }catch (ClassNotFoundException e1) {
         //JDBC driver class not found, print error message to the console
         out.println(e1.toString());
         }
         catch (SQLException e2) {
         // Exception when executing java.sql related commands, print error message to the console
         out.println(e2.toString());                           
         }
         catch (Exception e3) {
          // other unexpected exception, print error message to the console
         out.println(e3.toString());
         }
%>
<input type="hidden" name="telPer_num_<%= j %>" value="<%= tel_count %>" />
<%        
         j++;
        }
       }
     }
%>
<table width="600" border="0">
<td><input type="submit" name="zuruecken" value="zuruecken" onclick="self.location.href='anbieter.jsp'" width="" maxlength="40"/>
    <input type="hidden" name = "nZuruecken" value="<%= anzahlZuruecken %>"/></td>
    </table>
    
</body>
</html>

posted on 2006-02-08 07:28 fanxin 阅读(149) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

留言簿

文章档案

Java

matrix

weiqin

中国JSP技术网站

搜索

最新评论