(4.1-4.7)拼团项目进度汇报

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了(4.1-4.7)拼团项目进度汇报相关的知识,希望对你有一定的参考价值。

1.任务安排

计划时间 计划任务 计划是否完成
3.22-3.29  管理员的增删改查 
3.29-4.5  编写活动模块
4.5-4.12 完善活动的增删改查   

2.下周计划完成内容

  完善活动的增删改查

3.本周实现功能

  • a.编写活动类
  • b.完善活动的servlet层代码
  • c.基本实现用户的增删改查

 

4.本周实现代码

  整合了仕庄的代码

  •   servlet类都放在action包里,用于存放增删改查操作
  •   bean包里放实体类
  •   dao包里放dao接口类

   技术分享

主要编写了EventthreadServlet类中的doPost()中的增删改查:

package pintuan.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import pintuan.bean.User;
import pintuan.db.DBConnection;

public class UserServlet extends HttpServlet {
    private DBConnection dbc=new DBConnection();
    private static final long serialVersionUID = 1L;
       
  
    public UserServlet() {
    }

    
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String action=request.getParameter("action");
        if(action.equals("query")){
            String sql="select * from pt_user";
            ResultSet rs=null;
            List<User> userList=new ArrayList<User>();
            try {
                rs = dbc.doQueryRS(sql,new Object[]{});
                
                while(rs.next())
                {
                    User user=new User();
                    user.setUserName(rs.getString("UserName"));
                    user.setUserID(rs.getString("UserID"));
                    user.setId(rs.getInt("id"));
                    user.setPassword(rs.getString("Password"));
                    user.setEmail(rs.getString("Email"));
                    user.setIsDelete(rs.getInt("isDelete"));
                    user.setIsApplied(rs.getInt("isApplied"));
                    user.setIsProfile(rs.getInt("isProfile"));
        
                    userList.add(user);
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }   
            
            HttpSession session=request.getSession();
            session.setAttribute("userList", userList);
            request.getRequestDispatcher("user_list.jsp").forward(request, response);
        }else if(action.equals("del"))
        {
            int id=Integer.parseInt(request.getParameter("id"));
            String sql="delete from pt_user where id=?";
            int res=0;
            try {
                res = dbc.doUpdate(sql,new Object[]{id});
            } catch (SQLException e) {
                e.printStackTrace();
            }
            if(res>0)
            {
                request.getRequestDispatcher("user?action=query").forward(request, response);
            }else
            {
                PrintWriter out=response.getWriter();
                out.print("删除失败");
                out.close();
            }
        }else if(action.equals("add"))
        {
            String UserID=request.getParameter("UserID");
            String UserName = request.getParameter("UserName");
            String Password = request.getParameter("Password");
            String email = request.getParameter("email");
            int isApplied = Integer.parseInt(request.getParameter("isApplied"));
            int isDelete = Integer.parseInt(request.getParameter("isDelete"));
            int isProfile = Integer.parseInt(request.getParameter("isProfile"));
    
            String sql="insert into pt_user(UserID,UserName,Password,email,isApplied,isDelete,isProfile) values(?,?,?,?,?,?,?)";
            int res=0;
            try {
                res = dbc.doUpdate(sql,new Object[]{UserID,UserName,Password,email,isApplied,isDelete,isProfile});
            } catch (SQLException e) {
                e.printStackTrace();
            }
            if(res>0)
            {
                request.getRequestDispatcher("user?action=query").forward(request, response);
            }else
            {
                PrintWriter out=response.getWriter();
                out.print("添加失败");
                out.close();
            }
            
        }else if(action.equals("edit"))
        {
            int id=Integer.parseInt(request.getParameter("id"));
            String sql="select * from pt_user where id=?";
            User user=null;
            try {
                ResultSet rs=dbc.doQueryRS(sql,new Object[]{id});
                if(rs.next())
                {
                    user = new User();
                    user.setUserID(rs.getString("UserID"));
                    user.setUserName(rs.getString("UserName"));
                    user.setPassword(rs.getString("Password"));
                    user.setIsApplied(rs.getInt("isApplied"));
                    user.setIsDelete(rs.getInt("isDelete"));
                    user.setIsProfile(rs.getInt("isProfile"));
                    user.setId(rs.getInt("id"));
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
            HttpSession session=request.getSession();
            session.setAttribute("user", user);
            request.getRequestDispatcher("edit_user.jsp").forward(request, response);
            
        }else if(action.equals("update"))
        {
            int id=Integer.parseInt(request.getParameter("id"));
            String UserID=request.getParameter("UserID");
            String UserName = request.getParameter("UserName");
            String Password = request.getParameter("Password");
            String email = request.getParameter("email");
            int isApplied = Integer.parseInt(request.getParameter("isApplied"));
            int isDelete = Integer.parseInt(request.getParameter("isDelete"));
            int isProfile = Integer.parseInt(request.getParameter("isProfile"));
    
            String sql="update pt_user set "
                    + "UserID=?,UserName=?,Password=?,email=?,"
                    + "isApplied=?,isDelete=?,isProfile = ? where id=?";
            int res=0;
            try {
                res = dbc.doUpdate(sql,new Object[]{UserID,UserName,Password,email,isApplied,isDelete,isProfile,id});
            } catch (SQLException e) {
                e.printStackTrace();
            }
            if(res>0)
            {
                request.getRequestDispatcher("user?action=query").forward(request, response);
            }else
            {
                PrintWriter out=response.getWriter();
                out.print("更新失败");
                out.close();
            }
        }else if(action.equals("register"))
        {
            String UserID=request.getParameter("UserID");
            String UserName = request.getParameter("UserName");
            String Password = request.getParameter("Password");
            String email = request.getParameter("email");
            int isApplied = Integer.parseInt(request.getParameter("isApplied"));
            int isDelete = Integer.parseInt(request.getParameter("isDelete"));
            int isProfile = Integer.parseInt(request.getParameter("isProfile"));
    
            String sql="insert into pt_user(UserID,UserName,Password,email,isApplied,isDelete,isProfile) values(?,?,?,?,?,?,?)";
            int res=0;
            try {
                res = dbc.doUpdate(sql,new Object[]{UserID,UserName,Password,email,isApplied,isDelete,isProfile});
            } catch (SQLException e) {
                e.printStackTrace();
            }
            if(res>0)
            {
                request.getRequestDispatcher("register_result_test.jsp").forward(request, response);
            }else
            {
                PrintWriter out=response.getWriter();
                out.print("添加失败");
                out.close();
            }
            
        }
        else
        {
            
        }
    }

}

 

5.本周代码实现截图

 

 

 

 

 

 

6.本周碰到问题及解决方法

 

7.本周小结

以上是关于(4.1-4.7)拼团项目进度汇报的主要内容,如果未能解决你的问题,请参考以下文章

(4.16-4.22)拼团系统进度汇报

3.22-3.29课题(拼团系统)进度汇报

OSS最新进度汇报(2.25)

11组软件工程组队项目失物招领系统——进度和分工汇报

数据库进度汇报

第二周汇报进度