<%@ page  contentType="text/html;charset=utf-8" 
        import="java.sql.DriverManager,
                   java.sql.Connection,
                   java.sql.Statement,
                   java.sql.ResultSet,
                   java.sql.SQLException" %>
<%
  response.setContentType("text/html;charset=utf-8;");
  request.setCharacterEncoding("utf-8");     //charset, Encoding 설정
  Class.forName("com.mysql.jdbc.Driver");    // load the drive
  String DB_URL = 
          "jdbc:mysql://27.125.207.9:3306/idc?useUnicode=true&characterEncoding=utf-8";
                 // 주의 : test by changing mydb to name that you make
  String DB_USER = "idc";
  String DB_PASSWORD= "xptmxmzhem";
  Connection conn= null;
  Statement stmt = null;
  ResultSet rs   = null;

  try {
      conn = DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWORD);
      stmt = conn.createStatement();

      //String query = "SELECT clientdb.Client_Code,Client_Name,service_line,server_code,service_ip,service_payment_date,service_amount,service_nonpayment,service_note,adddb_case,adddb.client_code,adddb.service_code,adddb_nonpayment,adddb_payment,adddb_accountStatus,addDB_ip,addDB_payment_date FROM clientdb INNER JOIN servicedb ON clientdb.client_code = servicedb.client_code INNER JOIN adddb ON servicedb.service_code = adddb.service_code WHERE servicedb.service_code = adddb.service_code AND adddb_accountStatus='incomplete' AND adddb.client_code not in ('C116','C219') ORDER BY service_payment_date,Client_Name ASC ";
      String query = "SELECT clientdb.Client_Code,Client_Name,service_line,server_code,service_ip,service_payment_date,service_amount,service_nonpayment,service_note,adddb_case,adddb.client_code,adddb.service_code,adddb_nonpayment,adddb_payment,adddb_accountStatus,addDB_ip,addDB_payment_date FROM clientdb INNER JOIN servicedb ON clientdb.client_code = servicedb.client_code INNER JOIN adddb ON servicedb.service_code = adddb.service_code WHERE servicedb.service_code = adddb.service_code AND  adddb.client_code not in ('C116','C219') group by service_code ORDER BY Client_Name,service_payment_date,adddb_accountStatus ASC ";
      rs = stmt.executeQuery(query);
 %>


<%
    int result=0;
    int no1 = 0;
    int no2 = 0;
    try {
    no1 = Integer.parseInt(request.getParameter("num1"));
    no2 = Integer.parseInt(request.getParameter("num2"));
    } catch (Exception e) {
        
    }

String str = "";
String modStr = "";
String resultStr = "결과 값 : ";
if(request.getParameter("oper").equals("plus")) {
    result = no1 + no2;
    resultStr += result + "";
}
else if(request.getParameter("oper").equals("minus")) {
    str = "빼기 연산을 선택하셨습니다. <br>";
    result = no1 - no2;
    resultStr += result + "";
}
else if(request.getParameter("oper").equals("multi")) {
    str = "곱하기 연산을 선택하셨습니다. <br>";
    result = no1 * no2;
    resultStr += result + "";
}
else if(request.getParameter("oper").equals("divi")) {
    str = "나누기 연산을 선택하셨습니다. <br>";
    result = no1 / no2;
    int mod = no1 % no2;
    resultStr = "몫 : " + result;
    modStr = "나머지 : " + mod + "";
}
%>

<%= resultStr %> <%= modStr %>




<table border="1" cellspacing="0" text-align="center" align="center">
<tr>
<td>체크</td>
<td>코드</td>
<td>고객명</td>
<td>장비번호</td>
<td>아이피</td>
<td>결제일1</td>
<td>서비스가</td>
<td>결제금액</td>
<td>미납</td>
<td>종류</td>
<td>완료</td>

</tr>
<%
    while(rs.next()) { //rs 를 통해 테이블 객체들의 필드값을 넘겨볼 수 있다.
%><tr>
<td><input type="radio"></td>
<td><%=rs.getString("Client_Code")%></td>
<td><a href="/idcProject/IdcDepositNonPaymentList.dep?searchContent=<%=rs.getString("Client_Name")%>"><%=rs.getString("Client_Name")%></a></td>
<td><%=rs.getString("server_code")%></td>
<td><%=rs.getString("service_ip")%></td>
<td><%=rs.getString("service_payment_date")%></td>
<td><%=rs.getString("service_amount")%></td>
<% //String MK = sum(rs.getString("service_amount") -  rs.getString("service_nonpayment")); %>

<td><%=rs.getString(14)%></td>
<td><%=rs.getString("service_nonpayment")%></td>
<td><%=rs.getString("adddb_case")%></td>

<td><%=rs.getString("adddb_accountStatus")%></td>
</td>
</tr>
<%
    } // end while
%></table>
</form>
<%
  rs.close();        // ResultSet exit
  stmt.close();     // Statement exit
  conn.close();    // Connection exit
}
catch (SQLException e) {
      out.println("err:"+e.toString());
} 
%>



 