Id
|
Integer
|
Идентификатор поставки
|
ProductId
|
Integer
|
Идентификатор товара
|
Quantity
|
Integer
|
Количество единиц товара в поставке
|
ResponsiblePersonId
|
Integer
|
Идентификатор ответственного сотрудника
|
Таблицы Товар и Поставка связаны отношением «один ко многим», т.к. один
товар может участвовать во многих поставках, но каждая поставка содержит лишь
один товар.
Таблицы Сотрудник и Поставка связаны отношением «один ко многим», т.к.
один сотрудник может быть ответственным за многие поставки, но за одну поставку
несет ответственность лишь один сотрудник.
4. ПРОВЕРКА
РАБОТОСПОСОБНОСТИ ПО
На рисунке 5.1 представлен экран текущего состояния склада
Рисунок 5.1 - Текущее состояние склада
На рисунке 5.2 представлено окно регистрации нового товара
Рисунок 5.2 - Диалог добавления нового товара
На рисунке 5.3 представлен экран состояния склада после регистрации
нового товара.
Рисунок 5.3 - Экран состояния склада после регистрации нового товара.
На рисунке 5.4 представлен экран журнала поставок.
Рисунок 5.4 - Экран журнала поставок.
На рисунке 5.5 представлен экран регистрации входящей поставки.
Рисунок 5.5 - Экран регистрации входящей поставки.
На рисунке 5.6 представлен экран журнала поставок после регистрации новой
поставки
Рисунок 5.6 - Экран журнала поставок после регистрации новой поставки.
На рисунке 5.7 представлен экран журнала поставок, отфильтрованного по
товару MultiTabs.
Рисунок 5.7 - Экран журнала поставок, отфильтрованного по товару
MultiTabs.
На рисунке 5.8 представлен экран журнала поставок, отфильтрованного по
сотруднику Gregory House.
Рисунок 5.8 - Экран журнала поставок, отфильтрованного по сотруднику Gregory House.
ВЫВОДЫ
В ходе выполнения работы была разработана распределенная
информационно-справочная система для учета медицинских препаратов на складе.
Для успешной работы приложения вначале была разработана логическая,
физическая модель БД. Была разработана диаграмма классов, а также разработан
проект архитектуры системы.
В данной работе была использована классическая двухслойная архитектура
«клиент - сервер». Выбор архитектуры обоснован следующими преимуществами:
простота создания, быстрота работы, отсутствие высоких нагрузок на систему.
При разработке использовалась среда NetBeans 6.7.1 и СУБД JavaDB.
Для реализации подключения к БД использовался драйвер org.apache.derby.jdbc.ClientDriver и библиотека hibernate.
В ходе проверки корректности работы системы, ошибок выявлено не было.
ЛИТЕРАТУРА
1 Кей С. Хорстманн, Гари Корнелл Библиотека профессионала
Java 1,2 том - М:Издательский дом «Вильямс»,2010, 1120стр.
Swing руководство для начинающих - М:Издательский дом
«Вильямс»,2009, 697стр.
С. Орлик Многоуровневые модели в архитектуре клиент-сервер
http://ods.com.ua/win/rus/db/kbd97/22.htm
ПРИЛОЖЕНИЯ
Приложение А
Листинг исходного кода SQL-спринтов для создания базы данных
table ADMIN.Employee
(int Primary Key NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1,
INCREMENT BY 1),varchar(100) not null CHECK(LENGTH(Name) >
0),UK_Employee_Name UNIQUE (Name)
);table ADMIN.Product
(int Primary Key NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1,
INCREMENT BY 1),varchar(100) not null CHECK(LENGTH(Name) >
0),varchar(100),int not null default 0,UK_Product_Name UNIQUE (Name)
);table ADMIN.Shipment
(int Primary Key NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1,
INCREMENT BY 1),int not null,int not null,Timestamp,int not
null,FK_Shiment_Product Foreign Key (ProductId) References
Product(Id),FK_Shiment_Employee Foreign Key (ResponsiblePersonId) References
Employee(Id)
);into ADMIN.EMPLOYEE (Name)('James Winkles');into ADMIN.EMPLOYEE
(Name)('John Snipes');into ADMIN.EMPLOYEE (Name)('Gregory House');into
ADMIN.EMPLOYEE (Name)('Jessica Gamilton');into ADMIN.EMPLOYEE (Name)('Sarah
Daniels');into ADMIN.PRODUCT (Name, Manufacturer, QuantityInStock)('Strepsils',
'Ecoemical Inc.', 500);into ADMIN.PRODUCT (Name, Manufacturer,
QuantityInStock)('Tera Flu', 'Bio Pharm', 700);into ADMIN.PRODUCT (Name,
Manufacturer, QuantityInStock)('Vikodin', 'Biogeticals', 300);into
ADMIN.PRODUCT (Name, Manufacturer, QuantityInStock)('Coldrex', 'Green
Generation', 1000);into ADMIN.PRODUCT (Name, Manufacturer,
QuantityInStock)('Ascorbic acid', 'Ecoemical Inc.', 2000);into ADMIN.Shipment
(ProductId, Quantity, DateTime, ResponsiblePersonId)(1, 200,
TIMESTAMP('20.03.2011', '12:00:00'), 1);into ADMIN.Shipment (ProductId,
Quantity, DateTime, ResponsiblePersonId)(2, 400, TIMESTAMP('20.03.2011',
'13:00:00'), 1);into ADMIN.Shipment (ProductId, Quantity, DateTime,
ResponsiblePersonId)(1, 100, TIMESTAMP('20.03.2011', '14:00:00'), 3);into ADMIN.Shipment
(ProductId, Quantity, DateTime, ResponsiblePersonId)(3, 300,
TIMESTAMP('20.03.2011', '15:00:00'), 2);into ADMIN.Shipment (ProductId,
Quantity, DateTime, ResponsiblePersonId)(5, 500, TIMESTAMP('20.03.2011',
'16:00:00'), 5);
Приложение Б
Листинги исходных кодов классов клиентской части ПО
Классы-сущности
package
Entities;java.io.Serializable;java.util.List;javax.persistence.Basic;javax.persistence.CascadeType;javax.persistence.Column;javax.persistence.Entity;javax.persistence.GeneratedValue;javax.persistence.GenerationType;javax.persistence.Id;javax.persistence.NamedQueries;javax.persistence.NamedQuery;javax.persistence.OneToMany;javax.persistence.Table;
/**
*
* @author Humanity
*/
@Entity
@Table(name = "EMPLOYEE")
@NamedQueries({@NamedQuery(name =
"Employee.findAll", query = "SELECT e FROM Employee e"),
@NamedQuery(name = "Employee.findById", query = "SELECT e FROM
Employee e WHERE e.id = :id"), @NamedQuery(name =
"Employee.findByName", query = "SELECT e FROM Employee e WHERE
e.name = :name")})class Employee implements Serializable {static final
long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "ID")Integer id;
@Basic(optional = false)
@Column(name = "NAME")String name;
@OneToMany(cascade = CascadeType.ALL, mappedBy =
"responsiblepersonid")List<Shipment> shipmentList;Employee() {
}Employee(Integer id) {.id = id;
}Employee(Integer id, String name) {.id = id;.name = name;
}Integer getId() {id;
}void setId(Integer id) {.id = id;
}String getName() {name;
}void setName(String name) {.name = name;
}List<Shipment> getShipmentList() {shipmentList;
}void setShipmentList(List<Shipment> shipmentList)
{.shipmentList = shipmentList;
}
@Overrideint hashCode() {hash = 0;+= (id != null ?
id.hashCode() : 0);hash;
}
@Overrideboolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id
fields are not set(!(object instanceof Employee)) {false;
}other = (Employee) object;((this.id == null &&
other.id != null) || (this.id != null && !this.id.equals(other.id)))
{false;
}true;
}
@OverrideString toString() {name;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/Entities;java.io.Serializable;java.util.ArrayList;java.util.List;javax.persistence.Basic;javax.persistence.CascadeType;javax.persistence.Column;javax.persistence.Entity;javax.persistence.GeneratedValue;javax.persistence.GenerationType;javax.persistence.Id;javax.persistence.NamedQueries;javax.persistence.NamedQuery;javax.persistence.OneToMany;javax.persistence.Table;
/**
*
* @author Humanity
*/
@Entity
@Table(name = "PRODUCT")
@NamedQueries({@NamedQuery(name =
"Product.findAll", query = "SELECT p FROM Product p"),
@NamedQuery(name = "Product.findById", query = "SELECT p FROM
Product p WHERE p.id = :id"), @NamedQuery(name =
"Product.findByName", query = "SELECT p FROM Product p WHERE
p.name = :name"), @NamedQuery(name = "Product.findByManufacturer",
query = "SELECT p FROM Product p WHERE p.manufacturer =
:manufacturer"), @NamedQuery(name =
"Product.findByQuantityinstock", query = "SELECT p FROM Product
p WHERE p.quantityinstock = :quantityinstock")})class Product implements
Serializable {static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "ID")Integer id;
@Basic(optional = false)
@Column(name = "NAME")String name;
@Column(name = "MANUFACTURER")String manufacturer;
@Basic(optional = false)
@Column(name = "QUANTITYINSTOCK")int
quantityinstock;
@OneToMany(cascade = CascadeType.ALL, mappedBy =
"productid")List<Shipment> shipmentList;Product() {
}Product(Integer id) {.id = id;.shipmentList = new
ArrayList<Shipment>();
}Product(Integer id, String name, int quantityinstock) {.id =
id;.name = name;.quantityinstock = quantityinstock;.shipmentList = new
ArrayList<Shipment>();
}Product(Integer id, String name, String manufacturer, int
quantityinstock) {.id = id;.name = name;.manufacturer =
manufacturer;.quantityinstock = quantityinstock;.shipmentList = new
ArrayList<Shipment>();
}Integer getId() {id;
}void setId(Integer id) {.id = id;
}String getName() {name;
}void setName(String name) {.name = name;
}String getManufacturer() {manufacturer;
}void setManufacturer(String manufacturer) {.manufacturer =
manufacturer;
}int getQuantityinstock() {quantityinstock;
}void setQuantityinstock(int quantityinstock)
{.quantityinstock = quantityinstock;
}List<Shipment> getShipmentList() {shipmentList;
}void setShipmentList(List<Shipment> shipmentList)
{.shipmentList = shipmentList;
}
@Overrideint hashCode() {hash = 0;+= (id != null ?
id.hashCode() : 0);hash;
}
@Overrideboolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id
fields are not set(!(object instanceof Product)) {false;
}other = (Product) object;((this.id == null &&
other.id != null) || (this.id != null && !this.id.equals(other.id)))
{false;
}true;
}
@OverrideString toString() {name;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/Entities;java.io.Serializable;java.util.Date;javax.persistence.Basic;javax.persistence.Column;javax.persistence.Entity;javax.persistence.GeneratedValue;javax.persistence.GenerationType;javax.persistence.Id;javax.persistence.JoinColumn;javax.persistence.ManyToOne;javax.persistence.NamedQueries;javax.persistence.NamedQuery;javax.persistence.Table;javax.persistence.Temporal;javax.persistence.TemporalType;
/**
*
* @author Humanity
*/
@Entity
@Table(name = "SHIPMENT")
@NamedQueries({@NamedQuery(name =
"Shipment.findAll", query = "SELECT s FROM Shipment s"),
@NamedQuery(name = "Shipment.findById", query = "SELECT s FROM
Shipment s WHERE s.id = :id"), @NamedQuery(name = "Shipment.findByQuantity",
query = "SELECT s FROM Shipment s WHERE s.quantity = :quantity"),
@NamedQuery(name = "Shipment.findByDatetime", query = "SELECT s
FROM Shipment s WHERE s.datetime = :datetime")})class Shipment implements
Serializable {static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "ID")Integer id;
@Basic(optional = false)
@Column(name = "QUANTITY")int quantity;
@Column(name = "DATETIME")
@Temporal(TemporalType.TIMESTAMP)Date datetime;
@JoinColumn(name = "RESPONSIBLEPERSONID",
referencedColumnName = "ID")
@ManyToOne(optional = false)Employee responsiblepersonid;
@JoinColumn(name = "PRODUCTID",
referencedColumnName = "ID")
@ManyToOne(optional = false)Product productid;Shipment() {
}Shipment(Integer id) {.id = id;
}Shipment(Integer id, int quantity) {.id = id;.quantity =
quantity;
}Integer getId() {id;
}void setId(Integer id) {.id = id;
}int getQuantity() {quantity;
}void setQuantity(int quantity) {.quantity = quantity;
}Date getDatetime() {datetime;
}void setDatetime(Date datetime) {.datetime = datetime;
}Employee getResponsiblepersonid() {responsiblepersonid;
}void setResponsiblepersonid(Employee responsiblepersonid)
{.responsiblepersonid = responsiblepersonid;
}Product getProductid() {productid;
}void setProductid(Product productid) {.productid =
productid;
@Overrideint hashCode() {hash = 0;+= (id != null ?
id.hashCode() : 0);hash;
}
@Overrideboolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id
fields are not set(!(object instanceof Shipment)) {false;
}other = (Shipment) object;((this.id == null &&
other.id != null) || (this.id != null && !this.id.equals(other.id)))
{false;
}true;
}
@OverrideString toString() {"Entities.Shipment[id="
+ id + "]";
}
}
Слой доступа к данным
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/DAL;Entities.Employee;java.util.List;javax.persistence.EntityManager;javax.persistence.EntityTransaction;javax.persistence.Query;
/**
*
* @author Humanity
*/class EmployeeRepository {EntityManager
entityManager;String GetAllEmployeesQuery = "select e from Employee
e";EmployeeRepository(EntityManager entityManager) {.entityManager =
entityManager;
}List<Employee> GetAllEmployees() {query =
entityManager.createQuery(GetAllEmployeesQuery);query.getResultList();
}Employee GetEmployeeById(int employeeId) {employee =
entityManager.find(Employee.class, employeeId);employee;
}void InsertEmployee(Employee employee) {t =
entityManager.getTransaction();.begin();{.persist(employee);.flush();.commit();
} catch(Exception ex) {.rollback();
}
}void UpdateEmployee(Employee employee) {t =
entityManager.getTransaction();.begin();{.refresh(employee);.flush();.commit();
} catch(Exception ex) {.rollback();
}
}void DeleteEmployee(int employeeId) {t =
entityManager.getTransaction();.begin();{Employee =
GetEmployeeById(employeeId);.remove(Employee);.flush();.commit();
} catch(Exception ex) {.rollback();
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/DAL;Entities.Product;java.util.List;javax.persistence.EntityManager;javax.persistence.EntityTransaction;javax.persistence.Query;
/**
*
* @author Humanity
*/class ProductRepository {EntityManager entityManager;String
GetAllProductsQuery = "select p from Product
p";ProductRepository(EntityManager entityManager) {.entityManager =
entityManager;
}List<Product> GetAllProducts() {query =
entityManager.createQuery(GetAllProductsQuery);query.getResultList();
}Product GetProductById(int productId) {product =
entityManager.find(Product.class, productId);product;
}boolean InsertProduct(Product product) {t =
entityManager.getTransaction();.begin();{.merge(product);
//entityManager.persist(product);.commit();true;
} catch(Exception ex) {.rollback();false;
}
}void UpdateProduct(Product product) {t =
entityManager.getTransaction();.begin();{.refresh(product);.flush();.commit();
} catch(Exception ex) {.rollback();
}
}void DeleteProduct(int productId) {t =
entityManager.getTransaction();.begin();{Product =
GetProductById(productId);.remove(Product);.flush();.commit();
} catch(Exception ex) {.rollback();
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/DAL;Entities.Product;Entities.Shipment;java.lang.Math;java.util.List;javax.persistence.EntityManager;javax.persistence.EntityTransaction;javax.persistence.Query;
/**
*
* @author Humanity
*/class ShipmentRepository {EntityManager
entityManager;String GetAllShipmentsQuery = "select s from Shipment
s";String GetShipmentsForProductQuery = "select s from Shipment s
where s.productid.id = %1$d";String GetShipmentsForPersonQuery =
"select s from Shipment s where s.responsiblepersonid.id =
%1$d";String GetShipmentsForPersonAndProductQuery =
"select s from Shipment s where s.responsiblepersonid.id
= %1$d and s.productid.id = %2$d";ShipmentRepository(EntityManager
entityManager) {.entityManager = entityManager;
}List<Shipment> GetAllShipments() {query =
entityManager.createQuery(GetAllShipmentsQuery);query.getResultList();
}Shipment GetShipmentById(int shipmentId) {shipment =
entityManager.find(Shipment.class, shipmentId);shipment;
}List<Shipment> GetShipmentForProduct(int productId)
{query = entityManager.createQuery(String.format(GetShipmentsForProductQuery,
productId));query.getResultList();
}List<Shipment> GetShipmentForPerson(int personId)
{query = entityManager.createQuery(String.format(GetShipmentsForPersonQuery,
personId));query.getResultList();
}List<Shipment> GetShipmentList(int personId, int
productId) {(productId == 0){(personId == 0) {GetAllShipments();
} else {GetShipmentForPerson(personId);
}
} else {(personId == 0) {GetShipmentForProduct(productId);
} else {query =
entityManager.createQuery(String.format(GetShipmentsForPersonAndProductQuery,
personId, productId));query.getResultList();
}
}
}boolean InsertShipment(Shipment shipment) {p =
StockDatabase.getInstance().getProducts().GetProductById(shipment.getProductid().getId());(shipment.getQuantity()
< 0 &&.getQuantityinstock() < Math.abs(shipment.getQuantity())) {
// trying to take TOO MUCH from stock...false;
}finalQuantity = p.getQuantityinstock() +
shipment.getQuantity();.setQuantityinstock(finalQuantity);t = entityManager.getTransaction();{
.begin();.persist(shipment);.persist(p);
//entityManager.flush();.commit();true;
} catch(Exception ex) {.rollback();false;
}
}void UpdateShipment(Shipment shipment) {t =
entityManager.getTransaction();.begin();{.refresh(shipment);.flush();.commit();
} catch(Exception ex) {.rollback();
}
}void DeleteShipment(int shipmentId) {t =
entityManager.getTransaction();.begin();{Shipment =
GetShipmentById(shipmentId);.remove(Shipment);.flush();.commit();
} catch(Exception ex) {.rollback();
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/DAL;javax.persistence.EntityManager;javax.persistence.EntityManagerFactory;javax.persistence.Persistence;
/**
*
* @author Humanity
*/class StockDatabase {static class SingletonHolder {static
StockDatabase instance = new StockDatabase();
}static StockDatabase getInstance()
{SingletonHolder.instance;
}String connectionName = "StockDb";EntityManager
entityManager;employee;products;shipments;StockDatabase() {{factory =
Persistence.createEntityManagerFactory(connectionName);=
factory.createEntityManager();= new EmployeeRepository(entityManager);= new
ProductRepository(entityManager);= new ShipmentRepository(entityManager);
} catch (java.lang.ExceptionInInitializerError ex) {a =
ex.getException();b = ex.getCause();
}
}EmployeeRepository getEmployee() {employee;
}ProductRepository getProducts() {products;
}ShipmentRepository getShipments() {shipments;
}
}
Классы пользовательского интерфейса
/*
* StockView.java
*/stock;DAL.StockDatabase;Entities.Employee;Entities.Product;Entities.Shipment;Utils.Utils;org.jdesktop.application.Action;org.jdesktop.application.ResourceMap;org.jdesktop.application.SingleFrameApplication;org.jdesktop.application.FrameView;org.jdesktop.application.TaskMonitor;java.awt.event.ActionEvent;java.awt.event.ActionListener;java.util.ArrayList;java.util.List;javax.swing.ComboBoxModel;javax.swing.DefaultComboBoxModel;javax.swing.Timer;javax.swing.Icon;javax.swing.JDialog;javax.swing.JFrame;javax.swing.table.DefaultTableModel;javax.swing.table.TableModel;
/**
* The application's main frame.
*/class StockView extends FrameView {StockView(SingleFrameApplication
app) {(app);();
// status bar initialization - message timeout, idle icon and busy
animation, etcresourceMap = getResourceMap();messageTimeout =
resourceMap.getInteger("StatusBar.messageTimeout");= new
Timer(messageTimeout, new ActionListener() {void actionPerformed(ActionEvent e)
{
//statusMessageLabel.setText("");
}
});.setRepeats(false);busyAnimationRate =
resourceMap.getInteger("StatusBar.busyAnimationRate");(int i = 0; i
< busyIcons.length; i++) {[i] =
resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
}= new Timer(busyAnimationRate, new ActionListener() {void
actionPerformed(ActionEvent e) {= (busyIconIndex + 1) % busyIcons.length;
//statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
}
});= resourceMap.getIcon("StatusBar.idleIcon");
//statusAnimationLabel.setIcon(idleIcon);
//progressBar.setVisible(false);
// connecting action tasks to status bar via TaskMonitortaskMonitor = new
TaskMonitor(getApplication().getContext());.addPropertyChangeListener(new
java.beans.PropertyChangeListener() {void propertyChange(java.beans.PropertyChangeEvent
evt) {
/*String propertyName =
evt.getPropertyName();("started".equals(propertyName))
{(!busyIconTimer.isRunning()) {.setIcon(busyIcons[0]);= 0;.start();
}.setVisible(true);.setIndeterminate(true);
} else if ("done".equals(propertyName))
{.stop();.setIcon(idleIcon);.setVisible(false);.setValue(0);
} else if ("message".equals(propertyName)) {text =
(String)(evt.getNewValue());.setText((text == null) ? "" :
text);.restart();
} else if ("progress".equals(propertyName)) {value = (Integer)(evt.getNewValue());.setVisible(true);.setIndeterminate(false);.setValue(value);
}*/
}
});
//setResizable(false);.getColumnModel().getColumn(0).setMinWidth(0);.getColumnModel().getColumn(0).setMaxWidth(0);.getColumnModel().getColumn(0).setWidth(0);();();
}void RefillProductsTable() {<Product> products =
StockDatabase.getInstance().getProducts().GetAllProducts();model =
(DefaultTableModel) tableProducts.getModel();.setRowCount(0);(Product product :
products){.addRow(new Object[]{product, product.getId(), product.getName(),
product.getManufacturer(), product.getQuantityinstock() });
}
}void RefillShipmentTable()
{(StockDatabase.getInstance().getShipments().GetShipmentList(0, 0));
}void RefillShipmentTable(List<Shipment> shipments) {model =
(DefaultTableModel) tableShipments.getModel();.setRowCount(0);(Shipment
shipment : shipments){.addRow(new
Object[]{.convertDateToDateString(shipment.getDatetime()),.getProductid(),.getQuantity(),.getResponsiblepersonid()
});
}
}ComboBoxModel getEmployeeModel() {<Employee> people =
StockDatabase.getInstance().getEmployee().GetAllEmployees();.add(0, new
Employee(0, "No filter"));model = new
DefaultComboBoxModel(people.toArray());model;
}ComboBoxModel getProductsModel() {<Product> products =
StockDatabase.getInstance().getProducts().GetAllProducts();.add(0, new
Product(0, "No filter", 0));model = new
DefaultComboBoxModel(.toArray());model;
}
@Actionvoid showAboutBox() {(aboutBox == null) {mainFrame =
StockApp.getApplication().getMainFrame();= new StockAboutBox(mainFrame);.setLocationRelativeTo(mainFrame);
}.getApplication().show(aboutBox);
}
/** 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"> void initComponents() {= new
org.jdesktop.beansbinding.BindingGroup();= new javax.swing.JPanel();= new
javax.swing.JTabbedPane();= new javax.swing.JPanel();= new
javax.swing.JScrollPane();= new javax.swing.JTable();= new
javax.swing.JButton();= new javax.swing.JButton();= new javax.swing.JPanel();=
new javax.swing.JButton();= new javax.swing.JButton();= new
javax.swing.JScrollPane();= new javax.swing.JTable();= new
javax.swing.JComboBox();= new javax.swing.JLabel();= new
javax.swing.JButton();= new javax.swing.JComboBox();= new
javax.swing.JPopupMenu();= new javax.swing.JMenuItem();.setMinimumSize(new
java.awt.Dimension(507, 434));.setName("mainPanel"); //
NOI18N.jdesktop.beansbinding.Binding binding =
org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE,
jPopupMenu, org.jdesktop.beansbinding.ObjectProperty.create(), mainPanel,
org.jdesktop.beansbinding.BeanProperty.create("componentPopupMenu"));.addBinding(binding);.setName("jTabbedPane1");
// NOI18N=
org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE,
jPopupMenu, org.jdesktop.beansbinding.ObjectProperty.create(), jTabbedPane1,
org.jdesktop.beansbinding.BeanProperty.create("componentPopupMenu"));.addBinding(binding);.addFocusListener(new
java.awt.event.FocusAdapter() {void focusGained(java.awt.event.FocusEvent evt) {FocusGained(evt);
}
});.setName("jPanel2"); //
NOI18N.setName("jScrollPane1"); // NOI18N.setModel(new
javax.swing.table.DefaultTableModel(Object [][] {
},String [] {
"ProductObject", "ID", "Name",
"Manufacturer", "Quantity In Stock"
}
) {[] types = new Class [] {.lang.Object.class, java.lang.Integer.class,
java.lang.Object.class, java.lang.String.class, java.lang.Integer.class
};[] canEdit = new boolean [] {, false, false, false, false
};Class getColumnClass(int columnIndex) {types [columnIndex];
}boolean isCellEditable(int rowIndex, int columnIndex) {canEdit
[columnIndex];
}
});.setName("tableProducts"); //
NOI18N.setViewportView(tableProducts);.jdesktop.application.ResourceMap
resourceMap =
org.jdesktop.application.Application.getInstance(stock.StockApp.class).getContext().getResourceMap(StockView.class);.getColumnModel().getColumn(0).setResizable(false);.getColumnModel().getColumn(0).setPreferredWidth(0);.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tableProducts.columnModel.title4"));
// NOI18N.getColumnModel().getColumn(1).setPreferredWidth(50);.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("tableProducts.columnModel.title0"));
//
NOI18N.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("tableProducts.columnModel.title1"));
//
NOI18N.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("tableProducts.columnModel.title2"));
//
NOI18N.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("tableProducts.columnModel.title3"));
// NOI18N.setText(resourceMap.getString("btnRefresh.text")); //
NOI18N.setName("btnRefresh"); // NOI18N.addMouseListener(new
java.awt.event.MouseAdapter() {void mouseClicked(java.awt.event.MouseEvent evt)
{(evt);
}
});.setText(resourceMap.getString("btnAddProduct.text")); //
NOI18N.setName("btnAddProduct"); // NOI18N.addMouseListener(new
java.awt.event.MouseAdapter() {void mouseClicked(java.awt.event.MouseEvent evt)
{(evt);
}
});.swing.GroupLayout jPanel2Layout = new
javax.swing.GroupLayout(jPanel2);.setLayout(jPanel2Layout);Layout.setHorizontalGroup(Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 487, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(btnAddProduct)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 313,
Short.MAX_VALUE)
.addComponent(btnRefresh)))
.addContainerGap())
);Layout.setVerticalGroup(Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 379,
Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnRefresh)
.addComponent(btnAddProduct))
.addContainerGap())
);.addTab(resourceMap.getString("jPanel2.TabConstraints.tabTitle"),
jPanel2); // NOI18N.setName("jPanel1"); //
NOI18N.setText(resourceMap.getString("btnIncoming.text")); //
NOI18N.setName("btnIncoming"); // NOI18N.addMouseListener(new
java.awt.event.MouseAdapter() {void mouseClicked(java.awt.event.MouseEvent evt)
{(evt);
}
});.setText(resourceMap.getString("btnOutcoming.text")); //
NOI18N.setName("btnOutcoming"); // NOI18N.addMouseListener(new
java.awt.event.MouseAdapter() {void mouseClicked(java.awt.event.MouseEvent evt)
{(evt);
}
});.setName("jScrollPane2"); // NOI18N.setModel(new
javax.swing.table.DefaultTableModel(Object [][] {
},String [] {
"Date and time", "Product", "Quantity",
"Responsible Person"
}
));.setName("tableShipments"); //
NOI18N.setViewportView(tableShipments);.setModel(getEmployeeModel());.setMaximumSize(new
java.awt.Dimension(100, 20));.setMinimumSize(new java.awt.Dimension(100,
20));.setName("dropdownEmployeeFilter"); //
NOI18N.setPreferredSize(new java.awt.Dimension(100,
20));.setText(resourceMap.getString("jLabel1.text")); //
NOI18N.setName("jLabel1"); //
NOI18N.setText(resourceMap.getString("jButton2.text")); //
NOI18N.setName("jButton2"); // NOI18N.addMouseListener(new
java.awt.event.MouseAdapter() {void mouseClicked(java.awt.event.MouseEvent evt)
{MouseClicked(evt);
}
});.setModel(getProductsModel());.setMaximumSize(new
java.awt.Dimension(100, 20));.setMinimumSize(new java.awt.Dimension(100,
20));.setName("dropdownProductFilter"); //
NOI18N.setPreferredSize(new java.awt.Dimension(100, 20));.swing.GroupLayout
jPanel1Layout = new javax.swing.GroupLayout(jPanel1);.setLayout(jPanel1Layout);Layout.setHorizontalGroup(Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 487,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(btnIncoming)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnOutcoming))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(81, 81, 81)
.addComponent(dropdownProductFilter,
javax.swing.GroupLayout.PREFERRED_SIZE, 145,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(dropdownEmployeeFilter,
javax.swing.GroupLayout.PREFERRED_SIZE, 145,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2)))
.addContainerGap())
);Layout.setVerticalGroup(Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jButton2)
.addComponent(dropdownEmployeeFilter,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(dropdownProductFilter,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 350,
Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnIncoming)
.addComponent(btnOutcoming))
.addContainerGap())
);.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"),
jPanel1); // NOI18N.swing.GroupLayout mainPanelLayout = new
javax.swing.GroupLayout(mainPanel);.setLayout(mainPanelLayout);.setHorizontalGroup(.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
mainPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 512,
Short.MAX_VALUE)
.addContainerGap())
);.setVerticalGroup(.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 458,
Short.MAX_VALUE)
.addContainerGap())
);.setName("jPopupMenu"); // NOI18N.swing.ActionMap actionMap =
org.jdesktop.application.Application.getInstance(stock.StockApp.class).getContext().getActionMap(StockView.class,
this);.setAction(actionMap.get("showAboutBox")); //
NOI18N.setName("jMenuItem1"); //
NOI18N.add(jMenuItem1);(mainPanel);.bind();
}// </editor-fold> void
btnRefreshMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:();
}void btnIncomingMouseClicked(java.awt.event.MouseEvent evt)
{(addShipmentBox == null) {mainFrame =
StockApp.getApplication().getMainFrame();= new
AddShipmentDialog(mainFrame);.setLocationRelativeTo(mainFrame);
}.Initialize(true);.getApplication().show(addShipmentBox);();();
}void btnOutcomingMouseClicked(java.awt.event.MouseEvent evt)
{(addShipmentBox == null) {mainFrame =
StockApp.getApplication().getMainFrame();= new
AddShipmentDialog(mainFrame);.setLocationRelativeTo(mainFrame);
}.Initialize(false);.getApplication().show(addShipmentBox);();();
}void jTabbedPane1FocusGained(java.awt.event.FocusEvent evt) {
}
// Refresh with filter buttonvoid
jButton2MouseClicked(java.awt.event.MouseEvent evt) { employeeFilter =
(Employee)dropdownEmployeeFilter.getSelectedItem();productFilter =
(Product)dropdownProductFilter.getSelectedItem();(.getInstance().getShipments().GetShipmentList(.getId(),
productFilter.getId()));
}void btnAddProductMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:(addProductBox == null) {mainFrame =
StockApp.getApplication().getMainFrame();= new
AddProductDialog(mainFrame);.setLocationRelativeTo(mainFrame);
}.getApplication().show(addProductBox);();.setModel(getProductsModel());
}
// Variables declaration - do not modifyjavax.swing.JButton
btnAddProduct;javax.swing.JButton btnIncoming;javax.swing.JButton
btnOutcoming;javax.swing.JButton btnRefresh;javax.swing.JComboBox
dropdownEmployeeFilter;javax.swing.JComboBox
dropdownProductFilter;javax.swing.JButton jButton2;javax.swing.JLabel
jLabel1;javax.swing.JMenuItem jMenuItem1;javax.swing.JPanel
jPanel1;javax.swing.JPanel jPanel2;javax.swing.JPopupMenu
jPopupMenu;javax.swing.JScrollPane jScrollPane1;javax.swing.JScrollPane
jScrollPane2;javax.swing.JTabbedPane jTabbedPane1;javax.swing.JPanel
mainPanel;javax.swing.JTable tableProducts;javax.swing.JTable
tableShipments;org.jdesktop.beansbinding.BindingGroup bindingGroup;
// End of variables declarationfinal Timer messageTimer;final Timer
busyIconTimer;final Icon idleIcon;final Icon[] busyIcons = new Icon[15];int
busyIconIndex = 0;JDialog aboutBox;AddShipmentDialog
addShipmentBox;AddProductDialog addProductBox;
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* LoginForm.java
*
* Created on 19.03.2011, 18:23:01
*/stock;DAL.StockDatabase;Entities.Product;
/**
*
* @author Humanity
*/class AddProductDialog extends javax.swing.JDialog {
/** Creates new form LoginForm */AddProductDialog(java.awt.Frame parent)
{(parent);();();.setModal(true);
}AddProductDialog() {();();
}void ClearForm() {.setText("");.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">void initComponents() {= new
javax.swing.JButton();= new javax.swing.JLabel();= new javax.swing.JLabel();=
new javax.swing.JTextField();= new javax.swing.JTextField();= new
javax.swing.JLabel();("Add product");(true);("Form"); //
NOI18N(false);.swing.ActionMap actionMap =
org.jdesktop.application.Application.getInstance(stock.StockApp.class).getContext().getActionMap(AddProductDialog.class,
this);.setAction(actionMap.get("RegisterClick")); //
NOI18N.setText("Add Product");.setName("btnRegister"); //
NOI18N.addMouseListener(new java.awt.event.MouseAdapter() {void
mouseClicked(java.awt.event.MouseEvent evt) {(evt);
}
});.setText("Product name");.setName("jLabel4"); //
NOI18N.setName("lblStatus"); // NOI18N.setName("txtName");
// NOI18N.setName("txtManufacturer"); //
NOI18N.setText("Manufacturer");.setName("jLabel5"); //
NOI18N.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());().setLayout(layout);.setHorizontalGroup(.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 64,
Short.MAX_VALUE)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 161,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 65,
Short.MAX_VALUE)
.addComponent(txtManufacturer, javax.swing.GroupLayout.PREFERRED_SIZE,
161, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(lblStatus, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)
.addComponent(btnRegister, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE))
.addContainerGap())
);.setVerticalGroup(.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtManufacturer, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 38,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnRegister, javax.swing.GroupLayout.PREFERRED_SIZE, 21,
Short.MAX_VALUE)
.addContainerGap())
);();
}// </editor-fold> void
btnRegisterMouseClicked(java.awt.event.MouseEvent evt) {name =
txtName.getText();manufacturer = txtManufacturer.getText();(name.length() == 0)
{.setText("Enter a product name please");;
}(manufacturer.length() == 0) {.setText("Enter manufacturer's name
please");;
}product = new Product(0, name, manufacturer,
0);(StockDatabase.getInstance().getProducts().InsertProduct(product)) {
//success(false);
} else {.setText("An error occured");;
}
}
/**
* @param args the command line arguments
*/static void main(String args[]) {.awt.EventQueue.invokeLater(new Runnable()
{void run() {AddShipmentDialog().setVisible(true);
}
});
}
// Variables declaration - do not modifyjavax.swing.JButton
btnRegister;javax.swing.JLabel jLabel4;javax.swing.JLabel
jLabel5;javax.swing.JLabel lblStatus;javax.swing.JTextField txtManufacturer;javax.swing.JTextField
txtName;
// End of variables declaration
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* LoginForm.java
*
* Created on 19.03.2011, 18:23:01
*/stock;DAL.StockDatabase;Entities.Employee;Entities.Product;Entities.Shipment;java.awt.Component;java.util.Date;java.util.Vector;javax.swing.ComboBoxModel;javax.swing.DefaultComboBoxModel;javax.swing.JOptionPane;org.jdesktop.application.Action;
/**
*
* @author Humanity
*/class AddShipmentDialog extends javax.swing.JDialog {
/** Creates new form LoginForm */AddShipmentDialog(java.awt.Frame parent)
{(parent);();
//getRootPane().setDefaultButton(btnLogIn);= 1;.setModal(true);
}AddShipmentDialog() {();= 1;
}
// Positive for incoming goods, negative for outcomingint
quantityRatio;void Initialize(boolean isIncoming){= isIncoming ? 1 :
-1;(isIncoming
? "Incoming Shipment"
: "Outcoming Shipment");
}ComboBoxModel getProductsModel() {model = new
DefaultComboBoxModel(.getInstance().getProducts().GetAllProducts().toArray());model;
}ComboBoxModel getEmployeeModel() {model = new
DefaultComboBoxModel(.getInstance().getEmployee().GetAllEmployees().toArray());model;
}
* 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">void initComponents() {= new
javax.swing.JButton();= new javax.swing.JLabel();= new javax.swing.JLabel();=
new javax.swing.JComboBox();= new com.toedter.calendar.JDateChooser();= new
javax.swing.JSpinner();= new javax.swing.JComboBox();= new
javax.swing.JLabel();= new javax.swing.JLabel();= new javax.swing.JLabel();("Incoming
Shipment");(true);("Form"); // NOI18N(false);.swing.ActionMap
actionMap =
org.jdesktop.application.Application.getInstance(stock.StockApp.class).getContext().getActionMap(AddShipmentDialog.class,
this);.setAction(actionMap.get("RegisterClick")); //
NOI18N.setText("Add Shipment");.setName("btnRegister"); //
NOI18N.addMouseListener(new java.awt.event.MouseAdapter() {void
mouseClicked(java.awt.event.MouseEvent evt) {(evt);
}
});.setText("Product");.setName("jLabel4"); //
NOI18N.setName("lblStatus"); //
NOI18N.setModel(getProductsModel());.setName("dropdownProduct"); //
NOI18N.setDate(new Date());.setName("dateChooser"); //
NOI18N.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1),
Integer.valueOf(1), null, Integer.valueOf(1)));.setName("spinQuantity");
// NOI18N.setModel(getEmployeeModel());.setName("dropdownPerson"); //
NOI18N.setText("Quantity");.setName("jLabel1"); //
NOI18N.setText("Date");.setName("jLabel2"); // NOI18N.setText("Responsible
person");.setName("jLabel3"); // NOI18N.swing.GroupLayout layout
= new
javax.swing.GroupLayout(getContentPane());().setLayout(layout);.setHorizontalGroup(.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(btnRegister, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(dropdownProduct, 0, 180, Short.MAX_VALUE)
.addComponent(spinQuantity, javax.swing.GroupLayout.DEFAULT_SIZE, 180,
Short.MAX_VALUE)
.addComponent(dateChooser, javax.swing.GroupLayout.DEFAULT_SIZE, 180,
Short.MAX_VALUE)
.addComponent(dropdownPerson, 0, 180, Short.MAX_VALUE)))
.addComponent(lblStatus, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE))
.addContainerGap())
);.setVerticalGroup(.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(dropdownProduct, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spinQuantity, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(dateChooser, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(dropdownPerson, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 38,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnRegister, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);();
}// </editor-fold>void btnRegisterMouseClicked(java.awt.event.MouseEvent
evt) { product = (Product) dropdownProduct.getSelectedItem();quantity =
(Integer) spinQuantity.getValue();date = dateChooser.getDate();person =
(Employee) dropdownPerson.getSelectedItem();(quantity <= 0)
{.setText("Quantity must be positive");;
}(product == null) {.setText("Select a product please");;
}(person == null) {.setText("Select a responsive person
please");;
}
// Positive for incoming goods, negative for outcoming= quantityRatio *
quantity;p = StockDatabase.getInstance().getProducts().GetProductById(product.getId());(quantity
< 0 &&.getQuantityinstock() < Math.abs(quantity)) {
// trying to take TOO MUCH from stock....setText("There are only
"+p.getQuantityinstock()+" items of this product in stock.");;
} shipment = new Shipment();.setProductid(product);.setQuantity(quantity);.setDatetime(date);.setResponsiblepersonid(person);(StockDatabase.getInstance().getShipments().InsertShipment(shipment))
{
//success(false);
} else {.setText("An error occured");;
}
}
/**
* @param args the command line arguments
*/static void main(String args[]) {.awt.EventQueue.invokeLater(new
Runnable() {void run() {AddShipmentDialog().setVisible(true);
}
});
}
// Variables declaration - do not modify javax.swing.JButton btnRegister;com.toedter.calendar.JDateChooser
dateChooser;javax.swing.JComboBox dropdownPerson;javax.swing.JComboBox
dropdownProduct;javax.swing.JLabel jLabel1;javax.swing.JLabel
jLabel2;javax.swing.JLabel jLabel3;javax.swing.JLabel
jLabel4;javax.swing.JLabel lblStatus;javax.swing.JSpinner spinQuantity;
// End of variables declaration
}