package electric.dbs;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
import java.sql.*;
import javax.servlet.http.*;
import electric.*;
import java.text.SimpleDateFormat;
import electric.electricUtils.*;
public class Dbshop
{
private static final String LOAD_SHOP_BY_ID =
"SELECT * FROM [USER] WHERE [ID]=?";
private static final String INSERT_SHOP =
"INSERT INTO [USER] ([Id],[Username],[Password],[Shopname],[Area],[Peopleman],[Mantel],[Shoptel],[Usertype],[Createdate],[Status]) VALUES " +
"(?,?,?,?,?,?,?,?,?,?,?)";
private static final String UPDATE_SHOP =
"UPDATE [USER] SET [Username]=?,[Password]=?,[Shopname]=?," +
"[Area]=?,[Peopleman]=?,[Mantel]=?,[Shoptel]=?,[Usertype]=?,[Status]=?" +
" WHERE [Id]=?";
private static final String Del_SHOP =
"UPDATE [USER] SET [Status]=? WHERE [Id]=?";
private static final String CLEAR_SHOP = "DELETE FROM [USER] WHERE STATUS=" +
FinalConstants.STATUS_DELETE;
private int Id;
private String Username;
private String Password;
private String Shopname;
private String Area;
private String Peopleman;
private String Mantel;
private String Shoptel;
private int Usertype;
private String Createdate;
private int Status;
public Dbshop()
{}
public Dbshop(HttpServletRequest request) {
this.Id = DbSequenceManager.nextID(FinalConstants.T_SHOP);
this.Username = ParamUtils.getEscapeHTMLParameter(request, "username");
this.Password = ParamUtils.getEscapeHTMLParameter(request, "password");
this.Shopname = ParamUtils.getEscapeHTMLParameter(request, "shopname");
this.Area = ParamUtils.getEscapeHTMLParameter(request, "area");
this.Peopleman = ParamUtils.getEscapeHTMLParameter(request, "peopleman");
this.Mantel = ParamUtils.getEscapeHTMLParameter(request, "mantel");
this.Shoptel = ParamUtils.getEscapeHTMLParameter(request, "shoptel");
this.Usertype = ParamUtils.getIntParameter(request,"usertype");
SimpleDateFormat simpleDate = new SimpleDateFormat("yyyyMMdd");
String shiftDateToDate = simpleDate.format(new java.util.Date());
this.Createdate = shiftDateToDate;
this.Status = FinalConstants.STATUS_NORMAL;
insertIntoDb();
}
public Dbshop(int Id) throws ShopNotFoundException {
this.Id = Id;
// System.out.print(Id);
if (Id <= 0) {
return;
}
loadFromDb();
}
protected static Dbshop getInstance(int Id) throws
ShopNotFoundException {
return new Dbshop(Id);
}
protected void delete() {
setStatus(FinalConstants.STATUS_DELETE);
}
protected static void clear() {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(CLEAR_SHOP);
pstmt.executeUpdate();
}
catch (SQLException sqle) {
System.err.println(
"SQLException in DbTChatRooms.java:clearTChatRooms(): " + sqle);
sqle.printStackTrace();
}
finally {
try {
pstmt.close();
}
catch (Exception e) {
e.printStackTrace();
}
try {
con.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
/////////////////////////////////////////////////////////////////
public int getId() {
return this.Id;
}
public String getUsername(){
return this.Username;
}
public String getPassword(){
return this.Password;
}
public String getShopname(){
return this.Shopname;
}
public String getArea(){
return this.Area;
}
public String getPeopleman(){
return this.Peopleman;
}
public String getMantel(){
return this.Mantel;
}
public String getShoptel(){
return this.Shoptel;
}
public int getUsertype(){
return this.Usertype;
}
public String getCreatedate(){
return this.Createdate;
}
public int getStatus(){
return this.Status;
}
//////////////////////WRITE METHODS/////////////////////////////
/////////////////////////////////////////////////////////////////
public void setId(int Id) {
this.Id=Id;
saveToDb();
}
public void setUsername(String Username){
this.Username=Username;
saveToDb();
}
public void setPassword(String Password){
this.Password=Password;
saveToDb();
}
public void setShopname(String Shopname){
this.Shopname=Shopname;
saveToDb();
}
public void setArea(String Area){
this.Area=Area;
saveToDb();
}
public void setPeopleman(String Peopleman){
this.Peopleman=Peopleman;
saveToDb();
}
public void setMantel(String Mantel){
this.Mantel=Mantel;
saveToDb();
}
public void setShoptel(String Shoptel){
this.Shoptel=Shoptel;
saveToDb();
}
public void setUsertypee(int Usertype){
this.Usertype=Usertype;
saveToDb();
}
public void setCreatedate(String Createdate){
this.Createdate=Createdate;
saveToDb();
}
public void setStatus(int Status){
this.Status=Status;
DELToDb();
}
////////////////////////////////////////////////////////////////////////////////
public void modify(HttpServletRequest request) {
this.Id = ParamUtils.getIntParameter(request, "id");
this.Username = ParamUtils.getEscapeHTMLParameter(request, "username");
this.Password = ParamUtils.getEscapeHTMLParameter(request, "password");
this.Shopname = ParamUtils.getEscapeHTMLParameter(request, "shopname");
this.Area = ParamUtils.getEscapeHTMLParameter(request, "area");
this.Peopleman = ParamUtils.getEscapeHTMLParameter(request, "peopleman");
this.Mantel = ParamUtils.getEscapeHTMLParameter(request, "mantel");
this.Shoptel = ParamUtils.getEscapeHTMLParameter(request, "shoptel");
this.Usertype = ParamUtils.getIntParameter(request, "usertype");
this.Status = FinalConstants.STATUS_NORMAL;
saveToDb();
}
private void loadFromDb() throws ShopNotFoundException {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(LOAD_SHOP_BY_ID);
pstmt.setInt(1,Id);
ResultSet rs = pstmt.executeQuery();
if (!rs.next()) {
throw new ShopNotFoundException("从数据表[SHOP]中读取用户数据失败,欲读取的用户ID:[ " +
Id + "]!");
}
this.Id = rs.getInt("ID");
this.Username = rs.getString("Username");
this.Password = rs.getString("Password");
this.Shopname = rs.getString("Shopname");
this.Area = rs.getString("Area");
this.Peopleman = rs.getString("Peopleman");
this.Mantel = rs.getString("Mantel");
this.Shoptel = rs.getString("Shoptel");
this.Usertype = rs.getInt("Usertype");
this.Createdate = rs.getString("Createdate");
this.Status = rs.getInt("Status");
}
catch (SQLException sqle) {
throw new ShopNotFoundException("从数据表[SHOP]中读取用户数据失败,欲读取的用户ID:[ " +
Id + "]!");
}
finally {
try {
pstmt.close();
}
catch (Exception e) {
e.printStackTrace();
}
try {
con.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
private void insertIntoDb() {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(INSERT_SHOP);
pstmt.setInt(1, this.Id);
pstmt.setString(2,StringUtils.toChinese(this.Username));
pstmt.setString(3,StringUtils.toChinese(this.Password));
pstmt.setString(4,StringUtils.toChinese(this.Shopname));
pstmt.setString(5,StringUtils.toChinese(this.Area));
pstmt.setString(6,StringUtils.toChinese(this.Peopleman));
pstmt.setString(7,StringUtils.toChinese(this.Mantel));
pstmt.setString(8,StringUtils.toChinese(this.Shoptel));
pstmt.setInt(9,this.Usertype);
pstmt.setString(10,StringUtils.toChinese(this.Createdate));
pstmt.setInt(11,this.Status);
p
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
javaWeb项目整合开发的各个项目源码包括各种框架(struts+hibernate+spring) (850个子文件)
mouse.ani 24KB
banner_word.bak 181KB
banner.bak 179KB
bbs.bak 2KB
job.bmp 1.24MB
Dbshop.class 9KB
Dbware.class 9KB
Dbsell.class 8KB
Dbnews.class 8KB
Dbproduct.class 8KB
Dbmess.class 7KB
CrossTable.class 7KB
Shopdb.class 4KB
Messdb.class 4KB
caradd.class 3KB
FileText.class 3KB
Selldb.class 3KB
waredb.class 3KB
Productdb.class 3KB
Newsdb.class 3KB
SendGet.class 3KB
DbSequenceManager.class 3KB
OrderHelp.class 3KB
connDB.class 3KB
Str.class 2KB
shop.class 2KB
Student.class 2KB
Conn.class 2KB
sell.class 2KB
Bean1.class 2KB
ParamUtils.class 2KB
Condb.class 2KB
Data.class 2KB
ware.class 2KB
NewsShow.class 2KB
SearchTable.class 2KB
Cjob.class 2KB
Sjob.class 2KB
Condb.class 2KB
Company.class 2KB
Time.class 2KB
product.class 2KB
Show.class 2KB
news.class 2KB
Show.class 2KB
mess.class 1KB
DbConnectionManager.class 1KB
PopMenu.class 1KB
ProductNotFoundException.class 1KB
Bean3.class 1KB
WareNotFoundException.class 1KB
SellNotFoundException.class 1KB
NewsNotFoundException.class 1KB
MessNotFoundException.class 1KB
ShopNotFoundException.class 1KB
StringUtils.class 1KB
Str.class 1KB
chStr.class 1KB
CustomerTable.class 1KB
Pages.class 1KB
Sql.class 1021B
Count.class 983B
Time.class 832B
FinalConstants.class 696B
Show.class 689B
Show.class 689B
kxi__53406961538872917121115980710527.class 604B
MotifBean.class 584B
bookelement.class 351B
.classpath 752B
.classpath 555B
.classpath 432B
.classpath 432B
.classpath 432B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.container 49B
style.css 3KB
style.css 2KB
style.css 2KB
style.css 1KB
left.css 647B
default.css 525B
程序使用说明.doc 226KB
程序使用说明.doc 78KB
程序使用说明.doc 77KB
程序使用说明.doc 77KB
程序使用说明.doc 77KB
banner.fla 656KB
index_06.gif 84KB
intro.gif 65KB
zhuye_3.gif 60KB
Car1.gif 55KB
zhuye_1.gif 34KB
zhuye_2.gif 34KB
tiring-room_01.gif 32KB
shenbao_1.gif 32KB
shenbao_1.gif 32KB
共 850 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
sc233789892
- 粉丝: 0
- 资源: 26
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页