基于javaweb+jsp的药店医药信息管理系统(JavaWeb MySQL JSP Bootstrap Servlet SSM SpringBoot)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
技术框架
JavaWeb JavaBean JSP MVC MySQL Tomcat JavaScript Bootstrap.
基础JSP+Servlet或JSP+SSM(Spring、SpringMVC、MyBatis)框架或JSP+SSM+Maven(pom.xml)框架或SpringBoot…均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
登录、注册、退出、用户模块、公告模块、员工模块、进货模块、药品模块的增删改查管理
public static String decode(javax.servlet.http.HttpServletRequest request, String parameterName) {
String str;
if ((str = request.getParameter(parameterName)) == null) {
return null;
}
try {
if (isMessyCode(str)) {
str = new String(str.getBytes("ISO-8859-1"), "UTF-8");
}
if (isMessyCode(str)) {
str = new String(str.getBytes("GB2312"), "UTF-8");
}
if (isMessyCode(str)) {
str = new String(str.getBytes("GBK"), "UTF-8");
}
if (isMessyCode(str)) {
str = new String(str.getBytes("UTF-8"), "ISO-8859-1");
}
if (isMessyCode(str)) {
str = new String(str.getBytes("GB2312"), "ISO-8859-1");
*/
@RequestMapping("incomeList")
public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
this.redirectList(request, response);
}
/**
* 跳转到列表页面
*
* @param request
* @param response
*/
private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
//查询列和关键字
String searchColumn = Util.decode(request, "searchColumn");
String keyword = Util.decode(request, "keyword");
Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
params.put("searchColumn", searchColumn);//要查询的列
params.put("keyword", keyword);//查询的关键字
<button type="submit" class="btn btn-pill btn-warning btn-sm">提交</button> <button type="button" class="btn btn-pill btn-success btn-sm" onclick="javascript:history.back(-1);">取消</button>
</form>
</div>
</body>
<script type="text/javascript">
//提交之前进行检查,如果return false,则不允许提交
function check() {
//根据ID获取值
if (document.getElementById("employeeName").value.trim().length == 0) {
alert("姓名不能为空!");
return false;
}
if (document.getElementById("employeeNo").value.trim().length == 0) {
alert("工号不能为空!");
return false;
}
if (document.getElementById("employeeAge").value.trim().length == 0) {
alert("年龄不能为空!");
<if test ='medicineText != null'>#{medicineText}</if>
</trim>
</insert>
<!--批量删除-->
<delete id="doRemoveBatch" parameterType="java.util.Collection">
DELETE FROM `t_medicine` WHERE `id` IN
<foreach collection="list" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</delete>
<!--修改-->
<update id="doUpdate" parameterType="com.demo.vo.Medicine">
UPDATE `t_medicine`
<set>
<if test ='id != null'>`id` = #{id},</if>
<if test ='medicineName != null'>`medicine_name` = #{medicineName},</if>
<if test ='medicineNo != null'>`medicine_no` = #{medicineNo},</if>
*/
public class Medicine implements Serializable {
private Long id;//主键
private String medicineName;//药品名称
private String medicineNo;//编号
private String medicinePrice;//价格
private String medicineProducedate;//生产日期
private String medicineAvliabledate;//保质期
private String medicineProducer;//生产商
private String medicineText;//详细说明
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getMedicineName() {
return medicineName;
}
public void setMedicineName(String medicineName) {
this.medicineName = medicineName;
}
public String getMedicineNo() {
if (document.getElementById("incomeName").value.trim().length == 0) {
alert("药品名称不能为空!");
return false;
}
if (document.getElementById("incomeCount").value.trim().length == 0) {
alert("数量不能为空!");
return false;
}
if (document.getElementById("incomeUnit").value.trim().length == 0) {
alert("计量单位不能为空!");
return false;
}
if (document.getElementById("incomeInprice").value.trim().length == 0) {
alert("进货单价不能为空!");
return false;
}
if (document.getElementById("incomeIntime").value.trim().length == 0) {
alert("进货时间不能为空!");
return false;
}
return true;
* @param request
* @throws IOException
*/
@RequestMapping("medicineEdit")
public void edit(HttpServletResponse response, HttpServletRequest request) throws IOException {
Medicine vo = new Medicine();
vo.setId(Long.valueOf(Util.decode(request, "id")));
vo.setMedicineName(Util.decode(request, "medicineName"));
vo.setMedicineNo(Util.decode(request, "medicineNo"));
vo.setMedicinePrice(Util.decode(request, "medicinePrice"));
vo.setMedicineProducedate(Util.decode(request, "medicineProducedate"));
vo.setMedicineAvliabledate(Util.decode(request, "medicineAvliabledate"));
vo.setMedicineProducer(Util.decode(request, "medicineProducer"));
vo.setMedicineText(Util.decode(request, "medicineText"));
medicineService.update(vo);
this.redirectList(request, response);
}
/**
String codeChars = "0123456789";// 图形验证码的字符集合,系统将随机从这个字符串中选择一些字符作为验证码
// 获得验证码集合的长度
int charsLength = codeChars.length();
// 下面三条记录是关闭客户端浏览器的缓冲区
// 这三条语句都可以关闭浏览器的缓冲区,但是由于浏览器的版本不同,对这三条语句的支持也不同
// 因此,为了保险起见,建议同时使用这三条语句来关闭浏览器的缓冲区
response.setHeader("ragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
// 设置图形验证码的长和宽(图形的大小)
int width = 90, height = 20;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();// 获得用于输出文字的Graphics对象
Random random = new Random();
g.setColor(getRandomColor(180, 250));// 随机设置要填充的颜色
vo.setMedicineProducedate(Util.decode(request, "medicineProducedate"));
vo.setMedicineAvliabledate(Util.decode(request, "medicineAvliabledate"));
vo.setMedicineProducer(Util.decode(request, "medicineProducer"));
vo.setMedicineText(Util.decode(request, "medicineText"));
//调用Service层的增加(insert)方法
medicineService.insert(vo);
this.redirectList(request, response);
}
/**
* 删除药品
*
* @param response
* @param request
* @throws IOException
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
@Controller
public class AuthController extends HttpServlet {
@Autowired
private UserService userService;
@RequestMapping("authLogin")
g.setColor(getRandomColor(120, 180));// 随机设置字体颜色
// 用于保存最后随机生成的验证码
StringBuilder validationCode = new StringBuilder();
// 验证码的随机字体
String[] fontNames = {"Times New Roman", "Book antiqua", "Arial"};
for (int i = 0; i < 4; i++) {
// 随机设置当前验证码的字符的字体
g.setFont(new Font(fontNames[random.nextInt(3)], Font.ITALIC, height));
// 随机获得当前验证码的字符
char codeChar = codeChars.charAt(random.nextInt(charsLength));
validationCode.append(codeChar);
// 随机设置当前验证码字符的颜色
g.setColor(getRandomColor(10, 100));
// 在图形上输出验证码字符,x和y都是随机生成的
* @param request
* @throws IOException
*/
@RequestMapping("employeeList")
public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
this.redirectList(request, response);
}
/**
* 跳转到列表页面
*
* @param request
* @param response
*/
private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
//查询列和关键字
String searchColumn = Util.decode(request, "searchColumn");
String keyword = Util.decode(request, "keyword");
Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
params.put("searchColumn", searchColumn);//要查询的列
params.put("keyword", keyword);//查询的关键字
Map<String, Object> map = employeeService.list(params);
request.getSession().setAttribute("list", map.get("list"));
* 编辑进货
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("incomeEdit")
public void edit(HttpServletResponse response, HttpServletRequest request) throws IOException {
Income vo = new Income();
vo.setId(Long.valueOf(Util.decode(request, "id")));
vo.setIncomeName(Util.decode(request, "incomeName"));
vo.setIncomeType(Util.decode(request, "incomeType"));
vo.setIncomeCount(Util.decode(request, "incomeCount"));
vo.setIncomeUnit(Util.decode(request, "incomeUnit"));
vo.setIncomeInprice(Util.decode(request, "incomeInprice"));
vo.setIncomeIntime(Util.decode(request, "incomeIntime"));
vo.setIncomeText(Util.decode(request, "incomeText"));
incomeService.update(vo);
this.redirectList(request, response);
}
/**
* 获取进货的详细信息(详情页面与编辑页面要显示该进货的详情)并跳转回页面
/**
* 删除用户
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("userDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = Util.decode(request, "id");
userService.delete(Arrays.asList(id));
this.redirectList(request, response);
}
/**
* 编辑用户
<!--列表-->
<select id="findAllSplit" parameterType="java.util.Map" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" /> FROM `t_user`
<where>
<if test="searchColumn != null and searchColumn != '' and keyword != null and keyword != ''">
${searchColumn} LIKE CONCAT('%',#{keyword},'%') AND
</if>
1=1
</where>
ORDER BY id ASC
<if test="startIndex != null and pageSize != null">
LIMIT #{startIndex},#{pageSize};
</if>
</select>
<!--数量-->
<select id="getAllCount" parameterType="java.util.Map" resultType="Integer">
SELECT COUNT(*) FROM `t_user`
<where>
<if test="searchColumn != null and searchColumn != '' and keyword != null and keyword != ''">
${searchColumn} LIKE CONCAT('%',#{keyword},'%') AND
</if>
1=1
</where>
</select>
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getStartIndex() {
return startIndex;
}
public void setStartIndex(int startIndex) {
this.startIndex = startIndex;
}
public int getStart() {
return start;
}
public void setStart(int start) {
this.start = start;
}