最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

1-PPT效果Java swing jdbc DBUtils:自己設計功能的原創(chuàng)收銀管理系統(tǒng)【詩書畫唱】

2020-06-07 19:05 作者:詩書畫唱  | 我要投稿

效果:





目錄:本篇含Java部分的前4個Java文件


項目所用圖片素材:


SQL部分:


全都用四表查詢就不怕查不到內容

select * from sp s inner join gouwuche g on s.sp_id=g.sp_id inner join yonghu y on y.yh_id=g.yh_id inner join sp_type spt on spt.sp_typeid=s.sp_typeid where 1=1

其實商品編號主鍵,自增等都可以只用“唯一”,不然編號為1等的商品被刪除了就增加不了了

select * from sp a inner join sp_type b on a.sp_typeid=b.sp_typeid inner join gouwuche c on a.sp_id=c.sp_id

select * from sp s inner join gouwuche g on s.sp_id=g.sp_id inner join yonghu y on y.yh_id=g.yh_id inner join sp_type spt on

?spt.sp_typeid=s.sp_typeid where 1=1

select * from sp a inner join sp_type b on a.sp_typeid=b.sp_typeid

create database shouyin

create table yh_Type(

yh_typeid int primary key identity(1,1),

yh_typename varchar(100) not null


);

insert into yh_Type values('普通用戶');

insert into yh_Type values('管理員用戶');

create table yonghu(

?yh_ID int primary key identity(1,1),

?yh_Uname varchar(30)? unique,

?--這里設置為unique(唯一)的話,那么在顧客管理增加顧客時,用戶名可能會有兩個null,

?--插入時會報錯,先做簡單的,之后根據(jù)情況和要求做復雜高級的,但最好設置為unique。

?--yh_Uname varchar(30)? ,

yh_Pwd varchar(30) ,

yh_Name varchar(30) ,

yh_Age int,

yh_Sex varchar(20),

yh_Phone varchar(100),

?yh_Address varchar(200),

yh_jieshao varchar(500),

yh_Q varchar(500),

yh_A varchar(500),

yh_type nvarchar(20) check(yh_type='普通用戶' or yh_type='管理員用戶'),

);

insert into yonghu values('1','11','詩書畫唱1',21,'男','19999999999','江西','陽光帥氣的男孩子','你愛好多嗎?','多','普通用戶');

insert into yonghu values('2','22','詩書畫唱2',22,'男','29999999999','北京','陽光帥氣的男孩子','你看過的書多嗎?','多','普通用戶');

insert into yonghu values('3','33','詩書畫唱3',23,'男','39999999999','上海','陽光帥氣的男孩子','你會的技能多嗎?','多','普通用戶');

insert into yonghu values('4','44','詩書畫唱4',24,'男','49999999999','湖南','陽光帥氣的男孩子','你喜歡的動漫嗎?','多','普通用戶');

insert into yonghu values('6','1','詩書畫唱5',25,'男','59999999999','浙江','陽光帥氣的男孩子','你喜歡的歌曲多嗎?','多','管理員用戶');

--商品類型表

create table sp_type(

sp_typeid int primary key identity(1,1),

sp_typename nvarchar(100) not null


)

insert into sp_Type values('水果');


insert into sp_Type values('零食');


insert into sp_Type values('小吃');


insert into sp_Type values('日常用品');


--商品表

create table sp(


sp_id int primary key identity(1,1),


sp_name nvarchar(50) not null ,


--sp_name nvarchar(50) not null unique,


sp_typeid int,


sp_price decimal(10,2),


sp_jieshao nvarchar(100),


spCunHuoShuLiang int


)


insert into sp values('蘋果',1,1,'好吃的蘋果',200),('薯片',2,1,'好香的薯片',200),


('雞柳',3,1,'好吃的雞柳',200),('牙刷',4,4,'全自動牙刷',200);

--商品類型編號不可為5等不存在的編號,不然會有數(shù)據(jù)查不到

--購物車表


create table gouwuche(


gwc_id int primary key identity(1,1),


yh_id int,


--sp_id int,

sp_id int unique,


sp_num int


)


insert into gouwuche values(1,2,1);

insert into gouwuche values(1,3,1);

insert into gouwuche values(1,4,2);

insert into gouwuche(yh_id,sp_id,sp_num) values(1,1,1)

select * from yh_type;

select * from yonghu;

select * from sp_type;

select * from sp;

select * from gouwuche;

drop table sp_type

select * from sp s inner join gouwuche g on s.sp_id=g.sp_id inner join yonghu y on y.yh_id=g.yh_id where 1=1

drop table sp

drop table yh_type


drop table yonghu


drop table gouwuche;


Java部分:

1



package shouYinXiTong;

import java.awt.event.*;

import javax.swing.*;

public class chongZhiMiMa extends JFrame {

static JButton QuRenAnNiu = null;

static JLabel tiShiWenZi1, tiShiWenZi2 = null;


static JPasswordField miMaKuang1, miMaKuang2 = null;


public chongZhiMiMa() {


this.setLayout(null);


this.setTitle("重置密碼頁面");


this.setSize(500, 500);


this.setLocationRelativeTo(null);


this.setVisible(true);

//tiShiWenZi提示文字

tiShiWenZi1 = new JLabel("請輸入密碼");

tiShiWenZi2 = new JLabel("請再次輸入密碼");

tiShiWenZi1.setBounds(100, 100, 100, 30);

this.add(tiShiWenZi1);

tiShiWenZi2 = new JLabel("請再次輸入密碼");


tiShiWenZi2.setBounds(100, 140, 100, 30);


this.add(tiShiWenZi2);


QuRenAnNiu = new JButton("確認修改");


QuRenAnNiu.setBounds(100, 290, 150, 30);


this.add(QuRenAnNiu);




QuRenAnNiu.addActionListener

(new shijian_queRenXiuGai(this));




miMaKuang1 = new JPasswordField();


miMaKuang2 = new JPasswordField();


miMaKuang1.setBounds(280, 100, 100, 30);


miMaKuang2.setBounds(280, 140, 100, 30);


this.add(miMaKuang1);


this.add(miMaKuang2);


}




}




class shijian_queRenXiuGai implements ActionListener {

static chongZhiMiMa jieShouChuangTi = null;

public shijian_queRenXiuGai(chongZhiMiMa ChuangTi) {

this.jieShouChuangTi = ChuangTi;

}


@Override

public void actionPerformed(ActionEvent arg0) {

if (arg0.getActionCommand().equals("確認修改")) {

JOptionPane.showMessageDialog(null, "點擊了修改密碼按鈕");

String pwd1 = jieShouChuangTi.miMaKuang1.getText();

String pwd2 = jieShouChuangTi.miMaKuang2.getText();

if (pwd1.equals(pwd2)) {

String uname = gongjvClass.uname;

String sql = "update yonghu set yh_pwd='" + pwd1

+ "' where yh_uname= '" + uname + "'";

if (DBUtils.ZSG(sql)) {

JOptionPane.showMessageDialog(null, "密碼重置成功");

} else {

JOptionPane.showMessageDialog(null,?

"出現(xiàn)了未知的錯誤,請重試!");

}


} else {


JOptionPane.showMessageDialog(null, "兩次密碼輸入不一致");


return;


}


}


}


}



2





package shouYinXiTong;


import java.sql.*;


public class DBUtils {


static Connection con=null;


static Statement sta=null;


static ResultSet res=null;


//在靜態(tài)代碼塊中執(zhí)行


static{


try {


Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");


} catch (ClassNotFoundException e) {


// TODO Auto-generated catch block


e.printStackTrace();


}


}


//封裝鏈接數(shù)據(jù)庫的方法


public static Connection getCon(){


if(con==null){


try {


con=DriverManager.getConnection


("jdbc:sqlserver://localhost;databaseName=shouyin","qqq","123");


} catch (SQLException e) {


// TODO Auto-generated catch block


e.printStackTrace();


}


}


return con;


}


//查詢的方法


public static ResultSet Select(String sql){


con=getCon();//建立數(shù)據(jù)庫鏈接


try {


sta=con.createStatement();


res=sta.executeQuery(sql);


} catch (SQLException e) {


// TODO Auto-generated catch block


e.printStackTrace();


}


return res;


}


//增刪改查的方法


// 返回int類型的數(shù)據(jù)


public static boolean ZSG(String sql){


con=getCon();//建立數(shù)據(jù)庫鏈接


boolean b=false;


try {


sta=con.createStatement();


int num=sta.executeUpdate(sql);


//0就是沒有執(zhí)行成功,大于0 就成功了


if(num>0){


b=true;


}


} catch (SQLException e) {


// TODO Auto-generated catch block


e.printStackTrace();


}


return b;


}


}



3




package shouYinXiTong;


import java.awt.Color;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.sql.ResultSet;

import java.sql.SQLException;


import javax.swing.ImageIcon;

import javax.swing.JButton;

import javax.swing.JComboBox;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.JPasswordField;

import javax.swing.JTextField;


public class DengLu extends JFrame {


public static JButton dengLuAnNiu,?

quXiaoAnNiu, zhuCeAnNiu,


zhaoHuiMiMaAnNiu = null;


static JComboBox xiaLaKuang = null;




public static JLabel unameWenZi,?

pwdWenZi, imgJLabel,


yhTypeWenZi = null;




public static JPasswordField pwdKuang = null;




public static JTextField unameWenBenKuang = null;




public JPanel oldMianBan = null;




public dengLu() {



this.setTitle("收銀管理系統(tǒng)");


this.setLayout(null);




this.setSize(640, 500);



//this.setBackground(Color.black);


this.setLocationRelativeTo(null);




unameWenZi = new JLabel("用戶名");




pwdWenZi = new JLabel("密碼");


yhTypeWenZi = new JLabel("用戶類型");




xiaLaKuang = new JComboBox();




xiaLaKuang.addItem("普通用戶");




xiaLaKuang.addItem("管理員用戶");


xiaLaKuang.setBounds(180, 280, 140, 30);


yhTypeWenZi.setBounds(110, 280, 70, 30);


this.add(xiaLaKuang);


this.add(yhTypeWenZi);


unameWenZi.setBounds(110, 200, 70, 30);




pwdWenZi.setBounds(110, 240, 70, 30);


// 圖片


imgJLabel = new JLabel();


imgJLabel.setBounds(63, 0, 640, 200);


imgJLabel.setIcon(new?

ImageIcon("img//beijing.gif"));


oldMianBan = new JPanel();


oldMianBan.setLayout(null);


oldMianBan.setBounds(0, 0, 640, 200);


oldMianBan.add(imgJLabel);

oldMianBan.setBackground(Color.yellow);

this.add(oldMianBan);




this.add(unameWenZi);




this.add(pwdWenZi);


// JTextField_unametxt1 =?

//new JTextField("1");//寫死


unameWenBenKuang = new JTextField();

// 沒寫死


pwdKuang = new JPasswordField();

unameWenBenKuang.

setBounds(180, 200, 140, 30);

pwdKuang.setBounds(180, 240, 140, 30);


this.add(unameWenBenKuang);


this.add(pwdKuang);


DengLuAnNiu = new JButton("登錄");


dengLuAnNiu.setBounds(60, 320, 100, 35);


dengLuAnNiu.addActionListener

(new DengLuShiJian(this));


quXiaoAnNiu = new JButton("取消");


quXiaoAnNiu.setBounds(450, 320, 70, 35);


quXiaoAnNiu.addActionListener

(new DengLuShiJian(this));


zhuCeAnNiu = new JButton("普通用戶注冊");


zhuCeAnNiu.setBounds(190, 320, 120, 35);


zhuCeAnNiu.addActionListener

(new dengLuShiJian(this));


zhaoHuiMiMaAnNiu = new JButton("找回密碼");


zhaoHuiMiMaAnNiu.setBounds(330, 320, 90, 35);


zhaoHuiMiMaAnNiu.

addActionListener(new dengLuShiJian(this));


this.add(zhuCeAnNiu);


this.add(DengLuAnNiu);


this.add(quXiaoAnNiu);


this.add(zhaoHuiMiMaAnNiu);


this.setVisible(true);


}}


class dengLuShiJian implements ActionListener {


public DengLu jieShouChuangTi = null;


public DengLuShiJian(dengLu ChuangTi) {


this.jieShouChuangTi = ChuangTi;


}


@Override


public void actionPerformed

(ActionEvent arg0) {


String uname = jieShouChuangTi.

unameWenBenKuang.getText().trim();


String pwd = jieShouChuangTi.

pwdKuang.getText().trim();// 獲取密碼


String type = jieShouChuangTi.

xiaLaKuang.getSelectedItem().toString();


if (arg0.getActionCommand().

equals("登錄")) {


if (type.equals("管理員用戶")) {


String sql = "select * from yonghu "

+ "where yh_uname='" + uname


+ "' and yh_pwd='" + pwd +?

"' and yh_type='" + type


+ "'";


System.out.println(sql);


ResultSet res = DBUtils.Select(sql);


try {


if (res.next()) {


new glyDengLu(uname);

jieShouChuangTi.setVisible(false);


} else {


JOptionPane.showMessageDialog(null,


"用戶名或密碼錯誤或你不是管理員用戶"

+ "或用戶類型選擇錯誤");


}


} catch (SQLException e) {




e.printStackTrace();


}


} else if (type.equals("普通用戶")) {




String sql = "select * from yonghu "

+ "where yh_uname='" + uname


+ "' and yh_pwd='" + pwd +?

"' and yh_type='" + type


+ "'";


System.out.println(sql);


ResultSet res = DBUtils.Select(sql);


try {


if (res.next()) {




new ptGuKeDengLu(uname);




jieShouChuangTi.setVisible(false);




} else {


JOptionPane.showMessageDialog(null,


"用戶名或密碼錯誤或你不是管理員用戶或"

+ "用戶類型選擇錯誤");


}


} catch (SQLException e) {




e.printStackTrace();


}


}




} else if (arg0.getActionCommand()

.equals("普通用戶注冊")) {


new zhuCe();


} else if (arg0.getActionCommand()

.equals("找回密碼")) {


JOptionPane.showMessageDialog(null,?

"點擊了找回密碼按鈕");


new zhaoHuiMiMa();




}

else if (arg0.getActionCommand()

.equals("取消")) {


JOptionPane.showMessageDialog(null,?

"點擊了取消按鈕");


jieShouChuangTi.setVisible(false);




}

}


}



4



package shouYinXiTong;

import java.awt.Color;


import java.awt.Font;


import java.awt.event.ActionEvent;


import java.awt.event.ActionListener;


import java.awt.event.MouseEvent;


import java.awt.event.MouseListener;


import java.sql.ResultSet;


import java.sql.SQLException;


import java.util.Vector;




import javax.swing.BorderFactory;


import javax.swing.ButtonGroup;


import javax.swing.ImageIcon;


import javax.swing.JButton;


import javax.swing.JFrame;


import javax.swing.JLabel;


import javax.swing.JOptionPane;


import javax.swing.JPanel;


import javax.swing.JRadioButton;


import javax.swing.JScrollPane;


import javax.swing.JTable;


import javax.swing.JTextField;


import javax.swing.JTree;


import javax.swing.UIManager;


import javax.swing.event.TreeSelectionEvent;


import javax.swing.event.TreeSelectionListener;


import javax.swing.table.DefaultTableModel;


import javax.swing.tree.DefaultMutableTreeNode;


public class glyDengLu extends JFrame {

public static JButton btn_xiugai, btn_quxiao = null;

public static DefaultTableModel dtm = null;


static JButton qieHuanAnNiu, xiaoLiangAnNiu,?

geRenAnNiu, exitAnNiu ,AnNiu= null;


static JPanel JPanel_mianBan_top,?

JPanel_mianBan_left_bottom,


qieHuanYongHuMianBan, spXiaoLiangPHBMianBan,


updateMianBan, exitMianBan = null;


static JLabel lb_img, lb_title, lb_uname,

lb_pwd, lb_name, lb_sex,


lb_phone = null;


static JRadioButton rb1, rb2 = null;


public static JTable jt1 = null;


static JTextField txt_uname, txt_pwd,?

txt_name, txt_phone = null;




JTree JTree1 = null;

static ImageIcon img;





public glydengLu(String str) {




this.setTitle("管理員用戶登錄后的主界面");




this.setLayout(null);




this.setSize(700, 700);




this.setLocationRelativeTo(null);




JPanel_mianBan_top = new JPanel(null);




qieHuanAnNiu = new JButton("切換用戶",?

new ImageIcon("img//a.jpg"));




qieHuanAnNiu.setVerticalTextPosition(JButton.BOTTOM);




qieHuanAnNiu.setHorizontalTextPosition(JButton.CENTER);




qieHuanAnNiu.setBounds(100, 0, 120, 130);




xiaoLiangAnNiu = new JButton("商品銷量榜",?

new ImageIcon("img//b.jpg"));




xiaoLiangAnNiu.setVerticalTextPosition(JButton.BOTTOM);




xiaoLiangAnNiu.setHorizontalTextPosition(JButton.CENTER);




xiaoLiangAnNiu.setBounds(250, 0, 120, 130);




geRenAnNiu = new JButton("個人信息管理",?

new ImageIcon("img//c.jpg"));




geRenAnNiu.setVerticalTextPosition(JButton.BOTTOM);




geRenAnNiu.setHorizontalTextPosition(JButton.CENTER);




geRenAnNiu.setBounds(400, 0, 120, 130);




exitAnNiu = new JButton("退出系統(tǒng)",?

new ImageIcon("img//d.jpg"));




exitAnNiu.setVerticalTextPosition(JButton.BOTTOM);




exitAnNiu.setHorizontalTextPosition(JButton.CENTER);




exitAnNiu.setBounds(550, 0, 120, 130);




JPanel_mianBan_top.add(qieHuanAnNiu);




JPanel_mianBan_top.add(xiaoLiangAnNiu);




JPanel_mianBan_top.add(geRenAnNiu);




JPanel_mianBan_top.add(exitAnNiu);




JPanel_mianBan_left_bottom = new JPanel(null);




qieHuanYongHuMianBan = new JPanel(null);

//JPanel_mianBan_qieHuanYongHu.setFocusable(false);

//注釋調的代碼一般就是沒效果的

//JPanel_mianBan_qieHuanYongHu.setBackground(Color.yellow);

//

//JPanel_mianBan_qieHuanYongHu.setForeground(Color.blue);


spXiaoLiangPHBMianBan = new JPanel(null);

updateMianBan = new JPanel(null);

exitMianBan = new JPanel(null);

UIManager.put("Tree.collapsedIcon",?

new ImageIcon("img//1.png"));

UIManager.put("Tree.expandedIcon",?

new ImageIcon("img//2.png"));

UIManager.put("Tree.openIcon",?

new ImageIcon("img//3.png"));

UIManager.put("Tree.closedIcon",?

new ImageIcon("img//4.png"));

UIManager.put("Tree.leafIcon",?

new ImageIcon("img//5.png"));


DefaultMutableTreeNode dmtnAll =?

new DefaultMutableTreeNode("菜單列表");


DefaultMutableTreeNode dmtn1 =?

new DefaultMutableTreeNode("顧客管理");


DefaultMutableTreeNode dmtn2 =?

new DefaultMutableTreeNode("商品管理");


DefaultMutableTreeNode dmtnType3? =?

new DefaultMutableTreeNode(


"商品類型管理");




DefaultMutableTreeNode dmtn4 =?

new DefaultMutableTreeNode("查看購物車和結算");


dmtnAll.add(dmtn1);


dmtnAll.add(dmtn2);


dmtnAll.add(dmtnType3);


dmtnAll.add(dmtn4);


JTree1 = new JTree(dmtnAll);




JTree1.addTreeSelectionListener(new glsj(this));




JTree1.setBounds(10, 10, 150, 300);




JPanel_mianBan_left_bottom.add(JTree1);




qieHuanAnNiu.addActionListener(new glsj(this));




xiaoLiangAnNiu.addActionListener(new glsj(this));




geRenAnNiu.addActionListener(new glsj(this));




exitAnNiu.addActionListener(new glsj(this));




JPanel_mianBan_top.setBounds(0, 0, 700, 130);




JPanel_mianBan_left_bottom.setBounds(0, 130, 150, 600);




lb_title = new JLabel("個人信息修改");


lb_title.setFont(new Font("微軟雅黑", Font.BOLD, 30));


lb_title.setBounds(120, 40, 200, 30);




lb_uname = new JLabel("用戶名:");


lb_pwd = new JLabel("密碼:");


lb_name = new JLabel("真實姓名:");


lb_sex = new JLabel("性別:");


lb_phone = new JLabel("電話:");


lb_uname.setBounds(100, 90, 80, 30);


lb_pwd.setBounds(100, 130, 80, 30);


lb_name.setBounds(100, 170, 80, 30);


lb_sex.setBounds(100, 210, 80, 30);


lb_phone.setBounds(100, 250, 80, 30);


updateMianBan.add(lb_uname);


updateMianBan.add(lb_pwd);


updateMianBan.add(lb_name);


updateMianBan.add(lb_sex);


updateMianBan.add(lb_phone);


updateMianBan.add(lb_title);


txt_pwd = new JTextField();


txt_name = new JTextField();


txt_phone = new JTextField();


txt_uname = new JTextField();


txt_uname.setEditable(false);




btn_xiugai = new JButton("修改");


btn_xiugai.addActionListener(new glsj(this));




btn_quxiao = new JButton("取消");


btn_xiugai.setBounds(120, 290, 70, 30);


btn_quxiao.setBounds(240, 290, 70, 30);


txt_uname.setBounds(180, 90, 120, 30);


txt_pwd.setBounds(180, 130, 120, 30);


txt_name.setBounds(180, 170, 120, 30);


txt_phone.setBounds(180, 250, 120, 30);


rb1 = new JRadioButton("男", true);


rb2 = new JRadioButton("女", false);




ButtonGroup bg = new ButtonGroup();


bg.add(rb1);


bg.add(rb2);


rb1.setBounds(180, 210, 60, 30);


rb2.setBounds(250, 210, 60, 30);


updateMianBan.add(txt_uname);


updateMianBan.add(txt_pwd);


updateMianBan.add(txt_name);


updateMianBan.add(rb1);


updateMianBan.add(rb2);


updateMianBan.add(txt_phone);




updateMianBan.add(btn_quxiao);


updateMianBan.add(btn_xiugai);


lb_img = new JLabel();


lb_img.setBounds(0, 0, 532, 532);


lb_img.setIcon(new ImageIcon("img//圖片管理.png"));


qieHuanYongHuMianBan.add(lb_img);


qieHuanYongHuMianBan.setBounds(150, 130, 550, 600);




updateMianBan.setBounds(150, 130, 550, 600);




exitMianBan.setBounds(150, 130, 550, 600);




JPanel_mianBan_top.setBorder

(BorderFactory.createLineBorder(Color.red));




JPanel_mianBan_left_bottom.setBorder(BorderFactory


.createLineBorder(Color.green));

img=new ImageIcon("img//dd.jpg");


AnNiu =new JButton(img);

AnNiu.setBounds(0, 0,? 550, 600);

//JButton4 = new JButton("退出系統(tǒng)", new ImageIcon("img//d.jpg"));

qieHuanYongHuMianBan.setBorder(BorderFactory


.createLineBorder(Color.blue));

qieHuanYongHuMianBan.add(AnNiu);

qieHuanYongHuMianBan.setBackground(Color.black);



spXiaoLiangPHBMianBan.setBorder(BorderFactory


.createLineBorder(Color.red));




updateMianBan.setBorder(BorderFactory


.createLineBorder(Color.green));




exitMianBan.setBorder(BorderFactory


.createLineBorder(Color.blue));


if (spXiaoLiangPHBMianBan != null) {


this.remove(spXiaoLiangPHBMianBan);


}


Vector<Object> v_head = new Vector<Object>();


v_head.add("名次");


v_head.add("商品名稱");


v_head.add("購買數(shù)量");


String sql = "select * from sp a inner join gouwuche b on"


+ " a.sp_id=b.sp_id order by b.sp_num desc";


Vector<Vector<Object>> v_body = new Vector<Vector<Object>>();


ResultSet res = DBUtils.Select(sql);


int num = 1;


try {


while (res.next()) {


Vector<Object> v = new Vector<Object>();


v.add(num++);


v.add(res.getString("sp_name"));


v.add(res.getInt("sp_num"));


v_body.add(v);


}


} catch (SQLException e) {




e.printStackTrace();


}


dtm = new DefaultTableModel(v_body, v_head);




dtm = new DefaultTableModel(v_body, v_head) {


@Override


public boolean isCellEditable(int a, int b) {


return false;


}


};




jt1 = new JTable(dtm);


jt1.getTableHeader().setReorderingAllowed(false);

jt1.getTableHeader().setResizingAllowed(false);

jt1.setBackground(Color.yellow);


jt1.setForeground(Color.blue);


JScrollPane jsp = new JScrollPane(jt1);


jsp.setBounds(0, 0, 500, 500);


spXiaoLiangPHBMianBan = new JPanel();


spXiaoLiangPHBMianBan.add(jsp);


spXiaoLiangPHBMianBan.setBorder(BorderFactory


.createLineBorder(Color.green));




spXiaoLiangPHBMianBan.setBounds(150, 130, 550, 600);




this.add(spXiaoLiangPHBMianBan);


this.add(JPanel_mianBan_top);




this.add(JPanel_mianBan_left_bottom);




this.add(qieHuanYongHuMianBan);




this.add(spXiaoLiangPHBMianBan);




this.add(updateMianBan);




this.add(exitMianBan);




String sqlSelect = "select * from "

+ "yonghu where yh_uname='" + str + "'";


ResultSet resAgain = DBUtils.Select(sqlSelect);


try {


while (resAgain.next()) {




txt_uname.setText(resAgain.getString("yh_uname"));


txt_pwd.setText(resAgain.getString("yh_pwd"));


txt_phone.setText(resAgain.getString("yh_phone"));


txt_name.setText(resAgain.getString("yh_name"));


String sex = resAgain.getString("yh_sex");


if (sex.equals("男")) {


rb1.setSelected(true);


rb2.setSelected(false);


} else if (sex.equals("女")) {


rb2.setSelected(true);


rb1.setSelected(false);


}




}


} catch (SQLException e) {




e.printStackTrace();


}


this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


this.setVisible(true);




}




}




