Sunday, February 6, 2011

Database and Jsp



<%@ page import="java.sql.*, java.net.*, java.io.*, java.util.*"%>




<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.Properties"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="css/style_ie.css">
<title>Search</title>
<%
      Connection conn = null;
      CallableStatement procCall, procCall1 = null;
      ResultSet rs = null;
      ResultSet rs1 = null;
      String Searchaction = "";
      try {
            Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
            conn = DriverManager.getConnection("jdbc:sqlserver://nydev05:1433;Database=GTControl","GTCERTHub", "GTCERTHub");
            procCall = conn.prepareCall("{? = call GTControl..spqGetMarket()}");
            procCall.registerOutParameter(1, Types.BIGINT);
            rs = procCall.executeQuery();
            Searchaction = request.getParameter("btnSearch");
            if(Searchaction != null && Searchaction.equals("Search")){
                  procCall1 = conn.prepareCall("{? = call GTControl..spqSearchSecurities(?, ?, ?, ?)}");                       
                  procCall1.registerOutParameter(1, Types.BIGINT);
                  procCall1.setString(2, request.getParameter("marketList"));
                  procCall1.setString(3, request.getParameter("txtSymbol"));
                  procCall1.setString(4, request.getParameter("txtSedol"));
                  procCall1.setString(5, request.getParameter("txtIsin"));
//                String strIsin = request.getParameter("txtIsin");
//                String strMarket = request.getParameter("marketList");
//                if(((strIsin != null) || !(strIsin.equals(""))) && (strMarket == null || strMarket.equals("Select"))) {
//                out.println("<font color='red'><h4>Please enter ISIN and Market together.</h4></font>");
//                      procCall1.setString(5, "");
//                } else {
//                      procCall1.setString(5, request.getParameter("txtIsin"));
//                }

                  rs1 = procCall1.executeQuery();
                  List list = new ArrayList();
                  list.add(rs1);
            }
      } catch (Exception ex) {
            ex.printStackTrace();
      }
%>
</head>
<body>
<h1>Search Securities</h1>
<form name="frmSearch" action="Search.jsp" method="post">
<table border="0">
      <tr>
            <th class="body">Market</th>
            <td><select name="marketList" class="combo">
                        <option selected>Select</option>               
                  <%while(rs.next()){%>
                        <option value="<%=rs.getString(1)%>"><%=rs.getString(2)%></option>                 
                  <%} %>
            </select></td>
            <td>&nbsp;</td>
            <th class="body">Symbol</th>
            <td><input type="text" name="txtSymbol" size="15" class="bodyinput"></td>
            <td>&nbsp;</td>
            <th class="body">Sedol</th>
            <td><input type="text" name="txtSedol" size="15" class="bodyinput"></td>
            <td>&nbsp;</td>
            <th class="body">ISIN</th>
            <td><input type="text" name="txtIsin" size="15" class="bodyinput"></td>
            <td>&nbsp;</td>
            <td><input type="submit" value="Search" name="btnSearch" class="fBtn"></td>
      </tr>
