库存管理c语言程序,库存管理

[c]代码库package com.CsmsCode.Dao;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.util.ArrayList;

import java.util.List;

import com.CsmsCode.DB.DBConnection;

import com.CsmsCode.VO.UserVo;

public class UserDao {

public int login(String userLogin,String userPwd) throws ClassNotFoundException, SQLException

{

StringBuffer strSql=new StringBuffer();

strSql.append("select count(*) from users where userLogin='"+userLogin+"' and userPwd='"+userPwd+"'");

int r=0;

DBConnection db=new DBConnection();

Connection conn=db.getConnection();

PreparedStatement pst=conn.prepareStatement(strSql.toString());

ResultSet rs= pst.executeQuery();

while (rs.next())

{

r=rs.getInt("count(*)");

}

return r;

}

public List getUsers(String userLogin,String userName) throws ClassNotFoundException, SQLException

{

StringBuffer strSql=new StringBuffer();

strSql.append("select * from users where 1=1 ");

if (!userLogin.equals(""))

{

strSql.append(" and userLogin='"+userLogin+"' ");

}

if (!userName.equals(""))

{

strSql.append(" and userName='"+userName+"'");

}

DBConnection db=new DBConnection();

Connection conn=db.getConnection();

PreparedStatement pst=conn.prepareStatement(strSql.toString());

ResultSet rs= pst.executeQuery();

List users=new ArrayList();

while (rs.next())

{

UserVo myUser=new UserVo();

myUser.setFlag(rs.getInt("flag"));

myUser.setUserLogin(rs.getString("userLogin"));

myUser.setUserName(rs.getString("userName"));

myUser.setUserNote(rs.getString("userNote"));

myUser.setUserPwd(rs.getString("userPwd"));

users.add(myUser);

}

return users;

}

public void addUser(UserVo uservo) throws ClassNotFoundException, SQLException

{

StringBuffer strSql=new StringBuffer();

strSql.append("insert into users values ('"+uservo.getUserLogin()+"','"+uservo.getUserName()+"','"+uservo.getUserNote()+"','"+uservo.getUserPwd()+"','0)");

DBConnection db=new DBConnection();

Connection conn=db.getConnection();

PreparedStatement pst=conn.prepareStatement(strSql.toString());

pst.executeUpdate();

}

public void updateUser(UserVo uservo) throws ClassNotFoundException, SQLException

{

StringBuffer strSql=new StringBuffer();

strSql.append("update users set userName='"+uservo.getUserName()+"',userPwd='"+uservo.getUserPwd()+"',userNote='"+uservo.getUserNote()+"'where userLogin='"+uservo.getUserLogin()+"'");

DBConnection db=new DBConnection();

Connection conn=db.getConnection();

PreparedStatement pst=conn.prepareStatement(strSql.toString());

pst.executeUpdate();

}

public void delUser(String userLogin) throws ClassNotFoundException, SQLException

{

StringBuffer strSql=new StringBuffer();

strSql.append("delete from users where userLogin='"+userLogin+"' ");

DBConnection db=new DBConnection();

Connection conn=db.getConnection();

PreparedStatement pst=conn.prepareStatement(strSql.toString());

pst.executeUpdate();

}

}

[源代码打包下载]

7ab7b94785bbdb79d4aaa6009386543f.gifCsmsCode.rar(50积分)[0 次下载]

694748ed64b9390909c0d88230893790.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值