parent
5e51b2d32e
commit
52697bb1b5
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v9.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="output" path="build/classes"/>
|
||||
</classpath>
|
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>supermarket_management</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<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>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry excluding="**/node_modules/*|**/*.min.js|**/bower_components/*" kind="src" path="src/main/webapp"/>
|
||||
<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>
|
@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/webapp/jsp/ChangePassword.jsp=UTF-8
|
||||
encoding//src/main/webapp/jsp/MainCharts.jsp=UTF-8
|
||||
encoding/<project>=UTF-8
|
@ -0,0 +1,10 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
|
||||
org.eclipse.jdt.core.compiler.compliance=17
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=17
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="supermarket_management">
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<property name="context-root" value="supermarket_management"/>
|
||||
<property name="java-output-path" value="/supermarket_management/build/classes"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<runtime name="Apache Tomcat v9.0"/>
|
||||
<fixed facet="java"/>
|
||||
<fixed facet="wst.jsdt.web"/>
|
||||
<fixed facet="jst.web"/>
|
||||
<installed facet="java" version="17"/>
|
||||
<installed facet="jst.web" version="4.0"/>
|
||||
<installed facet="wst.jsdt.web" version="1.0"/>
|
||||
</faceted-project>
|
@ -0,0 +1 @@
|
||||
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
|
@ -0,0 +1 @@
|
||||
Window
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,48 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import com.supermarket_management.dao.FinancialReportsDao;
|
||||
import com.supermarket_management.entity.FinancialReport;
|
||||
|
||||
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("/AddReportServlet")
|
||||
public class AddReportServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public AddReportServlet() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
|
||||
double salesRevenue = Double.parseDouble(request.getParameter("sales_revenue"));
|
||||
double procurementCost = Double.parseDouble(request.getParameter("procurement_cost"));
|
||||
double empWageCost = Double.parseDouble(request.getParameter("emp_wage_cost"));
|
||||
double rentAndUtilities = Double.parseDouble(request.getParameter("rent_and_utilities"));
|
||||
double netProfit = Double.parseDouble(request.getParameter("net_profit"));
|
||||
Timestamp reportStartDate = Timestamp.valueOf(request.getParameter("report_start_date"));
|
||||
Timestamp reportEndDate = Timestamp.valueOf(request.getParameter("report_end_date"));
|
||||
|
||||
FinancialReport report = new FinancialReport(0, salesRevenue, procurementCost, empWageCost, rentAndUtilities, netProfit, reportStartDate, reportEndDate);
|
||||
FinancialReportsDao dao = new FinancialReportsDao();
|
||||
|
||||
try {
|
||||
if (dao.addReport(report) == 1) {
|
||||
response.getWriter().write("success");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.supermarket_management.dao.EditDao;
|
||||
|
||||
/**
|
||||
* Servlet implementation class ChangePasswordServlet
|
||||
*/
|
||||
@WebServlet("/ChangePasswordServlet")
|
||||
public class ChangePasswordServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public ChangePasswordServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// doGet(request, response);
|
||||
String oldPassword = request.getParameter("oldPassword");
|
||||
String newPassword = request.getParameter("newPassword");
|
||||
String id = request.getParameter("id");
|
||||
|
||||
int id1 = Integer.parseInt(id);
|
||||
EditDao editDao = new EditDao();
|
||||
try {
|
||||
int res = editDao.updataPassword(id1, newPassword);
|
||||
if (res == 1) {
|
||||
HttpSession session = request.getSession();
|
||||
session.setAttribute("password", newPassword);
|
||||
response.getWriter().write("success");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.supermarket_management.dao.DeleteDao;
|
||||
import com.supermarket_management.dao.EditDao;
|
||||
import com.supermarket_management.entity.Member;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
/**
|
||||
* Servlet implementation class EditUserServlet
|
||||
*/
|
||||
@WebServlet("/DeleteMemberServlet")
|
||||
public class DeleteMemberServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public DeleteMemberServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
String id=request.getParameter("member_id");
|
||||
|
||||
int id1 = Integer.parseInt(id);
|
||||
|
||||
Member member = new Member();
|
||||
member.setMemberId(id1);
|
||||
|
||||
DeleteDao deleteDao = new DeleteDao();
|
||||
|
||||
try {
|
||||
if (deleteDao.DeleteMember(member)==1) {
|
||||
response.getWriter().write("success");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.supermarket_management.dao.DeleteDao;
|
||||
import com.supermarket_management.dao.EditDao;
|
||||
import com.supermarket_management.entity.Product;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
/**
|
||||
* Servlet implementation class EditUserServlet
|
||||
*/
|
||||
@WebServlet("/DeleteProductServlet")
|
||||
public class DeleteProductServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public DeleteProductServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
String id=request.getParameter("product_id");;
|
||||
|
||||
System.out.println(id);
|
||||
int id1 = Integer.parseInt(id);
|
||||
|
||||
Product product = new Product();
|
||||
product.setId(id1);
|
||||
|
||||
DeleteDao deleteDao = new DeleteDao();
|
||||
|
||||
try {
|
||||
if (deleteDao.DeleteProduct(product)==1) {
|
||||
response.getWriter().write("success");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.supermarket_management.dao.FinancialReportsDao;
|
||||
|
||||
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("/DeleteReportServlet")
|
||||
public class DeleteReportServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public DeleteReportServlet() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
|
||||
int reportId = Integer.parseInt(request.getParameter("report_id"));
|
||||
FinancialReportsDao dao = new FinancialReportsDao();
|
||||
|
||||
try {
|
||||
if (dao.deleteReport(reportId) == 1) {
|
||||
response.getWriter().write("success");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.supermarket_management.dao.DeleteDao;
|
||||
import com.supermarket_management.dao.EditDao;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
/**
|
||||
* Servlet implementation class EditUserServlet
|
||||
*/
|
||||
@WebServlet("/DeleteSupplierServlet")
|
||||
public class DeleteSupplierServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public DeleteSupplierServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
String id=request.getParameter("supplier_id");
|
||||
System.out.println(id);
|
||||
|
||||
// System.out.println(id);
|
||||
int id1 = Integer.parseInt(id);
|
||||
|
||||
|
||||
DeleteDao deleteDao = new DeleteDao();
|
||||
|
||||
try {
|
||||
if (deleteDao.DeleteSupplier(id1)==1) {
|
||||
response.getWriter().write("success");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.supermarket_management.dao.DeleteDao;
|
||||
import com.supermarket_management.dao.EditDao;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
/**
|
||||
* Servlet implementation class EditUserServlet
|
||||
*/
|
||||
@WebServlet("/DeleteUserServlet")
|
||||
public class DeleteUserServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public DeleteUserServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
String name=request.getParameter("emp_name");
|
||||
String id=request.getParameter("emp_id");
|
||||
String gender=request.getParameter("emp_gender");
|
||||
String age=request.getParameter("emp_age");
|
||||
String contactinfo=request.getParameter("emp_contactinfo");
|
||||
String position=request.getParameter("emp_position");
|
||||
String password=request.getParameter("password");
|
||||
|
||||
System.out.println(id);
|
||||
int id1 = Integer.parseInt(id);
|
||||
int age1 = Integer.parseInt(age);
|
||||
|
||||
User user = new User();
|
||||
user.setName(name);
|
||||
user.setID(id1);
|
||||
user.setGender(gender);
|
||||
user.setPhone(contactinfo);
|
||||
user.setRole(position);
|
||||
System.out.println(user.getRole());
|
||||
user.setAge(age1);
|
||||
user.setPassword(password);
|
||||
|
||||
DeleteDao deleteDao = new DeleteDao();
|
||||
|
||||
try {
|
||||
if (deleteDao.DeleteUser(user)==1) {
|
||||
response.getWriter().write("success");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.supermarket_management.dao.EditDao;
|
||||
import com.supermarket_management.entity.Member;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
/**
|
||||
* Servlet implementation class EditUserServlet
|
||||
*/
|
||||
@WebServlet("/EditMemberServlet")
|
||||
public class EditMemberServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public EditMemberServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
String name=request.getParameter("member_name");
|
||||
String id=request.getParameter("member_id");
|
||||
String gender=request.getParameter("member_gender");
|
||||
String age=request.getParameter("member_age");
|
||||
String contactinfo=request.getParameter("member_contactinfo");
|
||||
String level=request.getParameter("member_level");
|
||||
String points=request.getParameter("points");
|
||||
|
||||
int id1 = Integer.parseInt(id);
|
||||
int age1 = Integer.parseInt(age);
|
||||
int p1 = Integer.parseInt(points);
|
||||
int l1 = Integer.parseInt(level);
|
||||
|
||||
Member member = new Member();
|
||||
member.setMemberName(name);
|
||||
member.setMemberId(id1);
|
||||
member.setMemberGender(gender);
|
||||
member.setMemberContactInfo(contactinfo);
|
||||
member.setMemberLevel(l1);
|
||||
member.setMemberAge(age1);
|
||||
member.setPoints(p1);
|
||||
|
||||
EditDao editDao = new EditDao();
|
||||
|
||||
try {
|
||||
if (editDao.EditMember(member)==1) {
|
||||
response.getWriter().write("success");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.supermarket_management.dao.EditDao;
|
||||
import com.supermarket_management.entity.Product;
|
||||
|
||||
/**
|
||||
* Servlet implementation class EditProductServlet
|
||||
*/
|
||||
@WebServlet("/EditProductServlet")
|
||||
public class EditProductServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public EditProductServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// doGet(request, response);
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
String name=request.getParameter("product_name");
|
||||
String id=request.getParameter("product_id");
|
||||
String brand=request.getParameter("brand");
|
||||
String category=request.getParameter("category_id");
|
||||
String purchase_price=request.getParameter("purchase_price");
|
||||
String selling_price=request.getParameter("selling_price");
|
||||
String member_price=request.getParameter("member_price");
|
||||
String stock_quantity=request.getParameter("stock_quantity");
|
||||
|
||||
int categoryid = Integer.parseInt(category);
|
||||
int id1 = Integer.parseInt(id);
|
||||
float pprice = Float.parseFloat(purchase_price);
|
||||
float sprice = Float.parseFloat(selling_price);
|
||||
float mprice = Float.parseFloat(member_price);
|
||||
float stock = Float.parseFloat(stock_quantity);
|
||||
|
||||
Product product = new Product();
|
||||
product.setName(name);
|
||||
product.setId(id1);
|
||||
product.setCategoryid(categoryid);
|
||||
product.setPurchase_price(pprice);
|
||||
product.setSelling_price(sprice);
|
||||
product.setMember_price(mprice);
|
||||
product.setStock_quantity(stock);
|
||||
|
||||
EditDao editDao = new EditDao();
|
||||
|
||||
try {
|
||||
if (editDao.EditProduct(product)==1) {
|
||||
response.getWriter().write("success");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.supermarket_management.dao.EditDao;
|
||||
import com.supermarket_management.entity.Supplier;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
/**
|
||||
* Servlet implementation class EditUserServlet
|
||||
*/
|
||||
@WebServlet("/EditSupplierServlet")
|
||||
public class EditSupplierServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public EditSupplierServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
String id=request.getParameter("supplier_id");
|
||||
String name=request.getParameter("supplier_name");
|
||||
String product=request.getParameter("supplier_product");
|
||||
String productId=request.getParameter("supplier_productid");
|
||||
String person=request.getParameter("supplier_person");
|
||||
String contactinfo=request.getParameter("supplier_contactinfo");
|
||||
|
||||
int id1 = Integer.parseInt(id);
|
||||
int pid = Integer.parseInt(productId);
|
||||
|
||||
Supplier supplier = new Supplier();
|
||||
supplier.setSupplierId(id1);
|
||||
supplier.setSupplierName(name);
|
||||
supplier.setProduct(product);
|
||||
supplier.setSupplierContactPerson(person);
|
||||
supplier.setSupplierContactInfo(contactinfo);
|
||||
supplier.setSuppliedProduct(pid);
|
||||
|
||||
|
||||
EditDao editDao = new EditDao();
|
||||
|
||||
try {
|
||||
if (editDao.EditSupplier(supplier)==1) {
|
||||
response.getWriter().write("success");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.supermarket_management.dao.EditDao;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
/**
|
||||
* Servlet implementation class EditUserServlet
|
||||
*/
|
||||
@WebServlet("/EditUserServlet")
|
||||
public class EditUserServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public EditUserServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
String name=request.getParameter("emp_name");
|
||||
String id=request.getParameter("emp_id");
|
||||
String gender=request.getParameter("emp_gender");
|
||||
String age=request.getParameter("emp_age");
|
||||
String contactinfo=request.getParameter("emp_contactinfo");
|
||||
String position=request.getParameter("emp_position");
|
||||
String password=request.getParameter("password");
|
||||
|
||||
int id1 = Integer.parseInt(id);
|
||||
int age1 = Integer.parseInt(age);
|
||||
|
||||
User user = new User();
|
||||
user.setName(name);
|
||||
user.setID(id1);
|
||||
user.setGender(gender);
|
||||
user.setPhone(contactinfo);
|
||||
user.setRole(position);
|
||||
System.out.println(user.getRole());
|
||||
user.setAge(age1);
|
||||
user.setPassword(password);
|
||||
|
||||
EditDao editDao = new EditDao();
|
||||
|
||||
try {
|
||||
if (editDao.EditUser(user)==1) {
|
||||
response.getWriter().write("success");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.supermarket_management.dao.CategoryDao;
|
||||
import com.supermarket_management.dao.FinancialReportsDao;
|
||||
import com.supermarket_management.entity.FinancialReport;
|
||||
import com.supermarket_management.entity.ProductCategory;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
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("/GetAllCategoryServlet")
|
||||
public class GetAllCategoryServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public GetAllCategoryServlet() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
|
||||
CategoryDao categoryDao = new CategoryDao();
|
||||
List<ProductCategory> categories = null;
|
||||
|
||||
try {
|
||||
categories = categoryDao.getAllCategoty();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", 0);
|
||||
result.put("msg", "success");
|
||||
result.put("data", categories);
|
||||
|
||||
String json = JSON.toJSONString(result);
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write(json);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doGet(request, response);
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.supermarket_management.dao.FinancialReportsDao;
|
||||
import com.supermarket_management.entity.FinancialReport;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
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("/GetAllReportsServlet")
|
||||
public class GetAllReportsServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public GetAllReportsServlet() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
|
||||
FinancialReportsDao dao = new FinancialReportsDao();
|
||||
List<FinancialReport> reports = null;
|
||||
|
||||
try {
|
||||
reports = dao.getAllReports();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (FinancialReport f : reports) {
|
||||
Date start = f.getReportStartDate();
|
||||
if (start!= null) {
|
||||
String StartTime = sdf.format(start);
|
||||
f.setStartTime(StartTime);
|
||||
}
|
||||
Date end = f.getReportEndDate();
|
||||
if (end!= null) {
|
||||
String EndTime = sdf.format(end);
|
||||
f.setEndTime(EndTime);
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", 0);
|
||||
result.put("msg", "success");
|
||||
result.put("data", reports);
|
||||
|
||||
String json = JSON.toJSONString(result);
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write(json);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doGet(request, response);
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.supermarket_management.dao.userDao;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
/**
|
||||
* Servlet implementation class LoginServlet
|
||||
*/
|
||||
@WebServlet("/LoginServlet")
|
||||
public class LoginServlet extends HttpServlet {
|
||||
userDao userDao = new userDao();
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public LoginServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
String name = request.getParameter("username");
|
||||
String password = request.getParameter("password");
|
||||
String role = request.getParameter("role");
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
// System.out.println();
|
||||
User user = new User();
|
||||
try {
|
||||
user = userDao.selectAllUsers(name, password,role);
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (user!=null) {
|
||||
if (user.getRole().equals("管理员")) {
|
||||
// response.sendRedirect(request.getContextPath()+"/jsp/AllUsers.jsp");
|
||||
|
||||
session.setAttribute("username", name);
|
||||
session.setAttribute("id", user.getID());
|
||||
session.setAttribute("gender", user.getGender());
|
||||
session.setAttribute("age", user.getAge());
|
||||
session.setAttribute("phone", user.getPhone());
|
||||
session.setAttribute("role", role);
|
||||
session.setAttribute("password", password);
|
||||
response.getWriter().write("success");
|
||||
}
|
||||
else if (user.getRole().equals("售货员")) {
|
||||
session.setAttribute("username", name);
|
||||
session.setAttribute("gender", user.getGender());
|
||||
session.setAttribute("age", user.getAge());
|
||||
session.setAttribute("phone", user.getPhone());
|
||||
session.setAttribute("role", role);
|
||||
session.setAttribute("password", password);
|
||||
response.getWriter().write("success");
|
||||
}
|
||||
else {
|
||||
session.setAttribute("username", name);
|
||||
session.setAttribute("gender", user.getGender());
|
||||
session.setAttribute("age", user.getAge());
|
||||
session.setAttribute("phone", user.getPhone());
|
||||
session.setAttribute("role", role);
|
||||
session.setAttribute("password", password);
|
||||
response.getWriter().write("success");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* Servlet implementation class LogoutServlet
|
||||
*/
|
||||
@WebServlet("/LogoutServlet")
|
||||
public class LogoutServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public LogoutServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session!= null) {
|
||||
session.invalidate();
|
||||
}
|
||||
response.setContentType("application/json");
|
||||
response.getWriter().write("{\"success\":true}");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
doGet(request, response);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.supermarket_management.dao.ReportDao;
|
||||
import com.supermarket_management.dao.userDao;
|
||||
import com.supermarket_management.entity.FinancialReport;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
/**
|
||||
* Servlet implementation class ProfitServlet
|
||||
*/
|
||||
@WebServlet("/ProfitServlet")
|
||||
public class ProfitServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public ProfitServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
ReportDao reportDao = new ReportDao();
|
||||
List<FinancialReport> reports = null;
|
||||
try {
|
||||
reports = reportDao.getAllNetProfit();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", 0);
|
||||
result.put("msg", "success");
|
||||
result.put("data", reports);
|
||||
String json = JSON.toJSONString(result);
|
||||
// System.out.println(json+"\n");
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write(json);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import com.supermarket_management.dao.FinancialReportsDao;
|
||||
import com.supermarket_management.entity.FinancialReport;
|
||||
|
||||
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("/UpdateReportServlet")
|
||||
public class UpdateReportServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public UpdateReportServlet() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
|
||||
int reportId = Integer.parseInt(request.getParameter("report_id"));
|
||||
double salesRevenue =Double.parseDouble(request.getParameter("sales_revenue"));
|
||||
double procurementCost = Double.parseDouble(request.getParameter("procurement_cost"));
|
||||
double empWageCost = Double.parseDouble(request.getParameter("emp_wage_cost"));
|
||||
double rentAndUtilities = Double.parseDouble(request.getParameter("rent_and_utilities"));
|
||||
double netProfit = Double.parseDouble(request.getParameter("net_profit"));
|
||||
Timestamp reportStartDate = Timestamp.valueOf(request.getParameter("report_start_date"));
|
||||
Timestamp reportEndDate = Timestamp.valueOf(request.getParameter("report_end_date"));
|
||||
|
||||
FinancialReport report = new FinancialReport(reportId, salesRevenue, procurementCost, empWageCost, rentAndUtilities, netProfit, reportStartDate, reportEndDate);
|
||||
FinancialReportsDao dao = new FinancialReportsDao();
|
||||
|
||||
try {
|
||||
if (dao.updateReport(report) == 1) {
|
||||
response.getWriter().write("success");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.supermarket_management.dao.EditDao;
|
||||
import com.supermarket_management.dao.addDao;
|
||||
import com.supermarket_management.entity.Member;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
/**
|
||||
* Servlet implementation class EditUserServlet
|
||||
*/
|
||||
@WebServlet("/addMemberServlet")
|
||||
public class addMemberServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public addMemberServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
String name=request.getParameter("member_name");
|
||||
String gender=request.getParameter("member_gender");
|
||||
String age=request.getParameter("member_age");
|
||||
String contactinfo=request.getParameter("member_contactinfo");
|
||||
String level=request.getParameter("member_level");
|
||||
String points=request.getParameter("points");
|
||||
|
||||
int age1 = Integer.parseInt(age);
|
||||
|
||||
int level1 = level==""?0:Integer.parseInt(level);
|
||||
int point = points==""?0:Integer.parseInt(points);
|
||||
|
||||
Member member = new Member();
|
||||
member.setMemberAge(age1);
|
||||
member.setMemberName(name);
|
||||
member.setMemberGender(gender);
|
||||
member.setMemberContactInfo(contactinfo);
|
||||
member.setMemberLevel(level1);
|
||||
member.setPoints(point);
|
||||
|
||||
|
||||
addDao addDao = new addDao();
|
||||
|
||||
try {
|
||||
if (addDao.addMember(member)==1) {
|
||||
response.getWriter().write("success");
|
||||
response.sendRedirect("/supermarket_management/jsp/AllMembers.jsp");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.supermarket_management.dao.EditDao;
|
||||
import com.supermarket_management.dao.addDao;
|
||||
import com.supermarket_management.entity.Product;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
/**
|
||||
* Servlet implementation class EditUserServlet
|
||||
*/
|
||||
@WebServlet("/addProductServlet")
|
||||
public class addProductServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public addProductServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
String name=request.getParameter("product_name");
|
||||
String category=request.getParameter("category_id");
|
||||
String brand=request.getParameter("brand");
|
||||
String purchase_price=request.getParameter("purchase_price");
|
||||
String selling_price=request.getParameter("selling_price");
|
||||
String member_price=request.getParameter("member_price");
|
||||
String stock=request.getParameter("stock_quantity");
|
||||
|
||||
int category_id = Integer.parseInt(category);
|
||||
float pprice = Float.parseFloat(purchase_price);
|
||||
float sprice = Float.parseFloat(selling_price);
|
||||
float mprice = Float.parseFloat(member_price);
|
||||
float stock1 = Float.parseFloat(stock);
|
||||
|
||||
Product product = new Product();
|
||||
product.setName(name);
|
||||
product.setCategoryid(category_id);
|
||||
product.setPurchase_price(pprice);
|
||||
product.setSelling_price(sprice);
|
||||
product.setMember_price(mprice);
|
||||
product.setStock_quantity(stock1);
|
||||
product.setBrand(brand);
|
||||
|
||||
addDao addDao = new addDao();
|
||||
|
||||
try {
|
||||
if (addDao.addProduct(product)==1) {
|
||||
response.getWriter().write("success");
|
||||
response.sendRedirect("/supermarket_management/jsp/AllProducts.jsp");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.supermarket_management.dao.EditDao;
|
||||
import com.supermarket_management.dao.SupplierDao;
|
||||
import com.supermarket_management.dao.addDao;
|
||||
import com.supermarket_management.entity.Member;
|
||||
import com.supermarket_management.entity.Product;
|
||||
import com.supermarket_management.entity.Supplier;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
/**
|
||||
* Servlet implementation class EditUserServlet
|
||||
*/
|
||||
@WebServlet("/addSupplierServlet")
|
||||
public class addSupplierServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public addSupplierServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
String name=request.getParameter("supplier_name");
|
||||
String person=request.getParameter("supplier_contact_person_name");
|
||||
String phone=request.getParameter("supplier_contact_info");
|
||||
String product=request.getParameter("supplied_product");
|
||||
|
||||
int pid = Integer.parseInt(product);
|
||||
|
||||
Supplier supplier = new Supplier();
|
||||
supplier.setSuppliedProduct(pid);
|
||||
supplier.setSupplierName(name);
|
||||
supplier.setSupplierContactPerson(person);
|
||||
supplier.setSupplierContactInfo(phone);
|
||||
|
||||
SupplierDao supplierDao = new SupplierDao();
|
||||
|
||||
try {
|
||||
if (supplierDao.addSupplier(supplier)) {
|
||||
response.getWriter().write("success");
|
||||
response.sendRedirect("/supermarket_management/jsp/AllSupplier.jsp");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.supermarket_management.dao.EditDao;
|
||||
import com.supermarket_management.dao.addDao;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
/**
|
||||
* Servlet implementation class EditUserServlet
|
||||
*/
|
||||
@WebServlet("/addUserServlet")
|
||||
public class addUserServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public addUserServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
String name=request.getParameter("emp_name");
|
||||
String gender=request.getParameter("emp_gender");
|
||||
String age=request.getParameter("emp_age");
|
||||
String contactinfo=request.getParameter("emp_contactinfo");
|
||||
String position=request.getParameter("emp_position");
|
||||
String password=request.getParameter("password");
|
||||
|
||||
int age1 = Integer.parseInt(age);
|
||||
|
||||
User user = new User();
|
||||
user.setName(name);
|
||||
user.setGender(gender);
|
||||
user.setPhone(contactinfo);
|
||||
user.setRole(position);
|
||||
user.setAge(age1);
|
||||
user.setPassword(password);
|
||||
|
||||
addDao addDao = new addDao();
|
||||
|
||||
try {
|
||||
if (addDao.addUser(user)==1) {
|
||||
response.getWriter().write("success");
|
||||
response.sendRedirect("/supermarket_management/jsp/AllUsers.jsp");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.supermarket_management.dao.MemberDao;
|
||||
import com.supermarket_management.dao.ProductDao;
|
||||
import com.supermarket_management.entity.Member;
|
||||
import com.supermarket_management.entity.Product;
|
||||
|
||||
/**
|
||||
* Servlet implementation class getAllMembersServlet
|
||||
*/
|
||||
@WebServlet("/getAllMembersServlet")
|
||||
public class getAllMembersServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public getAllMembersServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// doGet(request, response);
|
||||
MemberDao memberDao = new MemberDao();
|
||||
List<Member> members = null;
|
||||
try {
|
||||
members = memberDao.getAllMembers();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", 0);
|
||||
result.put("msg", "success");
|
||||
result.put("data", members);
|
||||
String json = JSON.toJSONString(result);
|
||||
// System.out.println(json+"\n");
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write(json);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.supermarket_management.dao.ProductDao;
|
||||
import com.supermarket_management.entity.Product;
|
||||
|
||||
/**
|
||||
* Servlet implementation class getAllProductsServlet
|
||||
*/
|
||||
@WebServlet("/getAllProductsServlet")
|
||||
public class getAllProductsServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public getAllProductsServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
ProductDao productDao = new ProductDao();
|
||||
List<Product> products = null;
|
||||
try {
|
||||
products = productDao.getAllproducts();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", 0);
|
||||
result.put("msg", "success");
|
||||
result.put("data", products);
|
||||
String json = JSON.toJSONString(result);
|
||||
// System.out.println(json+"\n");
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write(json);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
doGet(request, response);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.supermarket_management.dao.PurchaseOrderDao;
|
||||
import com.supermarket_management.entity.PurchaseOrder;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Servlet implementation class getAllPurchaseOrderServlet
|
||||
*/
|
||||
@WebServlet("/getAllPurchaseOrderServlet")
|
||||
public class getAllPurchaseOrderServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public getAllPurchaseOrderServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
PurchaseOrderDao purchaseorderdao = new PurchaseOrderDao();
|
||||
List<PurchaseOrder> purchaseorders = null;
|
||||
try {
|
||||
purchaseorders = purchaseorderdao.getAllPurchaseOrder();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (PurchaseOrder purchaseorder : purchaseorders) {
|
||||
Date orderdate = purchaseorder.getOrderDate();
|
||||
if (orderdate!= null) {
|
||||
String formattedOrderDate = sdf.format(orderdate);
|
||||
purchaseorder.setFormattedOrderDate(formattedOrderDate);
|
||||
}
|
||||
}
|
||||
for (PurchaseOrder purchaseorder : purchaseorders) {
|
||||
Date EstimatedDeliveryDate = purchaseorder.getEstimatedDeliveryDate();
|
||||
if (EstimatedDeliveryDate!= null) {
|
||||
String formattedEstimatedDeliveryDate = sdf.format(EstimatedDeliveryDate);
|
||||
purchaseorder.setFormattedEstimatedDeliveryDate(formattedEstimatedDeliveryDate);
|
||||
}
|
||||
}
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", 0);
|
||||
result.put("msg", "success");
|
||||
result.put("data", purchaseorders);
|
||||
String json = JSON.toJSONString(result);
|
||||
// System.out.println(json+"\n");
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write(json);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
doGet(request, response);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.supermarket_management.dao.SalePromotionDao;
|
||||
import com.supermarket_management.entity.SalePromotion;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Servlet implementation class getAllSalePromotionServlet
|
||||
*/
|
||||
@WebServlet("/getAllSalePromotionServlet")
|
||||
public class getAllSalePromotionServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public getAllSalePromotionServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
SalePromotionDao salepromotiondao = new SalePromotionDao();
|
||||
List<SalePromotion> salepromotion = null;
|
||||
try {
|
||||
salepromotion = salepromotiondao.getAllSalePromotion();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (SalePromotion salepromotion1 : salepromotion) {
|
||||
Date StartTime = salepromotion1.getStartTime();
|
||||
if (StartTime!= null) {
|
||||
String formattedStartTime = sdf.format(StartTime);
|
||||
salepromotion1.setFormattedStartTime(formattedStartTime);
|
||||
}
|
||||
Date EndTime = salepromotion1.getEndTime();
|
||||
if (EndTime!= null) {
|
||||
String formattedEndTime = sdf.format(EndTime);
|
||||
salepromotion1.setFormattedEndTime(formattedEndTime);
|
||||
}
|
||||
}
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", 0);
|
||||
result.put("msg", "success");
|
||||
result.put("data", salepromotion);
|
||||
String json = JSON.toJSONString(result);
|
||||
// System.out.println(json+"\n");
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write(json);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
doGet(request, response);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.supermarket_management.dao.SalesDao;
|
||||
import com.supermarket_management.entity.Sales;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Servlet implementation class getAllUserServlet
|
||||
*/
|
||||
@WebServlet("/getAllSalesServlet")
|
||||
public class getAllSalesServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public getAllSalesServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
SalesDao salesdao = new SalesDao();
|
||||
List<Sales> sales = null;
|
||||
try {
|
||||
sales = salesdao.getAllSales();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (Sales sale : sales) {
|
||||
Date saleDate = sale.getSaleTime();
|
||||
if (saleDate!= null) {
|
||||
String formattedsaleTime = sdf.format(saleDate);
|
||||
sale.setFormattedsaleTime(formattedsaleTime);
|
||||
}
|
||||
}
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", 0);
|
||||
result.put("msg", "success");
|
||||
result.put("data", sales);
|
||||
String json = JSON.toJSONString(result);
|
||||
// System.out.println(json+"\n");
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write(json);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
doGet(request, response);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.supermarket_management.dao.MemberDao;
|
||||
import com.supermarket_management.dao.ProductDao;
|
||||
import com.supermarket_management.dao.SupplierDao;
|
||||
import com.supermarket_management.entity.Member;
|
||||
import com.supermarket_management.entity.Product;
|
||||
import com.supermarket_management.entity.Supplier;
|
||||
|
||||
/**
|
||||
* Servlet implementation class getAllMembersServlet
|
||||
*/
|
||||
@WebServlet("/getAllSuppliersServlet")
|
||||
public class getAllSuppliersServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public getAllSuppliersServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// doGet(request, response);
|
||||
SupplierDao supplierDao = new SupplierDao();
|
||||
List<Supplier> suppliers = null;
|
||||
try {
|
||||
suppliers = supplierDao.getAllSuppliers();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", 0);
|
||||
result.put("msg", "success");
|
||||
result.put("data", suppliers);
|
||||
String json = JSON.toJSONString(result);
|
||||
// System.out.println(json+"\n");
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write(json);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.supermarket_management.dao.SearchDao;
|
||||
import com.supermarket_management.dao.userDao;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Servlet implementation class getAllUserServlet
|
||||
*/
|
||||
@WebServlet("/getAllUserServlet")
|
||||
public class getAllUserServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public getAllUserServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
|
||||
userDao userDao = new userDao();
|
||||
List<User> users = null;
|
||||
try {
|
||||
users = userDao.getAllUsers();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
for (User user : users) {
|
||||
Date hireDate = user.getHireDate();
|
||||
if (hireDate!= null) {
|
||||
String formattedHireDate = sdf.format(hireDate);
|
||||
user.setFormattedHireDate(formattedHireDate);
|
||||
}
|
||||
}
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", 0);
|
||||
result.put("msg", "success");
|
||||
result.put("data", users);
|
||||
String json = JSON.toJSONString(result);
|
||||
// System.out.println(json+"\n");
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write(json);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
doGet(request, response);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.Console;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.supermarket_management.dao.SumDataDao;
|
||||
import com.supermarket_management.dao.SupplierDao;
|
||||
import com.supermarket_management.entity.SumData;
|
||||
import com.supermarket_management.entity.Supplier;
|
||||
|
||||
/**
|
||||
* Servlet implementation class getSumData
|
||||
*/
|
||||
@WebServlet("/getSumData")
|
||||
public class getSumDataServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public getSumDataServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
|
||||
* response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
|
||||
* response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
SumDataDao sumDataDao = new SumDataDao();
|
||||
int ucnt = 0;
|
||||
int mcnt = 0;
|
||||
int pcnt = 0;
|
||||
try {
|
||||
ucnt = sumDataDao.getEmployeeSum();
|
||||
mcnt = sumDataDao.getMemberSum();
|
||||
pcnt = sumDataDao.getProdutSum();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
// System.out.println("ucnt:"+ucnt);
|
||||
SumData sumData = new SumData(ucnt, mcnt, pcnt);
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", 0);
|
||||
result.put("msg", "success");
|
||||
result.put("data", sumData);
|
||||
String json = JSON.toJSONString(result);
|
||||
// System.out.println(json+"\n");
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write(json);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package com.supermarket_management.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.supermarket_management.dao.SearchDao;
|
||||
import com.supermarket_management.dao.userDao;
|
||||
import com.supermarket_management.entity.Member;
|
||||
import com.supermarket_management.entity.User;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Servlet implementation class getAllUserServlet
|
||||
*/
|
||||
@WebServlet("/searchMemberServlet")
|
||||
public class searchMemberServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public searchMemberServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
// response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
request.setCharacterEncoding("utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
String name=request.getParameter("member_name");
|
||||
SearchDao searchDao = new SearchDao();
|
||||
List<Member> members = null;
|
||||
try {
|
||||
members = searchDao.selectAllMmebers(name);
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", 0);
|
||||
result.put("msg", "success");
|
||||
result.put("data", members);
|
||||
String json = JSON.toJSONString(result);
|
||||
// System.out.println(json+"\n");
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write(json);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
doGet(request, response);
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue