List of usage examples for com.google.gson JsonObject JsonObject
JsonObject
From source file:account.SalesReport.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w w w. ja 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 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(); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "SELECT v.v_date,t.TAX_NAME,SUM(v1.BASIC_AMT) AS basic,SUM(v1.tax_amt) AS tax,SUM(v1.ADD_TAX_AMT) AS add_tax,SUM(v1.DISC_RATE) AS disc,SUM(v1.AMT) AS amt \n" + "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 modelmst m ON s.MODEL_CD=m.MODEL_CD\n" + "LEFT JOIN taxmst t ON m.TAX_CD=t.TAX_CD\n" + "WHERE v_type <> 1 AND v.IS_DEL=0 and v_date >='" + from_date + "' " + "and v_date <='" + to_date + "' and is_del=0 GROUP BY v.V_DATE,t.TAX_NAME ORDER BY v.V_DATE"; 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("TAX_NAME", viewDataRs.getString("TAX_NAME")); object.addProperty("basic", viewDataRs.getString("basic")); object.addProperty("tax", viewDataRs.getString("tax")); object.addProperty("add_tax", viewDataRs.getString("add_tax")); object.addProperty("disc", viewDataRs.getString("disc")); object.addProperty("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.SalesReportAccount.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from ww w . 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 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.v_date,v.V_TYPE,v.INV_NO,b.BRAND_NAME,m.MODEL_NAME,s.SR_NAME,v1.MRP,v.INS_AMT,v.branch_cd,v1.TAG_NO," + " (SELECT SUM(sale_rate) FROM tag WHERE tag_no=v1.tag_no) as rate 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 a.ac_cd=v.AC_CD LEFT JOIN modelmst m ON s.MODEL_CD=m.MODEL_CD " + " LEFT JOIN brandmst b ON b.BRAND_CD=m.BRAND_CD WHERE v.IS_DEL=0 and s.sr_cd not in('S000050','S000047') " + " 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("INV_NO", (viewDataRs.getString("inv_no") == null) ? "" : viewDataRs.getString("inv_no")); object.addProperty("V_TYPE", (viewDataRs.getString("v_type") == null) ? "" : viewDataRs.getString("v_type")); object.addProperty("BRAND_NAME", (viewDataRs.getString("BRAND_NAME") == null) ? "" : viewDataRs.getString("BRAND_NAME")); object.addProperty("MODEL_NAME", (viewDataRs.getString("MODEL_NAME") == null) ? "" : viewDataRs.getString("MODEL_NAME")); object.addProperty("SR_NAME", (viewDataRs.getString("sr_name") == null) ? "" : viewDataRs.getString("sr_name")); object.addProperty("MRP", (viewDataRs.getString("rate") == null) ? 0.00 : viewDataRs.getDouble("rate")); object.addProperty("INS_AMT", (viewDataRs.getString("INS_AMT") == null) ? 0.00 : viewDataRs.getDouble("INS_AMT")); object.addProperty("V_DATE", (viewDataRs.getString("v_date") == null) ? "" : viewDataRs.getString("v_date")); object.addProperty("TAG_NO", (viewDataRs.getString("TAG_NO") == null) ? "" : viewDataRs.getString("TAG_NO")); object.addProperty("branch_cd", (viewDataRs.getString("branch_cd") == null) ? "" : 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.SalesReportBrijesh.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w w 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 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.v_date,v.V_TYPE,v.INV_NO,b.BRAND_NAME,m.MODEL_NAME,s.SR_NAME,v1.MRP,v.INS_AMT,v.branch_cd,v1.TAG_NO," + " (SELECT SUM(sale_rate) FROM tag WHERE tag_no=v1.tag_no) as rate 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 a.ac_cd=v.AC_CD LEFT JOIN modelmst m ON s.MODEL_CD=m.MODEL_CD " + " LEFT JOIN brandmst b ON b.BRAND_CD=m.BRAND_CD WHERE v.IS_DEL=0 and s.sr_cd not in('S000050','S000047') " + " 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("INV_NO", viewDataRs.getString("inv_no")); object.addProperty("V_TYPE", viewDataRs.getString("v_type")); object.addProperty("BRAND_NAME", viewDataRs.getString("BRAND_NAME")); object.addProperty("MODEL_NAME", viewDataRs.getString("MODEL_NAME")); object.addProperty("SR_NAME", viewDataRs.getString("sr_name")); object.addProperty("MRP", viewDataRs.getString("rate")); object.addProperty("INS_AMT", viewDataRs.getString("INS_AMT")); object.addProperty("V_DATE", viewDataRs.getString("v_date")); object.addProperty("TAG_NO", viewDataRs.getString("TAG_NO")); 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.SalesReportTax.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w . j ava 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 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.v_date,v.INV_NO,a.FNAME,a.TIN,t.TAX_NAME,sum(v1.BASIC_AMT) AS basic,sum(v1.tax_amt) AS tax,sum(v1.ADD_TAX_AMT) AS add_tax,sum(v1.DISC_RATE) AS disc,sum(v1.AMT) AS amt \n" + "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 modelmst m ON s.MODEL_CD=m.MODEL_CD\n" + "LEFT JOIN taxmst t ON m.TAX_CD=t.TAX_CD LEFT JOIN acntmst a ON v.AC_CD=a.AC_CD\n" + "WHERE v_type = 1 AND v.IS_DEL=0 and v_date >='" + from_date + "' " + "and v_date <='" + to_date + "' group by v.v_date,v.inv_no,a.fname,a.tin,t.tax_name ORDER BY v.inv_no"; 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("INV_NO", viewDataRs.getString("INV_NO")); object.addProperty("FNAME", viewDataRs.getString("FNAME")); object.addProperty("TIN", viewDataRs.getString("TIN")); object.addProperty("TAX_NAME", viewDataRs.getString("TAX_NAME")); object.addProperty("basic", viewDataRs.getString("basic")); object.addProperty("tax", viewDataRs.getString("tax")); object.addProperty("add_tax", viewDataRs.getString("add_tax")); object.addProperty("disc", viewDataRs.getString("disc")); object.addProperty("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.SalesReturnRegister.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w w w . jav 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 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 branch_cd = Integer.parseInt(request.getParameter("branch_cd")); final int pmt_mode = Integer.parseInt(request.getParameter("pmt_mode")); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "select v.branch_cd,v.REF_NO,v.V_TYPE,v.inv_no,a.FNAME,v.V_DATE,v.DET_TOT,v.TAX_AMT,v.ADD_TAX_AMT,v.NET_AMT from " + " SRHD v left join acntmst a on v.AC_CD=a.AC_CD where v_date >='" + from_date + "' " + "and v_date <='" + to_date + "' and is_del=0 "; if (pmt_mode != 2) { sql += " and pmt_mode=" + pmt_mode; } if (branch_cd != 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("ref_no", viewDataRs.getString("REF_NO")); object.addProperty("v_type", viewDataRs.getString("V_TYPE")); object.addProperty("inv_no", viewDataRs.getString("inv_no")); object.addProperty("fname", viewDataRs.getString("FNAME")); object.addProperty("v_date", viewDataRs.getString("V_DATE")); object.addProperty("det_tot", viewDataRs.getString("DET_TOT")); object.addProperty("tax_amt", viewDataRs.getString("TAX_AMT")); object.addProperty("add_tax_amt", viewDataRs.getString("ADD_TAX_AMT")); object.addProperty("net_amt", viewDataRs.getString("NET_AMT")); 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.SalesReturnRegisterDetail.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from ww w .j a va 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 ac_cd = request.getParameter("ac_cd"); final DBHelper helper = DBHelper.GetDBHelper(); final Connection dataConnection = helper.getConnMpAdmin(); final JsonObject jResultObj = new JsonObject(); final int branch_cd = Integer.parseInt(request.getParameter("branch_cd")); final int pmt_mode = Integer.parseInt(request.getParameter("pmt_mode")); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "select v.ref_no,'Sales Return' as v_type," + " v.INV_NO,v.V_DATE,v.PMT_MODE," + " case when a.FNAME is null then '' else fname end as fname,s.SR_ALIAS,s.SR_NAME,v1.IMEI_NO," + " v1.SERAIL_NO,v1.QTY,v1.RATE,v1.BASIC_AMT,v1.TAX_AMT,v1.ADD_TAX_AMT,v1.DISC_RATE,v1.MRP,v1.AMT,v.NET_AMT,p.CASH_AMT," + " p.BANK_AMT,p.CARD_AMT,p.bajaj_amt,v.DET_TOT,v.branch_cd," + " t.TAX_NAME from SRHD v left join SRDT v1 on v.REF_NO =v1.REF_NO " + " left join acntmst a on v.AC_CD=a.AC_CD left join SERIESMST s on s.SR_CD=v1.SR_CD left join PAYMENT p on v.REF_NO=p.REF_NO " + " left join TAXMST t on v1.TAX_CD=t.TAX_CD where v_date >='" + from_date + "' and is_del=0 and v.v_date <='" + to_date + "'"; if (!ac_cd.equalsIgnoreCase("")) { sql += " and v.ac_cd='" + ac_cd + "' "; } if (pmt_mode != 2) { sql += " and v.pmt_mode=" + pmt_mode; } if (branch_cd != 0) { sql += " and v.branch_cd=" + branch_cd; } sql += " order by v.V_DATE,v.INV_NO,v1.tag_no,v1.is_main desc"; pstLocal = dataConnection.prepareStatement(sql); ResultSet viewDataRs = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("ref_no", viewDataRs.getString("REF_NO")); object.addProperty("v_type", viewDataRs.getString("V_TYPE")); object.addProperty("inv_no", viewDataRs.getString("inv_no")); object.addProperty("fname", viewDataRs.getString("FNAME")); object.addProperty("SR_ALIAS", viewDataRs.getString("SR_ALIAS")); object.addProperty("SR_NAME", viewDataRs.getString("SR_NAME")); object.addProperty("IMEI_NO", viewDataRs.getString("IMEI_NO")); object.addProperty("SERAIL_NO", viewDataRs.getString("SERAIL_NO")); object.addProperty("v_date", viewDataRs.getString("V_DATE")); object.addProperty("QTY", viewDataRs.getInt("QTY")); object.addProperty("RATE", viewDataRs.getDouble("RATE")); object.addProperty("BASIC_AMT", viewDataRs.getDouble("BASIC_AMT")); object.addProperty("tax_amt", viewDataRs.getDouble("TAX_AMT")); object.addProperty("add_tax_amt", viewDataRs.getDouble("ADD_TAX_AMT")); object.addProperty("DISC_RATE", viewDataRs.getDouble("DISC_RATE")); object.addProperty("MRP", viewDataRs.getDouble("MRP")); object.addProperty("AMT", viewDataRs.getDouble("AMT")); object.addProperty("det_tot", viewDataRs.getDouble("DET_TOT")); object.addProperty("CASH_AMT", viewDataRs.getDouble("CASH_AMT")); object.addProperty("BANK_AMT", viewDataRs.getDouble("BANK_AMT")); object.addProperty("CARD_AMT", viewDataRs.getDouble("CARD_AMT")); object.addProperty("net_amt", viewDataRs.getDouble("NET_AMT")); object.addProperty("tax_name", viewDataRs.getString("tax_name")); object.addProperty("bajaj_amt", viewDataRs.getDouble("bajaj_amt")); object.addProperty("branch_cd", viewDataRs.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.SalesReturnRegisterDetailAccount.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w w w. j ava2 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 int branch_cd = Integer.parseInt(request.getParameter("branch_cd")); final int pmt_mode = Integer.parseInt(request.getParameter("pmt_mode")); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "select v.ref_no,'Sales Return' as v_type,v.INV_NO," + "v.V_DATE,v.PMT_MODE,v1.DISC_RATE,v1.MRP," + " case when a.FNAME is null then '' else fname end as fname,s.SR_ALIAS,s.SR_NAME,v1.IMEI_NO,v.branch_cd," + " v1.SERAIL_NO,v1.QTY,v1.RATE,v1.AMT,v.DET_TOT,v1.TAX_AMT,v1.ADD_TAX_AMT,v.NET_AMT,p.CASH_AMT,p.BANK_AMT,p.CARD_AMT,p.bajaj_amt" + ",t.TAX_NAME" + " ,v1.basic_amt from SRHD v left join SRDT v1 on v.REF_NO =v1.REF_NO left join acntmst a on v.AC_CD=a.AC_CD " + " left join SERIESMST s on s.SR_CD=v1.SR_CD left join PAYMENT p on v.REF_NO=p.REF_NO left join TAXMST t on v1.TAX_CD=t.TAX_CD " + " where v_date >='" + from_date + "' " + " and is_del=0 and v.v_date <='" + to_date + "'"; if (!ac_cd.equalsIgnoreCase("")) { sql += " and v.ac_cd='" + ac_cd + "' "; } if (pmt_mode != 2) { sql += " and v.pmt_mode=" + pmt_mode; } if (branch_cd != 0) { sql += " and v.branch_cd=" + branch_cd; } sql += " order by v.V_DATE,v.INV_NO,v1.tag_no,v1.is_main desc"; pstLocal = dataConnection.prepareStatement(sql); ResultSet viewDataRs = pstLocal.executeQuery(); JsonArray array = new JsonArray(); while (viewDataRs.next()) { JsonObject object = new JsonObject(); object.addProperty("ref_no", viewDataRs.getString("REF_NO")); object.addProperty("v_type", viewDataRs.getString("V_TYPE")); object.addProperty("inv_no", viewDataRs.getString("inv_no")); object.addProperty("v_date", viewDataRs.getString("V_DATE")); object.addProperty("fname", viewDataRs.getString("FNAME")); object.addProperty("SR_ALIAS", viewDataRs.getString("SR_ALIAS")); object.addProperty("SR_NAME", viewDataRs.getString("SR_NAME")); object.addProperty("IMEI_NO", viewDataRs.getString("IMEI_NO")); object.addProperty("SERAIL_NO", viewDataRs.getString("SERAIL_NO")); object.addProperty("QTY", viewDataRs.getInt("QTY")); object.addProperty("RATE", viewDataRs.getDouble("RATE")); object.addProperty("DISC_RATE", viewDataRs.getDouble("DISC_RATE")); object.addProperty("MRP", viewDataRs.getDouble("MRP")); object.addProperty("AMT", viewDataRs.getDouble("AMT")); object.addProperty("BASIC_ITEM_AMT", viewDataRs.getDouble("basic_amt")); object.addProperty("det_tot", viewDataRs.getDouble("DET_TOT")); object.addProperty("tax_amt", viewDataRs.getDouble("TAX_AMT")); object.addProperty("add_tax_amt", viewDataRs.getDouble("ADD_TAX_AMT")); object.addProperty("CASH_AMT", viewDataRs.getDouble("CASH_AMT")); object.addProperty("BANK_AMT", viewDataRs.getDouble("BANK_AMT")); object.addProperty("CARD_AMT", viewDataRs.getDouble("CARD_AMT")); object.addProperty("net_amt", viewDataRs.getDouble("NET_AMT")); object.addProperty("tax_name", viewDataRs.getString("tax_name")); object.addProperty("bajaj_amt", viewDataRs.getDouble("bajaj_amt")); object.addProperty("branch_cd", viewDataRs.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.SalesReturnReportTax.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from ww w . j a v 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(); if (dataConnection != null) { try { PreparedStatement pstLocal = null; String sql = "SELECT v.v_date,v.INV_NO,a.FNAME,a.TIN,t.TAX_NAME,sum(v1.BASIC_AMT) AS basic,sum(v1.tax_amt) AS tax,sum(v1.ADD_TAX_AMT) AS add_tax,sum(v1.DISC_RATE) AS disc,sum(v1.AMT) AS amt \n" + "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 modelmst m ON s.MODEL_CD=m.MODEL_CD\n" + "LEFT JOIN taxmst t ON m.TAX_CD=t.TAX_CD LEFT JOIN acntmst a ON v.AC_CD=a.AC_CD\n" + "WHERE v.IS_DEL=0 and v_date >='" + from_date + "' " + "and v_date <='" + to_date + "' group by v.v_date,v.inv_no,a.fname,a.tin,t.tax_name ORDER BY v.inv_no"; 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("INV_NO", viewDataRs.getString("INV_NO")); object.addProperty("FNAME", viewDataRs.getString("FNAME")); object.addProperty("TIN", viewDataRs.getString("TIN")); object.addProperty("TAX_NAME", viewDataRs.getString("TAX_NAME")); object.addProperty("basic", viewDataRs.getString("basic")); object.addProperty("tax", viewDataRs.getString("tax")); object.addProperty("add_tax", viewDataRs.getString("add_tax")); object.addProperty("disc", viewDataRs.getString("disc")); object.addProperty("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.SetReconsilationDate.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 rec_date = request.getParameter("rec_date"); final String ref_no = (request.getParameter("ref_no")); final JsonObject jResultObj = new JsonObject(); Connection dataConnection = null; if (dataConnection == null) { dataConnection = helper.getConnMpAdmin(); } if (dataConnection != null) { try { dataConnection.setAutoCommit(false); String sql = ""; PreparedStatement pstLocal = null; if (ref_no.startsWith("BP") || ref_no.startsWith("BR")) { sql = "update oldb2_2 set rec_date=? where doc_ref_no=?"; pstLocal = dataConnection.prepareStatement(sql); if (rec_date.equalsIgnoreCase("")) { pstLocal.setString(1, null); } else { pstLocal.setString(1, rec_date); } pstLocal.setString(2, ref_no); pstLocal.executeUpdate(); sql = "update bprhd set rec_date=? where ref_no=?"; pstLocal = dataConnection.prepareStatement(sql); if (rec_date.equalsIgnoreCase("")) { pstLocal.setString(1, null); } else { pstLocal.setString(1, rec_date); } pstLocal.setString(2, ref_no); pstLocal.executeUpdate(); } if (ref_no.startsWith("02")) { sql = "update oldb2_2 set rec_date=? where doc_ref_no=?"; pstLocal = dataConnection.prepareStatement(sql); if (rec_date.equalsIgnoreCase("")) { pstLocal.setString(1, null); } else { pstLocal.setString(1, rec_date); } pstLocal.setString(2, ref_no); pstLocal.executeUpdate(); sql = "update vilshd set rec_date=? where ref_no=?"; pstLocal = dataConnection.prepareStatement(sql); if (rec_date.equalsIgnoreCase("")) { pstLocal.setString(1, null); } else { pstLocal.setString(1, rec_date); } pstLocal.setString(2, ref_no); pstLocal.executeUpdate(); } if (ref_no.startsWith("CV")) { sql = "update oldb2_2 set rec_date=? where doc_ref_no=?"; pstLocal = dataConnection.prepareStatement(sql); if (rec_date.equalsIgnoreCase("")) { pstLocal.setString(1, null); } else { pstLocal.setString(1, rec_date); } pstLocal.setString(2, ref_no); pstLocal.executeUpdate(); sql = "update contrahd set rec_date=? where ref_no=?"; pstLocal = dataConnection.prepareStatement(sql); if (rec_date.equalsIgnoreCase("")) { pstLocal.setString(1, null); } else { pstLocal.setString(1, rec_date); } pstLocal.setString(2, ref_no); pstLocal.executeUpdate(); } if (ref_no.startsWith("JV")) { sql = "update oldb2_2 set rec_date=? where doc_ref_no=?"; pstLocal = dataConnection.prepareStatement(sql); if (rec_date.equalsIgnoreCase("")) { pstLocal.setString(1, null); } else { pstLocal.setString(1, rec_date); } pstLocal.setString(2, ref_no); pstLocal.executeUpdate(); sql = "update jvhd set rec_date=? where ref_no=?"; pstLocal = dataConnection.prepareStatement(sql); if (rec_date.equalsIgnoreCase("")) { pstLocal.setString(1, null); } else { pstLocal.setString(1, rec_date); } pstLocal.setString(2, ref_no); pstLocal.executeUpdate(); } dataConnection.commit(); dataConnection.setAutoCommit(true); jResultObj.addProperty("result", 1); jResultObj.addProperty("Cause", "success"); } catch (SQLNonTransientConnectionException ex1) { ex1.printStackTrace(); jResultObj.addProperty("result", -1); jResultObj.addProperty("Cause", "Server is down"); } catch (SQLException ex) { ex.printStackTrace(); 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.TypeWiseBrandWiseProfitStatement.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from ww 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 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,brand_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 brandmst b on m.brand_cd=b.brand_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 m.type_cd='" + type_cd + "'"; } if (!branch_cd.equalsIgnoreCase("0")) { sql += " and v.branch_cd=" + branch_cd + ""; } sql += " group by brand_name,branch_cd order by brand_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("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); }