1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680
|
package projet_youtube_produit;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.ResultSet;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import BDD.Parameter;
import BDD.ResultSetTableModel;
import BDD.db_connection;
/**
*
* @author monia
*/
public class Produit extends javax.swing.JFrame {
/**
* Creates new form produit
*/
ResultSet rs;
db_connection db;
Connection conn = null;
public Produit() {
db = new db_connection(new Parameter().HOST_DB, new Parameter().USERNAME_DB, new Parameter().PASSWORD_DB,
new Parameter().IPHOST, new Parameter().PORT);
initComponents();
table();
fillCombo();
}
public void table() {
String t[] = { "id", "code_produit", "reference", "designation", "rangement", "fournisseur", "remise", "prix",
"stock", "categorie", "limite", "tva", "marge" };
rs = db.querySelect(t, "produit");
tbl_prod.setModel(new ResultSetTableModel(rs));
}
void actualiser() {
txtid.setText("");
txtref.setText("");
txtdes.setText("");
txtran.setText("");
txtlim.setText("");
txtrem.setText("");
txtpri.setText("");
txtsto.setText("");
txttva.setText("");
txtmrg.setText("");
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated
// Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
tbl_prod = new javax.swing.JTable();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
txtdes = new javax.swing.JTextField();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
txtran = new javax.swing.JTextField();
jLabel14 = new javax.swing.JLabel();
txtid = new javax.swing.JTextField();
txtref = new javax.swing.JTextField();
txtrem = new javax.swing.JTextField();
txtpri = new javax.swing.JTextField();
txtsto = new javax.swing.JTextField();
txtfou = new javax.swing.JTextField();
jPanel3 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
comrech = new javax.swing.JComboBox();
jLabel5 = new javax.swing.JLabel();
txtrech = new javax.swing.JTextField();
txtmrg = new javax.swing.JTextField();
txtlim = new javax.swing.JTextField();
txttva = new javax.swing.JTextField();
jButton5 = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jLabelres = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
jcombcat = new javax.swing.JComboBox();
jcombfr = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setPreferredSize(new java.awt.Dimension(1350, 900));
getContentPane().setLayout(null);
jPanel1.setBackground(new java.awt.Color(231, 248, 251));
jPanel1.setPreferredSize(new java.awt.Dimension(840, 900));
jPanel1.setLayout(null);
tbl_prod.setModel(new javax.swing.table.DefaultTableModel(
new Object[][] { { null, null, null, null, null, null, null, null, null },
{ null, null, null, null, null, null, null, null, null },
{ null, null, null, null, null, null, null, null, null },
{ null, null, null, null, null, null, null, null, null } },
new String[] { "id", "code_produit", "reference", "designation", "rangement", "fournisseur", "remise",
"prix", "stock ", "categorie", "limite", "tva", "marge" }) {
Class[] types = new Class[] { java.lang.Integer.class, java.lang.String.class, java.lang.Object.class,
java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Integer.class,
java.lang.Integer.class, java.lang.Integer.class };
public Class getColumnClass(int columnIndex) {
return types[columnIndex];
}
});
tbl_prod.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
tbl_prodMouseClicked(evt);
}
});
tbl_prod.getColumnModel().getColumn(8).setCellRenderer(new MonCellRenderer());
jLabel5.setFont(new java.awt.Font("Tahoma", 4, 18)); // NOI18N
jLabel5.setText("Rechercher par :");
jPanel1.add(jLabel5);
jLabel5.setBounds(30, 60, 130, 30);
comrech.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "code_produit", "reference", "designation",
"rangement", "fournisseur", "remise", "prix", "stock", "limite", "tva", "marge" }));
jPanel1.add(comrech);
comrech.setBounds(180, 60, 150, 30);
jPanel1.add(txtrech);
txtrech.setBounds(20, 100, 150, 30);
jButton1.setFont(new java.awt.Font("Tahoma", 3, 18)); // NOI18N
jButton1.setText("Recherche ");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jPanel1.add(jButton1);
jButton1.setBounds(180, 100, 150, 30);
jLabel1.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
jLabelres.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
jLabelres.setText("Resultat :");
jLabelres.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 0, 1, 0, new java.awt.Color(0, 0, 0)));
jPanel1.add(jLabelres);
jLabelres.setBounds(480, 130, 100, 24);
jScrollPane1.setViewportView(tbl_prod);
jPanel1.add(jScrollPane1);
jScrollPane1.setBounds(0, 160, 1320, 160);
jButton2.setFont(new java.awt.Font("Tahoma", 4, 18)); // NOI18N
jButton2.setText("ajouter");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jPanel1.add(jButton2);
jButton2.setBounds(10, 320, 120, 40);
jButton3.setFont(new java.awt.Font("Tahoma", 4, 18)); // NOI18N
jButton3.setText("modifier");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jPanel1.add(jButton3);
jButton3.setBounds(130, 320, 110, 40);
jButton4.setFont(new java.awt.Font("Tahoma", 4, 18)); // NOI18N
jButton4.setText("supprimer");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jPanel1.add(jButton4);
jButton4.setBounds(240, 320, 130, 40);
jButton5.setFont(new java.awt.Font("Tahoma", 4, 18)); // NOI18N
jButton5.setText("actualiser");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jPanel1.add(jButton5);
jButton5.setBounds(370, 320, 130, 40);
jPanel2.setBackground(new java.awt.Color(204, 255, 255));
jPanel2.setPreferredSize(new java.awt.Dimension(1200, 600));
jPanel2.setLayout(null);
jLabel7.setFont(new java.awt.Font("Calibri", 1, 12)); // NOI18N
jLabel7.setText("Code produit :");
jPanel2.add(jLabel7);
jLabel7.setBounds(10, 10, 80, 27);
jLabel8.setFont(new java.awt.Font("Calibri", 1, 12)); // NOI18N
jLabel8.setText("Fournisseur :");
jPanel2.add(jLabel8);
jLabel8.setBounds(330, 10, 90, 20);
jPanel2.add(jcombfr);
jcombfr.setBounds(420, 10, 160, 30);
jLabel9.setFont(new java.awt.Font("Calibri", 1, 12)); // NOI18N
jLabel9.setText("Remise % :");
jPanel2.add(jLabel9);
jLabel9.setBounds(10, 50, 70, 27);
jPanel2.add(txtrem);
txtrem.setBounds(120, 50, 160, 30);
jLabel10.setFont(new java.awt.Font("Calibri", 1, 12)); // NOI18N
jLabel10.setText("Reference :");
jPanel2.add(jLabel10);
jLabel10.setBounds(330, 50, 70, 27);
jLabel11.setFont(new java.awt.Font("Calibri", 1, 12)); // NOI18N
jLabel11.setText("Designation :");
jPanel2.add(jLabel11);
jLabel11.setBounds(10, 100, 90, 27);
jPanel2.add(txtdes);
txtdes.setBounds(120, 100, 160, 30);
jLabel12.setFont(new java.awt.Font("Calibri", 1, 12)); // NOI18N
jLabel12.setText("prix :");
jPanel2.add(jLabel12);
jLabel12.setBounds(330, 100, 70, 27);
jPanel2.add(txtpri);
txtpri.setBounds(420, 100, 160, 30);
jLabel13.setFont(new java.awt.Font("Calibri", 1, 12)); // NOI18N
jLabel13.setText("stock :");
jPanel2.add(jLabel13);
jLabel13.setBounds(330, 140, 70, 27);
jPanel2.add(txtran);
txtran.setBounds(120, 140, 160, 30);
jLabel14.setFont(new java.awt.Font("Calibri", 1, 12)); // NOI18N
jLabel14.setText("rangement :");
jPanel2.add(jLabel14);
jLabel14.setBounds(10, 150, 90, 27);
jPanel2.add(txtid);
txtid.setBounds(120, 10, 160, 30);
jPanel2.add(txtref);
txtref.setBounds(420, 50, 160, 30);
jPanel2.add(txtsto);
txtsto.setBounds(420, 140, 160, 30);
jLabel15.setFont(new java.awt.Font("Calibri", 1, 12)); // NOI18N
jLabel15.setText("tva :");
jPanel2.add(jLabel15);
jLabel15.setBounds(730, 10, 100, 30);
jPanel2.add(txttva);
txttva.setBounds(790, 10, 160, 30);
jLabel16.setFont(new java.awt.Font("Calibri", 1, 12)); // NOI18N
jLabel16.setText("limite :");
jPanel2.add(jLabel16);
jLabel16.setBounds(730, 50, 100, 30);
jPanel2.add(txtlim);
txtlim.setBounds(790, 50, 160, 30);
jLabel17.setFont(new java.awt.Font("Calibri", 1, 12)); // NOI18N
jLabel17.setText("Marge :");
jPanel2.add(jLabel17);
jLabel17.setBounds(730, 90, 100, 30);
jPanel2.add(txtmrg);
txtmrg.setBounds(790, 90, 160, 30);
jLabel1.setFont(new java.awt.Font("Calibri", 1, 12)); // NOI18N
jLabel1.setText("categorie :");
jPanel2.add(jLabel1);
jLabel1.setBounds(730, 130, 100, 30);
jPanel2.add(jcombcat);
jcombcat.setBounds(790, 130, 160, 30);
jPanel1.add(jPanel2);
jPanel2.setBounds(10, 370, 1300, 600);
jPanel3.setBackground(new java.awt.Color(204, 255, 255));
jPanel3.setLayout(null);
jPanel1.add(jPanel3);
jPanel3.setBounds(510, 300, 809, 290);
getContentPane().add(jPanel1);
jPanel1.setBounds(0, 0, 1350, 900);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton2ActionPerformed
if (txtid.getText().equals("") || txtref.getText().equals("") || txtdes.getText().equals("")
|| txtran.getText().equals("") || txtrem.getText().equals("") || txtpri.getText().equals("")
|| txtsto.getText().equals("")) {
JOptionPane.showMessageDialog(this, "SVP entrer les informations complete");
} else {
String[] colon = { "code_produit", "reference", "designation", "rangement", "fournisseur", "remise", "prix",
"stock", "categorie", "limite", "tva", "marge" };
String[] inf = { txtid.getText(), txtref.getText(), txtdes.getText(), txtran.getText(),
String.valueOf(jcombfr.getSelectedItem()), txtrem.getText(), txtpri.getText(), txtsto.getText(),
String.valueOf(jcombcat.getSelectedItem()), txtlim.getText(), txttva.getText(), txtmrg.getText() };
System.out.println(db.queryInsert("produit", colon, inf));
table();
actualiser();
}
}// GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton3ActionPerformed
if (txtid.getText().equals("") || txtref.getText().equals("") || txtdes.getText().equals("")
|| txtran.getText().equals("") || txtrem.getText().equals("") || txtpri.getText().equals("")
|| txtsto.getText().equals("")) {
JOptionPane.showMessageDialog(this, "SVP entrer les informations complete");
} else {
String[] colon = { "code_produit", "reference", "designation", "rangement", "fournisseur", "remise", "prix",
"stock", "categorie", "limite", "tva", "marge" };
String[] inf = { txtid.getText(), txtref.getText(), txtdes.getText(), txtran.getText(),
String.valueOf(jcombfr.getSelectedItem()), txtrem.getText(), txtpri.getText(), txtsto.getText(),
String.valueOf(jcombcat.getSelectedItem()), txtlim.getText(), txttva.getText(), txtmrg.getText() };
String id = String.valueOf(tbl_prod.getValueAt(tbl_prod.getSelectedRow(), 0));
System.out.println(db.queryUpdate("produit", colon, inf, "id='" + id + "'"));
table();
actualiser();
}
}// GEN-LAST:event_jButton3ActionPerformed
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton4ActionPerformed
String id = String.valueOf(tbl_prod.getValueAt(tbl_prod.getSelectedRow(), 0));
if (JOptionPane.showConfirmDialog(this, "est ce que tu es sure que tu veux suuprimer", "attention!!!",
JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
db.queryDelete("produit", "id=" + id);
} else {
return;
}
table();
}// GEN-LAST:event_jButton4ActionPerformed
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton5ActionPerformed
if (txtrech.getText().equals("")) {
JOptionPane.showMessageDialog(this, "SVP entrer quelque chose");
} else {
if (comrech.getSelectedItem().equals("code_produit")) {
String colon[] = { "id", "code_produit", "reference", "designation", "rangement", "fournisseur",
"remise", "prix", "stock ", "categorie", "limite", "tva", "marge" };
rs = db.fcSelectCommand(colon, "produit", "code_produit LIKE '" + txtrech.getText() + "' ");
tbl_prod.setModel(new ResultSetTableModel(rs));
} else if (comrech.getSelectedItem().equals("reference")) {
String colon[] = { "id", "code_produit", "reference", "designation", "rangement", "fournisseur",
"remise", "prix", "stock ", "categorie", "limite", "tva", "marge" };
rs = db.fcSelectCommand(colon, "produit", "reference LIKE '" + txtrech.getText() + "' ");
tbl_prod.setModel(new ResultSetTableModel(rs));
} else if (comrech.getSelectedItem().equals("designation")) {
String colon[] = { "id", "code_produit", "reference", "designation", "rangement", "fournisseur",
"remise", "prix", "stock ", "categorie", "limite", "tva", "marge" };
rs = db.fcSelectCommand(colon, "produit", "designation LIKE '" + txtrech.getText() + "' ");
tbl_prod.setModel(new ResultSetTableModel(rs));
} else if (comrech.getSelectedItem().equals("rangement")) {
String colon[] = { "id", "code_produit", "reference", "designation", "rangement", "fournisseur",
"remise", "prix", "stock ", "categorie", "limite", "tva", "marge" };
rs = db.fcSelectCommand(colon, "produit", "rangement LIKE '" + txtrech.getText() + "' ");
tbl_prod.setModel(new ResultSetTableModel(rs));
} else if (comrech.getSelectedItem().equals("fournisseur")) {
String colon[] = { "id", "code_produit", "reference", "designation", "rangement", "fournisseur",
"remise", "prix", "stock ", "categorie", "limite", "tva", "marge" };
rs = db.fcSelectCommand(colon, "produit", "fournisseur LIKE '" + txtrech.getText() + "' ");
tbl_prod.setModel(new ResultSetTableModel(rs));
} else if (comrech.getSelectedItem().equals("remise")) {
String colon[] = { "id", "code_produit", "reference", "designation", "rangement", "fournisseur",
"remise", "prix", "stock ", "categorie", "limite", "tva", "marge" };
rs = db.fcSelectCommand(colon, "produit", "remise LIKE '" + txtrech.getText() + "' ");
tbl_prod.setModel(new ResultSetTableModel(rs));
} else if (comrech.getSelectedItem().equals("prix")) {
String colon[] = { "id", "code_produit", "reference", "designation", "rangement", "fournisseur",
"remise", "prix", "stock ", "categorie", "limite", "tva", "marge" };
rs = db.fcSelectCommand(colon, "produit", "prix LIKE '" + txtrech.getText() + "' ");
tbl_prod.setModel(new ResultSetTableModel(rs));
} else if (comrech.getSelectedItem().equals("stock")) {
String colon[] = { "id", "code_produit", "reference", "designation", "rangement", "fournisseur",
"remise", "prix", "stock ", "categorie", "limite", "tva", "marge" };
rs = db.fcSelectCommand(colon, "produit", "stock LIKE '" + txtrech.getText() + "' ");
tbl_prod.setModel(new ResultSetTableModel(rs));
} else if (comrech.getSelectedItem().equals("limite")) {
String colon[] = { "id", "code_produit", "reference", "designation", "rangement", "fournisseur",
"remise", "prix", "stock ", "categorie", "limite", "tva", "marge" };
rs = db.fcSelectCommand(colon, "produit", "limite LIKE '" + txtrech.getText() + "' ");
tbl_prod.setModel(new ResultSetTableModel(rs));
} else if (comrech.getSelectedItem().equals("tva")) {
String colon[] = { "id", "code_produit", "reference", "designation", "rangement", "fournisseur",
"remise", "prix", "stock ", "categorie", "limite", "tva", "marge" };
rs = db.fcSelectCommand(colon, "produit", "tva LIKE '" + txtrech.getText() + "' ");
tbl_prod.setModel(new ResultSetTableModel(rs));
} else if (comrech.getSelectedItem().equals("marge")) {
String colon[] = { "id", "code_produit", "reference", "designation", "rangement", "fournisseur",
"remise", "prix", "stock ", "categorie", "limite", "tva", "marge" };
rs = db.fcSelectCommand(colon, "produit", "marge LIKE '" + txtrech.getText() + "' ");
tbl_prod.setModel(new ResultSetTableModel(rs));
}
} // TODO add your handling code here:
}// GEN-LAST:event_jButton5ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton1ActionPerformed
actualiser();
table();
}// GEN-LAST:event_jButton1ActionPerformed
private void tbl_prodMouseClicked(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_tbl_prodMouseClicked
txtid.setText(String.valueOf(tbl_prod.getValueAt(tbl_prod.getSelectedRow(), 1)));
txtref.setText(String.valueOf(tbl_prod.getValueAt(tbl_prod.getSelectedRow(), 2)));
txtdes.setText(String.valueOf(tbl_prod.getValueAt(tbl_prod.getSelectedRow(), 3)));
txtran.setText(String.valueOf(tbl_prod.getValueAt(tbl_prod.getSelectedRow(), 4)));
txtrem.setText(String.valueOf(tbl_prod.getValueAt(tbl_prod.getSelectedRow(), 6)));
txtpri.setText(String.valueOf(tbl_prod.getValueAt(tbl_prod.getSelectedRow(), 7)));
txtsto.setText(String.valueOf(tbl_prod.getValueAt(tbl_prod.getSelectedRow(), 8)));
jcombcat.setSelectedItem(String.valueOf(tbl_prod.getValueAt(tbl_prod.getSelectedRow(), 9)));
jcombfr.setSelectedItem(String.valueOf(tbl_prod.getValueAt(tbl_prod.getSelectedRow(), 5)));
txtlim.setText(String.valueOf(tbl_prod.getValueAt(tbl_prod.getSelectedRow(), 10)));
txttva.setText(String.valueOf(tbl_prod.getValueAt(tbl_prod.getSelectedRow(), 11)));
txtmrg.setText(String.valueOf(tbl_prod.getValueAt(tbl_prod.getSelectedRow(), 12)));
}// GEN-LAST:event_tbl_prodMouseClicked
public void strocklimite() {
}
/**
* @param args the command line arguments
*/
public static class MonCellRenderer extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
int realindex = table.convertColumnIndexToView(10);
Integer val2 = (Integer)table.getValueAt(row,realindex);
Integer val1 = (Integer)value;
if(val1 <= val2 )
setBackground(Color.GREEN);
else
setBackground(null);
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
}
}
public static void main(String args[]) {
/* Set the Nimbus look and feel */
// <editor-fold defaultstate="collapsed" desc=" Look and feel setting code
// (optional) ">
/*
* If Nimbus (introduced in Java SE 6) is not available, stay with the default
* look and feel. For details see
* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Produit.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Produit.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Produit.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Produit.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
// </editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
private JMenuBar menuBar;
private JMenu Menufam;
private JMenu Menuprod;
private JMenu Menufou;
private JMenu Menucl;
private JMenu Menuentr;
private JMenu Menusrt;
private JMenu Menujr;
private JMenu Menuacht;
private JMenu Menuvent;
private JMenu Menuusers;
public void run() {
Produit p = new Produit();
menuBar = new JMenuBar();
// build the File menu
Menufam = new JMenu("Familles ");
Menufam.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
Menufam.setBorderPainted(true);
Menuprod = new JMenu("Produits ");
Menuprod.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
Menuprod.setBorderPainted(true);
Menuprod.setSelected(true);
Menufou = new JMenu("Fournissseurs ");
Menufou.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
Menufou.setBorderPainted(true);
Menucl = new JMenu("Clients ");
Menucl.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
Menucl.setBorderPainted(true);
Menucl.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new Client().setVisible(true);
p.dispose();
}
});
Menuentr = new JMenu("Entrees ");
Menuentr.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
Menucl.setBorderPainted(true);
Menusrt = new JMenu("Sorties ");
Menusrt.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
Menusrt.setBorderPainted(true);
Menujr = new JMenu("Journal ");
Menujr.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
Menujr.setBorderPainted(true);
Menuacht = new JMenu("FacturesAchat ");
Menuacht.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
Menuacht.setBorderPainted(true);
// build the Edit menu
Menuvent = new JMenu("FacturesVente ");
Menuvent.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
Menuvent.setBorderPainted(true);
Menuusers = new JMenu("Utilisateurs ");
// build the Edit menu
Menuusers.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
Menuusers.setBorderPainted(true);
// add menus to menubar
menuBar.add(Menufam);
menuBar.add(Menuprod);
menuBar.add(Menucl);
menuBar.add(Menuentr);
menuBar.add(Menusrt);
menuBar.add(Menujr);
menuBar.add(Menuacht);
menuBar.add(Menuvent);
menuBar.add(Menuusers);
// put the menubar on the frame
p.setJMenuBar(menuBar);
p.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
p.setPreferredSize(new Dimension(1350, 770));
p.pack();
p.setLocationRelativeTo(null);
p.setVisible(true);
}
});
}
private void fillCombo() {
try {
rs = db.querySelectcombo("categorie");
while (rs.next()) {
String name = rs.getString("nom");
jcombcat.addItem(name);
rs = db.querySelectcombo("fournisseur");
while (rs.next()) {
String namef = rs.getString("nom");
jcombfr.addItem(namef);
}
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox comrech;
private javax.swing.JComboBox jcombcat;
private javax.swing.JComboBox jcombfr;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabelres;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable tbl_prod;
private javax.swing.JTextField txtdes;
private javax.swing.JTextField txtmrg;
private javax.swing.JTextField txtlim;
private javax.swing.JTextField txttva;
private javax.swing.JTextField txtfou;
private javax.swing.JTextField txtid;
private javax.swing.JTextField txtpri;
private javax.swing.JTextField txtran;
private javax.swing.JTextField txtrech;
private javax.swing.JTextField txtref;
private javax.swing.JTextField txtrem;
private javax.swing.JTextField txtsto;
// End of variables declaration//GEN-END:variables
} |
Partager