-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80c74ff
commit b2526d7
Showing
7 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package vaccination.inventory; | ||
|
||
public class inventory { | ||
|
||
private String batch_no; | ||
private String vaccine_name; | ||
private String receive_date; | ||
private String country; | ||
private String expire_date; | ||
private int quantity; | ||
|
||
public inventory(String batch_no, String vaccine_name, String receive_date, String country, String expire_date, int quantity) { | ||
this.batch_no = batch_no; | ||
this.vaccine_name = vaccine_name; | ||
this.receive_date = receive_date; | ||
this.country = country; | ||
this.expire_date = expire_date; | ||
this.quantity = quantity; | ||
} | ||
|
||
|
||
public String getBatch_no() { | ||
return batch_no; | ||
} | ||
public String getVaccine_name() { | ||
return vaccine_name; | ||
} | ||
public String getReceive_date() { | ||
return receive_date; | ||
} | ||
public String getCountry() { | ||
return country; | ||
} | ||
public String getExpire_date() { | ||
return expire_date; | ||
} | ||
public int getQuantity() { | ||
return quantity; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package vaccination.inventory; | ||
|
||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
import java.sql.Statement; | ||
|
||
public class inventoryDBUtil { | ||
|
||
private static boolean isSuccess; | ||
private static Connection con = null; | ||
private static Statement stmt = null; | ||
private static ResultSet rs = null; | ||
|
||
public static boolean insertvaccine(String batch_no, String vaccine_name, String receive_date, String country, String expire_date, int quantity) { | ||
|
||
boolean isSuccess = false; | ||
|
||
try { | ||
//database call | ||
con = dbconnect.getConnection(); | ||
stmt = con.createStatement(); | ||
// double unitPrice=0; | ||
|
||
// //get the unit price from the item list | ||
// String sql1 = "SELECT unit FROM inventory_item WHERE name = '"+name+"' limit 1"; | ||
// ResultSet unit1 = stmt.executeQuery(sql1); | ||
// if(unit1.next()) | ||
// unitPrice = unit1.getDouble(1); | ||
// double total1 = unitPrice*quantity; | ||
|
||
String sql = "insert into inventory_all values ('"+batch_no+"','"+vaccine_name+"','"+receive_date+"','"+country+"','"+expire_date+"','"+quantity+"')"; | ||
int rs = stmt.executeUpdate(sql); | ||
|
||
if(rs > 0) { | ||
isSuccess = true; | ||
} else { | ||
isSuccess = false; | ||
} | ||
|
||
} | ||
catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
return isSuccess; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package vaccination.inventory; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.servlet.RequestDispatcher; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
|
||
@WebServlet("/inventory_insert") | ||
public class inventory_insert extends HttpServlet { | ||
private static final long serialVersionUID = 1L; | ||
|
||
|
||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
|
||
|
||
String batch_no = request.getParameter("batch_no"); | ||
String vaccine_name = request.getParameter("vaccine_name"); | ||
String receive_date = request.getParameter("receive_date"); | ||
String country = request.getParameter("country"); | ||
String expire_date = request.getParameter("expire_date"); | ||
int quantity = Integer.parseInt(request.getParameter("quantity")); | ||
|
||
|
||
boolean isTrue; | ||
|
||
|
||
isTrue = inventoryDBUtil.insertvaccine(batch_no, vaccine_name, receive_date, country, expire_date, quantity); | ||
|
||
|
||
if(isTrue == true) { | ||
RequestDispatcher dis = request.getRequestDispatcher("inventory_view.jsp"); | ||
dis.forward(request, response); | ||
} else { | ||
RequestDispatcher dis2 = request.getRequestDispatcher("inventory_unsuccess.jsp"); | ||
dis2.forward(request, response); | ||
} | ||
|
||
} | ||
|
||
} |