package com.lzw.dao;
import internalFrame.guanli.Item;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import model.TbGysinfo;
import model.TbKhinfo;
import model.TbKucun;
import model.TbRkthDetail;
import model.TbRkthMain;
import model.TbRukuDetail;
import model.TbRukuMain;
import model.TbSellDetail;
import model.TbSellMain;
import model.TbSpinfo;
import model.TbUserlist;
import model.TbXsthDetail;
import model.TbXsthMain;
public class Dao {
protected static String dbClassName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
protected static String dbUrl = "jdbc:microsoft:sqlserver://localhost:1433;"
+ "DatabaseName=db_JXC;SelectMethod=Cursor";
protected static String dbUser = "sa";
protected static String dbPwd = "";
protected static String second = null;
public static Connection conn = null;
static {
try {
if (conn == null) {
Class.forName(dbClassName).newInstance();
conn = DriverManager.getConnection(dbUrl, dbUser, dbPwd);
}
} catch (Exception ee) {
ee.printStackTrace();
}
}
private Dao() {
}
// 读取所有客户信息
public static List getKhInfos() {
List list = findForList("select id,khname from tb_khinfo");
return list;
}
// 读取所有供应商信息
public static List getGysInfos() {
List list = findForList("select id,name from tb_gysinfo");
return list;
}
// 读取客户信息
public static TbKhinfo getKhInfo(Item item) {
String where = "khname='" + item.getName() + "'";
if (item.getId() != null)
where = "id='" + item.getId() + "'";
TbKhinfo info = new TbKhinfo();
ResultSet set = findForResultSet("select * from tb_khinfo where "
+ where);
try {
if (set.next()) {
info.setId(set.getString("id").trim());
info.setKhname(set.getString("khname").trim());
info.setJian(set.getString("jian").trim());
info.setAddress(set.getString("address").trim());
info.setBianma(set.getString("bianma").trim());
info.setFax(set.getString("fax").trim());
info.setHao(set.getString("hao").trim());
info.setLian(set.getString("lian").trim());
info.setLtel(set.getString("ltel").trim());
info.setMail(set.getString("mail").trim());
info.setTel(set.getString("tel").trim());
info.setXinhang(set.getString("xinhang").trim());
}
} catch (SQLException e) {
e.printStackTrace();
}
return info;
}
// 读取指定供应商信息
public static TbGysinfo getGysInfo(Item item) {
String where = "name='" + item.getName() + "'";
if (item.getId() != null)
where = "id='" + item.getId() + "'";
TbGysinfo info = new TbGysinfo();
ResultSet set = findForResultSet("select * from tb_gysinfo where "
+ where);
try {
if (set.next()) {
info.setId(set.getString("id").trim());
info.setAddress(set.getString("address").trim());
info.setBianma(set.getString("bianma").trim());
info.setFax(set.getString("fax").trim());
info.setJc(set.getString("jc").trim());
info.setLian(set.getString("lian").trim());
info.setLtel(set.getString("ltel").trim());
info.setMail(set.getString("mail").trim());
info.setName(set.getString("name").trim());
info.setTel(set.getString("tel").trim());
info.setYh(set.getString("yh").trim());
}
} catch (SQLException e) {
e.printStackTrace();
}
return info;
}
// 读取用户
public static TbUserlist getUser(String name, String password) {
TbUserlist user = new TbUserlist();
ResultSet rs = findForResultSet("select * from tb_userlist where username='"
+ name + "'");
try {
if (rs.next()) {
user.setUsername(name);
user.setPass(rs.getString("pass"));
if (user.getPass().equals(password)) {
user.setName(rs.getString("name"));
user.setQuan(rs.getString("quan"));
}
}
} catch (SQLException e) {
e.printStackTrace();
}
return user;
}
// 执行指定查询
public static ResultSet query(String QueryStr) {
ResultSet set = findForResultSet(QueryStr);
return set;
}
// 执行删除
public static int delete(String sql) {
return update(sql);
}
// 添加客户信息的方法
public static boolean addKeHu(TbKhinfo khinfo) {
if (khinfo == null)
return false;
return insert("insert tb_khinfo values('" + khinfo.getId() + "','"
+ khinfo.getKhname() + "','" + khinfo.getJian() + "','"
+ khinfo.getAddress() + "','" + khinfo.getBianma() + "','"
+ khinfo.getTel() + "','" + khinfo.getFax() + "','"
+ khinfo.getLian() + "','" + khinfo.getLtel() + "','"
+ khinfo.getMail() + "','" + khinfo.getXinhang() + "','"
+ khinfo.getHao() + "')");
}
// 修改客户信息的方法
public static int updateKeHu(TbKhinfo khinfo) {
return update("update tb_khinfo set jian='" + khinfo.getJian()
+ "',address='" + khinfo.getAddress() + "',bianma='"
+ khinfo.getBianma() + "',tel='" + khinfo.getTel() + "',fax='"
+ khinfo.getFax() + "',lian='" + khinfo.getLian() + "',ltel='"
+ khinfo.getLtel() + "',mail='" + khinfo.getMail()
+ "',xinhang='" + khinfo.getXinhang() + "',hao='"
+ khinfo.getHao() + "' where id='" + khinfo.getId() + "'");
}
// 修改库存的方法
public static int updateKucunDj(TbKucun kcInfo) {
return update("update tb_kucun set dj=" + kcInfo.getDj()
+ " where id='" + kcInfo.getId() + "'");
}
// 修改供应商信息的方法
public static int updateGys(TbGysinfo gysInfo) {
return update("update tb_gysinfo set jc='" + gysInfo.getJc()
+ "',address='" + gysInfo.getAddress() + "',bianma='"
+ gysInfo.getBianma() + "',tel='" + gysInfo.getTel()
+ "',fax='" + gysInfo.getFax() + "',lian='" + gysInfo.getLian()
+ "',ltel='" + gysInfo.getLtel() + "',mail='"
+ gysInfo.getMail() + "',yh='" + gysInfo.getYh()
+ "' where id='" + gysInfo.getId() + "'");
}
// 添加供应商信息的方法
public static boolean addGys(TbGysinfo gysInfo) {
if (gysInfo == null)
return false;
return insert("insert tb_gysinfo values('" + gysInfo.getId() + "','"
+ gysInfo.getName() + "','" + gysInfo.getJc() + "','"
+ gysInfo.getAddress() + "','" + gysInfo.getBianma() + "','"
+ gysInfo.getTel() + "','" + gysInfo.getFax() + "','"
+ gysInfo.getLian() + "','" + gysInfo.getLtel() + "','"
+ gysInfo.getMail() + "','" + gysInfo.getYh() + "')");
}
// 添加商品
public static boolean addSp(TbSpinfo spInfo) {
if (spInfo == null)
return false;
return insert("insert tb_spinfo values('" + spInfo.getId() + "','"
+ spInfo.getSpname() + "','" + spInfo.getJc() + "','"
+ spInfo.getCd() + "','" + spInfo.getDw() + "','"
+ spInfo.getGg() + "','" + spInfo.getBz() + "','"
+ spInfo.getPh() + "','" + spInfo.getPzwh() + "','"
+ spInfo.getMemo() + "','" + spInfo.getGysname() + "')");
}
// 更新商品
public static int updateSp(TbSpinfo spInfo) {
return update("update tb_spinfo set jc='" + spInfo.getJc() + "',cd='"
+ spInfo.getCd() + "',dw='" + spInfo.getDw() + "',gg='"
+ spInfo.getGg() + "',bz='" + spInfo.getBz() + "',ph='"
+ spInfo.getPh() + "',pzwh='" + spInfo.getPzwh() + "',memo='"
+ spInfo.getMemo() + "',gysname='" + spInfo.getGysname()
+ "' where id='" + spInfo.getId() + "'");
}
// 读取商品信息
public static TbSpinfo getSpInfo(Item item) {
String where = "spname='" + item.getName() + "'";
if (item.getId() != null)
where = "id='" + item.getId() + "'";
ResultSet rs = findForResultSet("select * from tb_spinfo where "
+ where);
TbSpinfo spInfo = new TbSpinfo();
try {
if (rs.next()) {
spInfo.setId(rs.getString("id").trim());
spInfo.setBz(rs.getString("bz").trim());
spInfo.setCd(rs.getString("cd").trim());
spInfo.setDw(rs.getString("
计算机萍萍学姐
- 粉丝: 408
- 资源: 475
最新资源
- 基于java+springboot+vue+mysql的房屋租赁管理系统 源码+数据库+论文(高分毕设项目)).zip
- 基于智能软开关的配电网优化调度分析(含故障恢复能力与分布式电源影响),基于智能软开关的配电网优化调度matlab 采用matlab编程,分析得到了含智能软开关下的配电网故障恢复能力,包括恢复负荷、失电
- 基于java+springboot+vue+mysql的个人财务管理系统 源码+数据库+论文(高分毕设项目)).zip
- 轮式移动机器人基于运动学和动力学模型的双闭环控制结合自抗扰与非线性ESO的轨迹跟踪仿真程序,轮式移动机器人轨迹跟踪的MATHLAB程序,运用运动学和动力学模型的双闭环控制,借鉴自抗扰控制技术结合了非线
- 基于java+springboot+vue+mysql的高校院系学生信息管理系统 源码+数据库+论文(高分毕设项目)).zip
- 基于java+springboot+vue+mysql的果树生长系统 源码+数据库+论文(高分毕设项目)).zip
- ,基于SSM框架的校园外卖系统(JAVA WEB源码) 开发技术:SSM+BootStrap + maven + Layui + MySQL5.5 实现功能:包括用户端和管理员端; 前台主要功能有用户
- 成熟的非标套管机程序:伺服联动,模块化编程,高效定位,界面友好,可靠性高,适合电气工程师入门与进阶之选,一台成熟的非标套管机程序,设备已投产,包含详细注释程序+触摸屏组态,伺服联动,多路伺服绝对定位
- 基于java+springboot+vue+mysql的机场乘客服务系统 源码+数据库+论文(高分毕设项目)).zip
- "永磁同步模型电流预测控制与滑模控制:双矢量算法及新型趋近律的应用", 永磁同步模型电流预测控制+滑模控制 滑膜控制器采用新型趋近律与扰动观测器结合,提高系统鲁棒性和稳态特性 电流环采用预测控制
- 三菱PLC与LabVIEW通过MX通讯实现实时读写控制,三菱PLC和labview通过MX通讯,可以实时读写 ,核心关键词:三菱PLC;LabVIEW;MX通讯;实时读写;通信协议 ,"三菱PLC
- 基于java+springboot+vue+mysql的海鲜市场系统 源码+数据库+论文(高分毕设项目)).zip
- C# ASP.NET学生信息管理系统源代码分享:基于SQL Server实现基本增删改查功能,涵盖学生管理、课程管理、成绩管理等核心模块 ,C#-asp.net学生信息管理系统源代码 基于ASP.N
- 基于java+springboot+vue+mysql的兼职发布平台 源码+数据库+论文(高分毕设项目)).zip
- 安装包技术详解:涵盖Windows、macOS及Linux下不同类型及其制作与管理
- 基于java+springboot+vue+mysql的健身俱乐部网站 源码+数据库+论文(高分毕设项目)).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