⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gongshophandler.java~13~

📁 用java写的仓库管理
💻 JAVA~13~
字号:
package cangku;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import javax.swing.JOptionPane;

public class GongShopHandler implements ActionListener {
    DialogGongShopView gsh;
    GongShopModel model=new GongShopModel();
    ArrayList lis=model.ShopSelect();
    int i=0;
    public GongShopHandler(DialogGongShopView gsh){
        this.gsh=gsh;
    }
    public void select(int k){
        GongShopModel mode=new GongShopModel();
        mode=(GongShopModel) lis.get(k);
        gsh.txtShopID.setText(mode.get商品编号().trim());
        gsh.txtShopName.setText(mode.get商品名称().trim());
        gsh.txtShopjiancheng.setText(mode.get简称().trim());
        gsh.txtShopGuige.setText(mode.get规格().trim());
        gsh.txtShopQi.setText(Integer.toString(mode.get保质期()).trim());
        gsh.txtShopChanDi.setText(mode.get产地().trim());
        gsh.txtShopPirce.setText(mode.get单位().trim());
        gsh.txtShopjianPrice.setText(Integer.toString(mode.get进价()).trim());
        gsh.txtShopPiPrice.setText(Integer.toString(mode.get批发价()).trim());
        gsh.txtShoplianPrice.setText(Integer.toString(mode.get零售价()).trim());
        gsh.chbShopGongName.setSelectedIndex(k);
        gsh.txtShopGongNo.setText(mode.get供应商编号().trim());
        gsh.txtShopRearks.setText(mode.get备注().trim());
    }

    public void actionPerformed(ActionEvent e) {
        if(e.getActionCommand()=="Up"){
            i--;
            if(i>=0){
                select(i);
                gsh.btnshopNext.setEnabled(true);
                gsh.btnshopUpdate.setEnabled(true);
                gsh.btnshopDel.setEnabled(true);
                gsh.chbShopGongName.setEditable(false);
            }else{
                gsh.btnshopUp.setEnabled(false);
            }
        }
       if(e.getActionCommand()=="Next"){
           i++;
           if(i<lis.size()){
               select(i);
               gsh.btnshopUp.setEnabled(true);
               gsh.btnshopUpdate.setEnabled(true);
               gsh.btnshopDel.setEnabled(true);
               gsh.chbShopGongName.setEditable(false);
           }else{
               gsh.btnshopNext.setEnabled(false);
           }
       }
       if(e.getActionCommand()=="Add"){
            model.ShopBainhao();
            gsh.btnshopUp.setEnabled(true);
            gsh.btnshopNext.setEnabled(true);
            gsh.btnshopUpdate.setEnabled(false);
            gsh.btnshopDel.setEnabled(false);
            model.ShopBainhao();
            gsh.txtShopID.setText("S200"+model.get商品编号().trim());
            gsh.txtShopName.setText("");
            gsh.txtShopjiancheng.setText("");
            gsh.txtShopGuige.setText("");
            gsh.txtShopQi.setText("");
            gsh.txtShopChanDi.setText("");
            gsh.txtShopPirce.setText("");
            gsh.txtShopjianPrice.setText("");
            gsh.txtShopjianPrice.setEditable(true);
            gsh.txtShopPiPrice.setText("");
            gsh.txtShopPiPrice.setEditable(true);
            gsh.txtShoplianPrice.setText("");
            gsh.txtShoplianPrice.setEditable(false);
            gsh.chbShopGongName.setEditable(true);
            gsh.txtShopGongNo.setText("");
            gsh.txtShopRearks.setText("");
        }
        if(e.getActionCommand()=="Save"){
            if(gsh.txtShopName.getText().trim().equals("")||gsh.txtShopjiancheng.getText().trim().equals("")||gsh.txtShopGuige.getText().trim().equals("")||gsh.txtShopQi.getText().trim().equals("")||gsh.txtShopChanDi.getText().trim().equals("")||gsh.txtShopPirce.getText().trim().equals("")||gsh.txtShopjianPrice.getText().trim().equals("")||gsh.txtShopPiPrice.getText().trim().equals("")||gsh.txtShoplianPrice.getText().trim().equals("")||gsh.txtShopGongNo.getText().trim().equals("")||gsh.txtShopRearks.getText().trim().equals("")){
                JOptionPane.showMessageDialog(null,"信息输入不完整!","信息",JOptionPane.QUESTION_MESSAGE);
                return;
            }else{
               model.set商品编号(gsh.txtShopID.getText().trim());

            }
        }
        if(e.getActionCommand()=="Update"){}
        if(e.getActionCommand()=="Del"){}
        if(e.getActionCommand()=="Quxiao"){
//            gsh.btnshopDel.setEnabled(true);
//            select(0);
        }
        if(e.getActionCommand()=="Exit"){
            gsh.dispose();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -