📄 managerview.java~144~
字号:
package dvd;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
import java.lang.*;
import javax.swing.Timer;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class ManagerView extends JFrame {
private String names[]={"manager","waiter"};
private String dYear[]={"2004","2005","2006","2007","2008"};
private String dMonth[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
private String dDay[]={"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"};
Timer timer;
private Connection connection;
private String url = "jdbc:odbc:sql";
java.util.Date date=new java.util.Date();
String Time=date.toString();
JLabel jLabel1 = new JLabel();
JButton jButton1 = new JButton();
JButton jButton3 = new JButton();
JLabel jLabel5 = new JLabel();
JTextField jtx3 = new JTextField();
JTextField jtx4 = new JTextField();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
JLabel jLabel8 = new JLabel();
JComboBox jcb1 = new JComboBox(names);
JButton jButton4 = new JButton();
DVDManage DVD=new DVDManage();
JButton jButton5 = new JButton();
JLabel jLabel9 = new JLabel();
JTextField jtx1 = new JTextField();
JTextField jtx2 = new JTextField();
JComboBox jcb2 = new JComboBox(names);
JButton jButton6 = new JButton();
JPanel jPanel1 = new JPanel();
JLabel jLabel2 = new JLabel();
XYLayout xYLayout2 = new XYLayout();
JComboBox year = new JComboBox(dYear);
JComboBox month = new JComboBox(dMonth);
JComboBox day = new JComboBox(dDay);
JRadioButton jrb2 = new JRadioButton();
JRadioButton jrb3 = new JRadioButton();
ButtonGroup buttonGroup3 = new ButtonGroup();
JButton jButton2 = new JButton();
JRadioButton jrb1 = new JRadioButton();
JLabel jLabel3 = new JLabel();
JTextField jtx6 = new JTextField();
JTextField jtx7 = new JTextField();
JComboBox jcb3 = new JComboBox(names);
JButton jButton7 = new JButton();
JLabel jLabel4 = new JLabel();
GridBagLayout gridBagLayout1 = new GridBagLayout();
public ManagerView() {
try {
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
connection = DriverManager.getConnection(
url );
}
catch ( ClassNotFoundException cnfex ) {
System.err.println(
"Failed to load JDBC/ODBC driver." );
cnfex.printStackTrace();
System.exit( 1 ); // terminate program
}
catch ( SQLException sqlex ) {
System.err.println( "Unable to connect" );
sqlex.printStackTrace();
}
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
jLabel1.setBackground(Color.red);
jLabel1.setFont(new java.awt.Font("Dialog", 0, 30));
jLabel1.setForeground(new Color(255, 166, 255));
jLabel1.setText("经理操作窗口");
this.getContentPane().setLayout(gridBagLayout1);
jButton1.setBackground(UIManager.getColor("Button.disabledShadow"));
jButton1.setFont(new java.awt.Font("Serif", 0, 20));
jButton1.setForeground(Color.magenta);
jButton1.setText("销售情况详表");
jButton1.addActionListener(new ManagerView_jButton1_actionAdapter(this));
jButton3.setBackground(UIManager.getColor("Button.disabledShadow"));
jButton3.setFont(new java.awt.Font("Dialog", 0, 20));
jButton3.setForeground(Color.magenta);
jButton3.setText("碟片管理");
jButton3.addActionListener(new ManagerView_jButton3_actionAdapter(this));
this.getContentPane().setBackground(Color.white);
jLabel5.setFont(new java.awt.Font("Dialog", 0, 20));
jLabel5.setForeground(Color.magenta);
jLabel5.setText("新建登陆");
jtx3.setText("");
jLabel6.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel6.setForeground(Color.magenta);
jLabel6.setText("用户名 ");
jLabel7.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel7.setForeground(Color.magenta);
jLabel7.setText("密码");
jtx4.setText("");
jLabel8.setFont(new java.awt.Font("Dialog", 0, 15));
jLabel8.setForeground(Color.magenta);
jLabel8.setText("角色 ");
jButton4.setBackground(SystemColor.activeCaptionText);
jButton4.setFont(new java.awt.Font("Dialog", 0, 15));
jButton4.setForeground(new Color(0, 145, 0));
jButton4.setText("建立");
jButton4.addActionListener(new ManagerView_jButton4_actionAdapter(this));
jcb1.addActionListener(new ManagerView_jcb1_actionAdapter(this));
jButton5.setBackground(Color.white);
jButton5.setFont(new java.awt.Font("Dialog", 0, 20));
jButton5.setForeground(Color.magenta);
jButton5.setText("影片情况总览");
jButton5.addActionListener(new ManagerView_jButton5_actionAdapter(this));
jLabel9.setFont(new java.awt.Font("Dialog", 0, 20));
jLabel9.setForeground(Color.magenta);
jLabel9.setText("修改登陆");
jtx1.setText("");
jtx2.setText("");
jcb2.addActionListener(new ManagerView_jcb2_actionAdapter(this));
jButton6.setBackground(Color.white);
jButton6.setFont(new java.awt.Font("Dialog", 0, 15));
jButton6.setForeground(new Color(0, 104, 0));
jButton6.setText("修改");
jButton6.addActionListener(new ManagerView_jButton6_actionAdapter(this));
jLabel2.setFont(new java.awt.Font("Dialog", 0, 20));
jLabel2.setForeground(Color.magenta);
jLabel2.setText("销售结算");
jPanel1.setLayout(xYLayout2);
jrb2.setFont(new java.awt.Font("Dialog", 0, 15));
jrb2.setForeground(Color.blue);
jrb2.setText("按月结算");
jrb3.setFont(new java.awt.Font("Dialog", 0, 15));
jrb3.setForeground(Color.blue);
jrb3.setSelected(true);
jrb3.setText("按日结算");
jButton2.setFont(new java.awt.Font("Dialog", 0, 15));
jButton2.setForeground(Color.magenta);
jButton2.setText("结算");
jButton2.addActionListener(new ManagerView_jButton2_actionAdapter(this));
year.addActionListener(new ManagerView_year_actionAdapter(this));
jrb1.setFont(new java.awt.Font("Dialog", 0, 15));
jrb1.setForeground(Color.blue);
jrb1.setText("按年结算");
jLabel3.setFont(new java.awt.Font("Dialog", 0, 20));
jLabel3.setForeground(Color.magenta);
jLabel3.setText("删除登陆");
jtx7.setText(" ");
jtx6.setText("");
jButton7.setBackground(Color.white);
jButton7.setFont(new java.awt.Font("Dialog", 0, 15));
jButton7.setForeground(new Color(0, 118, 0));
jButton7.setText("删除");
jButton7.addActionListener(new ManagerView_jButton7_actionAdapter(this));
jLabel4.setFont(new java.awt.Font("DialogInput", 0, 15));
jLabel4.setForeground(new Color(0, 138, 0));
jLabel4.setText("" );
this.getContentPane().add(jLabel1, new GridBagConstraints(0, 0, 5, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(7, 160, 0, 33), 13, 10));
this.getContentPane().add(jtx4, new GridBagConstraints(3, 4, 2, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(11, 16, 0, 0), 94, 10));
this.getContentPane().add(jtx3, new GridBagConstraints(3, 2, 2, 2, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(7, 16, 0, 0), 94, 10));
this.getContentPane().add(jButton3, new GridBagConstraints(0, 3, 1, 2, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 28, 13, 0), 55, 1));
this.getContentPane().add(jButton1, new GridBagConstraints(0, 1, 1, 2, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(27, 28, 0, 0), 15, 1));
this.getContentPane().add(jLabel5, new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 8), 4, 13));
this.getContentPane().add(jLabel6, new GridBagConstraints(1, 2, 2, 2, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(7, 23, 0, 0), 3, 11));
this.getContentPane().add(jLabel7, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(11, 23, 0, 0), 17, 11));
this.getContentPane().add(jLabel8, new GridBagConstraints(1, 5, 3, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 23, 0, 0), 41, 9));
this.getContentPane().add(jcb1, new GridBagConstraints(3, 5, 2, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(8, 16, 0, 0), 28, 1));
this.getContentPane().add(jButton5, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 28, 0, 0), 15, 1));
this.getContentPane().add(jLabel9, new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 24, 0, 14), 4, 13));
this.getContentPane().add(jtx1, new GridBagConstraints(5, 2, 1, 2, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(7, 24, 0, 0), 94, 10));
this.getContentPane().add(jtx2, new GridBagConstraints(5, 4, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(11, 24, 0, 0), 94, 10));
this.getContentPane().add(jcb2, new GridBagConstraints(5, 5, 1, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(8, 24, 0, 0), 28, 1));
this.getContentPane().add(jButton6, new GridBagConstraints(5, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 33, 0, 14), 11, -1));
this.getContentPane().add(jButton4, new GridBagConstraints(4, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 0, 0, 18), 11, 0));
this.getContentPane().add(jPanel1, new GridBagConstraints(0, 7, 7, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(17, -1, 3, 0), 167, 34));
jPanel1.add(jLabel2, new XYConstraints(31, 34, 89, 50));
jPanel1.add(year, new XYConstraints(137, 43, 97, 29));
jPanel1.add(month, new XYConstraints(255, 43, 97, 29));
jPanel1.add(day, new XYConstraints(373, 43, 97, 29));
jPanel1.add(jButton2, new XYConstraints(27, 84, 90, 34));
jPanel1.add(jrb2, new XYConstraints(239, 81, 90, 33));
jPanel1.add(jrb1, new XYConstraints(139, 81, 90, 33));
jPanel1.add(jrb3, new XYConstraints(339, 81, 90, 33));
this.getContentPane().add(jLabel3, new GridBagConstraints(6, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 20, 0, 19), 4, 13));
this.getContentPane().add(jtx6, new GridBagConstraints(6, 2, 1, 2, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(7, 18, 0, 7), 94, 10));
this.getContentPane().add(jtx7, new GridBagConstraints(6, 4, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(11, 18, 0, 7), 91, 10));
this.getContentPane().add(jcb3, new GridBagConstraints(6, 5, 1, 1, 1.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(9, 18, 0, 7), 28, 1));
this.getContentPane().add(jButton7, new GridBagConstraints(6, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 32, 0, 16), 11, -1));
this.getContentPane().add(jLabel4, new GridBagConstraints(2, 8, 5, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 362, 27));
buttonGroup3.add(jrb2);
buttonGroup3.add(jrb3);
buttonGroup3.add(jrb1);
int delay = 1;//milliseconds
ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jLabel4.setText("当前日期:"+new java.util.Date().toString());
}
};
timer=new Timer(delay, taskPerformer);
timer.start();
}
void jcb1_actionPerformed(ActionEvent e) {
}
void jButton1_actionPerformed(ActionEvent e) {
String quire="select * from sell";
DVDFrame movieFrame=new DVDFrame(connection,quire);
movieFrame.setSize(500,500);
movieFrame.show();
}
void jButton3_actionPerformed(ActionEvent e) {
DVD.setSize(500, 500);
DVD.show();
//this.dispose();
}
void jButton5_actionPerformed(ActionEvent e) {
String quire1="select * from part_inf";
DVDFrame movieFrame=new DVDFrame(connection,quire1);
movieFrame.setSize(500,500);
movieFrame.show();
}
void jButton4_actionPerformed(ActionEvent e) {
try {
Statement statement = connection.createStatement();
String userName= jtx3.getText().trim();
String userPassword= jtx4.getText().trim();
String buildRole= jcb1.getSelectedItem().toString();
if(!(userName.equals("")||userPassword.equals("")))
{
if(buildRole.equals("manager")){
String insert1 = "insert into manager ("+
"managerName,passWord) values ('"+
userName+"','"+userPassword+"')";
connection.nativeSQL(insert1);
int result =statement.executeUpdate(insert1);
if(result==1)
{
JOptionPane.showMessageDialog(null,"新建经理登陆成功","bulid actor success",JOptionPane.INFORMATION_MESSAGE);
jtx3.setText("");
jtx4.setText("");
}
statement.close();
}
else if(buildRole.equals("waiter")){
String insert2 = "insert into waiter ("+
"waiterName,passWord) values ('"+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -