//orgdelete.jsp Delete the department page, from OrgManage.jsp
<% @ Page ContentType = "Text / HTML; Charset = BIG5"%> <% @ include file = "ORGCONNINCLUDE.JSP"%> <% @ page import = "javax.sql. *"%> <% request.setCharacterencoding ("BIG5"); String DepName = Request.getParameter ("name"); // out.println (depname "
"); string message = null; boolean autocmit = conn.getAutOxCommit ();
String query1 = "SELECT TOTAL" "from ngb_org" "where name = '" depunname "" ";
String query2 = "SELECT *" "from ngb_org" "Where total like?"
String delete = "delete from ngb_org" "Where total like?";
String delete1 = "delete from ngb_org" "where name =?";
String temp1 = null; String temp1a = null; String temp1aa = null; String temp1b = null; try {conn.setAutoCommit (false); PreparedStatement ps = conn.prepareStatement (query1); ResultSet rs1 = ps.executeQuery ();
While (RS1.Next ()) {temp1 = rs1.getstring ("total");} // out.println (TEMP1); temp1a = temp1.substring (0, 1); Temp1AA = Temp1.substring (0, 3 ); temp1b = temp1.substring (3,6); // out.println (TEMP1B);
/ * Delete department-level: second layer, third layer, each third layer belongs to the fourth layer to delete * / if (temp1a.equals ("b")) {ps = conn.preparestatement (delete); ps .setString (1, Temp1); int resultb1 = ps.executeUpdate (); if (Resultb1> 0) {// out.println ("delete b success !!!!); ps = conn.preparestatement (query2); query2); Ps.setString (1, Temp1b "%"); ResultSet Resultb2 = ps.executeQuery (); while (resultb2.next ()) {temp1 = resultb2.getstring ("total"); string namec1 = resultb2.getstring ("name" "); temp1a = temp1.substring (0, 1); temp1aa = temp1.substring (0, 3); TEMP1B = Temp1.Substring (3, 6); // out.println (Namec1); // Delete sub-sector Ps = conn.preparestatement (delete); ps.setstring (1, temp1); int resultb3 = ps.executeUpdate (); if (Resultb3> 0) {// Out.println ("delete c success !!!!!") ;
PS = conn.preparestatement (query2); ps.setstring (1, temp1b "%"); ResultSet BD3 = ps.executeQuery (); while (bd3.next ()) {
String Totalc1 = bd3.getstring ("total"); Namec1 = bd3.getstring ("name"); string temp1c = temp1.substring (0, 1); string temp1ca = temp1.substring (0, 3); string temp1cb = Temp1.substring (3,6); ps = conn.preparestatement (delete); ps.setstring (1, temp1aa "%"); // out.println (Namec1);
PS = conn.preparestatement (delete1); ps.setstring (1, namec1); int resultC2 = ps.executeUpdate (); if (resultc2> 0) {message = depname;}}}}}}}}}}}}}}}}}}}}}}
/ * Delete department-level: third layer and fourth layer to delete * /
IF (Temp1a.equals ("c")) {// Remove this department PS = conn.preparestatement (delete); ps.setstring (1, temp1); int resultC1 = ps.executeUpdate (); if (Resultc1> 0) {//out.println ("delete c success !!!!); // Delete sub-sector ps = conn.preparestatement (query2); ps.setstring (1, temp1b "% "); ResultSet RS2 = ps.executeQuery (); while (rs2.next ()) {string totalc1 = rs2.getstring ("total"); string namec1 = rs2.getstring ("name"); string temp1c = temp1.substring (0, 1); String Temp1ca = Temp1.substring (0, 3); string temp1cb = temp1.substring (3,6); ps = conn.preparestatement (delete); ps.setstring (1, temp1aa "%"); // out.println (Namec1 ); ps = conn.preparestatement (delete1); ps.setstring (1, namec1); int resultC2 = ps.executeUpdate (); if (resultc2> 0) {Message = depname;}
}}}
// Remove the 4th layer IF (Temp1a.equals ("D")) {ps = conn.preparestatement (delete); ps.setstring (1, temp1); int result3 = ps.executeUpdate (); if (Result3> 0) {Message = depname;}}