Skip to content
Open

ui #6

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions PizzaProject/src/pizza/Admin.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,13 @@ public static Object[] OrderData(AdminDAO info, int indexi) {
String adress = e.getAddress();
String delCheck = e.getdelCheck();


Object[] result = {time, pizza, adress,delCheck};
data = result;
}
return data;
}


// public static int readIndex(AdminDAO info, int indexi) {
// int index = info.selectMax();
//
// return index;
// }


public static String readTime(AdminDAO info, int indexi) {
ArrayList<AdminDTO>list = info.select(indexi);

Expand Down Expand Up @@ -110,5 +102,4 @@ public static int readPrice(AdminDAO info, int indexi) {
return Price;
}


}
118 changes: 71 additions & 47 deletions PizzaProject/src/pizza/AdminUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,86 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;


class AdminUI extends JFrame implements ActionListener{
JButton button1;
JButton button2;

AdminUI(){
this.getContentPane().setBackground(Color.white); // 프레임 배경색 지정
Container container = getContentPane();
container.setLayout(null);


button1 = new JButton("매출 관리");
button1.setBounds(101, 151,200,100);
button1.addActionListener(this);
class JButtonUI extends JFrame implements ActionListener{
JButton button1;
JButton button2;
JButton button3;
JLabel domino;

JButtonUI(){
this.getContentPane().setBackground(Color.white); // 프레임 배경색 지정
Container container = getContentPane();
container.setLayout(null);

//상단 로고
JButton logo = new JButton(new ImageIcon("./images/logo.jpg"));
logo.setBorderPainted(false);
logo.setContentAreaFilled(false);
logo.setBounds(0, 0, 400, 120);
container.add(logo);


button1 = new JButton(new ImageIcon("./images/mg.png"));
button1.setBounds(51, 180,300,150);
button1.setBorderPainted(false);
button1.setContentAreaFilled(false);
button1.setFocusPainted(false);
button1.addActionListener(this);


button2 = new JButton("주문 관리");
button2.setBounds(101, 401,200,100);
button2.addActionListener(this);

button2 = new JButton(new ImageIcon("./images/jg.png"));
button2.setBounds(51, 340,300,150);
button2.setBorderPainted(false);
button2.setContentAreaFilled(false);
button2.setFocusPainted(false);
button2.addActionListener(this);



container.add(button1);
container.add(button2);

setTitle("관리자 화면");
setSize(400,700);
setResizable(false);//창의 크기를 변경하지 못하게
setLocationRelativeTo(null);//창이 가운데 나오게
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);

}
domino = new JLabel(new ImageIcon("./images/logo2.png"));
domino.setBounds(173, 615,50,50);
// label1.setBorderPainted(false);
// label1.setContentAreaFilled(false);
// label1.setFocusPainted(false);


container.add(button1);
container.add(button2);
container.add(domino);

setTitle("관리자 화면");
setSize(400,700);
setResizable(false);//창의 크기를 변경하지 못하게
setLocationRelativeTo(null);//창이 가운데 나오게
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);

}

@Override
public void actionPerformed(ActionEvent e) {
String index = e.getActionCommand();
if(index.equals("매출 관리")) {
new RevenueUI();
this.dispose();
}else if(index.equals("주문 관리")) {
new OrderCheckUI();
this.dispose();
}
@Override
public void actionPerformed(ActionEvent e) {
// String index = e.getActionCommand();
if(e.getSource().equals(button1)) {
new RevenueUI();
this.dispose();
}else if(e.getSource().equals(button2)) {
new OrderCheckUI();
this.dispose();
}

}
}
}


//public class AdminUI {
//
// public static void main(String[] args) {
// JButtonUI start = new JButtonUI();
// }
//
//}
public class AdminUI {

public static void main(String[] args) {
JButtonUI start = new JButtonUI();
}

}
Empty file modified PizzaProject/src/pizza/AllViewMain.java
100755 → 100644
Empty file.
189 changes: 97 additions & 92 deletions PizzaProject/src/pizza/BasketControl.java
Original file line number Diff line number Diff line change
@@ -1,56 +1,36 @@
package pizza;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;

//import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.dbcp2.BasicDataSource;

class BasketControl {
Calendar date= Calendar.getInstance();
int day;
static int indexi =1;
ArrayList<Food> food = new ArrayList<Food>(); //음식 안에있는 정보들을 들고온다.
PizzaPickControl ppc;
Calendar date = Calendar.getInstance();
String PizzaName;
String Address = null;

// int price = ppc.PickPizzaInfo(choice).getPrice();

int price;

//DB에 저장할 배송지 이름 -> 메소드 구현시 수정필요



//기본 값인 X로 무조건 다 저장하고, UI에서 배송완료 버튼을 이벤트로 지정
//이벤트 발생시 O로 수정한다는 메소드를 추가 작성하면 될 듯.

//BasicDataSource ds;
BasicDataSource ds;

private String driver = "oracle.jdbc.driver.OracleDriver";
private String url = "jdbc:oracle:thin:@localhost:1521:xe";
private String userid = "scott";
private String passwd = "tiger";

BasketControl(PizzaPickControl ppc) {

try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

ds = new BasicDataSource(); //Connection Pool 기능과 Thread-safe 기능을 갖춤.
ds.setDriverClassName(driver);
ds.setUrl(url);
ds.setUsername(userid);
ds.setPassword(passwd);

// ds = new BasicDataSource(); //Connection Pool 기능과 Thread-safe 기능을 갖춤.
// ds.setDriverClassName(driver);
// ds.setUrl(url);
// ds.setUsername(userid);
// ds.setPassword(passwd);
//
// ds.setInitialSize(5); // 5개의 Connection을 공유하면서 사용할 수 있음. /5개까지 미리 만들어 놓는것 5명이 넘으면 new해서 새로 만듦.
ds.setInitialSize(5); // 5개의 Connection을 공유하면서 사용할 수 있음. /5개까지 미리 만들어 놓는것 5명이 넘으면 new해서 새로 만듦.
this.ppc = ppc;
}

Expand All @@ -70,71 +50,96 @@ public void finalPrice() {
}

//음식을 관리자에게 넘겨줘야한다.(DB)
public void PayForBasket(String pzName, String addr, int pri) {
int month = date.get(Calendar.MONTH)+1;
int day = date.get(Calendar.DAY_OF_MONTH);
int hour = date.get(Calendar.HOUR);
int min = date.get(Calendar.MINUTE);
String strMonth, strDay, strHour, strMin ;

this.PizzaName = pzName;
this.Address = addr;
this.price = pri;
String delCheck ="X";

strMonth = Integer.toString(month);
strDay = Integer.toString(day);
strHour = Integer.toString(hour);
strMin = Integer.toString(min);
public void PayForBasket(int choice) {
// if(day != date.get(Calendar.DAY_OF_MONTH)) {

String Timei = strMonth+"/"+strDay+" "+strHour+":"+strMin;
//DB에 저장할 시간( MM/DD HH:MM)형태


// indexi = 1;

// String PizzaName = ppc.PickPizzaInfo(choice).getName();
//DB에 저장할 피자이름
// }



Connection conn = null;
PreparedStatement pstmt = null;
String sql = "insert into orderCheck values(orderCheck_seq.nextVal,?,?,?,?,?)";
//orderCheck 라는 Table이 있다는 가정하에 작성.

int month = date.get(Calendar.MONTH)+1;
day = date.get(Calendar.DAY_OF_MONTH);
int hour = date.get(Calendar.HOUR);
int min = date.get(Calendar.MINUTE);
String strMonth, strDay, strHour, strMin ;

strMonth = Integer.toString(month);
strDay = Integer.toString(day);
strHour = Integer.toString(hour);
strMin = Integer.toString(min);

String Timei = strMonth+"/"+strDay+" "+strHour+":"+strMin;
//DB에 저장할 시간( MM/DD HH:MM)형태




// String PizzaName = ppc.PickPizzaInfo(choice).getName();
//DB에 저장할 피자이름
String PizzaName = "testPizza"+choice;
// 피자이름 입력 값 대입


String Address =null;
// 주소 입력 값 대입


try {
conn = DriverManager.getConnection(url, userid, passwd);

// conn = ds.getConnection();
pstmt = conn.prepareStatement(sql);
// pstmt.setString(1, "orderCheck_seq.nextVal");
pstmt.setString(1, Timei);
pstmt.setString(2, PizzaName);
pstmt.setString(3, Address);
pstmt.setString(4, delCheck);
pstmt.setInt(5, price);

int result = pstmt.executeUpdate();

if(result ==1) {
System.out.println("저장성공");
}else {
System.out.println("저장실패");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
try {
if(pstmt!=null) {pstmt.close();}
if(conn!=null){conn.close();}
}
catch (SQLException e) {
System.out.println(e.getMessage());
}
//DB에 저장할 배송지 이름 -> 메소드 구현시 수정필요

String delCheck ="X";

//기본 값인 X로 무조건 다 저장하고, UI에서 배송완료 버튼을 이벤트로 지정
//이벤트 발생시 O로 수정한다는 메소드를 추가 작성하면 될 듯.


// int price = ppc.PickPizzaInfo(choice).getPrice();

int price = 10000*choice;



Connection conn = null;
PreparedStatement pstmt = null;
String sql = "insert into orderCheck values(orderCheck_seq.nextVal,?,?,?,?,?)";
//orderCheck 라는 Table이 있다는 가정하에 작성.



try {

conn = ds.getConnection();
pstmt = conn.prepareStatement(sql);
// pstmt.setString(1, "orderCheck_seq.nextVal");
pstmt.setString(1, Timei);
pstmt.setString(2, PizzaName);
pstmt.setString(3, Address);
pstmt.setString(4, delCheck);
pstmt.setInt(5, price);

int result = pstmt.executeUpdate();

if(result ==1) {
System.out.println("저장성공");
indexi++;
}else {
System.out.println("저장실패");
}

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
try {
if(pstmt!=null) {pstmt.close();}
if(conn!=null){conn.close();}
}
catch (SQLException e) {
System.out.println(e.getMessage());
}
}



}

}

Loading