?? invoice.java
字號:
package good;
import javax.swing.JOptionPane;
import java.sql.ResultSet;
public class Invoice extends SortedList {
//定義與提貨清單關聯的存貨清單
private Inventory inventory;
private String goodId;
private String employeeId;
private int outnumber;
private String clientname;
private double outPrice;
private String outdate;
//提貨清單構造函數
public Invoice(Inventory _inventory) {
//調用父類SortedList的構造函數
super(new ItemComparer());
inventory = _inventory;
}
//在提貨清單中增加提貨條目,同時在存貨清單中對應的存貨條目上減少用戶輸入的貨物數量
public boolean addItem(String _id, int _number,double _outPrice) {
InventoryItem item = inventory.getPart(_id);
if ((item != null) && (item.units >= _number) && (_number >= 0)
&& !isFull()) {
item.remove(_number);
add(new InvoiceItem(item, _number,_outPrice));
return true;
} else
{
JOptionPane.showMessageDialog(null, "列表滿、項沒有找到或者貨物已經定購完!", "警告",
JOptionPane.ERROR_MESSAGE);
return false;
}
//System.out.println("List full, item not found or invalid units");
}
//根據用戶輸入的id,在提貨清單上刪除提貨條目
public void delItem(String _id) {
int index = indexOf(new Item(_id));
if (index >= 0)
delete(index);
}
public boolean Invoicedele()
{
DataConn storCon = new DataConn();
String addSql = null;
storCon.dataConnDerectForMySql();
//System.out.print(date);
addSql="Insert into Invoice(goodId,employeeId,clientName,OutDate,Outnumber"+
",OutPrice)values('"+goodId+"','"+employeeId+"','"+clientname+"','"+outdate+
"',"+outnumber+","+outPrice+")";
storCon.executeDerectUpdate(addSql);
//同時修改數量
storCon.dataConnDerectForMySql();
addSql="update goods set goodNumber=goodNumber-"+Integer.toString(outnumber)
+" where goodId='"+goodId+"'";
storCon.executeDerectUpdate(addSql);
return true;
}
//返回提貨清單上貨物的價格總和
public double getTotal() {
double total = 0.0;
for (int i = 0; i < getSize(); i++)
total += ((InvoiceItem) get(i)).total;
return total;
}
//以字符串的形式返回提貨清單
public String toString() {
return super.toString()+"提貨清單:" + Util.dollar(getTotal()) ;
}
public String getClientname() {
return clientname;
}
public void setClientname(String clientname) {
this.clientname = clientname;
}
public String getEmployeeId() {
return employeeId;
}
public void setEmployeeId(String employeeId) {
this.employeeId = employeeId;
}
public String getGoodId() {
return goodId;
}
public void setGoodId(String goodId) {
this.goodId = goodId;
}
public Inventory getInventory() {
return inventory;
}
public void setInventory(Inventory inventory) {
this.inventory = inventory;
}
public String getOutdate() {
return outdate;
}
public void setOutdate(String outdate) {
this.outdate = outdate;
}
public int getOutnumber() {
return outnumber;
}
public void setOutnumber(int outnumber) {
this.outnumber = outnumber;
}
public double getOutPrice() {
return outPrice;
}
public void setOutPrice(double outPrice) {
this.outPrice = outPrice;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -