📄 salepaneloper.java
字号:
package view.panel.subpaneloper;
import javax.swing.JOptionPane;
import view.com.CheckInputText;
import view.panel.subpanel.GetSalePanel;
import vo.SaleProductVo;
import dao.StoreDao;
/**
* 销售面板的简单操作
* @author linfeng
*
*/
public class SalePanelOper extends GetSalePanel {
/**
* 初始化各种文本框
*/
public static void initiaTextValue() {
product_id.setText("");
product_name.setText("");
product_price.setText("");
price_pct.setText("");
sale_num.setText("");
sale_sum.setText("");
}
/**
* 对用户输入的文本框的值进行核对
* @return
*/
public static boolean checkInputValue() {
CheckInputText check = new CheckInputText();
if (check.checkInputIsNull(product_id.getText())) {
JOptionPane.showMessageDialog(null, "商品编号不能为空", "message",
JOptionPane.YES_OPTION);
product_id.requestFocus();
return false;
}
if (check.checkInputIsNull(sale_num.getText())) {
JOptionPane.showMessageDialog(null, "售出数量不能为空", "message",
JOptionPane.YES_OPTION);
sale_num.requestFocus();
return false;
}
if (new StoreDao().findStoreById(getProductId())) {
if (new StoreDao().getStoreNumById(getProductId())
- Integer.parseInt(sale_num.getText()) >= 0) {
product_name.setText(new StoreDao().getStoreNameById(getProductId()));
product_type.setSelectedItem(new StoreDao()
.getStoreTypeById(getProductId()));
product_price.setText(String.valueOf(new StoreDao()
.getStorePriceById(getProductId())));
if (check.checkInputIsNull(price_pct.getText())) {
price_pct.setText("1.0");
}
sale_sum.setText(String.valueOf(Double.parseDouble(product_price
.getText())
* Double.parseDouble(price_pct.getText())
* Integer.parseInt(sale_num.getText())));
}else{
JOptionPane.showMessageDialog(null, "该种商品已经售完", "message",
JOptionPane.YES_OPTION);
}
} else {
JOptionPane.showMessageDialog(null, "不存在该种商品", "message",
JOptionPane.YES_OPTION);
}
return true;
}
/**
* 根据销售面板商品编号输入框的值获得SaleProductVo对象
* @return value SaleProductVo对象
*/
public static SaleProductVo getInputTextValue() {
SaleProductVo value;
int productId = Integer.parseInt(product_id.getText().trim());
String productName = product_name.getText();
String productType = new StoreDao().getStoreTypeById(getProductId());
double productPrice = Double.parseDouble(product_price.getText());
double pricePct = Double.parseDouble(price_pct.getText());
int saleNum = Integer.parseInt(sale_num.getText().trim());
double saleSum = Double.parseDouble(sale_sum.getText().trim());
String saleDate = txtSaleDate.getSelectedItem().toString().trim();
value = new SaleProductVo(productId, productName, productType,
productPrice, pricePct, saleNum, saleSum, saleDate);
return value;
}
/**
* 获得销售面板商品编号输入框的值
* @return proId 销售面板商品编号输入框的值
*/
public static int getProductId() {
int proId = Integer.parseInt(GetSalePanel.product_id.getText());
return proId;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -