/**
為海興等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及海興網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、海興網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
*?超市管理系統(tǒng)
*?@author?Administrator
*
*/
public?class?ChaoShiSystemManager?{
public?static?void?main(String[]?args)?{
new?HuoWuDomImpl().start();
}
}
class?HuoWu{
public?String?bianhao;?//商品編號(hào)
public?String?name;?//商品名稱
public?double?jiage;?//商品價(jià)格
}
class?HuoWuDomImpl{
private?static?java.util.ArrayListHuoWu?list?=?new?java.util.ArrayListHuoWu();
public?void?start(){
?int?num?=?0;
System.out.println("--歡迎登錄超市管理系統(tǒng)--");
System.out.println("1、添加商品");
System.out.println("2、查詢商品");
java.util.Scanner?sc?=?new?java.util.Scanner(System.in);
System.out.println("請(qǐng)輸入模塊名稱:");
try?{
num?=?sc.nextInt();
if(num?==?1){
setHuoWu();
new?HuoWuDomImpl().start();
}else?if(num?==?2){
getSeleteHuoWu();
new?HuoWuDomImpl().start();
}else{
throw?new?RuntimeException("提示:抱歉,模塊正在開(kāi)發(fā)中");
}
}?catch?(Exception?e)?{
e.printStackTrace();
throw?new?RuntimeException("提示:對(duì)不起,您的輸入有誤!");
}finally{
sc.close();
}
}
public?void?setHuoWu(){
HuoWu?hw?=?new?HuoWu();
java.util.Scanner?sc?=?new?java.util.Scanner(System.in);
System.out.println("請(qǐng)輸入商品編號(hào):");
hw.bianhao?=?sc.next();
System.out.println("請(qǐng)輸入商品名稱:");
hw.name?=?sc.next();
System.out.println("請(qǐng)輸入商品價(jià)格");
try?{
hw.jiage?=?sc.nextDouble();
}?catch?(Exception?e)?{
throw?new?RuntimeException("提示:商品價(jià)格輸入錯(cuò)誤!");
}finally{
sc.close();
}
list.add(hw);
System.out.println("提示:恭喜,添加成功!");
}
public?void?getSeleteHuoWu(){
java.util.Scanner?sc?=?new?java.util.Scanner(System.in);
System.out.println("請(qǐng)輸入商品編號(hào)...");
String?bianhao?=?sc.next();
java.util.Iterator?it?=?list.iterator();
while(it.hasNext()){
if(bianhao.equals(((HuoWu)it.next()).bianhao)){
System.out.println("商品編號(hào):"?+?((HuoWu)it.next()).bianhao);
System.out.println("商品名稱:"?+?((HuoWu)it.next()).name);
System.out.println("商品價(jià)格:"?+?((HuoWu)it.next()).jiage);
}
}
}
}
PS:程序可能還有點(diǎn)問(wèn)題,自己調(diào)試一下吧。改天有空我再來(lái)更新。
算是最簡(jiǎn)單的吧
package cn.job01;
import java.util.Scanner;
public class Lx07 {
public static void choice() {
System.out.println("登陸菜單 ");
System.out.println("1登陸系統(tǒng)");
System.out.println("2退出");
}
static void choice1() {
System.out.println("購(gòu)物管理系統(tǒng)客戶信息");
System.out.println("1顯示所有客戶信息");
System.out.println("2添加客戶信息");
System.out.println("3修改客戶信息");
System.out.println("4查詢客戶信息");
}
static void choice2() {
System.out.println("購(gòu)物管理系統(tǒng)真情回饋");
System.out.println("1幸運(yùn)大放送");
System.out.println("2幸運(yùn)抽獎(jiǎng)");
System.out.println("3生日問(wèn)候");
}
public static void main(String[] args) {
choice();
Scanner input = new Scanner(System.in);
System.out.println("請(qǐng)輸入1or2");
int num = input.nextInt();
switch (num) {
case 1:
System.out.println("主菜單");
System.out.println("1客戶信息管理");
System.out.println("2購(gòu)物結(jié)算");
System.out.println("3真情回饋");
System.out.println("4注銷");
break;
}
System.out.println("選擇輸入數(shù)字");
int num1 = input.nextInt();
switch (num1) {
case 1:
choice1();
break;
case 2:
System.out.println("購(gòu)物結(jié)算");
break;
case 3:
choice2();
break;
case 4:
choice();
break;
}
}
}
package?c;
import?java.util.Scanner;
public?class?SuperMarket?{
static?Scanner?scan?=?new?Scanner(System.in);
public?static?String?str;
public?static?void?main(String[]?args)?{
showMsg();
while?(scan.hasNext())?{
switch?(scan.nextInt())?{
case?1:
commodityManage();
break;
case?2:
customerManage();
break;
case?3:
orderManage();
break;
case?4:
exitSystem();
break;
default:
System.out.println("輸入錯(cuò)誤,請(qǐng)重新輸入!");
break;
}
}
scan.close();
}
/**
?*?顯示信息
?*/
public?static?void?showMsg()?{
System.out.println("===================================");
System.out.println("\t超??市??庫(kù)??存??管??理??系??統(tǒng)\t");
System.out.println("===================================");
System.out.println("1、商品管理");
System.out.println("2、客戶管理");
System.out.println("3、訂單管理");
System.out.println("4、退出系統(tǒng)");
System.out.println("===================================");
System.out.println("請(qǐng)輸入您的選擇(1-4):");
}
/**
?*?選項(xiàng)?1、商品管理
?*/
public?static?void?commodityManage()?{
str?=?"商品管理";
showWelcom(str);
System.out.println("以上為商品管理的信息!\n是否繼續(xù)?(按1繼續(xù)/其他結(jié)束):");
exitOrShow(1);
}
/**
?*?選項(xiàng)?2、客戶管理
?*/
public?static?void?customerManage()?{
str?=?"客戶管理";
System.out.println("以上為客戶管理的信息!\n是否繼續(xù)?(按2繼續(xù)/其他結(jié)束):");
exitOrShow(2);
}
/**
?*?選項(xiàng)?3、訂單管理
?*/
public?static?void?orderManage()?{
str?=?"訂單管理";
System.out.println("以上為訂單管理的信息!\n是否繼續(xù)?(按3繼續(xù)/其他結(jié)束):");
exitOrShow(3);
}
/**
?*?選項(xiàng)?4、退出系統(tǒng)
?*/
public?static?void?exitSystem()?{
System.exit(0);
}
public?static?void?showWelcom(String?str)?{
System.out.println("歡迎進(jìn)入"+?str?+"模塊");
System.out.println("===================================");
}
public?static?void?exitOrShow(int?nextInt)?{
if?(scan.nextInt()?!=?nextInt)?{
exitSystem();
}?else?{
showMsg();
}
}
}
package untitled5;
import java.io.*;
import java.net.*;
import java.sql.*;
import java.lang.*;
import javax.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
public class delbook extends JFrame {
JPanel contentPane;
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JTextField jTextField1 = new JTextField();
JLabel jLabel4 = new JLabel();
JTextField jTextField2 = new JTextField();
JLabel jLabel5 = new JLabel();
JTextField jTextField3 = new JTextField();
JLabel jLabel6 = new JLabel();
JTextField jTextField4 = new JTextField();
JButton jButton1 = new JButton();
//Construct the frame
public delbook() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
jLabel1.setFont(new java.awt.Font("SansSerif", 0, 25));
jLabel1.setForeground(Color.red);
jLabel1.setText("超市管理系統(tǒng)");
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(500,400));
this.setTitle("超市管理系統(tǒng)");
jLabel2.setFont(new java.awt.Font("SansSerif", 0, 30));
jLabel2.setText("業(yè)務(wù)單位信息");
jLabel3.setFont(new java.awt.Font("SansSerif", 0, 25));
jLabel3.setText("產(chǎn)品編號(hào)");
jTextField1.setText("");
jLabel4.setFont(new java.awt.Font("SansSerif", 0, 25));
jLabel4.setText("公司名稱");
jTextField2.setText("");
jLabel5.setFont(new java.awt.Font("SansSerif", 0, 25));
jLabel5.setText("訂單號(hào)碼");
jTextField3.setText("");
jLabel6.setFont(new java.awt.Font("SansSerif", 0, 25));
jLabel6.setText("電 話");
jTextField4.setText("");
jButton1.setFont(new java.awt.Font("SansSerif", 0, 25));
jButton1.setText("提交");
jButton1.addActionListener(new delbook_jButton1_actionAdapter(this));
contentPane.add(jLabel1, new XYConstraints(179, 1, 153, 32));
contentPane.add(jLabel2, new XYConstraints(162, 33, -1, -1));
contentPane.add(jLabel3, new XYConstraints(83, 89, -1, -1));
contentPane.add(jTextField1, new XYConstraints(189, 88, 141, 36));
contentPane.add(jTextField2, new XYConstraints(189, 149, 142, 36));
contentPane.add(jLabel4, new XYConstraints(84, 148, -1, -1));
contentPane.add(jTextField3, new XYConstraints(188, 206, 143, 33));
contentPane.add(jLabel5, new XYConstraints(84, 204, -1, -1));
contentPane.add(jLabel6, new XYConstraints(84, 253, -1, -1));
contentPane.add(jTextField4, new XYConstraints(189, 260, 143, 36));
contentPane.add(jButton1, new XYConstraints(197, 318, -1, -1));
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
void update() {
try {
//定義顯示的字符串
String str1;
String str2;
String str3;
String str4;
str1 = jTextField1.getText();
str2 = jTextField2.getText();
str3 = jTextField3.getText();
str4 = jTextField4.getText();
//裝載jdbc驅(qū)動(dòng)程序
String driverName = "oracle.jdbc.OracleDriver";
Driver driver = (Driver) Class.forName(driverName).newInstance();
//連接數(shù)據(jù)庫(kù)
Connection con = DriverManager.getConnection(
"jdbc:oracle:thin:@thsspc0791:1521:liuyong", "hr", "tongfang");
PreparedStatement pstmt = con.prepareStatement(
" insert Customer1('goodID','Name','PID','tel')values(?,?,?,?)");
pstmt.setString(1, str1);
pstmt.setString(2, str2);
pstmt.setString(1, str3);
pstmt.setString(4, str4);
ResultSet res = pstmt.executeQuery();
pstmt.close();
con.close();
}catch (InstantiationException e) {
System.out.println(e.getMessage());
}catch (IllegalAccessException e) {
System.out.println(e.getMessage());
}catch (ClassNotFoundException e) {
System.out.println(e.getMessage());
}catch (SQLException edd) {
edd.printStackTrace() ;
System.out.println(edd.getMessage());
}
}
void jButton1_actionPerformed(ActionEvent e) {
update();
}
}
class delbook_jButton1_actionAdapter implements java.awt.event.ActionListener {
delbook adaptee;
delbook_jButton1_actionAdapter(delbook adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
package untitled5;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
/**
* pTitle: /p
* pDescription: /p
* pCopyright: Copyright ? 2003/p
* pCompany: /p
* @author not attributable
* @version 1.0
*/
public class retur extends JFrame {
JPanel contentPane;
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel1 = new JLabel();
//Construct the frame
public retur() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
jLabel1.setFont(new java.awt.Font("SansSerif", 0, 20));
jLabel1.setForeground(Color.red);
jLabel1.setText("超市管理系統(tǒng)");
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("超市管理系統(tǒng)");
contentPane.add(jLabel1, new XYConstraints(139, 1, 126, 33));
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
}
package untitled5;
import java.io.*;
import java.net.*;
import java.sql.*;
import java.lang.*;
import javax.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import com.borland.dbswing.*;
//貨品信息登記
public class Frame2 extends JFrame {
JPanel contentPane;
JLabel jLabel1 = new JLabel();
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JTextField jTextField1 = new JTextField();
JLabel jLabel4 = new JLabel();
JTextField jTextField2 = new JTextField();
JPanel jPanel1 = new JPanel();
XYLayout xYLayout2 = new XYLayout();
JScrollPane jScrollPane1 = new JScrollPane();
JLabel jLabel5 = new JLabel();
JTextField jTextField3 = new JTextField();
//Construct the frame
public Frame2() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(600, 500));
this.setTitle("超市管理系統(tǒng)");
this.addHierarchyBoundsListener(new Frame2_this_hierarchyBoundsAdapter(this));
jLabel1.setFont(new java.awt.Font("SansSerif", 0, 25));
jLabel1.setForeground(Color.red);
jLabel1.setText("超市管理系統(tǒng)");
contentPane.setForeground(Color.black);
jLabel2.setFont(new java.awt.Font("SansSerif", 0, 30));
jLabel2.setText("產(chǎn) 品 信 息 展 示");
// statusBar.setFont(new java.awt.Font("SansSerif", 0, 20));
jLabel3.setFont(new java.awt.Font("SansSerif", 0, 20));
jLabel3.setText("產(chǎn)品名稱");
jTextField1.setText("");
jLabel4.setEnabled(true);
jLabel4.setFont(new java.awt.Font("SansSerif", 0, 20));
jLabel4.setText("產(chǎn)品ID號(hào)");
jTextField2.setText("");
jTextField2.addActionListener(new Frame2_jTextField2_actionAdapter(this));
jPanel1.setLayout(xYLayout2);
jLabel5.setFont(new java.awt.Font("SansSerif", 0, 25));
jLabel5.setForeground(Color.red);
jLabel5.setText("該產(chǎn)品詳細(xì)信息");
jTextField3.setText("");
contentPane.add(jLabel1, new XYConstraints(237, 0, 153, 40));
contentPane.add(jLabel2, new XYConstraints(200, 47, 231, 58));
contentPane.add(jLabel3, new XYConstraints(47, 102, 101, 42));
contentPane.add(jTextField1, new XYConstraints(128, 108, 112, 34));
contentPane.add(jTextField2, new XYConstraints(361, 107, 109, 36));
contentPane.add(jPanel1, new XYConstraints(75, 166, 453, 277));
jPanel1.add(jScrollPane1, new XYConstraints(14, 8, 433, 221));
jScrollPane1.getViewport().add(jTextField3, null);
jPanel1.add(jLabel5, new XYConstraints(112, 240, -1, -1));
contentPane.add(jLabel4, new XYConstraints(278, 111, -1, -1));
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
void Select() {
try {
String str1, str2;
str1 = jTextField1.getText();
str2 = jTextField2.getText();
當(dāng)前題目:商店管理系統(tǒng)java代碼 java商城代碼
分享地址:http://jinyejixie.com/article14/doseede.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、網(wǎng)站排名、網(wǎng)站導(dǎo)航、定制開(kāi)發(fā)、營(yíng)銷型網(wǎng)站建設(shè)、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)