SSH与SSM学习之SSH实现CRM练习10——编辑客户和删除客户
来源:互联网 发布:cdr,ai软件是什么 编辑:程序博客网 时间:2024/06/06 19:35
- SSH与SSM学习之SSH实现CRM练习10编辑客户和删除客户
- 一编辑客户图示
- 二删除客户图示
- 三编辑客户操作
- 1 CustomerAction
- 2 CustomerService
- 3 addjsp 主要修改
- 4 修改 listjsp 中的修改按钮
- 四删除客户
- 五源码下载
SSH与SSM学习之SSH实现CRM练习10——编辑客户和删除客户
一、编辑客户图示
二、删除客户图示
三、编辑客户操作
编辑客户,其实就是对已经存在的客户进行编辑。这样我们我们编辑的界面还是使用新增客户的界面。
编辑客户
第一,我们的Action提供编辑的方法 (toEdit)
第二,Service 提供edit方法
第三,DAO 提供更新的方法(其实已经存在了 saveOrUpdate)
第四,对add.jsp界面进行修改
第五,对list.jsp界面编辑按钮修改
3.1 CustomerAction
/** * @author:qiwenming * @date:2017/11/5 0005 0:34 * @description: * 用户相关Action */public class CustomerAction extends ActionSupport implements ModelDriven<Customer>{ ............ public String toEdit() throws Exception { //1 获取 id 对应的用户 Customer cust =cs.getById(customer.getCust_id()); //2 把用户添加到 域中 ActionContext.getContext().put("customer",cust); //3 并转发到编辑页面 return "edit"; } public String delete() throws Exception{ cs.delete(customer.getCust_id()); return "toList"; } ............}
源码位置
https://github.com/wimingxxx/ssh_crm/blob/master/src/com/qwm/ssh_crm/web/action/CustomerAction.java
3.2 CustomerService
CustomerService
/** * @author:qiwenming * @date:2017/11/5 0005 0:45 * @description: * 客户 */public interface CustomerService { .... Customer getById(Long cust_id); void delete(Long cust_id); ....}
CustomerServiceImpl
/** * @author:qiwenming * @date:2017/11/5 0005 0:47 * @description: */public class CustomerServiceImpl implements CustomerService { .... @Override public Customer getById(Long cust_id) { return cd.getById(cust_id); } @Override public void delete(Long cust_id) { cd.delete(cust_id); } .....}
源码位置
https://github.com/wimingxxx/ssh_crm/blob/master/src/com/qwm/ssh_crm/service/CustomerService.java
https://github.com/wimingxxx/ssh_crm/blob/master/src/com/qwm/ssh_crm/service/impl/CustomerServiceImpl.java
3.3 add.jsp 主要修改
对应add.jsp 主要修改是这样的
- 涉及到 之前是“添加用户”的地方,通过判断,来确认是 “添加用户”,还是“修改用户”
例如
.....<TITLE><s:property value="#customer==null?'添加':'修改'" />客户</TITLE>....<TD class=manageHead>当前位置:客户管理 > <s:property value="#customer==null?'添加':'修改'" />客户</TD>.....
- 提价的内容字段,需要加入初始值。例如
............... <TABLE cellSpacing=0 cellPadding=5 border=0> <TR> <td>客户名称:</td> <td> <INPUT class=textbox id=sChannel2 style="WIDTH: 180px" maxLength=50 name="cust_name" value="<s:property value="#customer.cust_name" />"> </td> <td>客户级别 :</td> <td id="level"> </td> </TR> <TR> <td>信息来源 :</td> <td id="source"></td> <td>客户行业:</td> <td id="industry"> </td> </TR> <TR> <td>固定电话 :</td> <td> <INPUT class=textbox id=sChannel2 style="WIDTH: 180px" maxLength=50 name="cust_phone" value="<s:property value="#customer.cust_phone" />"> </td> <td>移动电话 :</td> <td> <INPUT class=textbox id=sChannel2 style="WIDTH: 180px" maxLength=50 name="cust_mobile" value="<s:property value="#customer.cust_mobile" />"> </td> </TR> <tr> <td rowspan=2> <INPUT class=button id=sButton2 type=submit value=" 保存 " name=sButton2> </td> </tr> </TABLE> ...............
- 最主要的,还是要在隐藏域中加上cust_id
<input type="hidden" name="cust_id" value="<s:property value="#customer.cust_id" />" />
源码位置
https://github.com/wimingxxx/ssh_crm/blob/master/web/jsp/customer/add.jsp
3.4 修改 list.jsp 中的修改按钮
..... <a href="${pageContext.request.contextPath }/CustomerAction_toEdit?cust_id=<s:property value="#cust.cust_id"/>">修改</a>....
源码位置
https://github.com/wimingxxx/ssh_crm/blob/master/web/jsp/customer/list.jsp
四、删除客户
这个操作和上面基本一致,方法的修改在上面已经弄好了,主要就是,修改不 list.jsp的 删除按钮
.......<a href="${pageContext.request.contextPath }/CustomerAction_delete?cust_id=<s:property value="#cust.cust_id"/>">删除</a>.......
源码位置
https://github.com/wimingxxx/ssh_crm/blob/master/web/jsp/customer/list.jsp
五、源码下载
https://github.com/wimingxxx/ssh_crm
- SSH与SSM学习之SSH实现CRM练习10——编辑客户和删除客户
- SSH与SSM学习之SSH实现CRM练习02——客户列表02_PageBean
- SSH与SSM学习之SSH实现CRM练习03——客户列表03_CustomerDao
- SSH与SSM学习之SSH实现CRM练习04——客户列表04_CustomerService
- SSH与SSM学习之SSH实现CRM练习05——客户列表05_CustomerAction
- SSH与SSM学习之SSH实现CRM练习09——新增客户
- SSH与SSM学习之SSH实现CRM练习01——客户列表01_客户列表分析
- SSH与SSM学习之SSH实现CRM练习06——客户列表06_页面和测试
- SSH与SSM学习之SSH实现CRM练习17——添加客户拜访记录和列表
- SSH与SSM学习之SSH实现CRM练习07——BaseDao封装
- SSH与SSM学习之SSH实现CRM练习08——数据字典表
- SSH与SSM学习之SSH实现CRM练习11——文件上传
- SSH与SSM学习之SSH实现CRM练习12——文件上传原理
- SSH与SSM学习之SSH实现CRM练习13——添加联系人
- SSH与SSM学习之SSH实现CRM练习14——联系人列表
- SSH与SSM学习之SSH实现CRM练习15——注册登录
- SSH与SSM学习之SSH实现CRM练习16——登录校验拦截器
- SSH与SSM学习之SSH整合01——SSH整合原理和导包
- 基于Dijkstra算法的路径导航
- 杭电ACM OJ 1034 Candy Sharing Game 水水更健康(只是题目意思有点难理解)
- 蛮力法
- 社团发现算法分类及简介
- 解决spring-mvc spring拦截器 跨域问题
- SSH与SSM学习之SSH实现CRM练习10——编辑客户和删除客户
- 055day(赋值运算符的重载和运算符重载为友元函数,例题算24(递归)学习)
- glib-compile-schemas not found
- 在ubuntu中安装单机Hadoop(二)
- char类型是否有符号====》与不同编译环境相关
- All-round development
- 17.12.2B组总结
- Contest6 The K-th largest number
- 日本语能力测试(N2)经验心得