%@ page contentType="text/html;charset=euc-kr" %>
<%@ include file="/include/in_Import.jsp" %>
<%@ include file="/include/in_Function.jsp" %>
<%@ page import="kr.co.slight.jinhae.mail.*" %>
<%!
static {
try {
new kr.co.slight.jinhae.pool.JDCConnectionDriver("org.postgresql.Driver","jdbc:postgresql:hanmaum","postgres","");
} catch(Exception e) {
System.out.println("
JDCConnectionDriver Error : " + e.toString());
}
}
%>
<%
myUpload.initialize(pageContext);
myUpload.upload();
int no = 0;
String menuId = myUpload.getRequest().getParameter("menuId");
String companyNm = sutil.toNullStr(myUpload.getRequest().getParameter("companyNm"));
String galtype = sutil.toNullStr(myUpload.getRequest().getParameter("galtype"));
String galseason = sutil.toNullStr(myUpload.getRequest().getParameter("galseason"));
String season = sutil.toNullStr(myUpload.getRequest().getParameter("season"));
String type = sutil.toNullStr(myUpload.getRequest().getParameter("type"));
String title = sutil.toNullStr(myUpload.getRequest().getParameter("title"));
String writer = sutil.toNullStr(myUpload.getRequest().getParameter("writer"));
String article = sutil.toNullStr(myUpload.getRequest().getParameter("article"));
String passwd = sutil.toNullStr(myUpload.getRequest().getParameter("passwd"));
String update_yn = sutil.toNullStr(myUpload.getRequest().getParameter("update_yn"));
String no_str = sutil.toNullStr(myUpload.getRequest().getParameter("no_str"));
String sIp = request.getRemoteAddr();
String todate = sutil.toNullStr(myUpload.getRequest().getParameter("todate"));
String atcFile01 = "";
String atcFile02 = "";
String atcFile03 = "";
String fileName1 = "";
String fileName2 = "";
String fileName3 = "";
String list_page = "";
String file_nm = sutil.toNullStr(request.getParameter("file_nm"));
String file_nm_new = request.getParameter("file_nm_new");
String file_gubun = sutil.toNullStr(request.getParameter("file_gubun"));
try {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String query = null;
Statement stmt = null;
int i_rtn = 0;
conn = DriverManager.getConnection("jdbc:jdc:jdcpool");
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Start (°Ô½ÃÆÇ ¼öÁ¤ Á¤º¸ Update)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
//÷ºÎÆÄÀϽÃÀÛ
String file_name = null;
com.jspsmart.upload.File myFile = myUpload.getFiles().getFile(0);
com.jspsmart.upload.File myFile1 = myUpload.getFiles().getFile(1);
com.jspsmart.upload.File myFile2 = myUpload.getFiles().getFile(2);
if (!myFile.isMissing()) {
try {
File photo = new File("/project/scgoneheart/hanmaum/gallery/photo/"+fileName1);
//if (photo.exists()) {
// photo.delete();
//}
} catch (Exception e) { }
String f_name = todate.substring(0,4) + todate.substring(5,7) + todate.substring(8,10) + todate.substring(20,26) + "_1." + myFile.getFileExt();
myFile.saveAs("/project/scgoneheart/hanmaum/gallery/photo/" + f_name);
atcFile01 = f_name;
}
if (!myFile1.isMissing()) {
try {
File photo1 = new File("/project/scgoneheart/hanmaum/gallery/photo/"+fileName2);
if (photo1.exists()) {
photo1.delete();
}
} catch (Exception e) { }
String f_name1 = todate.substring(0,4) + todate.substring(5,7) + todate.substring(8,10) + todate.substring(20,26) + "_2." + myFile1.getFileExt();
myFile1.saveAs("/project/scgoneheart/hanmaum/gallery/photo/" + f_name1);
atcFile02 = f_name1;
}
if (!myFile2.isMissing()) {
try {
File photo2 = new File("/project/scgoneheart/hanmaum/gallery/photo/"+fileName3);
if (photo2.exists()) {
photo2.delete();
}
} catch (Exception e) { }
String f_name2 = todate.substring(0,4) + todate.substring(5,7) + todate.substring(8,10) + todate.substring(20,26) + "_3." + myFile2.getFileExt();
myFile2.saveAs("/project/scgoneheart/hanmaum/gallery/photo/" + f_name2);
atcFile03 = f_name2;
}
//÷ºÎÆÄÀÏ ³¡
stmt = conn.createStatement();
if(update_yn.equals("N")){ no_str = "";} else { no = Integer.parseInt(no_str);}
String sql = "";
boolean rtn = false;
if(update_yn.equals("N")){
System.out.println("insert");
//insert
sql = " insert into gallery ( no, type, title, article, writer, wdate, ip, passwd, hitcnt, state, photo1, photo2, photo3, season )";
sql += " values ( coalesce((select max(no)+1 from gallery),1), ?, ?, ?, ?, now(), ?, ?, 0, '1', ?, ?, ?, ? )";
}else if(update_yn.equals("D")){
System.out.println("delete");
//delete
sql = " delete from gallery where no=? and type=? ";
}else{
System.out.println("update");
//update
sql = " update gallery set title=?, article=?, writer=?, ip=?, season=? ";
if(atcFile01.length()>1){
sql += " , photo1=? ";
}
if(atcFile02.length()>1){
sql += " , photo2=? ";
}
if(atcFile03.length()>1){
sql += " , photo3=? ";
}
sql += " where no=? and type=?";
}
pstmt = conn.prepareStatement(sql);
if(update_yn.equals("N")){
//insert
pstmt.setString(1, type);
pstmt.setString(2, title);
pstmt.setString(3, article);
pstmt.setString(4, writer);
pstmt.setString(5, sIp);
pstmt.setString(6, passwd);
pstmt.setString(7, atcFile01);
pstmt.setString(8, atcFile02);
pstmt.setString(9, atcFile03);
pstmt.setString(10, season);
}else if(update_yn.equals("D")){
//delete
pstmt.setInt(1, no);
pstmt.setString(2, type);
}else{
//update
pstmt.setString(1, title);
pstmt.setString(2, article);
pstmt.setString(3, writer);
pstmt.setString(4, season);
pstmt.setString(5, season);
if(atcFile01.length()>1){
pstmt.setString(6, atcFile01);
if(atcFile02.length()>1){
pstmt.setString(7, atcFile02);
if(atcFile03.length()>1){
pstmt.setString(8, atcFile03);
pstmt.setInt(9, no);
pstmt.setString(10, type);
} else {
pstmt.setInt(7, no);
pstmt.setString(8, type);
}
} else if(atcFile03.length()>1){
pstmt.setString(7, atcFile03);
pstmt.setInt(8, no);
pstmt.setString(9, type);
} else {
pstmt.setInt(7, no);
pstmt.setString(8, type);
}
} else if(atcFile02.length()>1){
pstmt.setString(6, atcFile02);
if(atcFile03.length()>1){
pstmt.setString(7, atcFile03);
pstmt.setInt(8, no);
pstmt.setString(9, type);
} else {
pstmt.setInt(7, no);
pstmt.setString(8, type);
}
} else if(atcFile03.length()>1){
pstmt.setString(6, atcFile03);
pstmt.setInt(7, no);
pstmt.setString(8, type);
} else {
pstmt.setInt(6, no);
pstmt.setString(7, type);
}
}
if (pstmt.executeUpdate() >= 1) {
rtn = true;
}
if(rtn){
System.out.println("wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww ¼º°ø");
} else {
System.out.println("wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww ½ÇÆÐ");
};
if(galtype.equals("1")){
list_page = "gallery_04.jsp";
}else if(galtype.equals("2")){
list_page = "gallery_01.jsp";
}else if(galtype.equals("3")){
list_page = "gallery_09.jsp";
}else{
list_page = "gallery_10.jsp";
}
%>
<%
} catch (Exception e) {
// ¿¡·¯ÆäÀÌÁö·Î À̵¿............
out.println("JSP >> Exception : " + e.toString());
}
%>