├── DBconnection.java ├── EBookstore.java ├── GUI.java ├── SQLQuery1.sql ├── Use Case.pdf ├── Use Case2.pdf ├── WhatsApp Image 2025-03-19 at 21.20.44_4698f07c.jpg ├── WhatsApp Image 2025-04-26 at 17.05.57_c3511b10.jpg ├── WhatsApp Image 2025-04-28 at 13.44.31_65ceb2c5.jpg └── WhatsApp Image 2025-04-28 at 13.44.31_985a3873.jpg /DBconnection.java: -------------------------------------------------------------------------------- 1 | 2 | package ebookstore; 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.SQLException; 6 | import java.sql.Statement; 7 | import java.util.logging.Level; 8 | import java.util.logging.Logger; 9 | import java.sql.ResultSet; 10 | 11 | 12 | public class DBconnection // take care this is the class which already exist 13 | { 14 | public static Connection con; 15 | public static void ConnectToSQL() // to connect to SQL 16 | { 17 | try 18 | { 19 | String url = "jdbc:sqlserver://localhost:1433;databaseName=eBookStore;encrypt=true;trustServerCertificate=true;"; 20 | String username ="DB"; 21 | String password ="12345"; 22 | con= DriverManager.getConnection(url, username,password); 23 | System.out.println("CONNECTED"); 24 | } 25 | catch (SQLException ex) 26 | { 27 | Logger.getLogger(DBconnection.class.getName()).log(Level.SEVERE, null, ex); 28 | }} 29 | public static void Close () // to close the connection of SQL 30 | { 31 | try 32 | { 33 | con.close(); 34 | } 35 | catch (SQLException ex) 36 | { System.out.println("ERROR Connection"); } 37 | } 38 | 39 | public static boolean executeNonquary (String sqlStatement) //to update, delete, insert 40 | { 41 | try //ConnectToSQL(); 42 | 43 | { 44 | Statement stmt = con.createStatement(); 45 | stmt.execute(sqlStatement); 46 | return true; 47 | } 48 | catch (SQLException e) 49 | { 50 | System.out.println(e); //JOptionPane.showMessageDialog(null,"Cant make your edit"); 51 | 52 | return false; 53 | }} 54 | 55 | public static ResultSet GetData(String query) { //For SEARCH Process ONLY 56 | try { 57 | Statement s = con.createStatement(); 58 | return s.executeQuery(query); 59 | } catch (Exception e) { 60 | System.out.println(e); 61 | return null; 62 | }} 63 | } 64 | -------------------------------------------------------------------------------- /EBookstore.java: -------------------------------------------------------------------------------- 1 | 2 | package ebookstore; 3 | 4 | 5 | public class EBookstore 6 | { 7 | 8 | 9 | public static void main(String[] args) 10 | { 11 | DBconnection.ConnectToSQL(); 12 | 13 | //GUI2 G2 =new GUI2(); 14 | GUI G1 =new GUI(); 15 | 16 | 17 | // GUI3 G3 =new GUI3(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /GUI.java: -------------------------------------------------------------------------------- 1 | 2 | package ebookstore; 3 | 4 | import java.awt.Button; 5 | import java.awt.Color; 6 | import java.awt.Frame; 7 | import java.awt.Label; 8 | import java.awt.TextField; 9 | import java.awt.event.ActionEvent; 10 | import java.awt.event.ActionListener; 11 | import java.sql.ResultSet; 12 | import javax.swing.JOptionPane; 13 | 14 | 15 | public class GUI extends Frame implements ActionListener //Frame for BOOK 16 | //labbels objects 17 | { 18 | Frame GUI2= new Frame(); //Frame for publisher 19 | Frame GUI3= new Frame(); //Frame for Aouther 20 | 21 | //GUI2 for publisher 22 | 23 | // Label 24 | Label Publisher_ID = new Label("Publisher_ID"); 25 | Label frist_name = new Label("frist name"); 26 | Label last_name = new Label("last name"); 27 | Label city = new Label("City"); 28 | Label phone = new Label("phone"); 29 | 30 | //textfilde 31 | TextField tPublisher_ID = new TextField(); 32 | TextField tcity = new TextField(); 33 | TextField tfrist_name = new TextField(); 34 | TextField tlast_name = new TextField(); 35 | TextField tphone = new TextField(); 36 | 37 | // Button 38 | Button insert1 =new Button("insert"); 39 | Button Update1 =new Button("Update"); 40 | Button delete1 =new Button("delete"); 41 | Button search1 =new Button("search"); 42 | Button next1 =new Button("next"); 43 | 44 | //------------------------------ 45 | //GUI3 for Aouther 46 | // Label 47 | Label Author_ID = new Label("Author_ID"); 48 | Label frist_Name = new Label("Frist name"); 49 | Label last_Name = new Label("Last name"); 50 | 51 | 52 | //textfilde 53 | 54 | 55 | TextField tAuthor_ID = new TextField(); 56 | TextField tfrist_Name = new TextField(); 57 | TextField tlast_Name = new TextField(); 58 | 59 | // Button 60 | 61 | Button insert2 =new Button("insert"); 62 | Button Update2 =new Button("Update"); 63 | Button delete2 =new Button("delete"); 64 | Button search2 =new Button("search"); 65 | Button Back2 =new Button("Back"); 66 | Button exit2 =new Button("exit"); 67 | 68 | //------------------------------------------ 69 | 70 | //GUI1 For book 71 | Label ISBN =new Label("ISBN"); 72 | Label title =new Label("title"); 73 | Label type =new Label("type"); 74 | Label price =new Label("price"); 75 | Label page_count =new Label("page_count"); 76 | 77 | 78 | //textfield 79 | 80 | TextField tISBN =new TextField(); 81 | TextField ttitle =new TextField(); 82 | TextField ttype =new TextField(); 83 | TextField tprice =new TextField(); 84 | TextField tpage_count =new TextField(); 85 | 86 | 87 | //butttons 88 | Button insert =new Button("insert"); 89 | Button Update =new Button("Update"); 90 | Button delete =new Button("delete"); 91 | Button search =new Button("search"); 92 | Button next =new Button("next"); 93 | Button Back =new Button("Back"); 94 | 95 | 96 | 97 | 98 | GUI() 99 | { 100 | //Frame GUI3 Aouther 101 | GUI3.setLayout(null); 102 | GUI3.setBounds(200,200,600,420); 103 | GUI3.setBackground(new Color(169,169,169)); 104 | GUI3.setTitle("Author"); 105 | 106 | //Frame 107 | Author_ID .setBounds(30, 50, 100, 50); 108 | Author_ID.setForeground(Color.darkGray); 109 | GUI3.add(Author_ID); 110 | 111 | //label 112 | 113 | frist_Name .setBounds(30, 100, 100, 50); 114 | frist_Name.setForeground(Color.darkGray); 115 | GUI3.add(frist_Name); 116 | 117 | last_Name .setBounds(30, 150, 100, 50); 118 | last_Name.setForeground(Color.darkGray); 119 | GUI3.add(last_Name); 120 | 121 | // Text Filed 122 | 123 | tAuthor_ID.setBounds(130, 60, 100, 30); 124 | GUI3.add(tAuthor_ID); 125 | 126 | 127 | tfrist_Name.setBounds(130, 110, 100, 30); 128 | GUI3.add(tfrist_Name); 129 | 130 | 131 | tlast_Name.setBounds(130, 160, 100, 30); 132 | GUI3.add(tlast_Name); 133 | 134 | 135 | // Button 136 | 137 | 138 | insert2.setBounds(40, 350, 100, 30); 139 | GUI3.add(insert2); 140 | 141 | 142 | Update2.setBounds(180, 350, 100, 30); 143 | GUI3.add(Update2); 144 | 145 | 146 | delete2.setBounds(330, 350, 100, 30); 147 | GUI3.add(delete2); 148 | 149 | 150 | search2.setBounds(480, 350, 100, 30); 151 | GUI3.add(search2); 152 | 153 | 154 | Back2.setBounds(480, 60, 100, 30); 155 | GUI3.add(Back2); 156 | 157 | exit2.setBounds(480, 110, 100, 30); 158 | GUI3.add(exit2); 159 | 160 | 161 | GUI3.setVisible(false); 162 | 163 | // for action ls 164 | insert2.addActionListener(this); 165 | Update2.addActionListener(this); 166 | delete2.addActionListener(this); 167 | Back2.addActionListener(this); 168 | exit2.addActionListener(this); 169 | search2.addActionListener(this); 170 | 171 | //-------------------- 172 | //FARME gui2 Publisher 173 | GUI2.setLayout(null); 174 | GUI2.setBounds(200, 200, 600, 420); 175 | GUI2.setBackground(new Color(169,169,169)); 176 | GUI2.setTitle("publisher"); 177 | 178 | 179 | // labels 180 | 181 | Publisher_ID.setBounds(30, 50, 100, 50); 182 | Publisher_ID.setForeground(Color.darkGray); 183 | GUI2.add(Publisher_ID); 184 | 185 | 186 | frist_name.setBounds(30, 100, 100, 50); 187 | frist_name.setForeground(Color.darkGray); 188 | GUI2.add(frist_name); 189 | 190 | 191 | last_name.setBounds(30, 150, 100, 50); 192 | last_name.setForeground(Color.darkGray); 193 | GUI2.add(last_name); 194 | 195 | city.setBounds(30, 200, 100, 50); 196 | city.setForeground(Color.darkGray); 197 | GUI2.add(city); 198 | 199 | 200 | phone.setBounds(30, 250, 100, 50); 201 | phone.setForeground(Color.darkGray); 202 | GUI2.add(phone); 203 | 204 | 205 | //Text fild 206 | 207 | tPublisher_ID.setBounds(130, 60, 100, 30); 208 | GUI2.add(tPublisher_ID); 209 | 210 | 211 | tfrist_name.setBounds(130, 110, 100, 30); 212 | GUI2.add(tfrist_name); 213 | 214 | 215 | tlast_name.setBounds(130, 160, 100, 30); 216 | GUI2.add(tlast_name); 217 | 218 | 219 | tcity.setBounds(130, 210, 100, 30); 220 | GUI2.add(tcity); 221 | 222 | 223 | tphone.setBounds(130, 260, 100, 30); 224 | GUI2.add(tphone); 225 | 226 | //butttons 227 | 228 | insert1.setBounds(30, 350, 100, 30); 229 | GUI2.add(insert1); 230 | 231 | 232 | Update1.setBounds(180, 350, 100, 30); 233 | GUI2.add(Update1); 234 | 235 | 236 | delete1.setBounds(330, 350, 100, 30); 237 | GUI2.add(delete1); 238 | 239 | 240 | search1.setBounds(480, 350, 100, 30); 241 | GUI2.add(search1); 242 | 243 | 244 | 245 | next1.setBounds(480, 60, 100, 30); 246 | GUI2.add(next1); 247 | 248 | 249 | GUI2.setVisible(true); 250 | 251 | insert1.addActionListener(this); 252 | Update1.addActionListener(this); 253 | delete1.addActionListener(this); 254 | next1.addActionListener(this); 255 | search1.addActionListener(this); 256 | 257 | //------------------------- 258 | setLayout(null); 259 | setBounds(200,200,600,420); 260 | setBackground(new Color(169,169,169)); 261 | setTitle("Book"); 262 | ISBN.setBounds(30, 50, 100, 50); 263 | ISBN.setForeground(Color.darkGray); 264 | add(ISBN); 265 | 266 | 267 | title.setBounds(30, 100, 100, 50); 268 | title.setForeground(Color.darkGray); 269 | add(title); 270 | 271 | 272 | type.setBounds(30, 150, 100, 50); 273 | type.setForeground(Color.darkGray); 274 | add(type); 275 | 276 | 277 | price.setBounds(30, 200, 100, 50); 278 | price.setForeground(Color.darkGray); 279 | add(price); 280 | 281 | 282 | page_count.setBounds(30, 250, 100, 50); 283 | page_count.setForeground(Color.darkGray); 284 | add(page_count); 285 | 286 | 287 | insert.setBounds(30, 350, 100, 30); 288 | add(insert); 289 | 290 | 291 | Update.setBounds(180, 350, 100, 30); 292 | add(Update); 293 | 294 | 295 | delete.setBounds(330, 350, 100, 30); 296 | add(delete); 297 | 298 | 299 | search.setBounds(480, 350, 100, 30); 300 | add(search); 301 | 302 | 303 | next.setBounds(480, 60, 100, 30); 304 | add(next); 305 | 306 | Back.setBounds(480, 110, 100, 30); 307 | add(Back); 308 | 309 | 310 | tISBN.setBounds(130, 60, 100, 30); 311 | add(tISBN); 312 | 313 | 314 | ttitle.setBounds(130, 110, 100, 30); 315 | add(ttitle); 316 | 317 | 318 | ttype.setBounds(130, 160, 100, 30); 319 | add(ttype); 320 | 321 | 322 | tprice.setBounds(130, 210, 100, 30); 323 | add(tprice); 324 | 325 | 326 | tpage_count.setBounds(130, 260, 100, 30); 327 | add(tpage_count); 328 | 329 | 330 | 331 | 332 | 333 | insert.addActionListener(this); 334 | Update.addActionListener(this); 335 | delete.addActionListener(this); 336 | Back.addActionListener(this); 337 | next.addActionListener(this); 338 | search.addActionListener(this); 339 | 340 | setVisible(false); 341 | } 342 | 343 | /** 344 | * 345 | * @param e 346 | */ 347 | @Override 348 | public void actionPerformed(ActionEvent e) 349 | 350 | 351 | //GUI2 352 | { 353 | 354 | if(e.getSource()==insert1) 355 | { 356 | DBconnection.executeNonquary("insert into publisher values("+tPublisher_ID.getText()+",'"+tfrist_name.getText()+"','"+tlast_name.getText()+"','"+tcity.getText()+"','"+tphone.getText()+"')"); 357 | 358 | JOptionPane.showMessageDialog(null, "Publisher inserted successfully!"); 359 | 360 | } 361 | if(e.getSource()==Update1) 362 | { 363 | // DBconnection.executeNonquary("update set publisher values("+tPublisher_ID.getText()+",'"+tfrist_name.getText()+"','"+tlast_name.getText()+"','"+tcity.getText()+"','"+tphone.getText()+"')"); 364 | DBconnection.executeNonquary("update publisher set frist_name= '"+tfrist_name.getText()+"',laste_name='"+tlast_name.getText()+"',city='"+tcity.getText()+"',phone='"+tphone.getText()+"'Where Publisher_ID="+tPublisher_ID.getText()); 365 | 366 | JOptionPane.showMessageDialog(null, "Publisher Updated successfully!"); 367 | 368 | } 369 | if(e.getSource()==delete1) 370 | { 371 | DBconnection.executeNonquary("delete from publisher where Publisher_ID= "+tPublisher_ID.getText()); 372 | 373 | JOptionPane.showMessageDialog(null, "Publisher Deleted successfully!"); 374 | 375 | } 376 | if(e.getSource()==next1) 377 | { 378 | 379 | GUI2.setVisible(false); 380 | setVisible(true); 381 | GUI3.setVisible(false); 382 | } 383 | 384 | if(e.getSource()==search1) 385 | { 386 | try { 387 | String query = "select * from publisher where publisher_id = '" + tPublisher_ID.getText() + "'"; 388 | ResultSet db = DBconnection.GetData(query); 389 | if (db.next()) { 390 | tfrist_name.setText(db.getString("frist_name")); 391 | tlast_name.setText(db.getString("laste_name")); 392 | tcity.setText(db.getString("city")); 393 | tphone.setText(db.getString("phone")); 394 | JOptionPane.showMessageDialog(null, "publisher Found!"); 395 | 396 | } else { 397 | JOptionPane.showMessageDialog(null, "publisher not Found!"); 398 | 399 | } 400 | db.close(); 401 | } catch (Exception ex) { 402 | ex.printStackTrace(); 403 | } 404 | } 405 | 406 | 407 | //--------------------------------------------------------- 408 | 409 | //GUI 410 | 411 | if(e.getSource()==insert) 412 | { 413 | DBconnection.executeNonquary("insert into book values('"+tISBN.getText()+"','"+ttitle.getText()+"','"+ttype.getText()+"',"+tprice.getText()+","+tpage_count.getText()+","+tPublisher_ID.getText()+")"); 414 | 415 | JOptionPane.showMessageDialog(null, "BOOK inserted successfully!"); 416 | 417 | } 418 | if(e.getSource()==Update) 419 | { 420 | // DBconnection.executeNonquary("update set publisher values("+tPublisher_ID.getText()+",'"+tfrist_name.getText()+"','"+tlast_name.getText()+"','"+tcity.getText()+"','"+tphone.getText()+"')"); 421 | DBconnection.executeNonquary("update book set title= '"+ttitle.getText()+"',typee='"+ttype.getText()+"',price="+tprice.getText()+",page_count="+tpage_count.getText()+",publisher_id="+tPublisher_ID.getText()+" Where ISBN="+ISBN.getText()); 422 | 423 | JOptionPane.showMessageDialog(null, "Book Updated successfully!"); 424 | 425 | } 426 | 427 | if(e.getSource()==delete) 428 | { 429 | DBconnection.executeNonquary("delete from book where ISBN= "+ISBN.getText()); 430 | 431 | JOptionPane.showMessageDialog(null, "Book Deleted successfully!"); 432 | } 433 | 434 | if(e.getSource()==next) 435 | { 436 | 437 | GUI2.setVisible(false); 438 | setVisible(false); 439 | GUI3.setVisible(true); 440 | 441 | } 442 | if(e.getSource()==Back) 443 | { 444 | setVisible(false); 445 | GUI2.setVisible(true); 446 | 447 | } 448 | 449 | if(e.getSource()==search) 450 | { 451 | try { 452 | String query = "select * from Book where ISBN = '" + tISBN.getText() + "'"; 453 | ResultSet rs = DBconnection.GetData(query); 454 | if (rs.next()) { 455 | ttitle.setText(rs.getString("title")); 456 | ttype.setText(rs.getString("typee")); 457 | tpage_count.setText(String.valueOf(rs.getInt("page_count"))); 458 | tprice.setText(String.valueOf(rs.getFloat("price"))); 459 | tPublisher_ID.setText(rs.getString("publisher_id")); 460 | JOptionPane.showMessageDialog(null, "BOOK Found!"); 461 | } else 462 | { 463 | JOptionPane.showMessageDialog(null, "BOOK not Found!"); 464 | } 465 | } 466 | catch (Exception ex) 467 | { 468 | ex.printStackTrace(); 469 | } 470 | } 471 | 472 | 473 | //------------------------------------------------ 474 | 475 | //GUI3 476 | 477 | if(e.getSource()==insert2) 478 | { 479 | DBconnection.executeNonquary("insert into Author values('"+tAuthor_ID.getText()+"','"+tfrist_Name.getText()+"','"+tlast_Name.getText()+"')"); 480 | 481 | JOptionPane.showMessageDialog(null, "Author inserted successfully!"); 482 | } 483 | if(e.getSource()==Update2) 484 | { 485 | // DBconnection.executeNonquary("update set publisher values("+tPublisher_ID.getText()+",'"+tfrist_name.getText()+"','"+tlast_name.getText()+"','"+tcity.getText()+"','"+tphone.getText()+"')"); 486 | DBconnection.executeNonquary("update Author set firste_name= '"+tfrist_Name.getText()+"',laste_name='"+tlast_Name.getText()+"'Where author_ID ="+tAuthor_ID.getText()); 487 | 488 | JOptionPane.showMessageDialog(null, "Author Updated successfully!"); 489 | } 490 | if(e.getSource()==delete2) 491 | { 492 | DBconnection.executeNonquary("delete from Author where author_ID= "+tAuthor_ID.getText()); 493 | 494 | JOptionPane.showMessageDialog(null, "Author Deleted successfully!"); 495 | } 496 | if(e.getSource()==search2) 497 | { 498 | try { 499 | String query = "select * from Author where author_ID = '" + tAuthor_ID.getText() + "'"; 500 | ResultSet cs = DBconnection.GetData(query); 501 | if (cs.next()) { 502 | tfrist_Name.setText(cs.getString("firste_name")); 503 | tlast_Name.setText(cs.getString("laste_name")); 504 | 505 | JOptionPane.showMessageDialog(null, "Author Found!"); 506 | 507 | } else { 508 | JOptionPane.showMessageDialog(null, "Author not Found!"); 509 | 510 | } 511 | cs.close(); 512 | } catch (Exception ex) { 513 | ex.printStackTrace(); 514 | } 515 | } 516 | 517 | 518 | 519 | if(e.getSource()==Back2) 520 | { 521 | setVisible(true); 522 | GUI2.setVisible(false); 523 | GUI3.setVisible(false); 524 | } 525 | 526 | if(e.getSource()==exit2) 527 | { 528 | System.exit(0); 529 | } 530 | }} 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | -------------------------------------------------------------------------------- /SQLQuery1.sql: -------------------------------------------------------------------------------- 1 | create database eBookStore; 2 | 3 | /*the first thing create table publisher 4 | and create table for phone because i't multi valiue 5 | */ 6 | create table publisher 7 | ( 8 | publisher_id int primary key, 9 | frist_name varchar(10), 10 | laste_name varchar(10), 11 | city varchar(10) 12 | 13 | 14 | ); 15 | create table phone 16 | ( 17 | phone_number varchar(12), 18 | publisher_id int, 19 | foreign key (publisher_id) references publisher(publisher_id) 20 | ); 21 | 22 | /*creat table for book and also is in relationshipe one to many with publisher 23 | and many to many with Author 24 | */ 25 | 26 | create table book 27 | ( 28 | ISBN varchar(10) primary key not null, 29 | title varchar(30) , 30 | typee varchar(10), 31 | price float, 32 | page_count int, 33 | publisher_id int, 34 | foreign key (publisher_id) references publisher(publisher_id) 35 | ); 36 | 37 | /* 38 | create table Author 39 | */ 40 | 41 | create table Author 42 | ( 43 | author_id varchar(10) primary key, 44 | firste_name varchar(10), 45 | laste_name varchar(10) 46 | ); 47 | 48 | 49 | create table Author_Book 50 | ( 51 | author_id varchar(10), 52 | ISBN varchar(10) , 53 | primary key (author_id,ISBN), 54 | foreign key (author_id) references Author (author_id), 55 | foreign key (ISBN) references book (ISBN)); 56 | select * from book 57 | 58 | 59 | -------------------------------------------------------------------------------- /Use Case.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mihaked/Ebook_store/b21b38ec6584efb4bfcd327bba61d719e8b6dc98/Use Case.pdf -------------------------------------------------------------------------------- /Use Case2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mihaked/Ebook_store/b21b38ec6584efb4bfcd327bba61d719e8b6dc98/Use Case2.pdf -------------------------------------------------------------------------------- /WhatsApp Image 2025-03-19 at 21.20.44_4698f07c.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mihaked/Ebook_store/b21b38ec6584efb4bfcd327bba61d719e8b6dc98/WhatsApp Image 2025-03-19 at 21.20.44_4698f07c.jpg -------------------------------------------------------------------------------- /WhatsApp Image 2025-04-26 at 17.05.57_c3511b10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mihaked/Ebook_store/b21b38ec6584efb4bfcd327bba61d719e8b6dc98/WhatsApp Image 2025-04-26 at 17.05.57_c3511b10.jpg -------------------------------------------------------------------------------- /WhatsApp Image 2025-04-28 at 13.44.31_65ceb2c5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mihaked/Ebook_store/b21b38ec6584efb4bfcd327bba61d719e8b6dc98/WhatsApp Image 2025-04-28 at 13.44.31_65ceb2c5.jpg -------------------------------------------------------------------------------- /WhatsApp Image 2025-04-28 at 13.44.31_985a3873.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mihaked/Ebook_store/b21b38ec6584efb4bfcd327bba61d719e8b6dc98/WhatsApp Image 2025-04-28 at 13.44.31_985a3873.jpg --------------------------------------------------------------------------------