Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tubes2 wbd tokopink #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="lib"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="lib/javaws.jar"/>
<classpathentry kind="lib" path="lib/jce.jar"/>
<classpathentry kind="lib" path="lib/jfr.jar"/>
<classpathentry kind="lib" path="lib/jfxrt.jar"/>
<classpathentry kind="lib" path="lib/jsse.jar"/>
<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.27-bin.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
36 changes: 36 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>TubesWBD2alifa</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
12 changes: 12 additions & 0 deletions .settings/.jsdtscope
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="WebContent"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>
7 changes: 7 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
9 changes: 9 additions & 0 deletions .settings/org.eclipse.wst.common.component
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="TubesWBD2alifa">
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/lib"/>
<property name="context-root" value="TubesWBD2alifa"/>
<property name="java-output-path" value="/TubesWBD2alifa/build/classes"/>
</wb-module>
</project-modules>
10 changes: 10 additions & 0 deletions .settings/org.eclipse.wst.common.project.facet.core.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="Apache Tomcat v7.0"/>
<fixed facet="wst.jsdt.web"/>
<fixed facet="jst.web"/>
<fixed facet="java"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>
1 change: 1 addition & 0 deletions .settings/org.eclipse.wst.jsdt.ui.superType.container
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
1 change: 1 addition & 0 deletions .settings/org.eclipse.wst.jsdt.ui.superType.name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Window
1 change: 1 addition & 0 deletions IF3110-Tubes-II
Submodule IF3110-Tubes-II added at 37887e
3 changes: 3 additions & 0 deletions WebContent/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

14 changes: 14 additions & 0 deletions WebContent/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>ServletFileUploadExample</display-name>
<welcome-file-list>
<welcome-file>editbarang.jsp</welcome-file>
</welcome-file-list>
<context-param>
<description>Location to store uploaded file</description>
<param-name>file-upload</param-name>
<param-value>
c:\Users\Alifa\workspace\TubesWBD2alifa\WebContent\images\
</param-value>
</context-param>
</web-app>
80 changes: 80 additions & 0 deletions WebContent/admin.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<%@include file="header.jsp"%>
<html>
<head>
<title>barang </title>
</head>
<body>


<%
/******************* dummy ******************/
String kategori = request.getParameter("kat");

Connection conn=null;
ResultSet result=null;
Statement stmt=null;
ResultSetMetaData rsmd=null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch(Exception e){
out.write("Error!!!!!!" + e);
}
try {
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/tubesweb",
"root","");

Statement statement = conn.createStatement();

String sql1="select * from barang where kategori = '"+kategori+"'";

ResultSet resultSet = statement.executeQuery(sql1);
int i=0;
while (resultSet.next()) {
String path=resultSet.getString("path");
int id=resultSet.getInt("id");
String namabrg= resultSet.getString("namabarang");
int hargab=resultSet.getInt("harga");
if (i%2==0) {
%>

<%
%>
<div id="divresult">
<form id="formresult" name="formregistrasi" >
<img src='<%= path%>' height="100" width="100" > </br>
<span id="resultnama"> <a href="detailProduct.php?id=',$result['id'] ,'"> <b> <%= namabrg%></b> </a> </span>
<span id=resultharga> <%= hargab%> IDR</span> </br>
<input id="tomboldelete" name="tomboldelete" type="submit" value="delete" />
<input id="tomboledit" name="tomboledit" type="submit" value="edit" />
</form>
</div>'
<%} else {
%>
<div id="divresult">
<form id="formresult2" name="formregistrasi" >
<img src='<%= path%>' height="100" width="100" > </br>
<span id="resultnama"> <a href="detailProduct.php?id=',$result['id'] ,'"> <b> <%= namabrg%></b> </a> </span>
<span id=resultharga> <%= hargab%> IDR</span> </br>
<input id="tomboldelete" name="tomboldelete" type="submit" value="delete" />
<input id="tomboledit" name="tomboledit" type="submit" value="edit" />
</form>
</div>
<%
}
i++;

}
}
catch(SQLException e) {
System.out.println("Error!!!!!!" + e);
}
%>

<% if (request.getParameter("tomboledit")!=null) {
%> <script> window.location="editbarang.jsp"; </script><%

} %>