</table>
</form>          
      <%if(Searchaction != null && Searchaction.equals("Search")){%>
      <TABLE BORDER="1">
        <TR>
               <TH class="tablehead">Select</TH>
               <TH class="tablehead">Symbol</TH>
               <TH class="tablehead">Sedol</TH>
               <TH class="tablehead">ISIN</TH>
               <TH class="tablehead">SymbolDesc</TH>
               <TH class="tablehead">Exchange</TH>
                     <TH class="tablehead">Market</TH>
               <TH class="tablehead">Country</TH>
               <TH class="tablehead">SpecialCtryCode</TH>                                            
               <TH class="tablehead">LseSegment</TH>                                                           
               <TH class="tablehead">ExchangeSec</TH>
               <TH class="tablehead">TradingSysType</TH>                                            
               <TH class="tablehead">PriceMultiplier</TH>                                                                          
               <TH class="tablehead">LotSize</TH>                                                            
               <TH class="tablehead">QLot</TH>
               <TH class="tablehead">RLot</TH>                                            
               <TH class="tablehead">ClosePrice</TH>                                                                                         
               <TH class="tablehead">HighPrice</TH>
               <TH class="tablehead">LowPrice</TH>                                            
               <TH class="tablehead">Volume</TH>  
               <TH class="tablehead">LastUpdateDate</TH>                                                                                         
               <TH class="tablehead">ChgBy</TH>
               <TH class="tablehead">ChgAt</TH>                                            
               <TH class="tablehead">isDeleted</TH>                                                                                                                       
               <TH class="tablehead">Currency</TH>                                                                                         
               <TH class="tablehead">Broker1</TH>
               <TH class="tablehead">RIC</TH>                                            
               <TH class="tablehead">RoutingGroup</TH>                                                                                                                                      
           </TR>
            <%while(rs1.next()) { %>         
           <TR>
                  <td><a href="Search.jsp?mode=Edit&Market=<%= rs1.getString("Market") %>&Symbol=<%= rs1.getString("Symbol") %> ">Edit</a></td>
               <TD class="body"> <%= rs1.getString("Symbol") %> </TD>
               <TD class="body"> <%= rs1.getString("Sedol") %> </TD>
               <TD class="body"> <%= rs1.getString("ISIN") %> </TD>
               <TD class="body"> <%= rs1.getString("SymbolDesc") %> </TD>
               <TD class="body"> <%= rs1.getString("Exchange") %> </TD>
               <TD class="body"> <%= rs1.getString("Market") %> </TD>
               <TD class="body"> <%= rs1.getString("Country") %> </TD>
               <TD class="body"> <%= rs1.getString("SpecialCtryCode") %> </TD>
               <TD class="body"> <%= rs1.getString("LseSegment") %> </TD>
               <TD class="body"> <%= rs1.getString("ExchangeSec") %> </TD>              
               <TD class="body"> <%= rs1.getString("TradingSysType") %> </TD>
               <TD class="body"> <%= rs1.getString("PriceMultiplier") %> </TD>
               <TD class="body"> <%= rs1.getString("LotSize") %> </TD>
               <TD class="body"> <%= rs1.getString("QLot") %> </TD>
               <TD class="body"> <%= rs1.getString("RLot") %> </TD>
               <TD class="body"> <%= rs1.getString("ClosePrice") %> </TD>
               <TD class="body"> <%= rs1.getString("HighPrice") %> </TD>
               <TD class="body"> <%= rs1.getString("LowPrice") %> </TD>
               <TD class="body"> <%= rs1.getString("Volume") %> </TD>
               <TD class="body"> <%= rs1.getString("LastUpdateDate") %> </TD>                             
               <TD class="body"> <%= rs1.getString("ChgBy") %> </TD>
               <TD class="body"> <%= rs1.getString("ChgAt") %> </TD>
               <TD class="body"> <%= rs1.getString("isDeleted") %> </TD>
               <TD class="body"> <%= rs1.getString("Currency") %> </TD>
               <TD class="body"> <%= rs1.getString("Broker1") %> </TD>
               <TD class="body"> <%= rs1.getString("RIC") %> </TD>
               <TD class="body"> <%= rs1.getString("RoutingGroup") %> </TD>
           </TR>

       <BR>      
       <%}} %>
       </TABLE>      
      <%
      URL myURL=application.getResource("/WEB-INF/fieldstatus.properties");
      InputStream in = myURL.openStream();
      Properties p = new Properties();
      p.load(in);
      String strAction = request.getParameter("mode");
      if(strAction != null && strAction.equals("Edit")){
            String sqlString = "select * from GTControl..Securities where Market = '" + request.getParameter("Market") +"'and Symbol = '" + request.getParameter("Symbol") +"'";
            Statement stmt = null;
            stmt = conn.createStatement();
            ResultSet rs3 = null;
            rs3 = stmt.executeQuery(sqlString);
      %>
      <form metdod="post" action="Search.jsp">
      <%if(rs3.next()) {%>
      <table border="0" widtd="100%" cellpadding="0" cellspacing="0" class="subNavTable">
            <tr>
                  <td class="body">Sedol</td>
                  <%if(p.getProperty("Sedol").equalsIgnoreCase("Disabled")) {%>
                        <td><input type="text" name="txtSedol" disabled="disabled" value="<%=rs3.getString("Sedol")%>" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtSedol" value="<%=rs3.getString("Sedol")%>" class="bodyinput"></td>
                  <%} %>
                  <td>&nbsp;</td>
                  <td class="body">ISIN</td>
                  <%if(p.getProperty("ISIN").equalsIgnoreCase("Disabled")) {%>
                  <td><input type="text" name="txtISIN" value="<%=rs3.getString("ISIN")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtISIN" value="<%=rs3.getString("ISIN")%>" class="bodyinput"></td>
                  <%} %>
            </tr>
            <tr>
                  <td class="body">SymbolDesc</td>
                  <%if(p.getProperty("SymbolDesc").equalsIgnoreCase("Disabled")) {%>
                        <td>
                              <input type="text" name="txtSymbolDesc" value="<%=rs3.getString("SymbolDesc")%>" disabled="disabled" class="bodyinput">
                        </td>
                  <%} else { %>
                        <td>
                              <input type="text" name="txtSymbolDesc" value="<%=rs3.getString("SymbolDesc")%>" class="bodyinput">
                        </td>
                  <%} %>
                  <td>&nbsp;</td>
                  <td class="body">Exchange</td>
                  <%if(p.getProperty("Exchange").equalsIgnoreCase("Disabled")) {%>
                  <td><input type="text" name="txtExchange" value="<%=rs3.getString("Exchange")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtExchange" value="<%=rs3.getString("Exchange")%>" class="bodyinput"></td>
                  <%} %>
            </tr>
            <tr>
                  <td class="body">Market</td>             
                  <%if(p.getProperty("Market").equalsIgnoreCase("Disabled")) {%>
                  <td><input type="text" name="txtMarket" value="<%=rs3.getString("Market")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                 
                  <td><input type="hidden" name="txtHiddenSymbol"  value="<%=rs3.getString("Symbol")%>">
                  <input type="text" name="txtMarket" value="<%=rs3.getString("Market")%>" class="bodyinput"></td>
                  <%} %>
                  <td>&nbsp;</td>
                  <td class="body">Country</td>
                  <%if(p.getProperty("Country").equalsIgnoreCase("Disabled")) {%>
                        <td><input type="text" name="txtCountry" value="<%=rs3.getString("Country")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                        <td><input type="text" name="txtCountry" value="<%=rs3.getString("Country")%>" class="bodyinput"></td>
                  <%} %>
            </tr>
            <tr>
                  <td class="body">SpecialCtryCode</td>
                  <%if(p.getProperty("SpecialCtryCode").equalsIgnoreCase("Disabled")) {%>
                        <td><input type="text" name="txtSpecialCtryCode" value="<%=rs3.getString("SpecialCtryCode")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                        <td><input type="text" name="txtSpecialCtryCode" value="<%=rs3.getString("SpecialCtryCode")%>" class="bodyinput"></td>
                  <%} %>
                  <td>&nbsp;</td>
                  <td class="body">LseSegment</td>
                  <%if(p.getProperty("LseSegment").equalsIgnoreCase("Disabled")) {%>
                  <td><input type="text" name="txtLseSegment" value="<%=rs3.getString("LseSegment")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtLseSegment" value="<%=rs3.getString("LseSegment")%>" class="bodyinput"></td>
                  <%} %>
            </tr>
            <tr>
                  <td class="body">ExchangeSec</td>
                  <%if(p.getProperty("ExchangeSec").equalsIgnoreCase("Disabled")) {%>
                        <td><input type="text" name="txtExchangeSec" value="<%=rs3.getString("ExchangeSec")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                        <td><input type="text" name="txtExchangeSec" value="<%=rs3.getString("ExchangeSec")%>" class="bodyinput"></td>
                  <%} %>
                  <td>&nbsp;</td>
                  <td class="body">TradingSysType</td>
                  <%if(p.getProperty("TradingSysType").equalsIgnoreCase("Disabled")) {%>
                  <td><input type="text" name="txtTradingSysType" value="<%=rs3.getString("TradingSysType")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtTradingSysType" value="<%=rs3.getString("TradingSysType")%>" class="bodyinput"></td>
                  <%} %>
            </tr>
            <tr>
                  <td class="body">PriceMultiplier</td>
                  <%if(p.getProperty("PriceMultiplier").equalsIgnoreCase("Disabled")) {%>
                  <td><input type="text" name="txtPriceMultiplier" value="<%=rs3.getString("PriceMultiplier")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtPriceMultiplier" value="<%=rs3.getString("PriceMultiplier")%>" class="bodyinput"></td>              
                  <%} %>
                  <td>&nbsp;</td>
                  <td class="body">LotSize</td>
                  <%if(p.getProperty("LotSize").equalsIgnoreCase("Disabled")) {%>
                  <td><input type="text" name="txtLotSize" value="<%=rs3.getString("LotSize")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtLotSize" value="<%=rs3.getString("LotSize")%>" class="bodyinput"></td>                      
                  <%} %>
            </tr>                              
            <tr>
                  <td class="body">QLot</td>
                  <%if(p.getProperty("QLot").equalsIgnoreCase("Disabled")) {%>
                  <td><input type="text" name="txtQLot" value="<%=rs3.getString("QLot")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtQLot" value="<%=rs3.getString("QLot")%>" class="bodyinput"></td>
                  <%} %>
                  <td>&nbsp;</td>
                  <td class="body">RLot</td>
                  <%if(p.getProperty("RLot").equalsIgnoreCase("Disabled")) {%>
                  <td><input type="text" name="txtRLot" value="<%=rs3.getString("RLot")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtRLot" value="<%=rs3.getString("RLot")%>" class="bodyinput"></td>
                  <%} %>
            </tr>                              
            <tr>
                  <td class="body">ClosePrice</td>
                  <%if(p.getProperty("ClosePrice").equalsIgnoreCase("Disabled")) {%>
                  <td><input type="text" name="txtClosePrice" value="<%=rs3.getString("ClosePrice")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtClosePrice" value="<%=rs3.getString("ClosePrice")%>" class="bodyinput"></td>
                  <%} %>
                  <td>&nbsp;</td>
                  <td class="body">HighPrice</td>
                  <%if(p.getProperty("HighPrice").equalsIgnoreCase("Disabled")) {%>
                  <td><input type="text" name="txtdighPrice" value="<%=rs3.getString("HighPrice")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtdighPrice" value="<%=rs3.getString("HighPrice")%>" class="bodyinput"></td>              
                  <%} %>
            </tr>                              
            <tr>
                  <td class="body">LowPrice</td>
                  <%if(p.getProperty("LowPrice").equalsIgnoreCase("Disabled")) {%>
                        <td><input type="text" name="txtLowPrice" value="<%=rs3.getString("LowPrice")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                        <td><input type="text" name="txtLowPrice" value="<%=rs3.getString("LowPrice")%>" class="bodyinput"></td>
                  <%} %>
                  <td>&nbsp;</td>
                  <td class="body">Volume</td>
                  <%if(p.getProperty("Volume").equalsIgnoreCase("Disabled")) {%>
                  <td><input type="text" name="txtVolume" value="<%=rs3.getString("Volume")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtVolume" value="<%=rs3.getString("Volume")%>" class="bodyinput"></td>                       
                  <%} %>
            </tr>                                                                  
            <tr>
                  <td class="body">LastUpdateDate</td>
                  <%if(p.getProperty("LastUpdateDate").equalsIgnoreCase("Disabled")) {%>
                  <td><input type="text" name="txtLastUpdateDate" value="<%=rs3.getString("LastUpdateDate")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtLastUpdateDate" value="<%=rs3.getString("LastUpdateDate")%>" class="bodyinput"></td>
                  <%} %>
                  <td>&nbsp;</td>
                  <td class="body">ChgBy</td>
                  <%if(p.getProperty("ChgBy").equalsIgnoreCase("Disabled")) {%>
                  <td><input type="text" name="txtChgBy" value="<%=rs3.getString("ChgBy")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtChgBy" value="<%=rs3.getString("ChgBy")%>" class="bodyinput"></td>            
                  <%} %>
            </tr>                                                                  
            <tr>
                  <td class="body">ChgAt</td>
                  <%if(p.getProperty("ChgAt").equalsIgnoreCase("Disabled")) {%>                
                  <td><input type="text" name="txtChgAt" value="<%=rs3.getString("ChgAt")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtChgAt" value="<%=rs3.getString("ChgAt")%>" class="bodyinput"></td>
                  <%} %>
                  <td>&nbsp;</td>
                  <td class="body">isDeleted</td>
                  <%if(p.getProperty("isDeleted").equalsIgnoreCase("Disabled")) {%>            
                  <td><input type="text" name="txtisDeleted" value="<%=rs3.getString("isDeleted")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtisDeleted" value="<%=rs3.getString("isDeleted")%>" class="bodyinput"></td>
                  <%} %>
            </tr>                                                                  
            <tr>
                  <td class="body">Currency</td>
                  <%if(p.getProperty("Currency").equalsIgnoreCase("Disabled")) {%>                               
                  <td><input type="text" name="txtCurrency" value="<%=rs3.getString("Currency")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtCurrency" value="<%=rs3.getString("Currency")%>" class="bodyinput"></td>               
                  <%} %>
                  <td>&nbsp;</td>
                  <td class="body">Broker1</td>
                  <%if(p.getProperty("Broker1").equalsIgnoreCase("Disabled")) {%>                                
                  <td><input type="text" name="txtBroker1" value="<%=rs3.getString("Broker1")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtBroker1" value="<%=rs3.getString("Broker1")%>" class="bodyinput"></td>
                  <%} %>
            </tr>                                                                                                      
            <tr>
                  <td class="body">RIC</td>
                  <%if(p.getProperty("RIC").equalsIgnoreCase("Disabled")) {%>                              
                  <td><input type="text" name="txtRIC" value="<%=rs3.getString("RIC")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtRIC" value="<%=rs3.getString("RIC")%>" class="bodyinput"></td>            
                  <%} %>
                  <td>&nbsp;</td>
                  <td>RoutingGroup</td>
                  <%if(p.getProperty("RoutingGroup").equalsIgnoreCase("Disabled")) {%>                                                   
                  <td><input type="text" name="txtRoutingGroup" value="<%=rs3.getString("RoutingGroup")%>" disabled="disabled" class="bodyinput"></td>
                  <%} else { %>
                  <td><input type="text" name="txtRoutingGroup" value="<%=rs3.getString("RoutingGroup")%>" class="bodyinput"></td>
                  <%} %>
            </tr>      
            <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td><input type="submit" name="btnUpdate" value="Update" class="fBtn"></td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
            </tr>                                                                                                      
      </table>
</form>

      <%} }
      String strUpdate = request.getParameter("btnUpdate");
      if(strUpdate != null && strUpdate.equals("Update")) {
            Statement stmt1 = null;
            stmt1 = conn.createStatement();
            ResultSet rs4 = null;
            String updateQuery = "update GTControl..Securities set Sedol = '" + request.getParameter("txtSedol") +
                  "', LotSize = " + request.getParameter("txtLotSize") +                 
                  ", RLot = " + request.getParameter("txtRLot") +                  
                  ", QLot = " + request.getParameter("txtQLot") +                  
                  ", isDeleted = " + request.getParameter("isDeleted") +                                   
                  ", RIC = '" + request.getParameter("txtRIC") +
                  "', ExchangeSec = '" + request.getParameter("txtExchangeSec") +              
                  "', ISIN = '" + request.getParameter("txtISIN") +
                  "' where Market = '" + request.getParameter("txtMarket")+"' and Symbol = '" + request.getParameter("txtHiddenSymbol") +"'";
            int i = stmt1.executeUpdate(updateQuery);
            out.println("Security Updated.");

      }
      %>

</body>
</html>




The information in this message, including any attachment, is confidential and intended for use only by the designated recipient(s) named above. It is the property of BNY ConvergEx Group, LLC or its affiliates. If you are not the intended recipient, please return the message to the sender and delete all copies of it, including attachments, from your computer. Unauthorized use, disclosure, dissemination or copying of this message or any part hereof is strictly prohibited. This message is for information purposes only, is not intended to provide a sufficient basis on which to make an investment decision and should not be regarded as an offer to sell or a solicitation of an offer to buy any financial product. The information expressed herein may be changed at any time without notice or obligation to update. Email transmission cannot be guaranteed to be secure, virus-free or error-free. Therefore, we do not represent that this message is virus-free, complete or accurate and it should not be relied upon as such. BNY ConvergEx Group, LLC and its affiliates accept no liability for any damage sustained in connection with the content or transmission of this message.

No comments:

Post a Comment