class glsj implements ActionListener,?

TreeSelectionListener, MouseListener {




public glyDengLu jieShou = null;




public glsj(glydengLu chuangTi) {




jieShou = chuangTi;




}




@Override


public void actionPerformed(ActionEvent arg0) {




String str = arg0.getActionCommand();




if (arg0.getSource() == jieShou.qieHuanAnNiu) {


jieShou.qieHuanYongHuMianBan.setVisible(true);


//dd.JPanel_mianBan_qieHuanYongHu.setVisible(true);


new dengLu();




} else if (str.equals("商品銷量榜")) {




jieShou.spXiaoLiangPHBMianBan.setVisible(true);




jieShou.qieHuanYongHuMianBan.setVisible(false);




jieShou.updateMianBan.setVisible(false);




jieShou.exitMianBan.setVisible(false);




} else if (arg0.getSource() == jieShou.geRenAnNiu) {




jieShou.updateMianBan.setVisible(true);




jieShou.spXiaoLiangPHBMianBan.setVisible(false);




jieShou.qieHuanYongHuMianBan.setVisible(false);




jieShou.exitMianBan.setVisible(false);




} else if (arg0.getSource() == jieShou.exitAnNiu) {


System.exit(0);




} else if (arg0.getActionCommand().equals("修改")) {




String uname = jieShou.txt_uname.getText();


String phone = jieShou.txt_phone.getText();


String name = jieShou.txt_name.getText();


String pwd = jieShou.txt_pwd.getText();


String sex = "男";


if (jieShou.rb2.isSelected()) {


sex = "女";


}




String sql = "update users set upwd='" + pwd + "', uname='"


+ name + "' , yh_phone= ' " + phone + "' , yh_sex='" + sex


+ "' where yh_uname='" + uname + "'";


if (DBUtils.ZSG(sql)) {


JOptionPane.showMessageDialog(null, "個人信息更新成功");


return;


} else {


JOptionPane.showMessageDialog(null, "出現(xiàn)了未知的錯誤,請重試");


}




}




}




@Override


public void mouseClicked(MouseEvent arg0) {


// TODO Auto-generated method stub




}




@Override


public void mouseEntered(MouseEvent arg0) {


// TODO Auto-generated method stub




}




@Override


public void mouseExited(MouseEvent arg0) {


// TODO Auto-generated method stub




}




@Override


public void mousePressed(MouseEvent arg0) {


// TODO Auto-generated method stub




}




@Override


public void mouseReleased(MouseEvent arg0) {


// TODO Auto-generated method stub



}




@Override


public void valueChanged(TreeSelectionEvent arg0) {




DefaultMutableTreeNode getWenZi =?

(DefaultMutableTreeNode) jieShou.JTree1




.getLastSelectedPathComponent();




if (getWenZi.toString().equals("顧客管理")) {




new glyGuKeGuanLi();




} else if (getWenZi.toString().equals("商品管理")) {




new glyShangPinGuanLi();




} else if (getWenZi.toString().equals("商品類型管理")) {




new glyShangPinTypeGuanLi();




} else if (getWenZi.toString().equals("查看購物車和結算")) {




new glyGouWuChe();




}


}




}


1-PPT效果Java swing jdbc DBUtils:自己設計功能的原創(chuàng)收銀管理系統(tǒng)【詩書畫唱】的評論 (共 條)

分享到微博請遵守國家法律
措美县| 肃南| 安福县| 宝清县| 和静县| 顺义区| 海伦市| 黄冈市| 襄城县| 涿州市| 沁阳市| 四子王旗| 呼玛县| 梅州市| 临江市| 光泽县| 汉寿县| 合阳县| 乌审旗| 怀来县| 巩义市| 教育| 勃利县| 灵山县| 南溪县| 东兴市| 泊头市| 肥城市| 扬中市| 连江县| 建昌县| 蒲城县| 银川市| 浠水县| 宁南县| 石屏县| 长寿区| 阆中市| 沅江市| 济宁市| 肃宁县|