Skip to content
Snippets Groups Projects
Commit 7b547d03 authored by Timo Jeremy Pinzauti's avatar Timo Jeremy Pinzauti
Browse files

Zwischenstand der Artikelerstellung. Aktuell mit NetBeans Linking Problemen beschäftigt ...

parent 024e6938
Branches Anforderungen
No related tags found
No related merge requests found
......@@ -7,4 +7,4 @@ Dokumentation/Thumbs.db
Dokumentation/Klassendiagramm/Thumbs.db
Dokumentation/Uebung 1/Thumbs.db
=======
>>>>>>> 47d7bfd324c39b8339db585da515957e5ac54bd3
>>>>>>> 47d7bfd324c39b8339db585da515957e5ac54bd3
\ No newline at end of file
......@@ -11,4 +11,6 @@ public interface ShopDAO {
boolean viewShop(User user);
boolean addShop(User user, String shopName);
int getShopIdByUserId(int userId);
}
......@@ -5,6 +5,7 @@
*/
package org.s4s.gui.views;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.server.FileResource;
import com.vaadin.server.FontAwesome;
......@@ -31,13 +32,14 @@ import com.vaadin.ui.VerticalLayout;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import org.s4s.dao.impl.ArtikelerstellungsControl;
import org.s4s.process.control.ArtikelerstellungsControl;
import org.s4s.process.control.ShopControl;
/**
*
* @author synot
*/
public class ArtikelerstellungsView extends TemplateView {
public class ArtikelerstellungsView extends TemplateView implements View {
@Override
public void enter(ViewChangeListener.ViewChangeEvent event) {
......@@ -134,27 +136,54 @@ public class ArtikelerstellungsView extends TemplateView {
nsModul.setNullSelectionAllowed(false);
ArtikelerstellungsControl aCont = new ArtikelerstellungsControl();
ShopControl sCont = new ShopControl();
try {
nsModul.addItems(aCont.getModul());
} catch (Exception e) {
}
nsModul.setNullSelectionAllowed(false);
bErstellen.addClickListener((Button.ClickEvent event) -> {
if (tfName.isEmpty()) {
Notification.show("Bitte einen Namen eingeben!", Notification.Type.ERROR_MESSAGE);
} else if(taBeschreibung.isEmpty()) {
Notification.show("Bitte eine Beschreibung eingeben!", Notification.Type.ERROR_MESSAGE);
} else if(tfPreis.isEmpty()) {
Notification.show("Bitte einen Preis eingeben!", Notification.Type.ERROR_MESSAGE);
} else if(nsKategorie.isEmpty()) {
Notification.show("Bitte wählen Sie eine Kategorie aus!", Notification.Type.ERROR_MESSAGE);
} else {
boolean result = aCont.addProduct(tfName.getValue(), taBeschreibung.getValue(), dfVon.getValue(), dfBis.getValue(), tfPreis.getValue(), Byte image, int aId, int sId, true, 3, 2);
}
});
// bErstellen.addClickListener((Button.ClickEvent event) -> {
//
// if (tfName.isEmpty()) {
// Notification.show("Bitte einen Namen eingeben!", Notification.Type.ERROR_MESSAGE);
// } else if(taBeschreibung.isEmpty()) {
// Notification.show("Bitte eine Beschreibung eingeben!", Notification.Type.ERROR_MESSAGE);
// } else if(tfPreis.isEmpty()) {
// Notification.show("Bitte einen Preis eingeben!", Notification.Type.ERROR_MESSAGE);
// } else if(nsKategorie.isEmpty()) {
// Notification.show("Bitte wählen Sie eine Kategorie aus!", Notification.Type.ERROR_MESSAGE);
// } else {
// try {
// User u = (User) UI.getCurrent().getSession().getAttribute(Roles.CURRENTUSER);
// int sId = sCont.getShopIdByUserId(u.getUserId());
// int mId = aCont.getModulByName(nsModul.getValue().toString());
// int cId = 0;
// if (nsKategorie.getValue().equals("Multimedia")) {
// cId = 1;
// } else {
// cId = 2;
// }
//
// String name = tfName.getValue();
// String beschreibung = taBeschreibung.getValue();
// Date dVon = dfVon.getValue();
// Date dBis = dfBis.getValue();
// double preis = Double.parseDouble(tfPreis.getValue());
//
// boolean result = aCont.addProduct(name, beschreibung, dVon, dBis, preis, image, sId, mId, cId);
//
// if (result) {
// Notification.show("Artikel wurde erfolgreich gespeichert.", Notification.Type.ASSISTIVE_NOTIFICATION);
// } else {
// Notification.show("Artikel konnte nicht gespeichert werden!", Notification.Type.ERROR_MESSAGE);
// }
// } catch (DAOException ex) {
// Logger.getLogger(ArtikelerstellungsView.class.getName()).log(Level.SEVERE, null, ex);
// }
// }
// });
HorizontalLayout hKommand = new HorizontalLayout(bAbbrechen, bErstellen);
HorizontalLayout hVerfuegbarkeit = new HorizontalLayout(dfVon, dfBis);
......
......@@ -3,8 +3,10 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.s4s.dao.impl;
package org.s4s.process.control;
import com.vaadin.ui.Image;
import com.vaadin.ui.UI;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
......@@ -12,10 +14,13 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.s4s.dao.ProductDAO;
import org.s4s.dao.impl.AbstractDatabaseClass;
import org.s4s.exceptions.DAOException;
import org.s4s.modell.dto.Product;
import org.s4s.modell.dto.Shop;
import org.s4s.modell.dto.User;
import org.s4s.services.db.JDBCConnection;
import org.s4s.services.util.Roles;
/**
*
......@@ -23,6 +28,9 @@ import org.s4s.services.db.JDBCConnection;
*/
public class ArtikelerstellungsControl extends AbstractDatabaseClass implements ProductDAO {
private static final User user = (User) UI.getCurrent().getSession().getAttribute(Roles.CURRENTUSER);
private final Statement statement = JDBCConnection.getInstance().getStatement();
//DB-Block
Statement st;
String sql_select;
......@@ -33,7 +41,7 @@ public class ArtikelerstellungsControl extends AbstractDatabaseClass implements
ResultSet result;
try {
sql_select = "SELECT * FROM \"ERR\".\"Modul\"";
sql_select = "SELECT * FROM \"ERR\".\"modul\"";
result = JDBCConnection.getInstance().getStatement().executeQuery(sql_select);
while (result.next()) {
......@@ -46,10 +54,25 @@ public class ArtikelerstellungsControl extends AbstractDatabaseClass implements
return moduls;
}
public int getModulByName(String modul) throws DAOException {
int mId = 0;
ResultSet result;
@Override
public List<Product> getProductByTyp(String typ) throws DAOException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
try {
sql_select = "SELECT * FROM \"ERR\".\"modul\""
+ "WHERE name = \'" + modul + "\'";
result = JDBCConnection.getInstance().getStatement().executeQuery(sql_select);
while (result.next()) {
mId = result.getInt("modulid");
}
} catch (SQLException e) {
throw new DAOException(e);
}
return mId;
}
@Override
......@@ -57,13 +80,12 @@ public class ArtikelerstellungsControl extends AbstractDatabaseClass implements
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean addProduct(String name, String beschreibung, Date dVon, Date dBis, double preis, Byte pic, int artikelID, int shopID, boolean gekauft, int modulID, int cat) throws DAOException {
public boolean addProduct(String name, String beschreibung, Date dVon, Date dBis, double preis, Image pic, int shopID, int modulID, int cat) throws DAOException {
boolean done = false;
try {
sql_update = "INSERT INTO \"ERR\".\"artikel\" "
+ "VALUES(\'" + name + "\', \'" + beschreibung + "\', \'" + dVon + "\', \'" + preis + "\', \'" + dBis + "\', \'" + pic + "\', \'" + artikelID + "\', \'" + shopID + "\', \'" + gekauft + "\', \'" + modulID + "\', \'" + cat + "\')";
sql_update = "INSERT INTO \"ERR\".\"artikel\"(name, beschreibung, datum_von, preis, datum_bis, foto, shopid, gekauft, modulid, kategorie) "
+ "VALUES(\'" + name + "\', \'" + beschreibung + "\', \'" + dVon + "\', \'" + preis + "\', \'" + dBis + "\', \'" + pic + "\', \'" + modulID + "\', \'" + cat + "\')";
int exe = JDBCConnection.getInstance().getStatement().executeUpdate(sql_select);
......
package org.s4s.process.control;
/**
*
* @author synot
*/
public class ContactControl {
}
//package org.s4s.process.control;
//
//import com.vaadin.navigator.View;
//import org.s4s.gui.views.TemplateView;
//
///**
// *
// * @author synot
// */
//public class ContactControl extends TemplateView implements View {
//
//}
package org.s4s.process.control;
import com.vaadin.server.VaadinSession;
import com.vaadin.ui.UI;
import java.sql.ResultSet;
import java.sql.SQLException;
......@@ -94,6 +93,23 @@ public class ShopControl extends AbstractDatabaseClass implements ShopDAO {
}
}
@Override
public int getShopIdByUserId(int userId) {
int result = 0;
try {
ResultSet set = executeQuery("SELECT *"
+ "FROM \"ERR\".\"shop\" "
+ "WHERE besitzer = " + user.getUserId() + ";");
if (set.next()) {
result = set.getInt("shopid");
}
} catch (SQLException ex) {
Logger.getLogger(ShopDAO.class.getName()).log(Level.SEVERE, null, ex);
}
return result;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment