急求VB编写图书馆管理系统源代码带可执行程序

急求VB编写图书馆管理系统源代码带可执行程序,第1张

可以在Form_Load中判断user然后设置Menu的Enable属性. 具体是这样做的. 在一个模块中定义灶档Public user As String 先是登陆窗体.如果用户是guest 那么 user="guest" 否则 user="Administrator" 再到主窗体中: Sub Form_Load() If user="guest" then图书登记Menu.Enable=False ... Else 图书登记Menu.Enable=True ... End If End Sub“图书登记Menu”这种写法是没手辩掘有问题的。但是,我得搞清“图书登记Menu”是Name,还是Caption?如果毕核是Caption就不行,应该改了相应的Name,比如一个子菜单的Name为"Menu1",而它的Caption为"OpenMenu"那应该是Menu1.Enable=True.如果不是这里的原因,那就应该是判断user的流程出了问题.急求VB编写图书馆管理系统源代码带可执行程序

正好前段时间写好喊做过。看下符合需求不,唉上传不了,只有全发了

//该类是程序启动入口

package cn.bbs.gz.mybms

import java.io.IOException

public class Test

{

public static void main(String[] args) throws IOException

{

new BookManager().showMenu()

}

} //该类是数据存储中心

package cn.bbs.gz.mybms

import java.util.LinkedList

public class Books

{

static LinkedList<Book> list=new LinkedList<Book>()

static{

//初始化数据

list.add(new Book("Java核心技术123","SunWu",168,"香港旺角","J123","2013-03-15"))

list.add(new Book("Java编程思想","老马",128,"广州","G111","2013-01-26"))

list.add(new Book("Java框架集","老孙",89,"广州","S520","2013-03-17"))

list.add(new Book("HTML+CSS","老牛",99,"上海","H119","2013-03-18"))

list.add(new Book("JavaWeb开发","小丽",118,"北京","B1314","2008-08-08"))

}

} //该类是友衡Book模型

package cn.bbs.gz.mybms

public class Book

{

private String name//书名

private String author//作者

private double price//价钱

private String publisher//出版社

private String isbn//书号

private String date//出版日期

public Book() {

}

public Book(String name, String author, double price, String publisher,

String isbn, String date) {

super()

this.name = name

this.author = author

this.price = price

this.publisher = publisher

this.isbn = isbn

this.date = date

}

public String getName() {

return name

}

public void setName(String name) {

this.name = name

}

public String getAuthor() {

return author

}

public void setAuthor(String author) {

this.author = author

}

public double getPrice() {

return price

}

public void setPrice(double price) {

this.price = price

}

public String getPublisher() {

return publisher

}

public void setPublisher(String publisher) {

this.publisher = publisher

}

public String getIsbn() {

return isbn

}

public void setIsbn(String isbn) {

this.isbn = isbn

}

public String getDate() {

return 渗雀date

}

public void setDate(String date) {

this.date = date

}

} //该类是图书管理中心

package cn.itcast.gz.mybms

import java.io.IOException

import java.util.Collections

import java.util.Comparator

import java.util.LinkedList

import java.util.Scanner

public class BookManager

{

LinkedList<Book> list = Books.list

public void showMenu() throws IOException

{

//显示主菜单(一级菜单)

System.out.println("-------------------欢迎光临本图书管理系统-------------------")

System.out.println("(A)查看  (B)增加  (C)删除  (D)修改  (X)退出")

Scanner sc = new Scanner(System.in)

String str = sc.nextLine()

if(str.equalsIgnoreCase("A"))

{

System.out.println("-------------------------查询界面--------------------------")

showSelect()

}

else if(str.equalsIgnoreCase("B"))

{

System.out.println("-------------------------增加界面--------------------------")

showAdd()

}

else if(str.equalsIgnoreCase("C"))

{

System.out.println("-------------------------删除界面--------------------------")

showDelete()

}

else if(str.equalsIgnoreCase("D"))

{

System.out.println("-------------------------修改界面--------------------------")

showUpdate()

}

else if(str.equalsIgnoreCase("X"))

{

System.out.println("系统退出")

System.exit(0)

}

else

{

System.out.println("输入无效字符!!!")

showMenu()

}

}

private void showUpdate() throws IOException

{

// -------------------------修改界面--------------------------

String name =""//书名

String author=""//作者

double price=0.0//价钱

String publisher=""//出版社

String isbn=""//书号

String date=""//出版日期

Scanner sc = new Scanner(System.in)//字符串

Scanner sc2 = new Scanner(System.in)//整型

Scanner sc3 = new Scanner(System.in)//double型

System.out.println("书号\t书名\t\t作者\t价格\t出版社\t编号\t出版日期")

for(int i=0i<list.size()i++)

{

System.out.println(i+"\t"+list.get(i).getName()+"\t"+list.get(i).getAuthor()+"\t"+list.get(i).getPrice()

+"\t"+list.get(i).getPublisher()+"\t"+list.get(i).getIsbn()+"\t"+list.get(i).getDate())

}

System.out.println("请选择你要修改的书号:")

int num = sc2.nextInt()

if(num>=0 && num<list.size())

{

while(true)

{

System.out.println("请选择修改:(1)书名  (2)作者  (3)价格  (4)出版社  (5)编号  (6)出版日期  (7)保存修改  (8)退出")

int num2 = sc2.nextInt()

switch(num2)

{

case 1:

System.out.println("请输入新的书名:")

name = sc.nextLine()

break

case 2:

System.out.println("请输入新的作者:")

author = sc.nextLine()

break

case 3:

System.out.println("请输入新的价格:")

price = sc3.nextDouble()

break

case 4:

System.out.println("请输入新的出版社:")

publisher = sc.nextLine()

break

case 5:

System.out.println("请输入新的编号:")

isbn = sc.nextLine()

break

case 6:

System.out.println("请输入新的出版日期:")

date = sc.nextLine()

break

case 7:

/*if(!name.equals(""))

{

list.get(num).setName(name)

}

if(!author.equals(""))

{

list.get(num).setAuthor(author)

}

if(price!=0.0)

{

list.get(num).setPrice(price)

}

if(!publisher.equals(""))

{

list.get(num).setPublisher(publisher)

}

if(!isbn.equals(""))

{

list.get(num).setIsbn(isbn)

}

if(!date.equals(""))

{

list.get(num).setDate(date)

}*/

if(name.equals(""))

{

name = list.get(num).getName()

}

if(author.equals(""))

{

author = list.get(num).getAuthor()

}

if(price==0.0)

{

price = list.get(num).getPrice()

}

if(publisher.equals(""))

{

publisher = list.get(num).getPublisher()

}

if(isbn.equals(""))

{

isbn = list.get(num).getIsbn()

}

if(date.equals(""))

{

date = list.get(num).getDate()

}

list.set(num, new Book(name,author,price,publisher,isbn,date))

System.out.println("保存成功!")

break

case 8:

showMenu()

break

default :

System.out.println("输入不正确,请重新输入")

continue

}

}

}

else

{

System.out.println("您输入的书号不正确!")

showUpdate()

}

}

private void showDelete() throws IOException

{

// -------------------------删除界面--------------------------

System.out.println("书号\t书名\t\t作者\t价格\t出版社\t编号\t出版日期")

for(int i=0i<list.size()i++)

{

System.out.println(i+"\t"+list.get(i).getName()+"\t"+list.get(i).getAuthor()+"\t"+list.get(i).getPrice()

+"\t"+list.get(i).getPublisher()+"\t"+list.get(i).getIsbn()+"\t"+list.get(i).getDate())

}

System.out.println("请选择您要删除的书号:")

Scanner sc = new Scanner(System.in)

Scanner sc2 = new Scanner(System.in)

int num = sc.nextInt()

if(num>=0 && num<list.size())

{

if(list.remove(num)!=null)

{

System.out.println("删除成功!是否继续?(Y/N)")

String str = sc2.nextLine()

if(str.equalsIgnoreCase("Y"))

{

showDelete()

}

else

{

showMenu()

}

}

else

{

System.out.println("删除失败,请重新尝试")

showDelete()

}

}

else

{

System.out.println("您输入的数字不正确!")

showDelete()

}

}

private void showAdd() throws IOException

{

// -------------------------增加界面--------------------------

Scanner sc = new Scanner(System.in)

Scanner sc2 = new Scanner(System.in)

String name =""//书名

String author=""//作者

double price=0.0//价钱

String publisher=""//出版社

String isbn=""//书号

String date=""//出版日期

System.out.println("请输入书名:")

name = sc.nextLine()

System.out.println("请输入作者:")

author = sc.nextLine()

System.out.println("请输入价格:")

price = sc.nextDouble()

System.out.println("请输入出版社:")

publisher = sc2.nextLine()

System.out.println("请输入书号:")

isbn = sc2.nextLine()

System.out.println("请输入出版日期:")

date = sc2.nextLine()

boolean bo = list.add(new Book(name,author,price,publisher,isbn,date))

if(bo)

{

System.out.println("添加成功!")

System.out.println("您添加的书的信息是:")

System.out.println("书名:"+name)

System.out.println("作者:"+author)

System.out.println("价格:"+price)

System.out.println("出版社:"+publisher)

System.out.println("书号:"+isbn)

System.out.println("出版日期:"+date)

System.out.println("是否还要添加?(Y/N)")

String isAdd = sc2.nextLine()

if(isAdd.equalsIgnoreCase("Y"))

{

showAdd()

}

else

{

showMenu()

}

}

else

{

System.out.println("添加失败")

}

}

public void showSelect() throws IOException

{

//-------------------------查询界面--------------------------

System.out.println("书名\t\t作者\t价格\t出版社\t编号\t出版日期")

for(Book book : list)

{

System.out.println(book.getName()+"\t"+book.getAuthor()+"\t"+book.getPrice()

+"\t"+book.getPublisher()+"\t"+book.getIsbn()+"\t"+book.getDate())

}

System.out.println("请选择排序方式:(1)书名  (2)作者  (3)价格  (4)出版日期  (5)返回上一级")

Scanner sc = new Scanner(System.in)

String str = sc.nextLine()

select(str.charAt(0))

showSelect()

}

private void select(char c) throws IOException

{

Comparator<Book> comparator = null

switch(c)

{

case '1':

//按照 书名排序

comparator = new Comparator<Book>(){

@Override

public int compare(Book o1, Book o2)

{

if(o1.getName().compareTo(o2.getName())!=0)

{

return o1.getName().compareTo(o2.getName())

}

return String.valueOf(o1.getPrice()).compareTo(String.valueOf(o2.getPrice()))

}

}

break

case '2':

//按照 作者名称排序

comparator = new Comparator<Book>(){

@Override

public int compare(Book o1, Book o2)

{

if(o1.getAuthor().compareTo(o2.getAuthor())!=0)

{

return o1.getAuthor().compareTo(o2.getAuthor())

}

return String.valueOf(o1.getPrice()).compareTo(String.valueOf(o2.getPrice()))

}

}

break

case '3':

//按照价格排序

comparator = new Comparator<Book>(){

@Override

public int compare(Book o1, Book o2)

{

Double d1 = new Double(o1.getPrice())

Double d2 = new Double(o2.getPrice())

if(d1.compareTo(d2)!=0)

{

return d1.compareTo(d2)

}

return o1.getName().compareTo(o2.getName())

}

}

break

case '4':

//按照出版日期排序

comparator = new Comparator<Book>(){

@Override

public int compare(Book o1, Book o2)

{

if(o1.getDate().compareTo(o2.getDate())!=0)

{

return o1.getDate().compareTo(o2.getDate())

}

return String.valueOf(o1.getPrice()).compareTo(String.valueOf(o2.getPrice()))

}

}

break

case '5':

showMenu()

break

default :

System.out.println("请输入合法标识")

showSelect()

break

}

Collections.sort(list,comparator)

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12321827.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存