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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【项目源码】-java新奥家电连锁网络系统 SQLServer2005数据库 (1)将MR\18\WebRoot\Database文件夹中的数据库文件拷贝到本地机器中。 (2)打开SQLServer2005企业管理器,展开“数据库”节点,点击鼠标右键选择“附加”,即可打开附加数据库窗体,单击该窗体中的“附加”按钮,打开选择附加文件对话框,选择本项目数据库地址选择YWW_Data.MDF文件。单击“确定”按钮。即可完成数据库的复制。 将程序导入到MyEclipse中,并发布运行 (1)将“MR\18\”文件夹拷贝到MyEclipse的工作空间中。 (2)启动MyEclipse,在左侧的“包资源管理器”中,单击鼠标右键,选择“Import”菜单项,在弹出的对话框中,展开General节点,并选择“Existing Projects into Workspace”子节点
资源推荐
资源详情
资源评论
收起资源包目录
项目源码-java新奥家电连锁网络系统 (239个子文件)
banner_word.bak 181KB
banner.bak 179KB
bbs.bak 2KB
Dbshop.class 9KB
Dbware.class 9KB
Dbsell.class 8KB
Dbnews.class 8KB
Dbproduct.class 8KB
Dbmess.class 7KB
Shopdb.class 4KB
Messdb.class 4KB
Selldb.class 3KB
waredb.class 3KB
Productdb.class 3KB
Newsdb.class 3KB
DbSequenceManager.class 3KB
shop.class 2KB
sell.class 2KB
ParamUtils.class 2KB
ware.class 2KB
product.class 2KB
news.class 2KB
mess.class 1KB
DbConnectionManager.class 1KB
ProductNotFoundException.class 1KB
SellNotFoundException.class 1KB
MessNotFoundException.class 1KB
ShopNotFoundException.class 1KB
WareNotFoundException.class 1KB
NewsNotFoundException.class 1KB
StringUtils.class 1KB
FinalConstants.class 696B
kxi__53406961538872917121115980710527.class 604B
MotifBean.class 584B
.classpath 555B
org.eclipse.wst.jsdt.ui.superType.container 49B
style.css 2KB
程序使用说明.doc 60KB
banner.fla 656KB
tiring-room_01.gif 32KB
index_01.gif 30KB
bbs_detail_02.gif 26KB
index_02.gif 17KB
h_newchain.gif 5KB
h_manager.gif 5KB
h_modifyproduct.gif 5KB
h_modifygoods.gif 5KB
h_addgoods.gif 5KB
h_modifychain.gif 5KB
h_addbbs.gif 5KB
tiring-room_04.gif 5KB
h_product.gif 5KB
h_goods.gif 5KB
index_051.gif 5KB
h_modifybbs.gif 5KB
h_addproduct.gif 5KB
h_sellquery.gif 5KB
before_chain.GIF 5KB
h_sort.gif 5KB
h_user.gif 5KB
h_bbs.gif 5KB
h_broad.gif 5KB
index_04.gif 5KB
tiring-room_03.gif 5KB
before_contact.GIF 5KB
h_sell.gif 5KB
before_introduce.GIF 5KB
index_05.gif 4KB
before_produce.GIF 4KB
before_board.GIF 4KB
tiring-room_02.gif 4KB
tiring-room_05.gif 4KB
kxi_62662796387638636551133330490325.gif 3KB
kxi__49802698729824328581133330570487.gif 2KB
index_06.gif 2KB
tiring-room_06.gif 2KB
index_07.gif 1KB
index_08.gif 1KB
index_03.gif 1KB
index_12.gif 1022B
kxi_75649377050096477581121757622983.gif 912B
kxi__77443591989256511341115347300981.gif 571B
kxi__69207662776669041981115347109554.gif 571B
kxi_8398975948037079701114568325380.gif 508B
kxi_16922699061988454571133330377020.gif 502B
kxi_58583597018488113701114568287253.gif 499B
kxi_83531497354938770411114568351730.gif 484B
top.GIF 479B
kxi_17008417329482280241114568312603.gif 459B
kxi_50430858385283695161115347218992.gif 437B
del.gif 371B
del.gif 371B
kxi__90219241734970041531115344303523.gif 367B
list.gif 367B
modify.gif 245B
modify.gif 245B
tiring-room_07.gif 196B
index_10.gif 179B
tiring-room_08.gif 177B
kxi__14616905138749848731114568399776.gif 162B
共 239 条
- 1
- 2
- 3
资源评论
西攻城狮北
- 粉丝: 7081
- 资源: 434
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功