List of usage examples for com.google.gson JsonObject JsonObject
JsonObject
From source file:account.GetInsuranceRegister.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w w w .j a v a 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 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 { String sql = "select v1.branch_cd,v.ref_no,v1.inv_no,a.FNAME,(a1.ADD1||' '||a1.ADD2||' '||a1.ADD3) as ADD1,p.MOBILE1,s.SR_NAME,v1.V_DATE as ins_date,v.TAG_NO,v1.INS_AMT,v.RATE,v1.V_DATE from vilsdt v " + " left join SERIESMST s on v.SR_CD=s.SR_CD left join VILSHD v1 on v.REF_NO=v1.REF_NO left join acntmst a on v1.AC_CD=a.AC_CD " + " left join adbkmst a1 on a.AC_CD=a1.AC_CD left join phbkmst p on a.AC_CD=p.AC_CD " + " where v1.V_DATE>='" + from_date + "'" + " and v1.V_DATE<='" + to_date + "' and v1.is_del=0 " + " and (v.IMEI_NO<>'' or v.SERAIL_NO<>'') and INS_CD<>''"; if (branch_cd != 0) { sql += " and v1.branch_cd=" + branch_cd; } sql += " order by v1.V_DATE"; PreparedStatement 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("ADD1", viewDataRs.getString("ADD1")); object.addProperty("MOBILE1", viewDataRs.getString("MOBILE1")); object.addProperty("SR_NAME", viewDataRs.getString("SR_NAME")); object.addProperty("INS_DATE", viewDataRs.getString("ins_date")); object.addProperty("TAG_NO", viewDataRs.getString("TAG_NO")); object.addProperty("INV_NO", viewDataRs.getString("INV_NO")); object.addProperty("INS_AMT", viewDataRs.getDouble("INS_AMT")); object.addProperty("RATE", viewDataRs.getDouble("RATE")); object.addProperty("REF_NO", viewDataRs.getString("REF_NO")); 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.GetModelwiseMonthWiseSalesStatement.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w .j a va2 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 code = request.getParameter("code"); final String mode = request.getParameter("mode"); final String type_cd = request.getParameter("type_cd"); final String sub_type_cd = request.getParameter("sub_type_cd"); final String GD_CD = request.getParameter("GD_CD"); final String before_date = request.getParameter("before_date"); final String after_date = request.getParameter("after_date"); final String equal_date = request.getParameter("equal_date"); final String date_mode = request.getParameter("date_mode"); final String before_rate = request.getParameter("before_rate"); final String after_rate = request.getParameter("after_rate"); final String rate_mode = request.getParameter("rate_mode"); 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 { String sql = "SELECT t.branch_cd,SR_NAME,SUM(CASE WHEN DATEDIFF( CASE WHEN l.v_date IS NOT NULL THEN l.v_date WHEN t.PUR_DATE IS NOT NULL THEN t.PUR_DATE ELSE '2016-04-01' END ,v.V_DATE)*-1 <=15 " + " THEN 1 ELSE 0 END) AS day_15, " + " SUM(CASE WHEN DATEDIFF( CASE WHEN l.v_date IS NOT NULL THEN l.v_date WHEN t.PUR_DATE IS NOT NULL THEN t.PUR_DATE ELSE '2016-04-01' END ,v.V_DATE)*-1 <=45 and " + " DATEDIFF( CASE WHEN l.v_date IS NOT NULL THEN l.v_date WHEN t.PUR_DATE IS NOT NULL THEN t.PUR_DATE ELSE '2016-04-01' END ,v.V_DATE)*-1 >15 " + " THEN 1 ELSE 0 END )AS day_45, " + " SUM(CASE WHEN DATEDIFF( CASE WHEN l.v_date IS NOT NULL THEN l.v_date WHEN t.PUR_DATE IS NOT NULL THEN t.PUR_DATE ELSE '2016-04-01' END ,v.V_DATE)*-1 <=90 and " + " DATEDIFF( CASE WHEN l.v_date IS NOT NULL THEN l.v_date WHEN t.PUR_DATE IS NOT NULL THEN t.PUR_DATE ELSE '2016-04-01' END ,v.V_DATE)*-1 >45 " + " THEN 1 ELSE 0 END )AS day_90, " + " SUM(CASE WHEN DATEDIFF( CASE WHEN l.v_date IS NOT NULL THEN l.v_date WHEN t.PUR_DATE IS NOT NULL THEN t.PUR_DATE ELSE '2016-04-01' END ,v.V_DATE)*-1 >90 " + " THEN 1 ELSE 0 END ) AS day_100 " + " 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 brandmst b ON m.brand_cd=b.brand_cd " + " LEFT JOIN lbrphd l ON l.ref_no=t.PUR_REF_NO LEFT JOIN vilshd v ON v.REF_NO=t.SALE_REF_NO" + " LEFT JOIN acntmst a ON l.ac_cd=a.ac_cd WHERE t.is_del = 1 " + " "; if (mode.equalsIgnoreCase("brand")) { if (!code.equalsIgnoreCase("")) { sql += " and b.BRAND_CD='" + code + "'"; } } if (mode.equalsIgnoreCase("series")) { if (!code.equalsIgnoreCase("")) { sql += " and s.sr_cd='" + code + "'"; } } if (mode.equalsIgnoreCase("model")) { if (!code.equalsIgnoreCase("")) { sql += " and m.model_cd='" + code + "'"; } } if (date_mode.equalsIgnoreCase("2")) { sql += " and v_date <'" + before_date + "'"; } if (date_mode.equalsIgnoreCase("3")) { sql += " and v_date >'" + after_date + "'"; } if (date_mode.equalsIgnoreCase("4")) { sql += " and v_date ='" + equal_date + "'"; } if (rate_mode.equalsIgnoreCase("2")) { sql += " and PUR_RATE <" + before_rate + ""; } if (rate_mode.equalsIgnoreCase("3")) { sql += " and PUR_RATE >=" + after_rate + ""; } if (!type_cd.equalsIgnoreCase("")) { sql += " and m.type_cd='" + type_cd + "'"; } if (!sub_type_cd.equalsIgnoreCase("")) { sql += " and m.sub_type_cd='" + sub_type_cd + "'"; } if (!GD_CD.equalsIgnoreCase("2")) { sql += " and godown =" + GD_CD; } if (!branch_cd.equalsIgnoreCase("")) { sql += " and t.branch_cd='" + branch_cd + "' "; } sql += " GROUP BY t.branch_cd,sr_name"; PreparedStatement pstLocal = dataConnection.prepareStatement(sql); ResultSet rsLocal = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (rsLocal.next()) { JsonObject object = new JsonObject(); object.addProperty("SR_NAME", rsLocal.getString("SR_NAME")); object.addProperty("day_15", rsLocal.getString("day_15")); object.addProperty("day_45", rsLocal.getString("day_45")); object.addProperty("day_90", rsLocal.getString("day_90")); object.addProperty("day_100", rsLocal.getString("day_100")); object.addProperty("branch_cd", rsLocal.getString("branch_cd")); array.add(object); } lb.closeResultSet(rsLocal); 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.IMEWisePS.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w ww. ja v a2s .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 model_cd = request.getParameter("model_cd"); final String brand_cd = request.getParameter("brand_cd"); final String ac_cd = request.getParameter("ac_cd"); final String type_cd = request.getParameter("type_cd"); final String bill_no = request.getParameter("bill_no"); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); if (dataConnection != null) { try { String sql = "select a.FNAME,l.V_DATE,TAG_NO,SR_NAME,PUR_RATE,SALE_RATE,b.BRAND_NAME 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 brandmst b on m.brand_cd=b.brand_cd " + " left join LBRPHD l on l.REF_NO=t.PUR_REF_NO left join ACNTMST a on l.AC_CD=a.AC_CD where t.TAG_NO <> ''"; if (bill_no.equalsIgnoreCase("")) { sql += " and l.v_date>='" + from_date + "' and " + " l.v_date<='" + to_date + "'"; } else { sql += " and l.inv_no=" + bill_no; } if (!model_cd.equalsIgnoreCase("")) { sql += " and m.model_cd ='" + model_cd + "'"; } if (!brand_cd.equalsIgnoreCase("")) { sql += " and m.brand_cd ='" + brand_cd + "'"; } if (!ac_cd.equalsIgnoreCase("")) { sql += " and l.ac_cd ='" + ac_cd + "'"; } if (!type_cd.equalsIgnoreCase("")) { sql += " and m.type_cd ='" + type_cd + "'"; } sql += " order by l.v_date"; PreparedStatement pstLocal = dataConnection.prepareStatement(sql); ResultSet rsLocal = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (rsLocal.next()) { JsonObject object = new JsonObject(); object.addProperty("FNAME", rsLocal.getString("FNAME")); object.addProperty("V_DATE", rsLocal.getString("V_DATE")); object.addProperty("TAG_NO", rsLocal.getString("TAG_NO")); object.addProperty("SR_NAME", rsLocal.getString("SR_NAME")); object.addProperty("BRAND_NAME", rsLocal.getString("BRAND_NAME")); object.addProperty("PUR_RATE", rsLocal.getDouble("PUR_RATE")); object.addProperty("SALE_RATE", rsLocal.getDouble("SALE_RATE")); 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.IMEWisePSSales.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from www .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 { final String from_date = request.getParameter("from_date"); final String to_date = request.getParameter("to_date"); final String model_cd = request.getParameter("model_cd"); final String brand_cd = request.getParameter("brand_cd"); final String ac_cd = request.getParameter("ac_cd"); final String type_cd = request.getParameter("type_cd"); final String bill_no = request.getParameter("bill_no"); final boolean include = Boolean.parseBoolean(request.getParameter("include")); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); if (dataConnection != null) { try { String sql = "select a.FNAME,l.V_DATE,TAG_NO,SR_NAME,PUR_RATE,SALE_RATE,b.BRAND_NAME 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 brandmst b on m.brand_cd=b.brand_cd " + " left join VILSHD l on l.REF_NO=t.SALE_REF_NO left join ACNTMST a on l.AC_CD=a.AC_CD where t.TAG_NO <> ''"; if (bill_no.equalsIgnoreCase("")) { sql += " and l.v_date>='" + from_date + "' and " + " l.v_date<='" + to_date + "'"; } else { sql += " and l.inv_no=" + bill_no; } if (!model_cd.equalsIgnoreCase("")) { sql += " and m.model_cd ='" + model_cd + "'"; } if (!brand_cd.equalsIgnoreCase("")) { sql += " and m.brand_cd ='" + brand_cd + "'"; } if (!ac_cd.equalsIgnoreCase("")) { if (include) { sql += " and l.ac_cd ='" + ac_cd + "'"; } else { sql += " and l.ac_cd <>'" + ac_cd + "'"; } } if (!type_cd.equalsIgnoreCase("")) { sql += " and m.type_cd ='" + type_cd + "'"; } sql += " order by l.v_date"; PreparedStatement pstLocal = dataConnection.prepareStatement(sql); ResultSet rsLocal = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (rsLocal.next()) { JsonObject object = new JsonObject(); object.addProperty("FNAME", rsLocal.getString("FNAME")); object.addProperty("V_DATE", rsLocal.getString("V_DATE")); object.addProperty("TAG_NO", rsLocal.getString("TAG_NO")); object.addProperty("SR_NAME", rsLocal.getString("SR_NAME")); object.addProperty("BRAND_NAME", rsLocal.getString("BRAND_NAME")); object.addProperty("PUR_RATE", rsLocal.getDouble("PUR_RATE")); object.addProperty("SALE_RATE", rsLocal.getDouble("SALE_RATE")); 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.ListBills.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w ww . ja v a2s .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 ac_cd = request.getParameter("ac_cd"); final DBHelper helper = DBHelper.GetDBHelper(); final Library lb = Library.getInstance(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); final boolean sales = Boolean.parseBoolean((request.getParameter("sales"))); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "SELECT * FROM oldb2_4 WHERE ac_cd='" + ac_cd + "' and unpaid_amt <> 0"; if (sales) { sql += " AND tot_amt>0"; } else { sql += " AND tot_amt<0"; } sql += " order by DOC_DATE"; pstLocal = dataConnection.prepareStatement(sql); ResultSet viewDataRs = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("DOC_REF_NO", viewDataRs.getString("DOC_REF_NO")); object.addProperty("DOC_CD", viewDataRs.getString("DOC_CD")); object.addProperty("INV_NO", viewDataRs.getString("INV_NO")); object.addProperty("DOC_DATE", viewDataRs.getString("DOC_DATE")); object.addProperty("TOT_AMT", viewDataRs.getString("TOT_AMT")); object.addProperty("UNPAID_AMT", viewDataRs.getString("UNPAID_AMT")); object.addProperty("SR_NO", viewDataRs.getString("SR_NO")); if (lb.isDeleted(dataConnection, viewDataRs.getString("DOC_REF_NO"))) { array.add(object); } } jResultObj.addProperty("result", 1); jResultObj.addProperty("balance", lb.getBalance(dataConnection, ac_cd)); 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.ListBillsAdjsted.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w ww .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 ac_cd = request.getParameter("ac_cd"); final DBHelper helper = DBHelper.GetDBHelper(); final Library lb = Library.getInstance(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "SELECT doc_ref_no,dr_doc_cd,dr_inv_no,cr_doc_cd,cr_inv_no,amt,DR_DOC_REF_NO,CR_DOC_REF_NO FROM billadjst WHERE " + " DR_DOC_REF_NO IN (SELECT doc_ref_no FROM oldb2_2 WHERE ac_cd='" + ac_cd + "') OR " + " CR_DOC_REF_NO IN (SELECT doc_ref_no FROM oldb2_2 WHERE 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("DOC_REF_NO", viewDataRs.getString("DOC_REF_NO")); object.addProperty("DR_DOC_CD", viewDataRs.getString("DR_DOC_CD")); object.addProperty("CR_DOC_CD", viewDataRs.getString("CR_DOC_CD")); object.addProperty("DR_INV_NO", viewDataRs.getString("DR_INV_NO")); object.addProperty("CR_INV_NO", viewDataRs.getString("CR_INV_NO")); object.addProperty("TOT_AMT", viewDataRs.getString("AMT")); 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.MarginReport.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//w w w . j av a 2s .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 mode = request.getParameter("mode"); 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 int v_type = Integer.parseInt(request.getParameter("v_type")); 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 { String sql = "select v.branch_cd,TAG_NO,SR_NAME,BASIC_PUR_RATE AS PUR_RATE,SALE_RATE,b.BRAND_NAME,pur_ref_no,sale_ref_no 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 brandmst b on m.brand_cd=b.brand_cd" + " left join VILSHD v on t.SALE_REF_NO = v.REF_NO " + " where v.v_date>='" + from_date + "' and " + " v.v_date<='" + to_date + "' and v.is_del=0 and t.is_del=1 "; if (mode.equalsIgnoreCase("1")) { sql += " and (PUR_RATE-SALE_RATE) <0"; } if (v_type != 0) { sql += " and v.v_type =" + (v_type - 1); } if (mode.equalsIgnoreCase("2")) { sql += " and (PUR_RATE-SALE_RATE) =0"; } if (mode.equalsIgnoreCase("3")) { sql += " and (PUR_RATE-SALE_RATE) >0"; } 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 (!branch_cd.equalsIgnoreCase("0")) { sql += " and v.branch_cd=" + branch_cd; } sql += " order by SR_NAME"; // String sql = "select t.TAG_NO,SR_NAME,PUR_RATE,SALE_RATE,b.BRAND_NAME 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 brandmst b on " // + "m.brand_cd=b.brand_cd left join vilshd v on t.sale_ref_no=v.ref_no " // + " where v.v_date>='" + from_date + "' and " // + " v.v_date<='" + to_date + "' "; // sql += " order by SR_NAME"; PreparedStatement pstLocal = dataConnection.prepareStatement(sql); ResultSet rsLocal = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (rsLocal.next()) { JsonObject object = new JsonObject(); object.addProperty("TAG_NO", rsLocal.getString("TAG_NO")); object.addProperty("SR_NAME", rsLocal.getString("SR_NAME")); object.addProperty("PUR_RATE", rsLocal.getDouble("PUR_RATE")); object.addProperty("SALE_RATE", rsLocal.getDouble("SALE_RATE")); object.addProperty("PUR_REF_NO", rsLocal.getString("PUR_REF_NO")); object.addProperty("SALE_REF_NO", rsLocal.getString("SALE_REF_NO")); object.addProperty("branch_cd", rsLocal.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.MarginReportByTag.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String tag_no = request.getParameter("tag_no"); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); if (dataConnection != null) { try {/*from w ww . jav a2 s. com*/ String sql = "select t.branch_cd,TAG_NO,SR_NAME,PUR_RATE,SALE_RATE from tag t left join " + " SERIESMST s on t.sr_cd=s.sr_cd " + " where t.tag_no='" + tag_no + "' and t.is_del=1 "; sql += " order by SR_NAME"; PreparedStatement pstLocal = dataConnection.prepareStatement(sql); ResultSet rsLocal = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (rsLocal.next()) { JsonObject object = new JsonObject(); object.addProperty("TAG_NO", rsLocal.getString("TAG_NO")); object.addProperty("SR_NAME", rsLocal.getString("SR_NAME")); object.addProperty("PUR_RATE", rsLocal.getDouble("PUR_RATE")); object.addProperty("SALE_RATE", rsLocal.getDouble("SALE_RATE")); object.addProperty("branch_cd", rsLocal.getDouble("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.Phonebook.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from ww w . jav a2 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 String group_cd = request.getParameter("grp_cd"); final int v_type = Integer.parseInt(request.getParameter("v_type")); final boolean sales = Boolean.parseBoolean(request.getParameter("sales")); Library lb = Library.getInstance(); if (dataConnection != null) { try { PreparedStatement pstLocal = null; if (sales) { String sql = "select distinct(a.ac_cd),a.fname,concat(a1.add1,a1.add2,a1.add3) as address,(MOBILE1),email from VILSHD v " + " left join acntmst a on v.ac_cd=a.ac_cd left join phbkmst p1 on p1.ac_cd=a.ac_cd left join adbkmst a1 on a1.ac_cd=a.ac_cd" + " where v.IS_DEL=0 AND LENGTH(mobile1)>8 " + " and v.v_date>='" + from_date + "' " + " and v.v_date<='" + to_date + "'"; if (!group_cd.equalsIgnoreCase("")) { sql += " and a.grp_cd='" + group_cd + "' "; } if (v_type != 2) { sql += " and v.v_type=" + v_type; } 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("MOBILE1", (viewDataRs.getString("MOBILE1") == null) ? "" : viewDataRs.getString("MOBILE1")); object.addProperty("address", (viewDataRs.getString("address") == null) ? "" : viewDataRs.getString("address")); object.addProperty("EMAIL", (viewDataRs.getString("EMAIL") == null) ? "" : viewDataRs.getString("EMAIL")); array.add(object); } jResultObj.addProperty("result", 1); jResultObj.add("data", array); } else { String sql = "select distinct(a.ac_cd),a.fname,concat(a1.add1,a1.add2,a1.add3) as address,(MOBILE1),email from" + " acntmst a left join phbkmst p1 on p1.ac_cd=a.ac_cd left join adbkmst a1 on a1.ac_cd=a.ac_cd" + " where LENGTH(mobile1)>8 "; if (!group_cd.equalsIgnoreCase("")) { sql += " and a.group_cd='" + group_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("MOBILE1", (viewDataRs.getString("MOBILE1") == null) ? "" : viewDataRs.getString("MOBILE1")); object.addProperty("address", (viewDataRs.getString("address") == null) ? "" : viewDataRs.getString("address")); object.addProperty("EMAIL", (viewDataRs.getString("EMAIL") == null) ? "" : viewDataRs.getString("EMAIL")); array.add(object); } jResultObj.addProperty("result", 1); 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.PurchaseRateByTag.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from 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 { final String tag_no = request.getParameter("tag_no"); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); if (dataConnection != null) { try { String sql = "select TAG_NO,SR_NAME,PUR_RATE from tag t left join " + " SERIESMST s on t.sr_cd=s.sr_cd " + " where t.tag_no='" + tag_no + "' and t.is_del=0 "; sql += " order by SR_NAME"; PreparedStatement pstLocal = dataConnection.prepareStatement(sql); ResultSet rsLocal = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (rsLocal.next()) { JsonObject object = new JsonObject(); object.addProperty("TAG_NO", rsLocal.getString("TAG_NO")); object.addProperty("SR_NAME", rsLocal.getString("SR_NAME")); object.addProperty("PUR_RATE", rsLocal.getDouble("PUR_RATE")); 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); }