</body>
</html>
145 changes: 145 additions & 0 deletions WebContent/barang.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<%@include file="header.jsp"%>
<html>
<head>
<title>barang </title>
</head>
<body>
<form id="sorting" name="sorting" method="get">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;<select name="sorting" id="sorting">
<option value="">Sorting...</option>
<option value="nama" >Nama</option>
<option value="harga">Harga</option>
</select></form>
<%
/******************* dummy ******************/
String kategori = request.getParameter("kat");
Connection conn=null;
ResultSet result=null;
Statement stmt=null;
ResultSetMetaData rsmd=null;
String id = "0";
String nama = "";
String urut = request.getParameter("sorting");
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch(Exception e){
out.write("Error!!!!!!" + e);
}
try {
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/tubesweb",
"root","");
Statement statement = conn.createStatement();
String sql1="";
if (urut==null) {
sql1="select * from barang where kategori = '"+kategori+"'";
}
else if (urut.compareTo("nama")==0) {
sql1="select * from barang where kategori = '"+kategori+"' order by namabarang";
}else if (urut.compareTo("harga")==0) {
sql1="select * from barang where kategori = '"+kategori+"' order by harga";
}



ResultSet resultSet = statement.executeQuery(sql1);
nama = ses.getAttribute("user").toString();
int i=0;
while (resultSet.next()) {
id = resultSet.getString("id");
if (i%2==0) {
%> <div id="divproduct">
<form id="formproduct1" name="formaddcart" method="post" >
<img src="<%= resultSet.getString("path")%>" width="150" height="150"/><br>
Nama : <a href="detail.jsp?&idb=<%= id %>" ><%= resultSet.getString("namabarang")%></a> <br>
Harga : <%= resultSet.getString("harga")%><br>
Jumlah : <input type="text" id="jumlah" name="jumlah"/>
<input type="submit" value="add to cart" id="addcart" name="addcart"/>
<br><br><br></form></div><%
} else {
%> <div id="divproduct">
<form id="formproduct2" name="formaddcart" method="post" >
<img src="<%= resultSet.getString("path")%>" width="150" height="150"/><br>
Nama : <a href="detail.jsp?&idb=<%= id %>" ><%= resultSet.getString("namabarang")%></a> <br>
Harga : <%= resultSet.getString("harga")%><br>
Jumlah : <input type="text" id="jumlah" name="jumlah"/>
<input type="submit" value="add to cart" id="addcart" name="addcart"/>
<br><br><br></form></div><%

}


i++;


}
}
catch(SQLException e) {
System.out.println("Error!!!!!!" + e);
}

if (request.getParameter("addcart") != null) {
conn=null;
result=null;
stmt=null;
rsmd=null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch(Exception e){
out.write("Error!!!!!!" + e);
}
try {
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/tubesweb",
"root","");

Statement stat2 = conn.createStatement();
String sql2 = "select * from barang where id='"+id+"'";
ResultSet resultSet2 = stat2.executeQuery(sql2);
int stok = 0;
while (resultSet2.next()) {
stok = resultSet2.getInt("stok");
}
int jml = Integer.parseInt(request.getParameter("jumlah"));
if (stok==0) {
%><br> Maaf, stok habis<%
}
else if (jml > stok) {
%><br> Maaf, stok tidak mencukupi, sisa stok : <%= stok %><%
}
else {
int idnext = 0;
Statement stat3 = conn.createStatement();
String sql3 = "select * from cart";
int a = 1;
ResultSet rs = stat3.executeQuery(sql3);
while (rs.next()) {
a++;
}
id = request.getParameter("idba");
String idn = Integer.toString(idnext);
PreparedStatement stat1 = conn.prepareStatement("insert into cart (id,user,idbarang,jumlah,beli)value(?,?,?,?,?)");
stat1.setInt(1, a);
stat1.setString(2, nama);
stat1.setString(3, "7");
stat1.setString(4, request.getParameter("jumlah"));
stat1.setString(5, "0");

stat1.executeUpdate();
%><script>window.location("barang.jsp?&kat='"+kategori+"'");</script><%

}


}
catch(SQLException e) {
System.out.println("Error!!!!!!" + e);
}
}


%>

</body>
</html>
Loading