📄 dailyearningframe.java
字号:
int total = 0;
try {
if (rst.next()) {
total = rst.getInt(1);
if(total==0)
{
JOptionPane.showMessageDialog(this,"没有找到相关数据!!,统计失败!!");
this.btnQuery.setEnabled(false);
return;
}
cumpv.add(new Integer(total));
daily.setTotalBeforeTax(total); //得到税前总额
System.out.println(total);
}
} catch (SQLException ex1) {
ex1.printStackTrace();
}
float taxed = (float) (total * 0.1);
cumpv.add(new Float(taxed));
daily.setTax((int)taxed); //设置税额
int totalTaxed = total - (int) taxed;
cumpv.add(new Integer(totalTaxed));
daily.setTotalAfterTax(totalTaxed); //得到税后总额
cumpv.add(admin);
daily.setOperater(admin); //得到操作员
cumpdtm.addRow(cumpv);
cumpTable.setModel(cumpdtm);
this.btnQuery.setEnabled(false);
this.btnsave.setEnabled(true);
}
public void btnsave_actionPerformed(ActionEvent e) {
this.daily.getOnDate();
this.daily.getTotalBeforeTax();
this.daily.getTax();
this.daily.getTotalAfterTax();
this.daily.getOperater();
this.daily.getRemark();
String sql = "select ondate from dailyearning where ondate = '"+daily.getOnDate()+"'";
ResultSet rt = dbo.returnQuery(sql);
try {
if (rt.next()) {
JOptionPane.showMessageDialog(this,"该日数据已经统计!!");
return;
}
} catch (SQLException ex) {
ex.printStackTrace();
}
String insert = "insert into dailyEarning values ('"+this.daily.getOnDate()+"','"+this.daily.getTotalBeforeTax()+"','"+this.daily.getTax()+"','"+ this.daily.getTotalAfterTax()+"','"+ this.daily.getOperater()+"','"+ this.daily.getRemark()+"')";
if(dbo.updateNoReturn(insert))
{
JOptionPane.showMessageDialog(this,"保存成功!!");
}
else
{
JOptionPane.showMessageDialog(this,"该日数据已经统计!!");
return;
}
}
public void btnRrturn_actionPerformed(ActionEvent e) {
this.dispose();
}
public void cboYear_itemStateChanged(ItemEvent e) {
}
public void cboMonth_itemStateChanged(ItemEvent e) {
this.btnQuery.setEnabled(true);
this.cboDate.removeAllItems();
this.initCboDate();
int ye = Integer.parseInt(this.cboYear.getSelectedItem().toString());
if ((ye % 4 == 0 && ye % 100 != 0) || ye % 400 == 0) {
flag = true;
} else {
flag = false;
}
String mo = this.cboMonth.getSelectedItem().toString();
if (mo == "04" || mo == "06" || mo == "09" || mo == "11") {
this.cboDate.removeItem("31");
}
if (flag) {
if (mo.equals("02")) {
this.cboDate.removeItem("31");
this.cboDate.removeItem("30");
}
} else {
if (mo.equals("02")) {
this.cboDate.removeItem("31");
this.cboDate.removeItem("30");
this.cboDate.removeItem("29");
}
}
}
public void getCal() {
//得到当前日期
year = cal.get(Calendar.YEAR);
month = (cal.get(Calendar.MONTH) + 1);
date = cal.get(Calendar.DATE);
//显示当前年
for (int i = 0; i < this.cboYear.getItemCount(); i++) {
if (this.cboYear.getItemAt(i).toString().equals("" + year)) {
this.cboYear.setSelectedIndex(i);
}
}
if (month < 10) {
this.cboMonth.setSelectedItem("0" + month);
} else {
this.cboMonth.setSelectedItem("" + month);
}
//判断月份
for (int i = 0; i < this.cboMonth.getItemCount(); i++) {
String mon = "";
if (month < 10) {
mon = "0" + month;
} else {
mon = "" + month;
}
if (this.cboMonth.getItemAt(i).toString().equals(mon)) {
this.cboMonth.setSelectedIndex(i);
}
}
if (date < 10) {
this.cboDate.setSelectedItem("0" + date);
} else {
this.cboDate.setSelectedItem("" + date);
}
//判断日期
for (int i = 0; i < this.cboDate.getItemCount(); i++) {
String da = "";
if (date < 10) {
da = "0" + date;
} else {
da = "" + date;
}
if (this.cboDate.getItemAt(i).toString().equals(da)) {
this.cboDate.setSelectedIndex(i);
}
}
}
public void initCboYear() { //设置年份
this.cboYear.addItem("2007");
this.cboYear.addItem("2008");
this.cboYear.addItem("2009");
this.cboYear.setSelectedItem("2007");
}
public void initCboMonth() {
//设置月分
this.cboMonth.addItem("01");
this.cboMonth.addItem("02");
this.cboMonth.addItem("03");
this.cboMonth.addItem("04");
this.cboMonth.addItem("05");
this.cboMonth.addItem("06");
this.cboMonth.addItem("07");
this.cboMonth.addItem("08");
this.cboMonth.addItem("09");
this.cboMonth.addItem("10");
this.cboMonth.addItem("11");
this.cboMonth.addItem("12");
}
public void initCboDate() {
//设置日期
this.cboDate.addItem("01");
this.cboDate.addItem("02");
this.cboDate.addItem("03");
this.cboDate.addItem("04");
this.cboDate.addItem("05");
this.cboDate.addItem("06");
this.cboDate.addItem("07");
this.cboDate.addItem("08");
this.cboDate.addItem("09");
this.cboDate.addItem("10");
this.cboDate.addItem("11");
this.cboDate.addItem("12");
this.cboDate.addItem("13");
this.cboDate.addItem("14");
this.cboDate.addItem("15");
this.cboDate.addItem("16");
this.cboDate.addItem("17");
this.cboDate.addItem("18");
this.cboDate.addItem("19");
this.cboDate.addItem("20");
this.cboDate.addItem("21");
this.cboDate.addItem("22");
this.cboDate.addItem("23");
this.cboDate.addItem("24");
this.cboDate.addItem("25");
this.cboDate.addItem("26");
this.cboDate.addItem("27");
this.cboDate.addItem("28");
this.cboDate.addItem("29");
this.cboDate.addItem("30");
this.cboDate.addItem("31");
}
public void cboDate_itemStateChanged(ItemEvent e) {
this.btnQuery.setEnabled(true);
}
}
class DailyEarningFrame_cboDate_itemAdapter implements ItemListener {
private DailyEarningFrame adaptee;
DailyEarningFrame_cboDate_itemAdapter(DailyEarningFrame adaptee) {
this.adaptee = adaptee;
}
public void itemStateChanged(ItemEvent e) {
adaptee.cboDate_itemStateChanged(e);
}
}
class DailyEarningFrame_cboMonth_itemAdapter implements ItemListener {
private DailyEarningFrame adaptee;
DailyEarningFrame_cboMonth_itemAdapter(DailyEarningFrame adaptee) {
this.adaptee = adaptee;
}
public void itemStateChanged(ItemEvent e) {
adaptee.cboMonth_itemStateChanged(e);
}
}
class DailyEarningFrame_cboYear_itemAdapter implements ItemListener {
private DailyEarningFrame adaptee;
DailyEarningFrame_cboYear_itemAdapter(DailyEarningFrame adaptee) {
this.adaptee = adaptee;
}
public void itemStateChanged(ItemEvent e) {
adaptee.cboYear_itemStateChanged(e);
}
}
class DailyEarningFrame_btnRrturn_actionAdapter implements ActionListener {
private DailyEarningFrame adaptee;
DailyEarningFrame_btnRrturn_actionAdapter(DailyEarningFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnRrturn_actionPerformed(e);
}
}
class DailyEarningFrame_btnsave_actionAdapter implements ActionListener {
private DailyEarningFrame adaptee;
DailyEarningFrame_btnsave_actionAdapter(DailyEarningFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnsave_actionPerformed(e);
}
}
class DailyEarningFrame_btnQuery_actionAdapter implements ActionListener {
private DailyEarningFrame adaptee;
DailyEarningFrame_btnQuery_actionAdapter(DailyEarningFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnQuery_actionPerformed(e);
}
}
class DailyEarningFrame_btnMonth_actionAdapter implements ActionListener {
private DailyEarningFrame adaptee;
DailyEarningFrame_btnMonth_actionAdapter(DailyEarningFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnMonth_actionPerformed(e);
}
}
class DailyEarningFrame_btnDaily_actionAdapter implements ActionListener {
private DailyEarningFrame adaptee;
DailyEarningFrame_btnDaily_actionAdapter(DailyEarningFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnDaily_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -