반응형
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 |
import java.sql.*;
import java.util.*;
public class Db_test {
Connection con = null;
Statement stmt = null;
Db_test(){
try{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","hr","1234");
stmt = con.createStatement();
System.out.println("mssql jdbc test: connect ok!!");
}catch( Exception e ) {
System.out.println(e);
}
}
String show(String m){
String price = "";
try{
String sql = "SELECT price FROM bbq WHERE menu='"+m+"'";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
price = rs.getString("price");
}
}catch(Exception e){
System.out.println("show error"+e);
}
return price;
}
void save(String id, String ms, int t){
try{
String sql = "INSERT INTO bbq_p(id,menus,total) VALUES"
+"('"+id+"','"+ms+"','"+t+"')";
stmt.executeUpdate(sql);
stmt.close(); con.close();
}catch(Exception e){
System.out.println("save error"+e);
}
}//save
public static void main(String ar[]){
new Db_test();
}
} //db_test |
cs |
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 |
import java.awt.*;
import javax.swing.*;
import javax.swing.*;
import java.awt.event.*;
class Order1 extends JFrame implements ActionListener {
JLabel l1,l2,l3; JButton b1,b2; JTextField tf1, tf2;
Order1(){
super("login");
l1=new JLabel("BBQ",0);
l2=new JLabel("아이디");
l3=new JLabel("비번");
tf1=new JTextField(10);
tf2=new JTextField(10);
b1=new JButton("확인");
b1.addActionListener(this);
b2=new JButton("회원가입");
JPanel p1=new JPanel();
p1.setLayout(new FlowLayout());
p1.add(l2); p1.add(tf1);
JPanel p2=new JPanel();
p2.setLayout(new FlowLayout());
p2.add(l3); p2.add(tf2);
JPanel p3=new JPanel();
p3.setLayout(new FlowLayout());
p3.add(b1); p3.add(b2);
JPanel p4=new JPanel();
p4.setLayout(new BorderLayout());
p4.add("North", p1); p4.add("South", p2);
JPanel p5=new JPanel();
this.setLayout(new BorderLayout());
this.add("North", l1);
this.add("South", p3);
this.add("Center", p4);
this.setDefaultCloseOperation(3);
this.pack();
this.setVisible(true);
}
public static void main(String[] args) {
new Order1();
}
@Override
public void actionPerformed(ActionEvent e) {
String id = tf1.getText();
String pw = tf2.getText();
if(pw.equals("1234")){
new Order2(id);
this.setVisible(false);
}else {
tf2.setText("pw error");
}
}
} // order1 |
cs |
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 |
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Order2 extends JFrame implements ActionListener {
JLabel l1,l2,l3; JButton b1; JRadioButton bb1,bb2;
JComboBox jb1,jb2;
String id;
Order2(String id){
super(id+"주문하기");
this.id=id;
l1=new JLabel("메뉴");
l2=new JLabel("사이드 메뉴");
l3=new JLabel("파 무침");
b1=new JButton("확인");
b1.addActionListener(this);
bb1=new JRadioButton("선택", true);
bb2=new JRadioButton("미선택");
ButtonGroup bg=new ButtonGroup();
bg.add(bb1);
bg.add(bb2);
jb1=new JComboBox();
jb1.addItem("후라이드");
jb1.addItem("양념치킨");
jb1.addItem("간장치킨");
jb2=new JComboBox();
jb2.addItem("무");
jb2.addItem("콜라");
jb2.addItem("피클");
JPanel p1=new JPanel();
p1.setLayout(new FlowLayout());
p1.add(l1); p1.add(jb1);
JPanel p2=new JPanel();
p2.setLayout(new FlowLayout());
p2.add(l2); p2.add(jb2);
JPanel p3=new JPanel();
p3.setLayout(new FlowLayout());
p3.add(l3); p3.add(bb1); p3.add(bb2);
JPanel p4=new JPanel();
p4.setLayout(new BorderLayout());
p4.add("South", p1); p4.add("North", p2);
JPanel p5=new JPanel();
this.setLayout(new BorderLayout());
this.add("North", p4);
this.add("Center", p3);
this.add("South", b1);
this.setDefaultCloseOperation(3);
this.pack();
this.setVisible(true);
}
public static void main(String[] args) {
new Order2("");
}
@Override
public void actionPerformed(ActionEvent e) {
String m=(String)jb1.getSelectedItem();
String s=(String)jb2.getSelectedItem();
String p="";
if(bb1.isSelected()) p=bb1.getText();
else p=bb2.getText();
new Order3(id,m,s,p);
this.setVisible(false);
}//action
}//Order2 |
cs |
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 |
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Order3 extends JFrame implements ActionListener {
JLabel l1,l2,l3,l4; JButton b1,b2;
String id, m,s,p;
int total=0;
Order3(String id,String m,String s,String p){
super(id+"주문확인");
this.id=id; this.m=m; this.s=s; this.p=p;
l1=new JLabel("메뉴선택 : "+m);
l2=new JLabel("사이드메뉴 : "+s);
l3=new JLabel("파무침 선택 : "+p);
String m_price=new Db_test().show(m);
String s_price=new Db_test().show(s);
int im_price=Integer.parseInt(m_price);
int is_price=Integer.parseInt(s_price);
if(p.equals("선택"))
total=im_price+is_price+500;
else
total=im_price+is_price;
l4=new JLabel("총합 : "+total);
b1=new JButton("확인");
b1.addActionListener(new in());
b2=new JButton("수정");
b2.addActionListener(this);
JPanel p1=new JPanel();
p1.setLayout(new BorderLayout());
p1.add("North", l1); p1.add("Center", l2); p1.add("South", l3);
JPanel p3=new JPanel();
p3.setLayout(new FlowLayout());
p3.add(b1); p3.add(b2);
JPanel p2=new JPanel();
p2.setLayout(new BorderLayout());
this.add("North", p1); this.add("Center", l4); this.add("South", p3);
this.setDefaultCloseOperation(3);
this.pack();
this.setVisible(true);
}
class in implements ActionListener{
public void actionPerformed(ActionEvent e) {
new Db_test().save(id,(m+s),total);
System.exit(0);
}
}//in
public static void main(String[] args) {
//new Order3();
}
@Override
public void actionPerformed(ActionEvent e) {
new Order2(id,m,s,p);
this.setVisible(false);
}
}//Order3 |
cs |
반응형
'프로그래밍 > 시스템' 카테고리의 다른 글
[C] #define for문 (0) | 2017.06.06 |
---|---|
java 예외처리종류 & 사용방법 (2) | 2017.06.05 |
[윈도우 프로그래밍] 뮤텍스 크리티컬섹션 (0) | 2017.06.02 |
[java-OracleDB] DB 우편번호 검색 로직 (0) | 2017.05.25 |
[윈도우 프로그래밍] 스레드(thread) (0) | 2017.05.25 |