List of usage examples for com.google.gson JsonObject JsonObject
JsonObject
From source file:account.TypeWiseProftStatement.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// ww w .j av a 2 s . c om * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String from_date = request.getParameter("from_date"); final String to_date = request.getParameter("to_date"); final String type_cd = request.getParameter("type_cd"); final String branch_cd = request.getParameter("branch_cd"); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "select v.branch_cd,TYPE_NAME,sum(1) as qty,sum(t.PUR_RATE) as purchase,sum(t.SALE_RATE) as sales" + " from tag t left join SERIESMST s on t.SR_CD=s.SR_CD left join MODELMST m on s.MODEL_CD=m.MODEL_CD " + " left join TYPEMST t1 on m.TYPE_CD=t1.TYPE_CD left join VILSHD v on t.SALE_REF_NO=v.REF_NO" + " where t.is_del =1 and SALE_REF_NO <> '' " + " and v.v_date>='" + from_date + "' " + " and v.v_date<='" + to_date + "' "; if (!type_cd.equalsIgnoreCase("")) { sql += " and t1.type_cd='" + type_cd + "'"; } if (!branch_cd.equalsIgnoreCase("0")) { sql += " and v.branch_cd=" + branch_cd + ""; } sql += " group by TYPE_NAME,branch_cd order by type_name"; pstLocal = dataConnection.prepareStatement(sql); ResultSet viewDataRs = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("TYPE_NAME", viewDataRs.getString("TYPE_NAME")); object.addProperty("QTY", viewDataRs.getInt("qty")); object.addProperty("PURCHASE", viewDataRs.getDouble("purchase")); object.addProperty("SALES", viewDataRs.getDouble("sales")); object.addProperty("branch_cd", viewDataRs.getString("branch_cd")); array.add(object); } jResultObj.addProperty("result", 1); jResultObj.addProperty("Cause", "success"); jResultObj.add("data", array); } catch (SQLNonTransientConnectionException ex1) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", "Server is down"); } catch (SQLException ex) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", ex.getMessage()); } } response.getWriter().print(jResultObj); }
From source file:account.TypeWisePurchase.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w .ja v a 2 s .c om * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String from_date = request.getParameter("from_date"); final String to_date = request.getParameter("to_date"); final String ac_cd = request.getParameter("ac_cd"); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); final String sr_cd = request.getParameter("sr_cd"); final String type_cd = request.getParameter("type_cd"); final String brand_cd = request.getParameter("brnad_cd"); final String model_cd = request.getParameter("model_cd"); final String branch_cd = request.getParameter("branch_cd"); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "select v.branch_cd,m.model_name,t.TYPE_NAME,sum(v1.qty) as pcs,sum(v1.RATE) as tot_sales from LBRPHD v left join LBRPDT v1 on v.REF_NO=v1.REF_NO " + " left join SERIESMST s on v1.SR_CD=s.SR_CD \n" + " left join MODELMST m on s.MODEL_CD=m.MODEL_CD left join TYPEMST t on m.TYPE_CD=t.TYPE_CD where v.IS_DEL=0 " + " and v.v_date>='" + from_date + "' " + " and v.v_date<='" + to_date + "'"; if (!type_cd.equalsIgnoreCase("")) { sql += " and m.type_cd='" + type_cd + "' "; } if (!sr_cd.equalsIgnoreCase("")) { sql += " and s.SR_CD='" + sr_cd + "'"; } else if (!brand_cd.equalsIgnoreCase("")) { sql += " and m.brand_cd='" + brand_cd + "'"; } else if (!model_cd.equalsIgnoreCase("")) { sql += " and s.model_cd='" + model_cd + "'"; } if (!ac_cd.equalsIgnoreCase("")) { sql += " and v.ac_cd='" + ac_cd + "'"; } if (!branch_cd.equalsIgnoreCase("0")) { sql += " and v.branch_cd=" + branch_cd; } sql += " group by v.branch_cd,t.TYPE_NAME,m.model_name order by model_name"; pstLocal = dataConnection.prepareStatement(sql); ResultSet viewDataRs = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("model_name", viewDataRs.getString("model_name")); object.addProperty("type_name", viewDataRs.getString("type_name")); object.addProperty("pcs", viewDataRs.getInt("pcs")); object.addProperty("tot_sales", viewDataRs.getDouble("tot_sales")); object.addProperty("branch_cd", viewDataRs.getString("branch_cd")); array.add(object); } sql = "select v.branch_cd,m.model_name,t.TYPE_NAME,sum(v1.qty) as pcs,sum(v1.RATE) as tot_sales from prhd v left join prdt v1 on v.REF_NO=v1.REF_NO " + " left join SERIESMST s on v1.SR_CD=s.SR_CD \n" + " left join MODELMST m on s.MODEL_CD=m.MODEL_CD left join TYPEMST t on m.TYPE_CD=t.TYPE_CD where v.IS_DEL=0 " + " and v.v_date>='" + from_date + "' " + " and v.v_date<='" + to_date + "'"; if (!type_cd.equalsIgnoreCase("")) { sql += " and m.type_cd='" + type_cd + "' "; } if (!sr_cd.equalsIgnoreCase("")) { sql += " and s.SR_CD='" + sr_cd + "'"; } else if (!brand_cd.equalsIgnoreCase("")) { sql += " and m.brand_cd='" + brand_cd + "'"; } else if (!model_cd.equalsIgnoreCase("")) { sql += " and s.model_cd='" + model_cd + "'"; } if (!ac_cd.equalsIgnoreCase("")) { sql += " and v.ac_cd='" + ac_cd + "'"; } if (!branch_cd.equalsIgnoreCase("0")) { sql += " and v.branch_cd=" + branch_cd + ""; } sql += " group by t.TYPE_NAME,m.model_name order by m.model_name"; pstLocal = dataConnection.prepareStatement(sql); viewDataRs = pstLocal.executeQuery(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("model_name", viewDataRs.getString("model_name")); object.addProperty("type_name", viewDataRs.getString("type_name")); object.addProperty("pcs", viewDataRs.getInt("pcs") * -1); object.addProperty("tot_sales", viewDataRs.getDouble("tot_sales") * -1); object.addProperty("branch_cd", viewDataRs.getString("branch_cd")); array.add(object); } jResultObj.addProperty("result", 1); jResultObj.addProperty("Cause", "success"); jResultObj.add("data", array); } catch (SQLNonTransientConnectionException ex1) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", "Server is down"); } catch (SQLException ex) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", ex.getMessage()); } } response.getWriter().print(jResultObj); }
From source file:account.TypeWisePurchaseDetail.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w w w .jav a 2 s . c om*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String from_date = request.getParameter("from_date"); final String to_date = request.getParameter("to_date"); final String ac_cd = request.getParameter("ac_cd"); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); final String sr_cd = request.getParameter("sr_cd"); final String type_cd = request.getParameter("type_cd"); final String brand_cd = request.getParameter("brnad_cd"); final String model_cd = request.getParameter("model_cd"); final String branch_cd = request.getParameter("branch_cd"); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "select b.brand_name,m.model_name,v.branch_cd,v.ref_no,a.fname,s.sr_name,v.v_date,t.TYPE_NAME,v1.tag_no as IMEI_NO,(v1.qty) as pcs,(v1.RATE) as tot_sales from LBRPHD v left join LBRPdt v1 on v.REF_NO=v1.REF_NO " + " left join SERIESMST s on v1.SR_CD=s.SR_CD left join acntmst a on v.ac_cd=a.ac_cd " + " left join MODELMST m on s.MODEL_CD=m.MODEL_CD left join TYPEMST t on m.TYPE_CD=t.TYPE_CD" + " left join BRANDMST b on m.brand_cd=b.brand_cd where v.IS_DEL=0 " + " and v.v_date>='" + from_date + "' " + " and v.v_date<='" + to_date + "'"; if (!type_cd.equalsIgnoreCase("")) { sql += " and m.type_cd='" + type_cd + "' "; } if (!sr_cd.equalsIgnoreCase("")) { sql += " and s.SR_CD='" + sr_cd + "'"; } else if (!brand_cd.equalsIgnoreCase("")) { sql += " and m.brand_cd='" + brand_cd + "'"; } else if (!model_cd.equalsIgnoreCase("")) { sql += " and s.model_cd='" + model_cd + "'"; } if (!ac_cd.equalsIgnoreCase("")) { sql += " and v.ac_cd='" + ac_cd + "'"; } if (!branch_cd.equalsIgnoreCase("0")) { sql += " and v.branch_cd=" + branch_cd; } pstLocal = dataConnection.prepareStatement(sql); ResultSet viewDataRs = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("fname", viewDataRs.getString("fname")); object.addProperty("model_name", viewDataRs.getString("model_name")); object.addProperty("sr_name", viewDataRs.getString("sr_name")); object.addProperty("v_date", viewDataRs.getString("v_date")); object.addProperty("type_name", viewDataRs.getString("type_name")); object.addProperty("pcs", viewDataRs.getInt("pcs")); object.addProperty("tot_sales", viewDataRs.getDouble("tot_sales")); object.addProperty("IMEI_NO", viewDataRs.getString("IMEI_NO")); object.addProperty("REF_NO", viewDataRs.getString("REF_NO")); object.addProperty("branch_cd", viewDataRs.getString("branch_cd")); object.addProperty("brand_name", viewDataRs.getString("brand_name")); array.add(object); } sql = "select b.brand_name,m.model_name,v.branch_cd,v.ref_no,a.fname,s.sr_name,v.v_date,t.TYPE_NAME,case when IMEI_NO ='' then SERAIL_NO else IMEI_NO end as IMEI_NO,(v1.qty) as pcs,(v1.RATE) as tot_sales from prhd v left join prdt v1 on" + " v.REF_NO=v1.REF_NO " + " left join SERIESMST s on v1.SR_CD=s.SR_CD left join acntmst a on v.ac_cd=a.ac_cd " + " left join MODELMST m on s.MODEL_CD=m.MODEL_CD left join TYPEMST t on m.TYPE_CD=t.TYPE_CD" + " left join BRANDMST b on m.brand_cd=b.brand_cd where v.IS_DEL=0 " + " and v.v_date>='" + from_date + "' " + " and v.v_date<='" + to_date + "'"; if (!type_cd.equalsIgnoreCase("")) { sql += " and m.type_cd='" + type_cd + "' "; } if (!sr_cd.equalsIgnoreCase("")) { sql += " and s.SR_CD='" + sr_cd + "'"; } else if (!brand_cd.equalsIgnoreCase("")) { sql += " and m.brand_cd='" + brand_cd + "'"; } else if (!model_cd.equalsIgnoreCase("")) { sql += " and s.model_cd='" + model_cd + "'"; } if (!ac_cd.equalsIgnoreCase("")) { sql += " and v.ac_cd='" + ac_cd + "'"; } if (!branch_cd.equalsIgnoreCase("0")) { sql += " and v.branch_cd=" + branch_cd; } pstLocal = dataConnection.prepareStatement(sql); viewDataRs = pstLocal.executeQuery(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("fname", viewDataRs.getString("fname")); object.addProperty("model_name", viewDataRs.getString("model_name")); object.addProperty("sr_name", viewDataRs.getString("sr_name")); object.addProperty("v_date", viewDataRs.getString("v_date")); object.addProperty("type_name", viewDataRs.getString("type_name")); object.addProperty("pcs", viewDataRs.getInt("pcs") * -1); object.addProperty("tot_sales", viewDataRs.getDouble("tot_sales") * -1); object.addProperty("IMEI_NO", viewDataRs.getString("IMEI_NO")); object.addProperty("REF_NO", viewDataRs.getString("REF_NO")); object.addProperty("branch_cd", viewDataRs.getString("branch_cd")); object.addProperty("brand_name", viewDataRs.getString("brand_name")); array.add(object); } jResultObj.addProperty("result", 1); jResultObj.addProperty("Cause", "success"); jResultObj.add("data", array); } catch (SQLNonTransientConnectionException ex1) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", "Server is down"); } catch (SQLException ex) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", ex.getMessage()); } } response.getWriter().print(jResultObj); }
From source file:account.TypeWiseSales.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* w ww. j a va 2 s. co m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String from_date = request.getParameter("from_date"); final String to_date = request.getParameter("to_date"); final String ac_cd = request.getParameter("ac_cd"); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); final String sr_cd = request.getParameter("sr_cd"); final String type_cd = request.getParameter("type_cd"); final String brand_cd = request.getParameter("brnad_cd"); final String model_cd = request.getParameter("model_cd"); final String branch_cd = request.getParameter("branch_cd"); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "select v.branch_cd,b.brand_name,m.model_name,t.TYPE_NAME,sum(v1.qty) as pcs,sum(v1.RATE) as tot_sales from VILSHD v left join VILSDT v1 on v.REF_NO=v1.REF_NO " + " left join SERIESMST s on v1.SR_CD=s.SR_CD \n" + " left join MODELMST m on s.MODEL_CD=m.MODEL_CD left join TYPEMST t on m.TYPE_CD=t.TYPE_CD" + " left join brandmst b on b.brand_cd=m.brand_cd where v.IS_DEL=0 " + " and v.v_date>='" + from_date + "' " + " and v.v_date<='" + to_date + "'"; if (!type_cd.equalsIgnoreCase("")) { sql += " and m.type_cd='" + type_cd + "' "; } if (!sr_cd.equalsIgnoreCase("")) { sql += " and s.SR_CD='" + sr_cd + "'"; } else if (!brand_cd.equalsIgnoreCase("")) { sql += " and m.brand_cd='" + brand_cd + "'"; } else if (!model_cd.equalsIgnoreCase("")) { sql += " and s.model_cd='" + model_cd + "'"; } if (!ac_cd.equalsIgnoreCase("")) { sql += " and v.ac_cd='" + ac_cd + "'"; } if (!branch_cd.equalsIgnoreCase("0")) { sql += " and v.branch_cd=" + branch_cd; } sql += " group by v.branch_cd,t.TYPE_NAME,m.model_name,brand_name order by branch_cd,model_name"; pstLocal = dataConnection.prepareStatement(sql); ResultSet viewDataRs = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("brand_name", viewDataRs.getString("brand_name")); object.addProperty("model_name", viewDataRs.getString("model_name")); object.addProperty("type_name", viewDataRs.getString("type_name")); object.addProperty("pcs", viewDataRs.getInt("pcs")); object.addProperty("tot_sales", viewDataRs.getDouble("tot_sales")); object.addProperty("branch_cd", viewDataRs.getString("branch_cd")); array.add(object); } sql = "select v.branch_cd,b.brand_name,m.model_name,t.TYPE_NAME,sum(v1.qty) as pcs,sum(v1.RATE) as tot_sales from srhd v left join srdt v1 on v.REF_NO=v1.REF_NO " + " left join SERIESMST s on v1.SR_CD=s.SR_CD \n" + " left join MODELMST m on s.MODEL_CD=m.MODEL_CD left join TYPEMST t on m.TYPE_CD=t.TYPE_CD " + " left join brandmst b on b.brand_cd=m.brand_cd where v.IS_DEL=0 " + " and v.v_date>='" + from_date + "' " + " and v.v_date<='" + to_date + "'"; if (!type_cd.equalsIgnoreCase("")) { sql += " and m.type_cd='" + type_cd + "' "; } if (!sr_cd.equalsIgnoreCase("")) { sql += " and s.SR_CD='" + sr_cd + "'"; } else if (!brand_cd.equalsIgnoreCase("")) { sql += " and m.brand_cd='" + brand_cd + "'"; } else if (!model_cd.equalsIgnoreCase("")) { sql += " and s.model_cd='" + model_cd + "'"; } if (!ac_cd.equalsIgnoreCase("")) { sql += " and v.ac_cd='" + ac_cd + "'"; } if (!branch_cd.equalsIgnoreCase("0")) { sql += " and v.branch_cd=" + branch_cd + ""; } sql += " group by t.TYPE_NAME,m.model_name order by m.model_name"; pstLocal = dataConnection.prepareStatement(sql); viewDataRs = pstLocal.executeQuery(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("brand_name", viewDataRs.getString("brand_name")); object.addProperty("model_name", viewDataRs.getString("model_name")); object.addProperty("type_name", viewDataRs.getString("type_name")); object.addProperty("pcs", viewDataRs.getInt("pcs") * -1); object.addProperty("tot_sales", viewDataRs.getDouble("tot_sales") * -1); object.addProperty("branch_cd", viewDataRs.getString("branch_cd")); array.add(object); } jResultObj.addProperty("result", 1); jResultObj.addProperty("Cause", "success"); jResultObj.add("data", array); } catch (SQLNonTransientConnectionException ex1) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", "Server is down"); } catch (SQLException ex) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", ex.getMessage()); } } response.getWriter().print(jResultObj); }
From source file:account.TypeWiseSalesDetail.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w w w. j a va2s. co m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String from_date = request.getParameter("from_date"); final String to_date = request.getParameter("to_date"); final String ac_cd = request.getParameter("ac_cd"); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); final String sr_cd = request.getParameter("sr_cd"); final String type_cd = request.getParameter("type_cd"); final String brand_cd = request.getParameter("brnad_cd"); final String model_cd = request.getParameter("model_cd"); final String branch_cd = request.getParameter("branch_cd"); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "SELECT m.model_name,v.branch_cd,v.ref_no,a.fname,s.sr_name,v.v_date,t.TYPE_NAME,b.brand_name," + " CASE WHEN v1.IMEI_NO ='' THEN v1.SERAIL_NO ELSE v1.IMEI_NO END AS IMEI_NO,(v1.qty) AS pcs,(v1.RATE) AS tot_sales," + " t1.ac_name AS pur_party,MOBILE1,email FROM VILSHD v LEFT JOIN vilsdt v1 ON v.REF_NO=v1.REF_NO " + " LEFT JOIN SERIESMST s ON v1.SR_CD=s.SR_CD LEFT JOIN acntmst a ON v.ac_cd=a.ac_cd " + " LEFT JOIN MODELMST m ON s.MODEL_CD=m.MODEL_CD LEFT JOIN TYPEMST t ON m.TYPE_CD=t.TYPE_CD" + " left join brandmst b on b.brand_cd=m.brand_cd left join phbkmst p1 on p1.ac_cd=a.ac_cd" + " LEFT JOIN tag t1 ON t1.ref_no=v1.pur_tag_no WHERE v.IS_DEL=0 " + " and v.v_date>='" + from_date + "' " + " and v.v_date<='" + to_date + "'"; if (!type_cd.equalsIgnoreCase("")) { sql += " and m.type_cd='" + type_cd + "' "; } if (!sr_cd.equalsIgnoreCase("")) { sql += " and s.SR_CD='" + sr_cd + "'"; } else if (!brand_cd.equalsIgnoreCase("")) { sql += " and m.brand_cd='" + brand_cd + "'"; } else if (!model_cd.equalsIgnoreCase("")) { sql += " and s.model_cd='" + model_cd + "'"; } if (!ac_cd.equalsIgnoreCase("")) { sql += " and v.ac_cd='" + ac_cd + "'"; } if (!branch_cd.equalsIgnoreCase("0")) { sql += " and v.branch_cd=" + branch_cd; } sql += " order by v.branch_cd"; pstLocal = dataConnection.prepareStatement(sql); ResultSet viewDataRs = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("fname", viewDataRs.getString("fname")); object.addProperty("model_name", viewDataRs.getString("model_name")); object.addProperty("sr_name", viewDataRs.getString("sr_name")); object.addProperty("v_date", viewDataRs.getString("v_date")); object.addProperty("type_name", viewDataRs.getString("type_name")); object.addProperty("pcs", viewDataRs.getInt("pcs")); object.addProperty("tot_sales", viewDataRs.getDouble("tot_sales")); object.addProperty("IMEI_NO", viewDataRs.getString("IMEI_NO")); object.addProperty("brand_name", viewDataRs.getString("brand_name")); object.addProperty("PUR_PARTY", viewDataRs.getString("PUR_PARTY")); object.addProperty("REF_NO", viewDataRs.getString("REF_NO")); object.addProperty("MOBILE1", (viewDataRs.getString("MOBILE1") == null) ? "" : viewDataRs.getString("MOBILE1")); object.addProperty("EMAIL", (viewDataRs.getString("EMAIL") == null) ? "" : viewDataRs.getString("EMAIL")); object.addProperty("branch_cd", viewDataRs.getString("branch_cd")); array.add(object); } sql = "select m.model_name,v.branch_cd,v.ref_no,a.fname,s.sr_name,v.v_date,t.TYPE_NAME,b.brand_name" + " ,case when IMEI_NO ='' then SERAIL_NO else IMEI_NO end as IMEI_NO,(v1.qty) as pcs,(v1.RATE) as tot_sales" + " ,MOBILE1,email from srhd v left join srdt v1 on" + " v.REF_NO=v1.REF_NO " + " left join SERIESMST s on v1.SR_CD=s.SR_CD left join acntmst a on v.ac_cd=a.ac_cd " + " left join MODELMST m on s.MODEL_CD=m.MODEL_CD left join brandmst b on b.brand_cd=m.brand_cd" + " left join TYPEMST t on m.TYPE_CD=t.TYPE_CD left join phbkmst p1 on p1.ac_cd=a.ac_cd where v.IS_DEL=0 " + " and v.v_date>='" + from_date + "' " + " and v.v_date<='" + to_date + "'"; if (!type_cd.equalsIgnoreCase("")) { sql += " and m.type_cd='" + type_cd + "' "; } if (!sr_cd.equalsIgnoreCase("")) { sql += " and s.SR_CD='" + sr_cd + "'"; } else if (!brand_cd.equalsIgnoreCase("")) { sql += " and m.brand_cd='" + brand_cd + "'"; } else if (!model_cd.equalsIgnoreCase("")) { sql += " and s.model_cd='" + model_cd + "'"; } if (!ac_cd.equalsIgnoreCase("")) { sql += " and v.ac_cd='" + ac_cd + "'"; } if (!branch_cd.equalsIgnoreCase("0")) { sql += " and v.branch_cd=" + branch_cd; } pstLocal = dataConnection.prepareStatement(sql); viewDataRs = pstLocal.executeQuery(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("fname", viewDataRs.getString("fname")); object.addProperty("sr_name", viewDataRs.getString("sr_name")); object.addProperty("model_name", viewDataRs.getString("model_name")); object.addProperty("brand_name", viewDataRs.getString("brand_name")); object.addProperty("v_date", viewDataRs.getString("v_date")); object.addProperty("type_name", viewDataRs.getString("type_name")); object.addProperty("pcs", viewDataRs.getInt("pcs") * -1); object.addProperty("tot_sales", viewDataRs.getDouble("tot_sales") * -1); object.addProperty("IMEI_NO", viewDataRs.getString("IMEI_NO")); object.addProperty("REF_NO", viewDataRs.getString("REF_NO")); object.addProperty("MOBILE1", (viewDataRs.getString("MOBILE1") == null) ? "" : viewDataRs.getString("MOBILE1")); object.addProperty("EMAIL", (viewDataRs.getString("EMAIL") == null) ? "" : viewDataRs.getString("EMAIL")); object.addProperty("PUR_PARTY", ""); object.addProperty("branch_cd", viewDataRs.getString("branch_cd")); array.add(object); } jResultObj.addProperty("result", 1); jResultObj.addProperty("Cause", "success"); jResultObj.add("data", array); } catch (SQLNonTransientConnectionException ex1) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", "Server is down"); } catch (SQLException ex) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", ex.getMessage()); } } response.getWriter().print(jResultObj); }
From source file:account.UpdateBill.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from ww w . j av a 2 s . c o m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final DBHelper helper = DBHelper.GetDBHelper(); final Library lb = Library.getInstance(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); final String dr_doc_ref_no = (request.getParameter("dr_doc_ref_no")); final String cr_doc_ref_no = (request.getParameter("cr_doc_ref_no")); final String dr_doc_cd = (request.getParameter("DR_DOC_CD")); final String cr_doc_cd = (request.getParameter("CR_DOC_CD")); final String dr_inv_no = (request.getParameter("DR_INV_NO")); final String cr_inv_no = (request.getParameter("CR_INV_NO")); final double dr_amt = Double.parseDouble(request.getParameter("DR_AMT")); final double cr_amt = Double.parseDouble(request.getParameter("CR_AMT")); final int dr_sr_no = (int) Double.parseDouble(request.getParameter("DR_SR_NO")); final int cr_sr_no = (int) Double.parseDouble(request.getParameter("CR_SR_NO")); if (dataConnection != null) { try { dataConnection.setAutoCommit(false); PreparedStatement pstLocal = null; String sql = "update oldb2_4 set UNPAID_AMT=UNPAID_AMT-? where DOC_REF_NO=?"; pstLocal = dataConnection.prepareStatement(sql); if (dr_amt + cr_amt >= 0) { pstLocal.setDouble(1, cr_amt * -1); } else { pstLocal.setDouble(1, dr_amt); } pstLocal.setString(2, dr_doc_ref_no); pstLocal.executeUpdate(); sql = "update oldb2_4 set UNPAID_AMT=UNPAID_AMT+? where DOC_REF_NO=?"; pstLocal = dataConnection.prepareStatement(sql); if (dr_amt + cr_amt >= 0) { pstLocal.setDouble(1, cr_amt * -1); } else { pstLocal.setDouble(1, dr_amt); } pstLocal.setString(2, cr_doc_ref_no); pstLocal.executeUpdate(); sql = "INSERT INTO billadjst (doc_ref_no,DR_DOC_REF_NO,CR_DOC_REF_NO,DR_DOC_CD,CR_DOC_CD,DR_INV_NO,CR_INV_NO,AMT,dr_sr_no,cr_sr_no) values(?,?,?,?,?,?,?,?,?,?)"; pstLocal = dataConnection.prepareStatement(sql); pstLocal.setString(1, lb.generateKey(dataConnection, "billadjst", "DOC_REF_NO", "BI", 7)); pstLocal.setString(2, dr_doc_ref_no); pstLocal.setString(3, cr_doc_ref_no); pstLocal.setString(4, dr_doc_cd); pstLocal.setString(5, cr_doc_cd); pstLocal.setString(6, dr_inv_no); pstLocal.setString(7, cr_inv_no); pstLocal.setDouble(8, (dr_amt >= Math.abs(cr_amt)) ? Math.abs(cr_amt) : dr_amt); pstLocal.setInt(9, dr_sr_no); pstLocal.setInt(10, cr_sr_no); pstLocal.executeUpdate(); dataConnection.commit(); dataConnection.setAutoCommit(true); jResultObj.addProperty("result", 1); jResultObj.addProperty("Cause", "success"); } catch (SQLNonTransientConnectionException ex1) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", "Server is down"); try { dataConnection.rollback(); dataConnection.setAutoCommit(true); } catch (Exception e) { } } catch (SQLException ex) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", ex.getMessage()); try { dataConnection.rollback(); dataConnection.setAutoCommit(true); } catch (Exception e) { } } finally { lb.closeConnection(dataConnection); } } response.getWriter().print(jResultObj); }
From source file:account.updateDenomation.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from www. j a v a 2 s. c o m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final Library lb = Library.getInstance(); final String v_date = request.getParameter("v_date"); final String branch_cd = request.getParameter("branch_cd"); final String note_cd = request.getParameter("note_cd"); final String qty = request.getParameter("qty"); final DBHelper helper = DBHelper.GetDBHelper(); final JsonObject jResultObj = new JsonObject(); final Connection dataConnection = helper.getConnMpAdmin(); if (dataConnection != null) { try { String sql = "delete from denomation where v_date=? and branch_cd=? and note_cd=?"; PreparedStatement pstLocal = dataConnection.prepareStatement(sql); pstLocal.setString(1, v_date); pstLocal.setString(2, branch_cd); pstLocal.setString(3, note_cd); pstLocal.executeUpdate(); sql = "insert into denomation (v_date,branch_cd,note_cd,qty) values (?,?,?,?)"; pstLocal = dataConnection.prepareStatement(sql); pstLocal.setString(1, v_date); pstLocal.setString(2, branch_cd); pstLocal.setString(3, note_cd); pstLocal.setString(4, qty); pstLocal.executeUpdate(); jResultObj.addProperty("result", 1); jResultObj.addProperty("Cause", "success"); } catch (SQLNonTransientConnectionException ex1) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", "Server is down"); } catch (SQLException ex) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", ex.getMessage()); } finally { lb.closeConnection(dataConnection); } } response.getWriter().print(jResultObj); }
From source file:account.UpdateNlc.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from www . j a va 2 s .com * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String detailJson = request.getParameter("detail"); TypeToken<List<NlcModel>> token = new TypeToken<List<NlcModel>>() { }; final List<NlcModel> detail = new Gson().fromJson(detailJson, token.getType()); final ArrayList<NlcModel> data = (ArrayList<NlcModel>) detail; final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final Library lb = Library.getInstance(); final JsonObject jResultObj = new JsonObject(); if (dataConnection != null) { try { dataConnection.setAutoCommit(false); PreparedStatement pstUpdate1 = null; String sql1 = "update tag set disc_per=?,extra_support=?,backend=?,activation=?,prize_drop=? where ref_no=?"; pstUpdate1 = dataConnection.prepareStatement(sql1); for (int i = 0; i < data.size(); i++) { pstUpdate1.setDouble(1, data.get(i).getDisc_per()); pstUpdate1.setDouble(2, data.get(i).getExtra_support()); pstUpdate1.setDouble(3, data.get(i).getBackend()); pstUpdate1.setDouble(4, data.get(i).getActivation()); pstUpdate1.setDouble(5, data.get(i).getPrize_drop()); pstUpdate1.setString(6, data.get(i).getRef_no()); pstUpdate1.executeUpdate(); } String sql = "update oldb2_1 set dr_" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "=dr_" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "+? where ac_CD=?"; PreparedStatement pstUpdate = dataConnection.prepareStatement(sql); pstUpdate.setDouble(1, data.get(0).getCnAmount()); pstUpdate.setString(2, data.get(0).getAc_cd()); pstUpdate.executeUpdate(); sql = "insert into oldb2_2 (doc_ref_no,doc_date,doc_cd,ac_cd," + "val,crdr,particular,opp_ac_cd,time_stamp,INV_NO) values(?,CURRENT_DATE,?,?,?,?,?,?,CURRENT_TIMESTAMP,?)"; pstUpdate = dataConnection.prepareStatement(sql); pstUpdate.setString(1, "PD"); pstUpdate.setString(2, "PD"); pstUpdate.setString(3, data.get(0).getAc_cd()); pstUpdate.setDouble(4, data.get(0).getCnAmount()); pstUpdate.setString(5, "0"); pstUpdate.setString(6, data.get(0).getRemark()); pstUpdate.setString(7, ""); pstUpdate.setString(8, "0"); pstUpdate.executeUpdate(); sql = "insert into prize_drop (pur_tag_no,sr_no,voucher_no,v_date,remark,prev_rate,rate,ac_cd) values (?,?,?,CURRENT_DATE,?,?,?,?)"; pstUpdate = dataConnection.prepareStatement(sql); for (int i = 0; i < data.size(); i++) { pstUpdate.setString(1, data.get(i).getRef_no()); pstUpdate.setInt(2, i + 1); pstUpdate.setString(3, lb.generateKey(dataConnection, "prize_drop", "voucher_no", "PZ", 7)); pstUpdate.setString(4, data.get(i).getRemark()); pstUpdate.setDouble(5, 0.00); pstUpdate.setDouble(6, data.get(i).getExtra_support() + data.get(i).getBackend() + data.get(i).getBackend() + data.get(i).getActivation() + data.get(i).getPrize_drop()); pstUpdate.setString(7, data.get(i).getAc_cd()); pstUpdate.executeUpdate(); } dataConnection.commit(); dataConnection.setAutoCommit(true); jResultObj.addProperty("result", 1); jResultObj.addProperty("Cause", "success"); } catch (SQLNonTransientConnectionException ex1) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", "Server is down"); try { dataConnection.rollback(); dataConnection.setAutoCommit(true); } catch (SQLException ex) { Logger.getLogger(UpdatePrize.class.getName()).log(Level.SEVERE, null, ex); } } catch (SQLException ex) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", ex.getMessage()); try { dataConnection.rollback(); dataConnection.setAutoCommit(true); } catch (SQLException ex2) { Logger.getLogger(UpdatePrize.class.getName()).log(Level.SEVERE, null, ex2); } } } response.getWriter().print(jResultObj); }
From source file:account.UpdateOLDB2_4.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w ww.ja v a2 s . c o m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String unpaid_amt = request.getParameter("unpaid_amt"); final String doc_ref_no = request.getParameter("doc_ref_no"); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "UPDATE oldb2_4 SET unpaid_amt=? WHERE doc_ref_no=?"; pstLocal = dataConnection.prepareStatement(sql); pstLocal.setString(1, unpaid_amt); pstLocal.setString(2, doc_ref_no); pstLocal.executeUpdate(); jResultObj.addProperty("result", 1); jResultObj.addProperty("Cause", "success"); } catch (SQLNonTransientConnectionException ex1) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", "Server is down"); } catch (SQLException ex) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", ex.getMessage()); } } response.getWriter().print(jResultObj); }
From source file:account.UpdatePrize.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w ww . ja v a2 s . com*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String detailJson = request.getParameter("detail"); TypeToken<List<PrizeDrop>> token = new TypeToken<List<PrizeDrop>>() { }; final List<PrizeDrop> detail = new Gson().fromJson(detailJson, token.getType()); final ArrayList<PrizeDrop> data = (ArrayList<PrizeDrop>) detail; final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final Library lb = Library.getInstance(); final JsonObject jResultObj = new JsonObject(); if (dataConnection != null) { try { dataConnection.setAutoCommit(false); PreparedStatement pstLocal = null; PreparedStatement pstLocal1 = null; String sql = "insert into prize_drop (pur_tag_no,sr_no,voucher_no,v_date,remark,prev_rate,rate,ac_cd) values (?,?,?,CURRENT_DATE,?,?,?,?)"; String sql1 = "update tag set pur_rate=pur_rate-? where ref_no=?"; pstLocal = dataConnection.prepareStatement(sql); pstLocal1 = dataConnection.prepareStatement(sql1); for (int i = 0; i < data.size(); i++) { pstLocal.setString(1, data.get(i).getPur_tag_no()); pstLocal.setInt(2, i + 1); if (data.get(i).getVoucher_no().equalsIgnoreCase("")) { pstLocal.setString(3, lb.generateKey(dataConnection, "prize_drop", "voucher_no", "PZ", 7)); } else { pstLocal.setString(3, data.get(i).getVoucher_no()); } pstLocal.setString(4, data.get(i).getRemark()); pstLocal.setDouble(5, data.get(i).getPrevious_rate()); pstLocal.setDouble(6, data.get(i).getRate()); pstLocal.setString(7, data.get(i).getAc_cd()); pstLocal.executeUpdate(); pstLocal1.setDouble(1, data.get(i).getRate()); pstLocal1.setString(2, data.get(i).getPur_tag_no()); pstLocal1.executeUpdate(); sql = "update oldb2_1 set dr_" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "=dr_" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "+? where ac_CD=?"; PreparedStatement pstUpdate = dataConnection.prepareStatement(sql); pstUpdate.setDouble(1, data.get(i).getRate()); pstUpdate.setString(2, data.get(i).getAc_cd()); pstUpdate.executeUpdate(); sql = "insert into oldb2_2 (doc_ref_no,doc_date,doc_cd,ac_cd," + "val,crdr,particular,opp_ac_cd,time_stamp,INV_NO) values(?,CURRENT_DATE,?,?,?,?,?,?,CURRENT_TIMESTAMP,?)"; pstUpdate = dataConnection.prepareStatement(sql); pstUpdate.setString(1, "PD"); pstUpdate.setString(2, "PD"); pstUpdate.setString(3, data.get(i).getAc_cd()); pstUpdate.setDouble(4, data.get(i).getRate()); pstUpdate.setString(5, "0"); pstUpdate.setString(6, data.get(i).getRemark()); pstUpdate.setString(7, ""); pstUpdate.setString(8, "0"); pstUpdate.executeUpdate(); } dataConnection.commit(); dataConnection.setAutoCommit(true); jResultObj.addProperty("result", 1); jResultObj.addProperty("Cause", "success"); } catch (SQLNonTransientConnectionException ex1) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", "Server is down"); try { dataConnection.rollback(); dataConnection.setAutoCommit(true); } catch (SQLException ex) { Logger.getLogger(UpdatePrize.class.getName()).log(Level.SEVERE, null, ex); } } catch (SQLException ex) { jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", ex.getMessage()); try { dataConnection.rollback(); dataConnection.setAutoCommit(true); } catch (SQLException ex2) { Logger.getLogger(UpdatePrize.class.getName()).log(Level.SEVERE, null, ex2); } } } response.getWriter().print(jResultObj); }