⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bookmanager.java

📁 一个简单的网上订书系统 java的课程设计
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		insert("BID00184","Long Chen","The World to Come: A Novel","25438756 ","PID005","3 ","2007-5-22",52.45 ,"This book is useful for the java programing beginner.","SCno005");
		insert("BID00185","Suzanne Matson","The Yiddish Policemen\\'s Union, limited edition ","64964147 ","PID008","4 ","2007-5-22",24.99 ,"Fragments of a Great Secret have been found in the oral tradition.","SCNO021");
		insert("BID00186","Christopher Hitchens ","The Yiddish Policemen\\'s Union: A Novel","61524048 ","PID015","1 ","2006-11-28",38.25 ,"Keith Donohue\\'s sparkling debut novel was first presented by the publisher as.","SCNO009");
		insert("BID00187","James Patterson","Three Cups of Tea: One Man\\'s Mission to Promote Peace . . . One School at a Time ","65000740 ","PID015","4 ","2007-5-8",64.29 ,"Fragments of a Great Secret have been found in the oral tradition.","SCNO002");
		insert("BID00188","Andy Fu","Time and Roomage","62916988 ","PID001","2 ","2006-12-4",54.82 ,"Starred Review. In this remarkable effort, National Book.","SCNO016");
		insert("BID00189","Don Huaffman","To be a good doctor","64906902 ","PID008","1 ","2007-4-24",23.00 ,"Keith Donohue\\'s sparkling debut novel was first presented by the publisher as.","SCNO026");
		insert("BID00190","Christopher Hitchens ","To be a TM","62121022 ","PID012","1 ","2006-11-28",45.35 ,"Starred Review. In this remarkable effort, National Book Award.","SCNO012");
		insert("BID00191","Christopher Hitchens ","Twilight","62320014 ","PID008","1 ","2006-11-28",47.72 ,"It\\'s official! Harry Potter and the Deathly Hallows.","SCNO013");
		insert("BID00192","J.K ROb","Water for Elephants: A Novel","69881689 ","PID010","1 ","2007-5-8",61.92 ,"In his sixth book of combustible investigative journalism, Langewiesche.","SCNO025");
		insert("BID00193","William Langewiesche","Water for Elephants: A Novel (Paperback)","68687740 ","PID009","1 ","2007-5-5",47.72 ,"Starred Review. In this remarkable effort, National Book.","SCNO019");
		insert("BID00194","Cynthia Marie Rizzo","Where Have All the Leaders Gone? ","65035407 ","PID010","4 ","2007-5-1",25.95 ,"Fragments of a Great Secret have been found in the oral tradition.","SCNO010");
		insert("BID00195","Andy Fu","Where the Wild Things Are","63115979 ","PID003","1 ","2006-12-4",57.19 ,"In his sixth book of combustible investigative journalism, Langewiesche.","SCNO017");
		insert("BID00196","Lalita Tademy","Women & Money: Owning the Power to Control Your Destiny ","64919850 ","PID003","5 ","2004-2-16",99.80 ,"Fragments of a Great Secret have been found in the oral tradition.","SCNO002");
		insert("BID00197","J. K. Rowling","World Without End","65027703 ","PID012","4 ","2007-5-1",23.95 ,"Fragments of a Great Secret have been found in the oral tradition.","SCNO014");
		insert("BID00198","Andy Fu","You: On A Diet: The Owner\\'s Manual for Waist Management ","62717997 ","PID009","2 ","2006-11-28",52.45 ,"Keith Donohue\\'s sparkling debut novel was first presented by the publisher as.","SCNO015");
		insert("BID00199","Jeannette Walls","YOU: The Owner\\'s Manual: An Insider\\'s Guide to the Body that Will Make You Healthier and Younger ","65033481 ","PID011","4 ","2007-5-1",13.95 ,"Fragments of a Great Secret have been found in the oral tradition.","SCNO011");
		insert("BID00200","Rhonda Byrne","Your Destiny Switch: Master Your Key Emotions, and Attract the Life of Your Dreams ","67294800 ","PID012","2 ","2007-5-1",23.95 ,"Keith Donohue\\'s sparkling debut novel was first presented by the publisher as.","SCNO012");

		
		return null;
	}


	public static int insert(String[] args) {
		if (args.length != 10) {
			System.err.print("BookManeger arguments input error.");
			return -1;
		}
		String query = "insert into book values(";
		return e.execute(Checker.argsInsert(query, args));
	}

	public static int insert(String BID, String author, String title,
			String isbn, String PID, String edition, String publicationDate,
			double price, String descripition, String SCno) {
		String query = "insert into book values(" + Checker.checkNull(BID)
				+ "," + Checker.checkNull(author) + ","
				+ Checker.checkNull(title) + "," + Checker.checkNull(isbn)
				+ "," + Checker.checkNull(PID) + ","
				+ Checker.checkNull(edition) + ","
				+ Checker.checkNull(publicationDate) + ","
				+ Checker.checkNull(String.valueOf(price)) + ","
				+ Checker.checkNull(descripition) + ","
				+ Checker.checkNull(SCno) + ");";
		return e.execute(query);
	}

	public static int deleteByBID(String BID) {
		String query = "delete from book where BID = " + Checker.checkNull(BID)
				+ ";";
		return e.execute(query);
	}

	public static int update(String BID, String description, double price) {
		
		String s1= Checker.checkNull(BID);

		if (s1 == Checker.nullStr) {
			System.err.println("BookManager update error: Book ID is null");
			return -1;
		}

		String s2= Checker.checkNull(description);

		if (s2 == Checker.nullStr && price == 0.0) {
			System.err
					.println("BookManager update error: Don't update any date.");
			return -1;
		}

		String tmp1 = "", tmp2 = "";

		
		if (s2 != Checker.nullStr)
			tmp1 = " description = " + Checker.updateOnNull(description);

		if (price != 0.0)
			tmp2 = " price = " + price;

		String query = "update book set" + tmp1
				+ Checker.addComma(String.valueOf(price), description) + tmp2
				+ " where BID = " + s1 + ";";
		System.out.println(query);

		return e.execute(query);
	}
	
	public static String getNewBookID(){

		String ID = pre;
		String last = s.getLastID(TablesManager.book);
		if(last == null) return "BID00000";
 		int num = Integer.parseInt(last.substring(3));
		num++;
		last = String.valueOf(num);
		for(int i = last.length() ;i<5 ;i++)
			ID = ID.concat("0");
		ID = ID.concat(last);
		return ID;
	}	

	private static final String pre = "BID";
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -