April 2024 | Mon | Tue | Wed | Thu | Fri | Sat | Sun |
---|
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 | | | | | | Calendar |
|
| | Quản Lý Nhà Hàng FRI | |
| | Tác giả | Thông điệp |
---|
connguoibian_tn_9 Thành viên bậc 1
Tổng số bài gửi : 9 Points : 21 Reputation : 1 Join date : 24/07/2009 Age : 35 Đến từ : Thiên Đường Hạnh Phúc
| Tiêu đề: Quản Lý Nhà Hàng FRI Fri Jul 24, 2009 10:41 pm | |
| Sau mấy ngày tẩm ngẩm, thế là cũng gần xong cái nhà hàng của mình zòi. Nhưng seo phần kết nối cơ sở dữ liệu thì dở qué. uhm.. Post thử mí file lên mọi ng xem nhen File MenuChinh.java - Code:
-
import java.awt.*; import java.awt.event.*; public class MenuChinh { public static void main(String[] args) { createMenu(); } private static void createMenu() { //tao frame cho chuong trinh final Frame fr = new Frame("Chuong trinh quan ly nha hang"); fr.setLayout(new BorderLayout()); //tao Menu Bar MenuBar menu = new MenuBar(); //tao cac Menu Menu menuFile = new Menu("File"); Menu menuUpdate = new Menu("Cap Nhat"); Menu menuProcess = new Menu("Xu Ly"); Menu menuHelp = new Menu("Help"); //tao Menu Item cho File MenuItem trangThai = new MenuItem("Trang thai Ban"); trangThai.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new TrangThai("Trang Thai Ban"); } }); MenuItem goiMon = new MenuItem("Goi Mon"); goiMon.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new GoiMon("Goi Mon"); } }); MenuItem tinhTien = new MenuItem("Tinh Tien"); tinhTien.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new TinhTien("Tinh Tien"); } }); MenuItem thoat = new MenuItem("Thoat"); thoat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { System.exit(0); } }); menuFile.add(trangThai); menuFile.add(goiMon); menuFile.add(tinhTien); menuFile.addSeparator(); menuFile.add(thoat); //tao Menu Item cho Update MenuItem themBan = new MenuItem("Danh sach Ban"); themBan.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new ThemBan("Danh sach Ban"); } }); MenuItem themThucDon = new MenuItem("Thuc Don"); themThucDon.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new ThucDon("Thuc Don"); } }); menuUpdate.add(themBan); menuUpdate.add(themThucDon); //tao Menu Item cho Process //tao Menu Item cho Help MenuItem troGiup = new MenuItem("Tro Giup"); troGiup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new TroGiup("Tro Giup"); } }); MenuItem about = new MenuItem("About"); about.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new About("About"); } }); menuHelp.add(troGiup); menuHelp.add(about); //gan cac Menu vao MenuBar menu.add(menuFile); menu.add(menuUpdate); MenuItem thayDoi = new MenuItem("Thay Doi Mon"); thayDoi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new ThemMon("Thay Doi Mon"); } }); MenuItem ghepBan = new MenuItem("Ghep Ban"); ghepBan.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new GhepBan("Ghep ban"); } }); menuProcess.add(thayDoi); menuProcess.add(ghepBan); menu.add(menuProcess); menu.add(menuHelp); //gan MenuBar vao khung fr.setMenuBar(menu); Label lb = new Label("CHUONG TRINH QUAN LY NHA HANG FRI",Label.CENTER); lb.setFont(new Font("Times Roman",Font.BOLD,30)); fr.add(lb,BorderLayout.CENTER); fr.setBounds(0,0, 800, 570); fr.setVisible(true); fr.setFont(new Font("Arial",Font.PLAIN,13)); //xu ly su kien dong cua so ung dung fr.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } }
Hẳn nhiên là cái bài nó chưa chạy zòi..Đây mới chỉ là dự án. vả lại...cái cơ sở SQL mình chưa rành nữa | |
| | | connguoibian_tn_9 Thành viên bậc 1
Tổng số bài gửi : 9 Points : 21 Reputation : 1 Join date : 24/07/2009 Age : 35 Đến từ : Thiên Đường Hạnh Phúc
| Tiêu đề: File TrangThai.java Fri Jul 24, 2009 10:46 pm | |
| hix..Tui hết sửa dc mí cái file có liên kế zòi, bạn nào sửa dc sửa giùm nha Tui ziết bằng SQL, nhưng mà hog chạy, vì seo thì ..no way - Code:
-
import java.awt.*; import java.awt.event.*; import java.sql.*; public class TrangThai extends Frame implements ActionListener { int n=0;//dung de duyet cac ban Panel panelSouth = new Panel(); Label lbChinh = new Label("Trang thai Ban",Label.CENTER); TextArea txaChinh = new TextArea(); Button buttXem = new Button(" Xem "); Button buttThoat = new Button(" Thoat "); Choice chMaBan = new Choice(); Choice chTenBan = new Choice(); java.sql.Connection con; java.sql.Statement stmt; ResultSet rs; public TrangThai(String title) { super(title); lbChinh.setFont(new Font("Tahoma",Font.BOLD,20)); add(lbChinh,BorderLayout.NORTH); txaChinh.setEditable(false); txaChinh.setText("\tTen Ban\t\tTrang thai\n\n"); add(txaChinh,BorderLayout.CENTER); panelSouth.add(buttXem); panelSouth.add(buttThoat); add(panelSouth,BorderLayout.SOUTH); buttXem.addActionListener(this); buttThoat.addActionListener(this); setFont(new Font("Arial",Font.PLAIN,14)); setLocation(200,50); setSize(400, 400); setResizable(false); setVisible(true); try { connect(); rs = stmt.executeQuery("SELECT * FROM Ban"); rs.next(); while(!rs.isAfterLast()) { chMaBan.addItem(rs.getString(1)); chTenBan.addItem(rs.getString(2)); n++; rs.next(); } } catch(Exception e){} } public void actionPerformed(ActionEvent e) { if (e.getSource()==buttXem) Xem(); if(e.getSource() == buttThoat) { setVisible(false); } } public void Xem() { try { connect(); rs = stmt.executeQuery("SELECT BanID FROM Goi_mon"); for(int i = 0; i<n;i++) { String s = chMaBan.getItem(i); rs.first(); boolean flag = false; while(!rs.isAfterLast()) { if(rs.getString(1).equals(s)) { flag = true; break; } rs.next(); } if(flag == true) txaChinh.append("\t"+chTenBan.getItem(i)+"\t\t\tDa su dung"); else txaChinh.append("\t"+chTenBan.getItem(i)+"\t\t\tChua su dung"); txaChinh.append("\n"); } } catch(Exception e) { System.err.println("Error: "+e.toString()); } } public void connect() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //Nap trinh dieu khien Access } catch (ClassNotFoundException ex) { System.out.print("Error: " + ex.getMessage()); } try { String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=c:/cafe.mdb"; con = DriverManager.getConnection(url); stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); } catch(SQLException se) { System.err.println("Error: "+se.getMessage()); } } }
--------------------------------------------------------- File GoiMon.java - Code:
-
import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; public class GoiMon extends Frame implements ActionListener { Panel panelCenter = new Panel(); Panel panelSub = new Panel(new GridLayout(4,2,10,10)); Panel panelSouth = new Panel(); Panel panelSpace = new Panel(); Label lbSpace = new Label(" "); Label lbGoiMon = new Label("GOI MON",Label.CENTER); Label lbMaGoi = new Label("Luot goi:"); Label lbBan = new Label("Ban:"); Label lbDoUong = new Label("Do uong:"); Label lbSoLuong = new Label("So luong:"); TextField txtMaGoi = new TextField("Vd: 23 la Ban 2,Luot goi 3"); Choice chBan = new Choice(); Choice chTenBan = new Choice(); Choice chDoUong = new Choice(); Choice chTenDoUong = new Choice(); TextField txtSoLuong = new TextField(); Button buttLuu = new Button(" Luu "); Button buttThoat = new Button(" Thoat "); java.sql.Connection con; java.sql.Statement stmt; ResultSet rs; public GoiMon(String title) { super(title); lbGoiMon.setFont(new Font("Tahoma",Font.BOLD,20)); add(lbGoiMon,BorderLayout.NORTH); panelSub.add(lbMaGoi); panelSub.add(txtMaGoi); panelSub.add(lbBan); try { connect(); rs = stmt.executeQuery("SELECT * FROM Ban"); rs.next(); while(!rs.isAfterLast()) { chBan.addItem(rs.getString(1)); chTenBan.addItem(rs.getString(2)); rs.next(); } } catch(Exception e){} try { connect(); rs = stmt.executeQuery("SELECT * FROM Thuc_don"); rs.next(); while(!rs.isAfterLast()) { chDoUong.addItem(rs.getString(1)); chTenDoUong.addItem(rs.getString(2)); rs.next(); } } catch(Exception e){}
panelSub.add(chTenBan); panelSub.add(lbDoUong); panelSub.add(chTenDoUong); panelSub.add(lbSoLuong); panelSub.add(txtSoLuong); panelCenter.add(panelSub); panelSpace.add(lbSpace); panelCenter.add(panelSpace); add(panelCenter,BorderLayout.CENTER); panelSouth.add(buttLuu); add(panelSouth,BorderLayout.SOUTH); panelSouth.add(buttThoat); add(panelSouth,BorderLayout.SOUTH); buttLuu.addActionListener(this); buttThoat.addActionListener(this); setFont(new Font("Arial",Font.PLAIN,14)); setLocation(180,50); setSize(500, 250); setResizable(false); setVisible(true); } public void actionPerformed(ActionEvent e) { if (e.getSource()==buttLuu) Luu(); if(e.getSource() == buttThoat) { setVisible(false); } } public void Luu() { try { connect(); rs = stmt.executeQuery("SELECT * FROM Goi_mon"); rs.moveToInsertRow(); rs.updateLong(1, Long.parseLong(txtMaGoi.getText())); int n = chTenBan.getSelectedIndex(); rs.updateString(2, chBan.getItem(n)); int m = chTenDoUong.getSelectedIndex(); rs.updateString(3,chDoUong.getItem(m)); rs.updateLong(4, Long.parseLong(txtSoLuong.getText())); rs.insertRow(); txtMaGoi.setText(""); txtSoLuong.setText(""); } catch(Exception e) { System.err.println("Error: "+e.toString()); } } public void connect() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //Nap trinh dieu khien Access } catch (ClassNotFoundException ex) { System.out.print("Error: " + ex.getMessage()); } try { String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=c:/cafe.mdb"; con = DriverManager.getConnection(url); stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); } catch(SQLException se) { System.err.println("Error: "+se.getMessage()); } } }
Hog, mà phải nói là mình làm quản lý NHÀ HÀNG mà nấu ăn dở tệ lun.. Ac ac.. Chắc có tài lèm quản lý chớ hog phải đầu bếp..^^ Ah..Đang lèm típ, từ từ tui post típ nhen. | |
| | | | Quản Lý Nhà Hàng FRI | |
|
Trang 1 trong tổng số 1 trang | |
Similar topics | |
|
| Permissions in this forum: | Bạn không có quyền trả lời bài viết
| |
| |
| |