RetController.java (do get) (my file for reference for a test.. IS LOGIC good Enough ?

RetController.java (do get) (my file for reference for a test.. IS LOGIC good Enough ?

    try
    {
        Connection conn=Create_Connection.conOpen();
        System.out.println(conn);
        String submit=request.getParameter("submit");
        System.out.println(submit);

        if(submit.equals("View"))
        {
            try {


                ArrayList<RetailerBean> l=new ArrayList<RetailerBean>();

                l=RetDAO.view(conn);

                request.setAttribute("list1", l);
                RequestDispatcher disp=request.getRequestDispatcher("ViewRetailer.jsp");
                disp.forward(request, response);

            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        if(submit.equals("Register"))
        {  


                System.out.println("hii");
                String n=request.getParameter("name");
                System.out.println(n);
                String n1=request.getParameter("licence_no");
                String n2=request.getParameter("contact_addr");
                int n3=Integer.parseInt(request.getParameter("contact_no"));
                String n4=request.getParameter("email");
                String n5=request.getParameter("d");
                String n6=request.getParameter("m");
                String n7=request.getParameter("y");
                String date=n5+"-"+n6+"-"+n7;
                String n8=request.getParameter("uname");
                System.out.println(n8); 
                System.out.println(n7);
                String n9=request.getParameter("pass");
                String handset1[]=request.getParameterValues("prod");
                int handset[]=new int [handset1.length];
                for(int i=0;i<handset1.length;i++)
                {
                    handset[i]=Integer.parseInt(handset1[i]);
                    System.out.println(handset[i]);

                }
                RetailerBean ret=new RetailerBean();
                ret.setName(n);
                System.out.println(ret.getName());
                System.out.println(n9);
                ret.setLicence(n1);
                ret.setContactno(n3);
                ret.setAddress(n2);
                ret.setEmailid(n4);
                ret.setDob(date);
                ret.setUsername(n8);
                ret.setPassword(n9);

                int b=(int)Math.floor((Math.random()*100)+1);
                String nm="ret"+b;
                System.out.println("check id="+nm);
                ret.setId(nm);
                ret.setHandset(handset);


                RetDAO rd=new RetDAO();
                rd.insert(conn,ret);







        }


        if(submit.equals("ret_id"))
        {   

                String ret_id=request.getParameter("id");
                System.out.println(ret_id);
                System.out.println("hii");

                System.out.println("What");
                int a=RetDAO.searchDelete(conn,ret_id);
                System.out.println("hello");
                System.out.println(a);

                if(a==1)
                {  
                    int b=RetDAO.chk_order(conn,ret_id);
                    System.out.println("b="+b);

                    if(b==2)
                    {
                        System.out.println("FSdSdSD");
                        int c=RetDAO.untag(conn, ret_id);
                        System.out.println("c="+c);
                        int d=RetDAO.deleteRet(conn, ret_id);
                        System.out.println("d="+d);
                        System.out.println("Retailer only present in retailer table");
                    }
                    else if(b==1)
                    {
                        System.out.println("Row will be deleted");
                        int c=RetDAO.untag(conn, ret_id);
                        int d=RetDAO.delete(conn, ret_id);
                        System.out.println(c);
                        System.out.println(d);
                        //System.out.println("Row can be deleted");
                    }
                    else 
                    {   
                        System.out.println("Row cannot be deleted");
                    }
                }
                else response.sendRedirect("Ret_error.jsp");
        }


        if (submit.equals("request"))
        {

            ArrayList<RetailerBean> l=new ArrayList<RetailerBean>();

            l=RetDAO.viewRequest(conn);
            //RetailerBean c=l.get(0);
        //  String f= c.getId();

            System.out.println("hello");
            //request.setAttribute("list2", l);
        //  RequestDispatcher disp=request.getRequestDispatcher("ViewRequest.jsp");
        //  disp.forward(request, response)

            if(l.isEmpty())
            {System.out.println("he");
                response.sendRedirect("Ret_error.jsp");
            }
            System.out.println("mngh");
                HttpSession s=request.getSession();

            s.setAttribute("view1",l);

            response.sendRedirect("ViewRequest.jsp");

            }


        if(submit.equals("tag"))
        {
            System.out.println();
            String approve=request.getParameter("Approve");
            System.out.println(approve);

            /*String n=request.getParameter("hidden");
            System.out.println(n);*/
        }



        if(submit.equals("requestret"))
        {
            ArrayList<RetailerBean> l=new ArrayList<RetailerBean>();

            l=RetDAO.viewRequestRetailer(conn);
            //RetailerBean c=l.get(0);
        //  String f= c.getId();


            //request.setAttribute("list2", l);
        //  RequestDispatcher disp=request.getRequestDispatcher("ViewRequest.jsp");
        //  disp.forward(request, response)

            if(l.isEmpty())
            {
                response.sendRedirect("Ret_error.jsp");
            }

                HttpSession s=request.getSession();

            s.setAttribute("view2",l);

            response.sendRedirect("ViewRequestRetailer.jsp");
        }


        }
        catch(Exception e)
        {

        }

}
View Answers









Related Tutorials/Questions & Answers:

Ads