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

📄 dbcddialog.java

📁 我做的第一个java MIS项目
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            this.setSize(330,370);
        }






        //增加rec数据时的初始化
        if (dialogtemp.getflag()==5)
        {
            int newrecid=BusinessAction.getmaxrecid()+1;
            txfrecid.setText(newrecid+"");
            //初始化panel和按钮
            btnok.setBounds(new Rectangle(56, 330, 85, 29));
            btncancel.setBounds(new Rectangle(186, 330, 85, 29));
            jPanel3.setBounds(new Rectangle(14, 13, 294, 300));
            this.getContentPane().add(jPanel3);
            this.setTitle("添加记录数据");
            this.setSize(330,405);
        }
        //编辑rec数据时的初始化
        if (dialogtemp.getflag()==6)
        {
            //得到临时Vector的值并显示在Dialog中
            Vector show=dialogtemp.getmdfvector();
            txfrecid.setText(show.elementAt(0).toString());
            txfreccardid.setText(show.elementAt(1).toString());
            txfreccdid.setText(show.elementAt(2).toString());
            txfrecstarttime.setText(show.elementAt(3).toString());
            txfrecendtime.setText(show.elementAt(4).toString());
            //初始化panel和按钮
            btnok.setBounds(new Rectangle(56, 330, 85, 29));
            btncancel.setBounds(new Rectangle(186, 330, 85, 29));
            jPanel3.setBounds(new Rectangle(14, 13, 294, 300));
            this.getContentPane().add(jPanel3);
            this.setTitle("添加记录数据");
            this.setSize(330,405);
        }





        //居中主窗体
        Dimension ScreenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension FrameSize= this.getSize();
        this.setLocation((ScreenSize.width-FrameSize.width)/2,(ScreenSize.height-FrameSize.height)/2);
    }

    JPanel jPanel1 = new JPanel();
    JPanel jPanel2 = new JPanel();
    JPanel jPanel3 = new JPanel();
    JLabel jLabel1 = new JLabel();
    JTextField txfcdid = new JTextField();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JComboBox cobcdtype = new JComboBox();
    JTextField txfcdactor = new JTextField();
    JLabel jLabel5 = new JLabel();
    JTextField txfcdname = new JTextField();
    JLabel jLabel6 = new JLabel();
    JComboBox cobcdmtype = new JComboBox();
    JTextArea txacdnote = new JTextArea();
    JLabel jLabel7 = new JLabel();
    JButton btncancel = new JButton();
    JButton btnok = new JButton();
    JCheckBox chbcdexist = new JCheckBox();
    JLabel jLabel8 = new JLabel();
    JTextField txfcardid = new JTextField();
    JLabel jLabel11 = new JLabel();
    JTextField txfcardbalance = new JTextField();
    JLabel jLabel12 = new JLabel();
    JTextField txfcardpwd = new JTextField();
    JLabel jLabel13 = new JLabel();
    JLabel jLabel9 = new JLabel();
    JTextField txfcardusername = new JTextField();
    JTextField txfcardrestnum = new JTextField(); //取消按钮动作

    JTextField txfrecid = new JTextField();
    JTextField txfreccardid = new JTextField();
    JTextField txfreccdid = new JTextField();
    JTextField txfrecstarttime = new JTextField();
    JTextField txfrecendtime = new JTextField();
    JLabel jLabel10 = new JLabel();
    JLabel jLabel14 = new JLabel();
    JLabel jLabel15 = new JLabel();
    JLabel jLabel16 = new JLabel();
    JLabel jLabel17 = new JLabel();
    public void jButton1_actionPerformed(ActionEvent e) {
        dialogtemp.setflag(0);
        dialogtemp.setcdid("");
        this.dispose();
    }
    //确定按钮动作
    public void jButton2_actionPerformed(ActionEvent e) {
        //得到必要信息
            //初始化cd变量
            String cdid=null;
            String cdexist=null;
            String cdname=null;
            String cdtype=null;
            String cdmtype=null;
            String cdactor=null;
            String cdnote=null;
            if (dialogtemp.getflag()==1 || dialogtemp.getflag()==2)
            {
                cdid=txfcdid.getText().trim();
                cdexist="";
                if(chbcdexist.isSelected())
                {cdexist="1";}
                else
                {cdexist="0";}
                cdname=txfcdname.getText().trim();
                cdtype=cobcdtype.getSelectedItem().toString();
                cdmtype=cobcdmtype.getSelectedItem().toString();
                cdactor=txfcdactor.getText().trim();
                cdnote=txacdnote.getText();
            }
            //初始化card变量
            String cardid=null;
            String cardpwd=null;
            String cardusername=null;
            String cardbalance=null;
            String cardrestnum=null;
            if (dialogtemp.getflag()==3 || dialogtemp.getflag()==4)
            {
                cardid=txfcardid.getText().trim();
                cardpwd=txfcardpwd.getText().trim();
                cardusername=txfcardusername.getText().trim();
                cardbalance=txfcardbalance.getText().trim();
                cardrestnum=txfcardrestnum.getText().trim();
            }
            //初始化rec变量
            String recid=null;
            String reccdid=null;
            String reccardid=null;
            String recstarttime=null;
            String recendtime=null;
            if (dialogtemp.getflag()==5 || dialogtemp.getflag()==6)
            {
                recid=txfrecid.getText().trim();
                reccdid=txfreccdid.getText().trim();
                reccardid=txfreccardid.getText().trim();
                recstarttime=txfrecstarttime.getText().trim();
                recendtime=txfrecendtime.getText().trim();
            }




        //cd表编辑:
        if (dialogtemp.getflag()==1 || dialogtemp.getflag()==2){
            if (cdname.equals("") || cdtype.equals("") || cdmtype.equals(""))
            {new JOptionPane().showMessageDialog(this,"请填写完整信息","提示",JOptionPane.WARNING_MESSAGE);}
            else
            {
                //增加数据的确定代码
                if (dialogtemp.getflag() == 1) {
                //增加功能实现
                if (cdactor.equals("")) {cdactor = "无";}
                if (cdnote.equals("")) {cdnote = "无";}
                String tsql = "insert cd values (" + cdid + ",'" + cdexist +"','" + cdname + "','" + cdtype + "','" + cdmtype +"','" + cdactor + "','" + cdnote + "')";
                new RunSQL().runsql(tsql);
                new JOptionPane().showMessageDialog(this, "添加成功!", "提示", 1);
                //清理信息
                txfcdname.setText("");
                chbcdexist.setSelected(true);
                txfcdactor.setText("无");
                txacdnote.setText("无");
                txfcdid.setText((BusinessAction.getmaxcdid() + 1) + "");
            }
            if (dialogtemp.getflag() == 2) {
                //修改功能实现
                String cdexiststr = "";
                if (chbcdexist.isSelected()) {
                    cdexiststr = "1";
                } else {
                    cdexiststr = "0";
                }
                String mdfstr = "update cd set cdexist='" + cdexiststr +
                                "',cdname='" + txfcdname.getText() +
                                "',cdtype='" +
                                cobcdtype.getSelectedItem().toString() +
                                "',cdmtype='" +
                                cobcdmtype.getSelectedItem().toString() +
                                "',cdactor='" + txfcdactor.getText() +
                                "',cdnotes='" + txacdnote.getText() +
                                "' where cdid='" + txfcdid.getText() + "'";
                new RunSQL().runsql(mdfstr);
                new JOptionPane().showMessageDialog(this, "修改成功!", "提示", 1);
            }
        }
        }
        //card表编辑:
        if (dialogtemp.getflag()==3 || dialogtemp.getflag()==4){
            //强壮性检查
            if (cardid.equals("") || cardpwd.equals("") || cardusername.equals("") || cardbalance.equals("") || cardrestnum.equals(""))
            {new JOptionPane().showMessageDialog(this,"请填写完整信息","提示",JOptionPane.WARNING_MESSAGE);}
            else
            {
                 if (dialogtemp.getflag()==3)
                 {
                         //增加card表数据
                         String sqlcardadd="insert card values ('"+cardid+"','"+cardpwd+"','"+cardusername+"','"+cardbalance+"','"+cardrestnum+"')";
                         new RunSQL().runsql(sqlcardadd);
                         new JOptionPane().showMessageDialog(this, "添加成功!", "提示", 1);
                         //清理信息
                         txfcardid.setText((BusinessAction.getmaxcardid()+1)+"");
                         txfcardpwd.setText("");
                         txfcardusername.setText("");
                         txfcardbalance.setText("");
                         txfcardrestnum.setText("");
                 }
                 else
                 {
                         //编辑card表数据
                         String sqlcardmdf="update card set cardpwd='"+cardpwd+"',cardusername='"+cardusername+"',cardbalance='"+cardbalance+"',cardrestnum='"+cardrestnum+"' where cardid='"+cardid+"'";
                         new RunSQL().runsql(sqlcardmdf);
                         new JOptionPane().showMessageDialog(this, "修改成功!", "提示", 1);
                 }
            }
        }
        //rec表编辑:
        if (dialogtemp.getflag()==5 || dialogtemp.getflag()==6){
            //强壮性检查
            if (recid.equals("") || reccdid.equals("") || reccardid.equals("") || recstarttime.equals("") || recendtime.equals(""))
            {new JOptionPane().showMessageDialog(this,"请填写完整信息","提示",JOptionPane.WARNING_MESSAGE);}
            else
            {
                if (dialogtemp.getflag()==5)
                 {
                         //增加rec表数据
                         String sqlcardadd="insert record values ('"+recid+"','"+reccardid+"','"+reccdid+"','"+recstarttime+"','"+recendtime+"')";
                         new RunSQL().runsql(sqlcardadd);
                         new JOptionPane().showMessageDialog(this, "添加成功!", "提示", 1);
                         //清理信息
                         txfrecid.setText((BusinessAction.getmaxrecid()+1)+"");
                         txfreccdid.setText("");
                         txfreccardid.setText("");
                         txfrecstarttime.setText("");
                         txfrecendtime.setText("");
                 }
                 else
                 {
                         //编辑rec表数据
                         String sqlrecmdf="update record set reccdid='"+reccdid+"',reccardid='"+reccardid+"',recstarttime='"+recstarttime+"',recendtime='"+recendtime+"' where recid='"+recid+"'";
                         new RunSQL().runsql(sqlrecmdf);
                         new JOptionPane().showMessageDialog(this, "修改成功!", "提示", 1);
                 }
            }
        }
    }
}


class dbcdDialog_jButton2_actionAdapter implements ActionListener {
    private dbcdDialog adaptee;
    dbcdDialog_jButton2_actionAdapter(dbcdDialog adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton2_actionPerformed(e);
    }
}


class dbcdDialog_jButton1_actionAdapter implements ActionListener {
    private dbcdDialog adaptee;
    dbcdDialog_jButton1_actionAdapter(dbcdDialog adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }
}

⌨️ 快捷键说明

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