List of usage examples for com.google.gson JsonArray JsonArray
public JsonArray()
From source file:account.CreditNoteReport.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* 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 model_cd = (request.getParameter("model_cd")); final String memory_cd = (request.getParameter("memory_cd")); final String type_cd = (request.getParameter("type_cd")); final boolean sales = Boolean.parseBoolean((request.getParameter("sales"))); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "select t.ac_name as fname,s.sr_name,t.pur_date as v_date,t1.TYPE_NAME,(t.tag_no) as pcs,(t.PUR_RATE) as tot_sales,t.ref_no as pur_tag_no" + ",sales.V_DATE as sales_date,disc_per,extra_support,backend,activation,prize_drop 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 sales on t.SALE_REF_NO=sales.REF_NO where t.PUR_DATE>='" + from_date + "' " + " and t.PUR_DATE<='" + to_date + "' "; if (sales) { } else { sql += " and (sales.V_DATE>'" + to_date + "' or t.SALE_REF_NO='')"; } if (!model_cd.equalsIgnoreCase("")) { sql += " and m.model_cd='" + model_cd + "'"; } if (!memory_cd.equalsIgnoreCase("")) { sql += " and s.MEMORY_CD='" + memory_cd + "'"; } if (!type_cd.equalsIgnoreCase("")) { sql += " and m.type_cd='" + type_cd + "'"; } if (!ac_cd.equalsIgnoreCase("")) { sql += " and sales.ac_cd='" + ac_cd + "'"; } sql += " and t.is_del <> -1 order by t.PUR_DATE"; 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("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.getString("pcs")); object.addProperty("tot_sales", viewDataRs.getDouble("tot_sales")); object.addProperty("PUR_TAG_NO", viewDataRs.getString("PUR_TAG_NO")); object.addProperty("sales_date", viewDataRs.getString("sales_date")); object.addProperty("disc_per", viewDataRs.getString("disc_per")); object.addProperty("extra_support", viewDataRs.getString("extra_support")); object.addProperty("backend", viewDataRs.getString("backend")); object.addProperty("activation", viewDataRs.getString("activation")); object.addProperty("prize_drop", viewDataRs.getString("prize_drop")); 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.DailyBankStatementDetail.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//w ww . j a v a 2s. 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 from_date = request.getParameter("from_date"); final String to_date = request.getParameter("to_date"); final String branch_cd = request.getParameter("branch_cd"); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); final Library lb = Library.getInstance(); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "SELECT doc_date,branch_cd,doc_ref_no,(CASE WHEN CRDR=0 THEN val ELSE val*-1 END) AS bal FROM oldb2_2 \n" + " WHERE ac_cd IN (SELECT ac_cd FROM acntmst WHERE grp_cd IN (SELECT grp_cd FROM groupmst WHERE group_name='BANK')) " + " AND doc_cd <>'SL' " + " and doc_date>='" + from_date + "' " + " and doc_date<='" + to_date + "' and branch_cd <>0"; if (!branch_cd.equalsIgnoreCase("0")) { sql += " and 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("v_date", viewDataRs.getString("doc_date")); object.addProperty("bal", viewDataRs.getDouble("bal")); object.addProperty("branch_cd", viewDataRs.getString("branch_cd")); object.addProperty("doc_ref_no", viewDataRs.getString("doc_ref_no")); array.add(object); } lb.closeResultSet(viewDataRs); lb.closeStatement(pstLocal); 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()); } finally { lb.closeConnection(dataConnection); } } response.getWriter().print(jResultObj); }
From source file:account.DailyBankSummary.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w w w. 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 String from_date = request.getParameter("from_date"); final String to_date = request.getParameter("to_date"); final int branch_cd = Integer.parseInt(request.getParameter("branch_cd")); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); final Library lb = Library.getInstance(); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "SELECT branch_cd,doc_date,SUM(CASE WHEN CRDR=0 THEN val ELSE val*-1 END) AS bal FROM oldb2_2 \n" + " WHERE ac_cd IN (SELECT ac_cd FROM acntmst WHERE grp_cd IN (SELECT grp_cd FROM groupmst WHERE group_name='BANK')) " + " AND doc_cd <>'SL' " + " and doc_date>='" + from_date + "' " + " and doc_date<='" + to_date + "' and branch_cd =" + branch_cd + " group by doc_date,branch_cd"; pstLocal = dataConnection.prepareStatement(sql); ResultSet viewDataRs = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("v_date", viewDataRs.getString("doc_date")); object.addProperty("bal", viewDataRs.getDouble("bal")); object.addProperty("branch_cd", viewDataRs.getDouble("branch_cd")); array.add(object); } lb.closeResultSet(viewDataRs); lb.closeStatement(pstLocal); 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()); } finally { lb.closeConnection(dataConnection); } } response.getWriter().print(jResultObj); }
From source file:account.DailyCashStatementDetail.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from ww w.ja v a 2s . 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 from_date = request.getParameter("from_date"); final String to_date = request.getParameter("to_date"); final String branch_cd = request.getParameter("branch_cd"); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); final Library lb = Library.getInstance(); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "SELECT doc_date,branch_cd,doc_ref_no,(CASE WHEN CRDR=0 THEN val ELSE val*-1 END) AS bal FROM oldb2_2 \n" + " WHERE ac_cd IN (SELECT ac_cd FROM acntmst WHERE grp_cd IN (SELECT grp_cd FROM groupmst WHERE group_name='CASH')) " + " AND doc_cd <>'SL' " + " and doc_date>='" + from_date + "' " + " and doc_date<='" + to_date + "' and branch_cd <>0"; if (!branch_cd.equalsIgnoreCase("0")) { sql += " and 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("v_date", viewDataRs.getString("doc_date")); object.addProperty("bal", viewDataRs.getDouble("bal")); object.addProperty("branch_cd", viewDataRs.getString("branch_cd")); object.addProperty("doc_ref_no", viewDataRs.getString("doc_ref_no")); array.add(object); } lb.closeResultSet(viewDataRs); lb.closeStatement(pstLocal); 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()); } finally { lb.closeConnection(dataConnection); } } response.getWriter().print(jResultObj); }
From source file:account.DailyCashSummary.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w ww . jav a 2s . 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 from_date = request.getParameter("from_date"); final String to_date = request.getParameter("to_date"); final int branch_cd = Integer.parseInt(request.getParameter("branch_cd")); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); final Library lb = Library.getInstance(); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "SELECT doc_date,branch_cd,SUM(CASE WHEN CRDR=0 THEN val ELSE 0 END) AS dr_bal,SUM(CASE WHEN CRDR=0 THEN val ELSE val*-1 END) AS bal" + ",SUM(CASE WHEN CRDR=1 THEN val*-1 ELSE 0 END) AS cr_bal FROM oldb2_2 \n" + " WHERE ac_cd IN (SELECT ac_cd FROM acntmst WHERE grp_cd IN (SELECT grp_cd FROM groupmst WHERE group_name='CASH')) " + " AND doc_cd <>'SL' AND doc_cd <>'CO' " + " and doc_date>='" + from_date + "' " + " and doc_date<='" + to_date + "' and branch_cd =" + branch_cd + " group by doc_date,branch_cd"; pstLocal = dataConnection.prepareStatement(sql); ResultSet viewDataRs = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("v_date", viewDataRs.getString("doc_date")); object.addProperty("dr_bal", viewDataRs.getDouble("dr_bal")); object.addProperty("cr_bal", viewDataRs.getDouble("cr_bal")); object.addProperty("bal", viewDataRs.getDouble("bal")); object.addProperty("branch_cd", viewDataRs.getDouble("branch_cd")); array.add(object); } lb.closeResultSet(viewDataRs); lb.closeStatement(pstLocal); 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()); } finally { lb.closeConnection(dataConnection); } } response.getWriter().print(jResultObj); }
From source file:account.DailySalesStatement.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* w ww . 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 String from_date = request.getParameter("from_date"); final String to_date = request.getParameter("to_date"); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); final int mode = Integer.parseInt(request.getParameter("mode")); final int branch_cd = Integer.parseInt(request.getParameter("branch_cd")); final Library lb = Library.getInstance(); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "select v.branch_cd,v.v_date,sum(v.ins_amt) as ins,sum(net_amt) as net_amt,sum(v.head_disc) as MOP," + "sum(v.BUY_BACK_AMT) as buy_back,(SELECT SUM(disc_rate) FROM vilsdt v1 WHERE v1.REF_NO=v.REF_NO)AS adjst" + ",sum(p.CASH_AMT) as cash," + "sum(p.CARD_AMT) as card,sum(p.BANK_AMT) as bank,sum(p.BAJAJ_AMT) as bajaj" + " from VILSHD v left join PAYMENT p on v.REF_NO=p.REF_NO where is_del =0 " + " and v.v_date>='" + from_date + "' " + " and v.v_date<='" + to_date + "'"; if (mode != 2) { sql += " and v.V_TYPE=" + mode; } if (branch_cd != 0) { sql += " and v.branch_cd=" + branch_cd; } sql += " group by v.v_date,v.branch_cd"; pstLocal = dataConnection.prepareStatement(sql); ResultSet viewDataRs = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("v_date", viewDataRs.getString("v_date")); object.addProperty("ins", viewDataRs.getDouble("ins")); object.addProperty("net_amt", viewDataRs.getDouble("net_amt")); object.addProperty("buy_back", viewDataRs.getDouble("buy_back")); object.addProperty("cash", viewDataRs.getDouble("cash")); object.addProperty("card", viewDataRs.getString("card")); object.addProperty("bank", viewDataRs.getString("bank")); object.addProperty("bajaj", viewDataRs.getString("bajaj")); object.addProperty("adjst", viewDataRs.getString("adjst")); object.addProperty("MOP", viewDataRs.getString("MOP")); object.addProperty("branch_cd", viewDataRs.getString("branch_cd")); array.add(object); } lb.closeResultSet(viewDataRs); lb.closeStatement(pstLocal); 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()); } finally { lb.closeConnection(dataConnection); } } response.getWriter().print(jResultObj); }
From source file:account.DailySalesStatementDetail.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 DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); final int mode = Integer.parseInt(request.getParameter("mode")); final int branch_cd = Integer.parseInt(request.getParameter("branch_cd")); final Library lb = Library.getInstance(); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "SELECT v.branch_cd,v.inv_no,v.v_type,a.fname,v.v_date,(p.card_chg+p.bajaj_chg) AS ins,(NET_AMT) AS net_amt,SUM(v1.DISC_RATE) AS adjst,\n" + " (v.BUY_BACK_AMT) AS buy_back,(p.CASH_AMT) AS cash,(p.CARD_AMT) AS card,(p.BANK_AMT) AS bank,(p.BAJAJ_AMT) AS bajaj,(p.DISC_AMT) AS mop " + " ,p.card_no,tid_no FROM VILSHD v LEFT JOIN PAYMENT p ON v.REF_NO=p.REF_NO LEFT JOIN acntmst a ON v.ac_cd=a.ac_cd\n" + " LEFT JOIN vilsdt v1 ON v.REF_NO=v1.REF_NO WHERE is_del =0 " + " and v.v_date>='" + from_date + "' " + " and v.v_date<='" + to_date + "'"; if (mode != 2) { sql += " and v.V_TYPE=" + mode; } if (branch_cd != 0) { sql += " and v.branch_cd=" + branch_cd; } sql += " GROUP BY v.REF_NO order by v.v_date,v.v_type,v.inv_no"; pstLocal = dataConnection.prepareStatement(sql); ResultSet viewDataRs = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("inv_no", viewDataRs.getString("inv_no")); object.addProperty("v_type", viewDataRs.getString("v_type")); object.addProperty("fname", viewDataRs.getString("fname")); object.addProperty("v_date", viewDataRs.getString("v_date")); object.addProperty("ins", viewDataRs.getDouble("ins")); object.addProperty("net_amt", viewDataRs.getDouble("net_amt")); object.addProperty("buy_back", viewDataRs.getDouble("buy_back")); object.addProperty("cash", viewDataRs.getDouble("cash")); object.addProperty("card", viewDataRs.getString("card")); object.addProperty("bank", viewDataRs.getString("bank")); object.addProperty("bajaj", viewDataRs.getString("bajaj")); object.addProperty("adjst", viewDataRs.getString("adjst")); object.addProperty("branch_cd", viewDataRs.getString("branch_cd")); object.addProperty("MOP", viewDataRs.getString("MOP")); object.addProperty("card_no", viewDataRs.getString("card_no")); object.addProperty("tid_no", viewDataRs.getString("tid_no")); array.add(object); } lb.closeResultSet(viewDataRs); lb.closeStatement(pstLocal); 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()); } finally { lb.closeConnection(dataConnection); } } response.getWriter().print(jResultObj); }
From source file:account.DCRegister.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w . j av a 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 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"); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "select d.ref_no,FNAME,d.INV_NO,d.V_DATE,d1.TAG_NO,s.SR_NAME,d1.RATE,d1.remark from DCHD d left join DCDT d1 on d.REF_NO=d1.REF_NO " + " left join ACNTMST a on d.AC_CD=a.AC_CD left join SERIESMST s on d1.SR_CD=s.SR_CD " + " left join modelmst m on m.model_cd = s.model_cd where d.IS_DEL=0" + " and d.v_date>='" + from_date + "' " + " and d.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 s.brand_cd='" + brand_cd + "'"; } else if (!model_cd.equalsIgnoreCase("")) { sql += " and s.model_cd='" + model_cd + "'"; } if (!ac_cd.equalsIgnoreCase("")) { sql += " and d.ac_cd='" + ac_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("SR_NAME", viewDataRs.getString("SR_NAME")); object.addProperty("V_DATE", viewDataRs.getString("V_DATE")); object.addProperty("RATE", viewDataRs.getDouble("RATE")); object.addProperty("TAG_NO", viewDataRs.getString("TAG_NO")); object.addProperty("REF_NO", viewDataRs.getString("REF_NO")); object.addProperty("REMARK", viewDataRs.getString("REMARK")); 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.EOD.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w ww.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 String from_date = request.getParameter("from_date"); final String to_date = request.getParameter("to_date"); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); final int mode = Integer.parseInt(request.getParameter("mode")); final int branch_cd = Integer.parseInt(request.getParameter("branch_cd")); final Library lb = Library.getInstance(); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "select sum(v.ins_amt) as ins,sum(net_amt) as net_amt,sum(v.head_disc) as MOP," + "sum(v.BUY_BACK_AMT) as buy_back,(SELECT SUM(disc_rate) FROM vilsdt v1 WHERE v1.REF_NO=v.REF_NO)AS adjst" + ",sum(p.CASH_AMT) as cash," + "sum(p.CARD_AMT) as card,sum(p.BANK_AMT) as bank,sum(p.BAJAJ_AMT) as bajaj" + " from VILSHD v left join PAYMENT p on v.REF_NO=p.REF_NO where is_del =0 " + " and v.v_date>='" + from_date + "' " + " and v.v_date<='" + to_date + "'"; if (mode != 2) { sql += " and v.V_TYPE=" + mode; } if (branch_cd != 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("ins", viewDataRs.getDouble("ins")); object.addProperty("net_amt", viewDataRs.getDouble("net_amt")); object.addProperty("buy_back", viewDataRs.getDouble("buy_back")); object.addProperty("cash", viewDataRs.getDouble("cash")); object.addProperty("card", viewDataRs.getString("card")); object.addProperty("bank", viewDataRs.getString("bank")); object.addProperty("bajaj", viewDataRs.getString("bajaj")); object.addProperty("adjst", viewDataRs.getString("adjst")); array.add(object); } lb.closeResultSet(viewDataRs); lb.closeStatement(pstLocal); 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()); } finally { lb.closeConnection(dataConnection); } } response.getWriter().print(jResultObj); }
From source file:account.GenralLedger.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// w ww . ja 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 { DBHelper helper = DBHelper.GetDBHelper(); dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); ac_cd = request.getParameter("ac_cd"); from_date = request.getParameter("from_date"); to_date = request.getParameter("to_date"); try { if (dataConnection != null) { double opb = 0.00; String sql = "(select (select case when sum(val) is null then 0 else sum(val)end from OLDB2_2 where AC_CD='" + ac_cd + "' and DOC_DATE<'" + from_date + "' and CRDR=0) -" + "(select case when sum(val) is null then 0 else sum(val)end from OLDB2_2 where AC_CD='" + ac_cd + "' " + "and DOC_DATE<'" + from_date + "' and CRDR=1) as opb from dual) "; PreparedStatement pstLocal = dataConnection.prepareStatement(sql); viewDataRS = pstLocal.executeQuery(); if (viewDataRS.next()) { jResultObj.addProperty("opb", viewDataRS.getDouble("opb")); opb = viewDataRS.getDouble("opb"); } else { jResultObj.addProperty("opb", 0.00); } makeQuery(); double opbRs = 0.00; JsonArray array = new JsonArray(); while (viewDataRS.next()) { JsonObject object = new JsonObject(); object.addProperty("FNAME", viewDataRS.getString("FNAME")); if (viewDataRS.getString("DOC_REF_NO").startsWith("05")) { object.addProperty("DOC_REF_NO", viewDataRS.getString("BILL_NO")); } else if (viewDataRS.getString("DOC_REF_NO").startsWith("02")) { object.addProperty("DOC_REF_NO", viewDataRS.getString("INV_NO")); } else if (viewDataRS.getString("INV_NO").equalsIgnoreCase("0")) { object.addProperty("DOC_REF_NO", viewDataRS.getString("DOC_REF_NO")); } else { object.addProperty("DOC_REF_NO", viewDataRS.getString("INV_NO")); } object.addProperty("DOC_DATE", viewDataRS.getString("DOC_DATE")); object.addProperty("DOC_CD", viewDataRS.getString("DOC_CD")); object.addProperty("DR", lb.roundOffDoubleValue(viewDataRS.getDouble("DR"))); object.addProperty("CR", lb.roundOffDoubleValue(viewDataRS.getDouble("CR"))); opbRs += viewDataRS.getDouble("DR") - viewDataRS.getDouble("CR"); object.addProperty("BAL", lb.roundOffDoubleValue(opbRs)); object.addProperty("PARTICULAR", viewDataRS.getString("PARTICULAR")); object.addProperty("OPP_AC_CD", viewDataRS.getString("OPP_AC_CD")); object.addProperty("REF_NO", viewDataRS.getString("doc_ref_no")); object.addProperty("OPB", opb); array.add(object); } jResultObj.addProperty("opb", opb); 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()); } finally { lb.closeConnection(dataConnection); } response.getWriter().print(jResultObj); }