?? goods.java
字號:
package good;
import java.sql.ResultSet;
import java.util.Vector;
public class Goods {
/**
* @param args
*/
private String goodId;
private String goodName;
private String goodNumber;
private String goodPrice;
public String getGoodId() {
return goodId;
}
public void setGoodId(String goodId) {
this.goodId = goodId;
}
public String getGoodName() {
return goodName;
}
public void setGoodName(String goodName) {
this.goodName = goodName;
}
public String getGoodNumber() {
return goodNumber;
}
public void setGoodNumber(String goodNumber) {
this.goodNumber = goodNumber;
}
public String getGoodPrice() {
return goodPrice;
}
public void setGoodPrice(String goodPrice) {
this.goodPrice = goodPrice;
}
public boolean goodsAdd()
{
DataConn storCon = new DataConn();
String addSql = null;
storCon.dataConnDerectForMySql();
addSql="Insert into goods(goodId,goodName,goodNumber,goodPrice) values('"+goodId
+"','"+goodName+"','"+goodNumber+"','"+goodPrice+"')";
storCon.executeDerectUpdate(addSql);
return true;
}
public boolean goodsModi()
{
DataConn storCon = new DataConn();
String addSql = null;
storCon.dataConnDerectForMySql();
addSql="update goods set goodName='"+goodName+"',"+
"goodNumber='"+goodNumber+"',goodPrice='"+goodPrice+
"' where goodId='"+goodId+"'";
storCon.executeDerectUpdate(addSql);
return true;
}
public Vector GetAllGoodId() {
String quy;
String temp;
int i = 0;
DataConn storCon = new DataConn();
Vector list = new Vector();
storCon.dataConnDerectForMySql();
ResultSet rs = null;
quy = "select goodid from goods order by goodId";
try {
rs = storCon.executeDerectQuery(quy);
while (rs.next()) {
temp=rs.getString(1);
System.out.println(temp);
list.add(temp==null? "":temp.trim());
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
public void resultData() {
String quy;
DataConn storCon = new DataConn();
String addSql = null;
ResultSet rs = null;
storCon.dataConnDerectForMySql();
quy = "select * from goods where goodId='" + this.getGoodId() +"'";
try {
rs = storCon.executeDerectQuery(quy);
if (rs.next()) {
this.setGoodName(rs.getString("goodName"));
this.setGoodNumber(rs.getString("GoodNumber"));
this.setGoodPrice(rs.getString("GoodPrice"));
} else {
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public boolean checkData() {
String quy;
DataConn storCon = new DataConn();
ResultSet rs = null;
storCon.dataConnDerectForMySql();
quy = "select * from goods where goodId='" + this.getGoodId() + "'";
try {
rs = storCon.executeDerectQuery(quy);
if (rs.next()) {
return false;
} else {
return true;
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public boolean checkExist(String id) {
String quy;
DataConn storCon = new DataConn();
ResultSet rs = null;
storCon.dataConnDerectForMySql();
quy = "select * from goods where goodId='" + id + "'";
try {
rs = storCon.executeDerectQuery(quy);
if (rs.next()) {
return false;
} else {
return true;
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
private void goodName(String string) {
// TODO Auto-generated method stub
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -