RetDAO.java (part2) .. will give good points to everyone. Is this logic good?
public static int delete(Connection conn,String ret_id) throws Exception
{
st=conn.createStatement();
rs=st.executeQuery("select * from retailer where retailer_id='"+ret_id+"'");
rs.next();
String s1=rs.getString(1);
String s2=rs.getString(2);
String s3=rs.getString(3);
String s4=rs.getString(4);
int s5=rs.getInt(5);
String s6=rs.getString(6);
String s7=rs.getString(8);
String s8=rs.getString(9);
System.out.println(s1);
System.out.println(s2);
System.out.println(s3);
System.out.println(s4);
System.out.println(s5);
System.out.println(s6);
System.out.println(s7);
System.out.println(s8);
int a=st.executeUpdate("insert into inactive values('"+s1+"','"+s2+"','"+s3+"','"+s4+"',"+s5+",'"+s6+"')");
System.out.println("a="+a);
int z=st.executeUpdate("delete from order_table,retailer where retailer_id='"+ret_id+"'");
return z;
}
public static ArrayList viewRequest(Connection conn) throws Exception
{
ArrayList<RetailerBean> l=new ArrayList<RetailerBean>();
st=conn.createStatement();
ResultSet rs=st.executeQuery("select * from tag_request_tbl");
while(rs.next())
{
RetailerBean b=new RetailerBean();
b.setId(rs.getString(1));
// b.setHandset(rs.getString(3));
//b.setAccessories(rs.getString(3));
//b.setSim(rs.getString(3));
b.setProductid(rs.getInt(2));
System.out.println(rs.getInt(2));
l.add(b);
}
return l;
}
public static void tagApprove(Connection conn,String ret) throws Exception
{
st=conn.createStatement();
ResultSet rs=st.executeQuery("select productmodel_id from tag_request_tbl where retailer_id='"+ret+"'");
//System.out.println(rs.getFetchSize());
/*while( rs.next())
{
System.out.println(rs.getInt(1));
}*/
while( rs.next())
{
int i=st.executeUpdate("insert into tag_product_tbl values('"+ret+"', "+rs.getInt(1)+")");
System.out.println("i="+i);
}
int j=st.executeUpdate("delete from tag_request_tbl where retailer_id='"+ret+"'");
System.out.println("j="+j);
}
//}
public static void tagReject(Connection conn,String ret) throws Exception
{
st=conn.createStatement();
ResultSet rs=st.executeQuery("select productmodel_id from tag_request_tbl where retailer_id='"+ret+"'");
while( rs.next())
{ // String product_id=rs.getString(1);
// System.out.println(product_id);
//while (rs.next())
//{
//int i=st.executeUpdate("insert into tag_product_tbl values('"+ret+"', '"+rs.getString(1)+"')");
//System.out.println(i);
st.executeUpdate("delete from tag_request_tbl where retailer_id='"+ret+"'");
}
// }
}
public static ArrayList viewRequestRetailer(Connection conn) throws Exception
{
ArrayList<RetailerBean> l=new ArrayList<RetailerBean>();
st=conn.createStatement();
ResultSet rs=st.executeQuery("select retailer_id,retailer_name from retailer where status='inactive'");
while(rs.next())
{
RetailerBean b=new RetailerBean();
b.setId(rs.getString(1));
// b.setHandset(rs.getString(3));
//b.setAccessories(rs.getString(3));
//b.setSim(rs.getString(3));
b.setName(rs.getString(2));
l.add(b);
}
return l;
}
public static void retailerApprove(Connection conn,String ret) throws Exception
{
st=conn.createStatement();
System.out.println(ret);
ResultSet rs=st.executeQuery("select user_name,password from retailer where retailer_id='"+ret+"'");
int r=st.executeUpdate("update retailer set status='active' where retailer_id='"+ret+"'");
int h=st.executeUpdate("update login_tbl set status='active' where user_name='"+rs.getString(1)+"' and password='"+rs.getString(2)+"'");
//while( rs.next())
//{ // String product_id=rs.getString(1);
// System.out.println(product_id);
//while (rs.next())
//{
//int i=st.executeUpdate("insert into tag_product_tbl values('"+ret+"', '"+rs.getString(1)+"')");
System.out.println(r);
System.out.println(h);
// st.executeUpdate("delete from tag_request_tbl where retailer_id='"+ret+"'");
}
// }
public static void retailerReject(Connection conn,String ret) throws Exception
{
st=conn.createStatement();
st=conn.createStatement();
ResultSet rs=st.executeQuery("select user_name,password from retailer where retailer_id='"+ret+"'");
int r=st.executeUpdate("update retailer set status='reject' where retailer_id='"+ret+"'");
int h=st.executeUpdate("update login_tbl set status='reject' where user_name='"+rs.getString(1)+"' and password='"+rs.getString(2)+"'");
//while( rs.next())
//{ // String product_id=rs.getString(1);
// System.out.println(product_id);
//while (rs.next())
//{
//int i=st.executeUpdate("insert into tag_product_tbl values('"+ret+"', '"+rs.getString(1)+"')");
System.out.println(r);
System.out.println(h);
// st.executeUpdate("delete from tag_request_tbl where retailer_id='"+ret+"'");
// }
}
}
View Answers
Related Tutorials/Questions & Answers:
Advertisements