1、 数据库课程设计商品销售管理系统 import java.awt.event.*; import java.awt.*; import javax.swing.*; import java.sql.*; import javax.swing.table.AbstractTableModel; public class LoginBackPanel extends JFrame implements ActionListener{ private static final long serialVersionUID = 1L;
2、 JButton button1,button2; JTextField F1; Choice c; Container ct = getContentPane(); public LoginBackPanel(String str){ super(str); setBak(); JPanel panel = new JPanel(); panel.setOpaque(false);
3、 ct.add(panel); panel.setLayout(new FlowLayout(FlowLayout.CENTER,60,20)); c = new Choice(); c.add(" Boss "); c.add(" Salesman "); JLabel J1 = new JLabel("验证身份:"); JLabel J2 = new JLabel("登录密码:"); F1 = new JTextField(9);
4、 button1 = new JButton("登录"); button2 = new JButton("退出"); button1.addActionListener(this); button2.addActionListener(this); panel.add(J1); panel.add(c); panel.add(J2); panel.add(F1); panel.add(button1); panel.add(button2); add(panel); } public v
5、oid setBak(){ //设置背景方法 ((JPanel)this.getContentPane()).setOpaque(false); ImageIcon img = new ImageIcon("e://数据库课程设计//六月物语.jpg"); JLabel background = new JLabel(img); this.getLayeredPane().add(background, new Integer(Integer.MIN_VALUE));
6、 background.setBounds(0, 0, img.getIconWidth(), img.getIconHeight()); } public void actionPerformed(ActionEvent e){ if(e.getSource()==button1){ if(c.getSelectedItem().equals(" Boss ")&&F1.getText().equals("boss")){ this.dispose(); BS bs=new BS("管理员
7、界面"); bs.setSize(500,250); bs.setLocation(450,250); bs.setVisible(true); } if(c.getSelectedItem().equals(" Salesman ")&&F1.getText().equals("salesman")){ this.dispose(); SL sl=new SL("销售员界面"); sl.setSize(500,25
8、0); sl.setLocation(450,250); sl.setVisible(true); } } if(e.getSource()==button2){ System.exit(0); } } public static void main(String[]args){ LoginBackPanel lgp=new LoginBackPanel("管理系统登录"); lgp.setDefaultCloseOperation(JFrame.
9、EXIT_ON_CLOSE); lgp.setSize(300,200); lgp.setLocation(550,250); lgp.setVisible(true); } } class BS extends JFrame implements ActionListener{ JButton B1,B2,B3,B4,B5,B6,B7; Container ct = getContentPane(); public BS(String str){ super(str); setBak();
10、 JPanel JP = new JPanel(); JP.setOpaque(false); ct.add(JP); JP.setLayout(new FlowLayout(FlowLayout.CENTER,30,50)); B1 = new JButton("销售情况"); B2 = new JButton("客户退货"); B3 = new JButton("销售收款"); B4 = new JBu
11、tton("客户信息"); B5 = new JButton("员工管理"); B6 = new JButton("进货信息"); B7 = new JButton("更换角色"); B1.addActionListener(this); B2.addActionListener(this); B3.addActionListener(this); B4.addActionListener(this); B5.addActionListener(this); B6.addActionListener(this); B7.addActi
12、onListener(this); JP.add(B1); JP.add(B2); JP.add(B3); JP.add(B4); JP.add(B5); JP.add(B6); JP.add(B7); add(JP); } public void setBak(){ ((JPanel)this.getContentPane()).setOpaque(false); ImageIcon img = new ImageIcon("e://数据库课程设计//六月物语1.jpg")
13、 JLabel background = new JLabel(img); this.getLayeredPane().add(background, new Integer(Integer.MIN_VALUE)); background.setBounds(0, 0, img.getIconWidth(), img.getIconHeight()); } public void actionPerformed(ActionEvent e){ if(e.getSource()==B1){ this.dispose();
14、 CXFPXX cxfpxx = new CXFPXX("日常销售—【发票情况】"); cxfpxx.setSize(700,300); cxfpxx.setLocation(350,250); cxfpxx.setVisible(true); } if(e.getSource()==B2){ this.dispose(); XSTHXX xsthxx = new XSTHXX("日常销售—【销售退货】"); xsthxx.set
15、Size(700,300); xsthxx.setLocation(350,250); xsthxx.setVisible(true); } if(e.getSource()==B3){ this.dispose(); XSXXCX xsxxcx = new XSXXCX("日常销售—【销售收款】"); xsxxcx.setSize(700,300); xsxxcx.setLocation(350,250); xsxx
16、cx.setVisible(true); } if(e.getSource()==B4){ this.dispose(); HYXXCX hyxxcx = new HYXXCX("基本信息管理—【会员信息】"); hyxxcx.setSize(700,300); hyxxcx.setLocation(350,250); hyxxcx.setVisible(true); } if(e.getSource()==B5){ this.dispose()
17、 YGGL yggl = new YGGL("员工管理—【员工信息】"); yggl.setSize(500,200); yggl.setLocation(450,250); yggl.setVisible(true); } if(e.getSource()==B6){ this.dispose(); JHXX jhxx = new JHXX("商品更新—【进货信息】"); jhxx.setSize(300,150);
18、 jhxx.setLocation(500,250); jhxx.setVisible(true); } if(e.getSource()==B7){ this.dispose(); LoginBackPanel xt = new LoginBackPanel("管理系统登录"); xt.setSize(300,200); xt.setLocation(550,250); xt.setVisible(true); } } }
19、class BG2 extends AbstractTableModel{ String rq,ph,mc,bh,dj,sl,je; final String[] columnNames={"开票日期","销售票号","商品名称","商品编号","商品单价/元","销售数量/个","销售金额/元"}; Object[][]data=new Object[100][7]; public BG2(){ int m=0; String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=课程设
20、计"; Connection con; String sql; Statement stmt; try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); }catch(java.lang.ClassNotFoundException e){ } try{ con=DriverManager.getConnection(url,"sa","123456"); stmt=con.crea
21、teStatement(); sql="SELECT * FROM 销售发票 "; ResultSet rs=stmt.executeQuery(sql); while(rs.next()){ rq=rs.getString(1); ph=rs.getString(2); mc=rs.getString(3); bh=rs.getString(4); dj=rs.getString(5); sl=rs.getString(6); je=rs.getString(7); data[m][0]=rq;d
22、ata[m][1]=ph;data[m][2]=mc;data[m][3]=bh;data[m][4]=dj;data[m][5]=sl;data[m++][6]=je; } stmt.close(); con.close(); }catch(SQLException e){ System.out.println("0"); } } public int getColumnCount(){ return columnNames.length; } public int getRowCount(){
23、 return data.length; } public String getColumnName(int col){ return columnNames[col]; } public Object getValueAt(int row,int col){ return data[row][col]; } public void setValueAt(Object value,int row,int col){ int numRows=getRowCount(); int numCols=getColumnCount();
24、
for(int i=0;i 25、tr);
setLayout(new BorderLayout());
b = new JButton("确定");
b.addActionListener(this);
p = new JPanel();
p.add(b);
bg2 = new BG2();
t = new JTable(bg2);
s = new JScrollPane(t);
add(s,"Center");
add(p,"South");
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==b){ 26、
this.dispose();
BS cxfpxx = new BS("管理员界面");
cxfpxx.setSize(500,250);
cxfpxx.setLocation(450,250);
cxfpxx.setVisible(true);
}
}
}
class BG3 extends AbstractTableModel{
String rq,mc,yy,sl,je;
final String[] columnNames={"退货日期","商品名称"," 27、退货原因","退货数量/件","退货金额/元"};
Object[][]data=new Object[100][5];
public BG3(){
int m=0;
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=课程设计";
Connection con;
String sql;
Statement stmt;
try{
Class.forName("com.microsoft.jdbc.sqlse 28、rver.SQLServerDriver");
}catch(java.lang.ClassNotFoundException e){
}
try{
con=DriverManager.getConnection(url,"sa","123456");
stmt=con.createStatement();
sql="SELECT * FROM 退货记录 ";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
rq=rs.getSt 29、ring(1);
mc=rs.getString(2);
yy=rs.getString(3);
sl=rs.getString(4);
je=rs.getString(5);
data[m][0]=rq;data[m][1]=mc;data[m][2]=yy;data[m][3]=sl;data[m++][4]=je;
}
stmt.close();
con.close();
}catch(SQLException e){
System.out.println("0");
30、 }
}
public int getColumnCount(){
return columnNames.length;
}
public int getRowCount(){
return data.length;
}
public String getColumnName(int col){
return columnNames[col];
}
public Object getValueAt(int row,int col){
return data[row][col];
}
public void setVal 31、ueAt(Object value,int row,int col){
int numRows=getRowCount();
int numCols=getColumnCount();
for(int i=0;i 32、3;
JTable t;
JButton b;
JPanel p;
JScrollPane s;
public XSTHXX(String str){
super(str);
setLayout(new BorderLayout());
b = new JButton("确定");
b.addActionListener(this);
p = new JPanel();
p.add(b);
bg3 = new BG3();
t = new JTable(bg3);
s = new JScrollPane(t);
33、add(s,"Center");
add(p,"South");
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==b){
this.dispose();
BS cxfpxx = new BS("管理员界面");
cxfpxx.setSize(500,250);
cxfpxx.setLocation(450,250);
cxfpxx.setVisible(true);
}
}
}
34、class BG4 extends AbstractTableModel{
String rq,mc,dj,sl,je;
final String[] columnNames={"开票日期","商品名称","商品单价/元","销售数量/个","销售金额/元"};
Object[][]data=new Object[100][5];
public BG4(){
int m=0;
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=课程设计";
Connect 35、ion con;
String sql;
Statement stmt;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}catch(java.lang.ClassNotFoundException e){
}
try{
con=DriverManager.getConnection(url,"sa","123456");
stmt=con.createStatement();
36、sql="SELECT 开票日期,商品名称,[商品单价/元],[销售数量/个],[销售金额/元] FROM 销售发票 ";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
rq=rs.getString(1);
mc=rs.getString(2);
dj=rs.getString(3);
sl=rs.getString(4);
je=rs.getString(5);
data[m][0]=rq;data[m][1]=mc;;data[m][2]=dj;da 37、ta[m][3]=sl;data[m++][4]=je;
}
stmt.close();
con.close();
}catch(SQLException e){
System.out.println("0");
}
}
public int getColumnCount(){
return columnNames.length;
}
public int getRowCount(){
return data.length;
}
public String getColumnName(i 38、nt col){
return columnNames[col];
}
public Object getValueAt(int row,int col){
return data[row][col];
}
public void setValueAt(Object value,int row,int col){
int numRows=getRowCount();
int numCols=getColumnCount();
for(int i=0;i 39、ls;j++){
System.out.print(" "+data[i][j]);
}
}
}
}
class XSXXCX extends JFrame implements ActionListener{
BG4 bg4;
JTable t;
JButton b;
JPanel p;
JScrollPane s;
public XSXXCX(String str){
super(str);
setLayout(new BorderLayout());
b = new JButton( 40、"确定");
b.addActionListener(this);
p = new JPanel();
p.add(b);
bg4 = new BG4();
t = new JTable(bg4);
s = new JScrollPane(t);
add(s,"Center");
add(p,"South");
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==b){
this.dispose();
BS cxfpxx = new BS("管 41、理员界面");
cxfpxx.setSize(500,250);
cxfpxx.setLocation(450,250);
cxfpxx.setVisible(true);
}
}
}
class BG5 extends AbstractTableModel{
String ch,lx,dz,rq;
final String[] columnNames={"客户称呼","联系方式","客户地址","入会日期"};
Object[][]data=new Object[100][4];
publi 42、c BG5(){
int m=0;
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=课程设计";
Connection con;
String sql;
Statement stmt;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}catch(java.lang.ClassNotFoundExceptio 43、n e){
}
try{
con=DriverManager.getConnection(url,"sa","123456");
stmt=con.createStatement();
sql="SELECT * FROM 客户信息 ";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
ch=rs.getString(1);
lx=rs.getString(2);
dz=rs.getString(3);
rq=rs.ge 44、tString(4);
data[m][0]=ch;data[m][1]=lx;data[m][2]=dz;data[m++][3]=rq;
}
stmt.close();
con.close();
}catch(SQLException e){
System.out.println("0");
}
}
public int getColumnCount(){
return columnNames.length;
}
public int getRowCount(){
return da 45、ta.length;
}
public String getColumnName(int col){
return columnNames[col];
}
public Object getValueAt(int row,int col){
return data[row][col];
}
public void setValueAt(Object value,int row,int col){
int numRows=getRowCount();
int numCols=getColumnCount();
for(in 46、t i=0;i 47、Layout(new BorderLayout());
b = new JButton("确定");
b.addActionListener(this);
p = new JPanel();
p.add(b);
bg5 = new BG5();
t = new JTable(bg5);
s = new JScrollPane(t);
add(s,"Center");
add(p,"South");
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==b){
48、this.dispose();
BS cxfpxx = new BS("管理员界面");
cxfpxx.setSize(500,250);
cxfpxx.setLocation(450,250);
cxfpxx.setVisible(true);
}
}
}
class YGGL extends JFrame implements ActionListener{
JButton B1,B2,B3,B4,B5;
Container ct = getContentPane();
pu 49、blic YGGL(String str){
super(str);
setBak();
JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setLayout(new FlowLayout(FlowLayout.CENTER,60,40));
B1 = new JButton("添加员工");
B2 = new JButton("删除员工");
B3 = new 50、JButton("员工名单");
B4 = new JButton("更新信息");
B5 = new JButton("返回");
B1.addActionListener(this);
B2.addActionListener(this);
B3.addActionListener(this);
B4.addActionListener(this);
B5.addActionListener(this);
panel.add(B1);
panel.add(B2);
panel.add(B3);
panel.add(B4);






