예제 #1
0
 // this method every time load the rackList from database and then display
 // it in table
 public void loadTableData() {
   int j = 0;
   while (j < tableModel.getRowCount()) {
     tableModel.removeRow(j);
   }
   rackList = dbValue.getRackDetail(tableid.getStoreId(comboBox1.getSelectedItem().toString()));
   for (int i = 0; i < rackList.size(); i++) {
     RackModel rack = rackList.get(i);
     tableModel.addRow(new Object[] {i + 1, rack.getRackName()});
   }
 }
예제 #2
0
 // for viewing the selected element details in table
 private void view() {
   boolean status = true;
   if (table1.getSelectedRowCount() != 1) {
     status = false;
     new ValidationMSG(this, "Please Select A Row from Table Then Click");
   }
   if (status) {
     rack = rackList.get(table1.getSelectedRow());
     textField1.setText(rack.getRackName());
     textArea1.setText(rack.getRackDesc());
     comboBox1.setSelectedItem(fieldName.getStoreName(rack.getStoreId()));
   }
 }
예제 #3
0
 // for update a record
 private void update() {
   boolean status = true;
   if (rack == null) {
     status = false;
     new ValidationMSG(
         this, "Please Select A Row from Table Then Click on View to Update Rack Details");
   } else if (valid.isEmpty(textField1.getText())) {
     status = false;
     new ValidationMSG(this, "Please Insert Rack Name");
   }
   if (status) {
     rack.setRackName(textField1.getText());
     if (!valid.isEmpty(textArea1.getText())) rack.setRackDesc(textArea1.getText());
     dbupdate.updateRack(rack);
     reset();
     loadTableData();
     rack = null;
   }
 }
예제 #4
0
  // used to save a new record
  private void save() {
    // check validation for empty field
    boolean status = true;
    if (valid.isEmpty(textField1.getText())) {
      status = false;
      new ValidationMSG(this, "Please Insert Rack Name");
    }

    // /insert rack when all inputs are valid
    if (status) {
      RackModel rack = new RackModel();
      rack.setRackId(0);
      rack.setRackName(textField1.getText());
      if (!valid.isEmpty(textArea1.getText())) rack.setRackDesc(textArea1.getText());
      rack.setFirmId(1);
      rack.setStoreId(tableid.getStoreId(comboBox1.getSelectedItem().toString()));
      dbinsert.insertRack(rack);
      rack.setDefault();

      loadTableData();
      reset();
    }
  }