<%@ 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">
<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();
// out.println("anbieter_guid ="+anbieter_guid) ;
try {
// Step 1. Load the JDBC driver
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
// Step 2. Create a Connection object
Connection
con_anbieter
=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost;1433;databaseName=RFID;","boxer",
"boxer");
// Step 3. Create a Statement object and call its executeUpdate
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+"')";
//out.println("sql_anbieter:"+sql_anbieter);
//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)
{
RandomGUID my_person_guid = new RandomGUID();
String person_guid =
my_person_guid.toString();
// out.println("person_guid_"+i+ "="+person_guid);
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>
</table>
<table width="700" border="0">
<tr>
<td width="86"> Nachname: </td>
<td width="48"><%= nachname %></td>
<td width="552"></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
{
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++)
{
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();
if(tel_type_str != null)
{
if (tel_type_str.equals("telPer1") )
{
tel1 = "selected";
}
else if (tel_type_str.equals("telPer2") )
{
tel2 = "selected";
}
else if (tel_type_str.equals("telPer3") )
{
tel3 = "selected";
}
}
//#################################################################################
%>
<table>
<tr>
<td
width="126">TelNr._<%= j %>_<%= ii %>:
</td>
<td
width="138"><input type="text" name="telPer<%= j %>_<%=
ii %>" value="<%=
tel_per_str%>"/></td>
<td
width="408"><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></td>
</tr>
<input type="hidden"
name="telPer_num_<%= j %>" value="<%= tel_count %>" />
</table>
<%
RandomGUID my_tel_guid = new RandomGUID();
String tel_guid =
my_tel_guid.toString();
}
%>
<!--in Datenbank
speichern##########################################################################-->
<%
try {
// Step 1. Load the JDBC driver
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
// Step 2. Create a Connection object
Connection con_person
=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost;1433;databaseName=RFID;","boxer",
"boxer");
// Step 3. Create a Statement object and call its executeUpdate
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());
//out.println("Es gibt ein Ueberschreit der String");
}
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>