• 添加/修改保存


    public void savePersonnelNotice() throws IOException {
    HttpServletResponse response = getResponse();
    response.setContentType("text/html; charset=UTF-8");
    response.setHeader("Cache-Control", "no-cache");
    String backString = "0";// 添加成功
    String noticeTitle = getRequest().getParameter("noticetitle");// 公告标题
    String noticeContent = getRequest().getParameter("noticecontent");// 公告内容
    int yesOrNoStick = Integer.parseInt(getRequest().getParameter("yesOrNoStick"));// 是否置顶
    String noticeId = getRequest().getParameter("noticeid");// 公告id
    int yesOrNoNews=Integer.parseInt(getRequest().getParameter("yesOrNoNews"));//是否最新
    String uploadFiles=getRequest().getParameter("uploadFiles");//获取附件名
    Integer personnelNoticeTypeId=Integer.parseInt(getRequest().getParameter("personnelNoticeType"));//人事公告类别id
    String queryString;
    if (noticeTitle != null && noticeTitle != "") {
    if (noticeId != null && noticeId != "") {// 判断是否重复
    queryString = "from PersonnelNotice where noticeTitle='"+ noticeTitle + "'and id!='" + noticeId + "'";
    } else {
    queryString = "from PersonnelNotice where noticeTitle='"+ noticeTitle + "'";
    }
    List<PersonnelNotice> personnellist = searchManager.find(queryString);
    // 判断置顶是否超过5个
    String stickGreaterThanFive = "from PersonnelNotice where yesOrNoStick=1";
    if (personnellist.size() > 0) {// 如果存在
    backString = "1"; // 人事公告名称已经存在
    }else {// 如果不存在
    if (noticeId == null||noticeId.equals("")) {
    if(((searchManager.find(stickGreaterThanFive).size()) >= Constants.INTFIVE)&&(yesOrNoStick==1)){
    backString = "4";
    }else{
    personnelnotice = new PersonnelNotice();
    backString = "2";// 添加
    }
    } else {//是编辑
    queryString = "from PersonnelNotice where id='" + noticeId+ "'";
    List<PersonnelNotice> personnelnoticelist = searchManager.find(queryString);
    if (personnelnoticelist.size() > 0) {
    personnelnotice = personnelnoticelist.get(0);
    if(((searchManager.find(stickGreaterThanFive).size()) >= Constants.INTFIVE)&&(yesOrNoStick==1)
    &&(personnelnotice.getYesOrNoStick().equals(Constants.TWO))){
    backString = "4";
    }else{
    backString = "3";
    }
    }
    }
    if(!backString.equals("4")){
    personnelnotice.setNoticeTitle(noticeTitle);
    personnelnotice.setNoticeContent(noticeContent);
    personnelnotice.setCreateDate(new Date());
    personnelnotice.setYesOrNoStick(yesOrNoStick);
    personnelnotice.setYesOrNoNews(yesOrNoNews);
    personnelnotice.setEnclosureName(uploadFiles);
    PersonnelNoticeType personnelNoticeType=personnelNoticeTypeManager
    .getPersonnelNoticeTypeById(personnelNoticeTypeId);
    personnelnotice.setPersonnelNoticeType(personnelNoticeType);
    searchManager.saveOrUpdate(personnelnotice);
    }
    }
    }

    PrintWriter out = response.getWriter();
    out.print(backString);
    out.close();
    }

    public String addPersonnelNoticeType(String id,String userName) {
    String backString="";
    if(checkPersonnelNoticeTypeNameExist(id,userName).equals("1")){
    //用户名已经存在
    return "1";
    }else{
    if(id==null || id.equals("")){
    personnelNoticeType=new PersonnelNoticeType();
    backString="2";
    }else{
    personnelNoticeType=personnelNoticeTypeDao.getPersonnelNoticeTypeByid(Integer.parseInt(id));
    backString="3";
    }
    personnelNoticeType.setName(userName);
    personnelNoticeType.setCreateTime(new Date());
    personnelNoticeTypeDao.savePersonnelNoticeType(personnelNoticeType);
    return backString;
    }

    }

  • 相关阅读:
    Delphi中TFlowPanel实现滚动条效果
    Delphi组件开发-在窗体标题栏添加按钮(使用MakeObjectInstance(NewWndProc),并处理好多消息)
    减小Delphi的Exe文件大小(11种方法)
    画出太极图
    类似地图的以鼠标为中心缩放图像
    andoid x项目的优化 1
    ICON图标文件解析
    所有语言的Awesome(2)
    获取EIP(汇编语言直接给Delphi变量赋值)
    Qt Windows下链接子系统与入口函数(终结版)(可同时存在main和WinMain函数)
  • 原文地址:https://www.cnblogs.com/shuenjian901/p/3483702.html
Copyright © 2020-2023  润新知