package com.wy.dao; import java.sql.ResultSet; import java.sql.SQLException; import java.util.*; import com.wy.form.ConsumerForm; import com.wy.tool.JDBConnection; public class ConsumerDao { private JDBConnection connection = null; private ConsumerForm consumerForm = null; public ConsumerDao() { connection = new JDBConnection(); } // 以数据库编号为条件,修改用户信息 public boolean front_updateConsumerForm(ConsumerForm form) { boolean flag = false; String sql = "update tb_consumer set account='" + form.getAccount() + "',password='" + form.getPassword() + "',name='" + form.getName() + "',sex='" + form.getSex() + "',QQNumber='" + form.getQQNumber() + "',mainPage='" + form.getMainPage() + "',interest='" + form.getInterest() + "',eMail='" + form.getEMail() + "' where id='" + form.getId() + "'"; if (connection.executeUpdate(sql)) { flag = true; } return flag; } // 更新用户操作 public boolean updateConsumerForm(ConsumerForm form) { boolean flag = false; String sql = "update tb_consumer set account='" + form.getAccount() + "',password='" + form.getPassword() + "',name='" + form.getName() + "',sex='" + form.getSex() + "',QQNumber='" + form.getQQNumber() + "',mainPage='" + form.getMainPage() + "',interest='" + form.getInterest() + "',eMail='" + form.getEMail() + "' where manageLevel='" + form.getManageLevel() + "'"; if (connection.executeUpdate(sql)) { flag = true; } return flag; } // 删除用户信息 public boolean deleteConsumerForm(String account) { boolean flag = false; String sql = "delete from tb_consumer where account='" + account + "'"; if (connection.executeUpdate(sql)) { flag = true; } return flag; } // 添加用户信息 public boolean addConsumerForm(ConsumerForm form) { boolean flag = false; String sql = "insert into tb_consumer values ("+(int)Math.random()*99999999+",'" + form.getAccount() + "','" + form.getPassword() + "','" + form.getName() + "','" + form.getSex() + "','" + form.getQQNumber() + "','" + form.getMainPage() + "','" + form.getInterest() + "','" + form.getEMail() + "','" + form.getManageLevel() + "')"; if (connection.executeUpdate(sql)) { flag = true; } return flag; } public String getConsumerForm(Integer id) { String sql = "select * from tb_consumer where id='" + id + "'"; String name=""; try { ResultSet rs = connection.executeQuery(sql); while (rs.next()) { name=rs.getString("name"); } } catch (SQLException e) { e.printStackTrace(); } return name; } // 以用户名为查询条件,查询一组数据 public ConsumerForm getConsumerForm(String account) { String sql = "select * from tb_consumer where account='" + account + "'"; try { ResultSet rs = connection.executeQuery(sql); while (rs.next()) { consumerForm = new ConsumerForm(); consumerForm.setId(Integer.valueOf(rs.getString(1))); consumerForm.setAccount(rs.getString(2)); consumerForm.setPassword(rs.getString(3)); consumerForm.setName(rs.getString(4)); consumerForm.setSex(rs.getString(5)); consumerForm.setQQNumber(rs.getString(6)); consumerForm.setMainPage(rs.getString(7)); consumerForm.setInterest(rs.getString(8)); consumerForm.setEMail(rs.getString(9)); consumerForm.setManageLevel(rs.getString(10)); } } catch (SQLException e) { e.printStackTrace(); } return consumerForm; } // 根据用户账号查询所有的数据 public List getConsumerList(String manageLevel) { List list = new ArrayList(); String sql = "select * from tb_consumer where manageLevel='" + manageLevel + "'"; try { ResultSet rs = connection.executeQuery(sql); while (rs.next()) { consumerForm = new ConsumerForm(); consumerForm.setId(Integer.valueOf(rs.getString(1))); consumerForm.setAccount(rs.getString(2)); consumerForm.setPassword(rs.getString(3)); consumerForm.setName(rs.getString(4)); consumerForm.setSex(rs.getString(5)); consumerForm.setQQNumber(rs.getString(6)); consumerForm.setMainPage(rs.getString(7)); consumerForm.setInterest(rs.getString(8)); consumerForm.setEMail(rs.getString(9)); consumerForm.setManageLevel(rs.getString(10)); list.add(consumerForm); } } catch (SQLException e) { e.printStackTrace(); } return list; } }
最近下载更多
sz1111111 LV2
3月26日
寒江雪2017 LV9
1月23日
李朝磊 LV18
1月6日
pangzhihui LV12
2023年12月27日
wanglongfei2 LV2
2023年6月15日
13133117021 LV4
2023年5月31日
ewan007 LV29
2023年3月13日
你们的代码都是我的了 LV16
2022年12月5日
gnnhka LV10
2022年11月8日
SQ2930501923 LV14
2022年10月10日
最近浏览更多
sz1111111 LV2
3月26日
寒江雪2017 LV9
1月23日
duoduo1234 LV2
1月15日
taoshen95 LV14
1月11日
wttttts LV2
1月1日
hxy19991216 LV4
2023年12月30日
asddwh LV12
2023年12月29日
pangzhihui LV12
2023年12月27日
李朝磊 LV18
2023年12月21日
颜菜菜 LV2
2023年12月19日