首页>代码>JSP+Struts2开发诚欣企业免费电子商城网站系统源代码下载>/企业电子商城/Shopping/src/com/wy/dao/ManagerDao.java
package com.wy.dao;

import java.sql.*;
import java.util.*;
import com.wy.domain.ManagerForm;
import com.wy.tool.JDBConnection;

//�Թ���Ա�IJ���
public class ManagerDao {
  private Connection connection = null; //�������ӵĶ���
  private PreparedStatement ps = null; //����Ԥ׼���Ķ���
  private JDBConnection jdbc = null; //������ݿ����Ӷ���
  public ManagerDao() {
    jdbc = new JDBConnection();
    connection = jdbc.connection; //���ù��췽��ȡ����ݿ�����
  }

  //�Թ���Ա��IJ�ѯ����
  public void insertManager(ManagerForm form) {
    try {

      ps = connection.prepareStatement("insert into tb_manager values (null,?,?,?,?)");
      ps.setString(1, form.getAccount());
      ps.setString(2, form.getPassword());
      ps.setString(3, form.getName());
      ps.setInt(4, 0);
      ps.executeUpdate();
      ps.close();
    }
    catch (SQLException ex) {
    	ex.printStackTrace();
    }
  }

  //�޸Ĺ���Ա����ķ���
  public void updateManagerPassword(ManagerForm form) {
    try {
      ps = connection.prepareStatement("update tb_manager set password=? where account=?");
      ps.setString(1, form.getPassword());
      ps.setString(2,form.getAccount());
      ps.executeUpdate();
      ps.close();
    }
    catch (SQLException ex) {
    	ex.printStackTrace();
    }
  }


  //ɾ�����Ա�IJ���
  public void deleteManager(Integer id) {
    try {
      ps = connection.prepareStatement("delete from tb_manager where id=?");
      ps.setInt(1, id.intValue());
      ps.executeUpdate();
      ps.close();
    }
    catch (SQLException ex) {
    	ex.printStackTrace();
    }
  }

  //��ѯȫ������Ա����Ϣ
  public List selectManager() {
    List list = new ArrayList();
    ManagerForm manager = null;
    try {
      ps = connection.prepareStatement("select * from tb_manager order by id DESC");
      ResultSet rs = ps.executeQuery();
      while (rs.next()) {
        manager = new ManagerForm();
        manager.setId(Integer.valueOf(rs.getString(1)));
        manager.setAccount(rs.getString(2));
        manager.setPassword(rs.getString(3));
        manager.setName(rs.getString(4));
        manager.setSigh(Integer.valueOf(rs.getString(5)));
        list.add(manager);
      }
    }
    catch (SQLException ex) {
    	ex.printStackTrace();
    }
    return list;
  }

//�Թ���Ա�˺�Ϊ������ѯ����Ա��Ϣ
  public ManagerForm selectOne(String account) {
    ManagerForm manager = null;
    try {
      ps = connection.prepareStatement("select * from tb_manager where account=?");
      ps.setString(1, account);
      ResultSet rs = ps.executeQuery();
      while (rs.next()) {
        manager = new ManagerForm();
        manager.setId(Integer.valueOf(rs.getString(1)));
        manager.setAccount(rs.getString(2));
        manager.setPassword(rs.getString(3));
        manager.setName(rs.getString(4));
        manager.setSigh(Integer.valueOf(rs.getString(5)));
      }
    }
    catch (SQLException ex) {
    	ex.printStackTrace();
    }
    return manager;
  }



}
最近下载更多
sunshine255  LV5 2022年4月30日
lzlzyw  LV14 2022年3月24日
1487878315  LV10 2021年11月29日
夏未尽花已落  LV1 2020年6月14日
12385522272  LV4 2020年4月28日
hancro  LV5 2020年3月11日
sunskyasd  LV6 2019年12月18日
528679484  LV5 2019年10月23日
caifangfang  LV5 2019年6月25日
itscod  LV6 2019年6月16日
最近浏览更多
Mhgfhjyrf  LV3 2024年12月9日
1260669501  LV1 2024年8月31日
KEKUN123  LV1 2024年6月22日
lilitu  LV6 2024年5月26日
1134116035 2024年2月28日
暂无贡献等级
ljhgff  LV1 2024年2月18日
heshao  LV2 2024年2月7日
打工皇帝  LV1 2023年11月3日
qhlssd 2023年7月31日
暂无贡献等级
smmmm123  LV8 2022年12月28日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友