你是需要这样的代码吗?
10多年专注成都网站制作,成都企业网站建设,个人网站制作服务,为大家分享网站制作知识、方案,网站设计流程、步骤,成功服务上千家企业。为您提供网站建设,网站制作,网页设计及定制高端网站建设服务,专注于成都企业网站建设,高端网页制作,对成都火锅店设计等多个领域,拥有多年的网站维护经验。
你是需要B/S模式的还是C/S模式的?
这些功能写起来比较简单,在后台连个数据库,做些数据的处理就可以了。不过要我这没有现成的,要自己的写的话估计没有时间了。如果你是在学习java的话,建议你自己动手写写,这个小系统能用到好多东西。
简单点的话直接用JDBC边数据库,要是好点可以考虑使用Hibernate,如果写成B/S模式的话,还可以考虑使用一些MVC的框架,struts或者spring,前台还能使用到ajax.当然,你还需要打印报表的功能,这个也是一个难点。
代码。
你这个代码很大啊,管理系统。
不知道是javaweb的 还是就是java写的一个图形界面程序?
给你一个思想。
登陆上选择不同的身份,提供不同的值,判断不同的值就可以进行不同的显示效果。
权限最大的就可以利用 type==这个值||type==这个值就可以显示这个界面。
web 的话就是OGNL语言使用
图形界面也差不多。
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("超市管理系统");
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(500,400));
this.setTitle("超市管理系统");
jLabel2.setFont(new java.awt.Font("SansSerif", 0, 30));
jLabel2.setText("业务单位信息");
jLabel3.setFont(new java.awt.Font("SansSerif", 0, 25));
jLabel3.setText("产品编号");
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("订单号码");
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驱动程序
String driverName = "oracle.jdbc.OracleDriver";
Driver driver = (Driver) Class.forName(driverName).newInstance();
//连接数据库
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("超市管理系统");
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("超市管理系统");
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("超市管理系统");
this.addHierarchyBoundsListener(new Frame2_this_hierarchyBoundsAdapter(this));
jLabel1.setFont(new java.awt.Font("SansSerif", 0, 25));
jLabel1.setForeground(Color.red);
jLabel1.setText("超市管理系统");
contentPane.setForeground(Color.black);
jLabel2.setFont(new java.awt.Font("SansSerif", 0, 30));
jLabel2.setText("产 品 信 息 展 示");
// statusBar.setFont(new java.awt.Font("SansSerif", 0, 20));
jLabel3.setFont(new java.awt.Font("SansSerif", 0, 20));
jLabel3.setText("产品名称");
jTextField1.setText("");
jLabel4.setEnabled(true);
jLabel4.setFont(new java.awt.Font("SansSerif", 0, 20));
jLabel4.setText("产品ID号");
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("该产品详细信息");
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();
你好 具体实现如下:
#includestdio.h
#includestring.h
#includestdlib.h
#define w 1.8/*水1.8元/吨*/
#define e 0.5/*电0.5元/度*/
struct user{
char name[10],ID[20];/*用户的姓名和身份证号码*/
double water,electricity;/*用水(吨)、电(度)量*/
double monney;/*总共的水电费用*/
}u[100];/*用户最大容量为100*/
/*显示用户信息*/
void display(){
int n;/*确定当前用户的人数*/
int i;
for(n=0;n100;n++)
if(u[n].monney==0) break;
if(n==0)
printf("系统无用户,需要添加!^_^\n");
else
for(i=0;in;i++)
printf("\n编号:%d\t姓名:%s\tID:%s\t用水量:%.1f吨\t用电量:%.1f度\n",i+1,u[i].name,u[i].ID,u[i].water,u[i].electricity);
}
/*添加用户*/
void add(){
int n;/*确定当前用户的人数*/
for(n=0;n100;n++)
if(u[n].monney==0) break;
printf("\t\t\t请输入新用户的姓名:");
scanf("%s",u[n].name);
printf("\t\t\t请输入新用户的ID(18位):");
scanf("%s",u[n].ID);
printf("\t\t\t请输入新用户的用水量:");
scanf("%lf",u[n].water);
printf("\t\t\t请输入新用户的用电量:");
scanf("%lf",u[n].electricity);
u[n].monney=(u[n].water)*w+(u[n].electricity)*e;
printf("\n添加成功!\n");
}
/*修改用户信息*/
void alter(){
char name[10];
int n;/*确定当前用户的人数*/
int i;
printf("\t\t\t请输入您的姓名:");
scanf("%s",name);
for(n=0;n100;n++)
if(u[n].monney==0) break;
for(i=0;in;i++)
if(strcmp(u[i].name,name)==0){
int choice=0;
printf("\n\t\t\t1.修改ID\n\t\t\t2.修改用水量\n\t\t\t3.修改用电量\n\t\t\t4.退出\n");
printf("\n\t\t\t请输入您的选择:");
GOTO1:scanf("%d",choice);
switch(choice)
{
case 1:
printf("\n\t\t\t请输入ID:");
scanf("%s",u[i].ID);
break;
case 2:
printf("\n\t\t\t请输入用水量:");
scanf("%lf",u[i].water);
break;
case 3:
printf("\n\t\t\t请输入用电量:");
scanf("%lf",u[i].electricity);
break;
case 4:
break;
default:
printf("\t\t\t输入错误,请重新输入:");
goto GOTO1;
}
printf("\n修改成功!\n");
break;
}
if(i==n)
printf("\n\t\t\t没有此用户,您可以选择注册新用户^_^!\n");
}
/*删除用户*/
void delete_(){
int n,i=0,j;
for(n=0;n100;n++)
if(u[n].monney==0) break;
display();
printf("\n\t\t\t请输入要删除用户对应的编号:");
scanf("%d",i);
for(j=i-1;jn;j++){
strcpy(u[j].name,u[j+1].name);
u[j].electricity=u[j+1].electricity;
strcpy(u[j].ID,u[j+1].ID);
u[j].monney=u[j+1].monney;
u[j].water=u[j+1].water;
}
u[n-1].monney=0;
printf("删除成功!^_^\n");
}
/*用户管理*/
void m_user(){
int choice=0;
GOTO2:system("cls");
printf("\t\t\t---------------------\n");
printf("\t\t\t| 用户管理^_^ |\n");
printf("\t\t\t---------------------\n\n\n");
printf("\n\t\t\t1.显示用户信息\n\t\t\t2.添加用户\n\t\t\t3.修改用户信息\n\t\t\t4.删除用户信息\n\t\t\t5.退出");
printf("\n\t\t\t请输入您的选择:");
GOTO3:scanf("%d",choice);
switch(choice)
{
case 1:
display();
system("pause");
goto GOTO2;
case 2:
add();
system("pause");
goto GOTO2;
case 3:
alter();
system("pause");;
goto GOTO2;
case 4:
delete_();
system("pause");;
goto GOTO2;
case 5:
break;
default:
printf("\t\t\t输入有误,请重新输入:");
goto GOTO3;
}
}
/*收费管理*/
void m_fee(){
int n,i,choice=0;
double w_sum=0,e_sum=0;
GOTO4:system("cls");
printf("\t\t\t---------------------\n");
printf("\t\t\t| 收费管理^_^ |\n");
printf("\t\t\t---------------------\n\n\n");
for(n=0;n100;n++)
if(u[n].monney==0) break;
printf("\n\t\t\t1.用户费用信息查询\n\t\t\t2.总水费\n\t\t\t3.总电费\n\t\t\t4.总费用\n\t\t\t5.退出\n");
printf("\n\t\t\t请输入您的选择:");
GOTO5:scanf("%d",choice);
switch(choice)
{
case 1:
if(n==00)
printf("\n\t\t\t系统无注册用户!\n");
else
for(i=0;in;i++){
printf("\n\t姓名:%s\t水费:%.2f元\t电费:%.2f元\t缴纳的总费用:%.2f元\n",u[i].name,(u[i].water)*w,(u[i].electricity)*e,u[i].monney);
w_sum+=u[i].water*w;
e_sum+=u[i].electricity*e;
}
system("pause");
goto GOTO4;
case 2:
printf("\n\t\t\t系统用户缴纳的总水费:%.2f元\n",w_sum);
system("pause");
goto GOTO4;
case 3:
printf("\n\t\t\t系统用户缴纳的总电费:%.2f元\n",e_sum);
system("pause");
goto GOTO4;
case 4:
printf("\n\t\t\t系统用户缴纳的总费用:%.2f元\n",w_sum+e_sum);
system("pause");
goto GOTO4;
case 5:
printf("管理完毕!\n");
break;
default:
printf("\n\t\t\t输入错误,请重新输入:");
goto GOTO5;
}
}
void main(){
int choice=0;
GOTO6:system("cls");
printf("\t\t\t-----------------------------------\n");
printf("\t\t\t| 欢迎进入水电费管理系统^_^ |\n");
printf("\t\t\t-----------------------------------\n\n\n");
printf("\n\t\t\t1.用户管理\n\t\t\t2.收费管理\n\t\t\t3.退出\n");
printf("\n\t\t\t请输入您的选择:");
GOTO7:scanf("%d",choice);
switch(choice)
{
case 1:
m_user();
system("pause");
goto GOTO6;
case 2:
m_fee();
system("pause");
goto GOTO6;
case 3:
break;
default:
printf("\n您的输入有误,请重新输入:");
goto GOTO7;
}
}
共享了 希望能帮助更多人
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("输入错误,请重新输入!");
break;
}
}
scan.close();
}
/**
* 显示信息
*/
public static void showMsg() {
System.out.println("===================================");
System.out.println("\t超 市 库 存 管 理 系 统\t");
System.out.println("===================================");
System.out.println("1、商品管理");
System.out.println("2、客户管理");
System.out.println("3、订单管理");
System.out.println("4、退出系统");
System.out.println("===================================");
System.out.println("请输入您的选择(1-4):");
}
/**
* 选项 1、商品管理
*/
public static void commodityManage() {
str = "商品管理";
showWelcom(str);
System.out.println("以上为商品管理的信息!\n是否继续?(按1继续/其他结束):");
exitOrShow(1);
}
/**
* 选项 2、客户管理
*/
public static void customerManage() {
str = "客户管理";
System.out.println("以上为客户管理的信息!\n是否继续?(按2继续/其他结束):");
exitOrShow(2);
}
/**
* 选项 3、订单管理
*/
public static void orderManage() {
str = "订单管理";
System.out.println("以上为订单管理的信息!\n是否继续?(按3继续/其他结束):");
exitOrShow(3);
}
/**
* 选项 4、退出系统
*/
public static void exitSystem() {
System.exit(0);
}
public static void showWelcom(String str) {
System.out.println("欢迎进入"+ str +"模块");
System.out.println("===================================");
}
public static void exitOrShow(int nextInt) {
if (scan.nextInt() != nextInt) {
exitSystem();
} else {
showMsg();
}
}
}