Программное обеспечение учёта медицинских препаратов на складе - Курсовая работа

бесплатно 0
4.5 118
Разработка распределённой системы учёта медицинских препаратов на складе. Требования к программному обеспечению, анализ концептуальной модели. Архитектурное проектирование программы в среде NetBeans 6.7.1 и СУБД JavaDB. Проверка ее работоспособности.


Аннотация к работе
Основным объектом манипулирования системы служат товары и записи о поставках, которые содержат информацию о доставленном товаре, объеме партии и ответственном лице-работнике склада. Система должна позволять просматривать состояние склада, то есть точный объем каждого вида продукции, хранящейся на складе. Система должна позволять регистрировать новые виды продукции на складе. Система должна позволять регистрировать операции ввоз партий продукции на склад и их вывоз. Система должна позволять регистрировать новый товар на складе.Многопользовательские системы, основанные на классической технологии клиент/сервер, называются двухзвенными системами или системами с «толстым клиентом». На клиентскую часть возлагается обеспечение интерфейса пользователя, посылка запросов серверу БД (серверной части системы), получение результатов и сообщений от сервера, управление бизнес - правилами, проверку корректности, допустимости и обработку данных согласно содержащихся в них алгоритмах. На рисунке 6.1 представлена схема классической архитектуры клиент/сервер. Многозвенными системами клиент/сервер называют более новые системы с так называемым ”тонким” клиентом. На рисунке 6.2 представлена схема архитектуры клиент/сервер с “тонким” клиентом.На рисунке 5.1 представлен экран текущего состояния склада На рисунке 5.2 представлено окно регистрации нового товара На рисунке 5.3 представлен экран состояния склада после регистрации нового товара. На рисунке 5.4 представлен экран журнала поставок. На рисунке 5.6 представлен экран журнала поставок после регистрации новой поставкиВ ходе выполнения работы была разработана распределенная информационно-справочная система для учета медицинских препаратов на складе. Была разработана диаграмма классов, а также разработан проект архитектуры системы.

Вывод
В ходе выполнения работы была разработана распределенная информационно-справочная система для учета медицинских препаратов на складе.

Для успешной работы приложения вначале была разработана логическая, физическая модель БД. Была разработана диаграмма классов, а также разработан проект архитектуры системы.

В данной работе была использована классическая двухслойная архитектура «клиент - сервер». Выбор архитектуры обоснован следующими преимуществами: простота создания, быстрота работы, отсутствие высоких нагрузок на систему.

При разработке использовалась среда NETBEANS 6.7.1 и СУБД JAVADB.

Для реализации подключения к БД использовался драйвер org.apache.derby.jdbc.CLIENTDRIVER и библиотека hibernate.

В ходе проверки корректности работы системы, ошибок выявлено не было.

Список литературы
1 Кей С. Хорстманн, Гари Корнелл Библиотека профессионала Java 1,2 том - М:Издательский дом «Вильямс»,2010, 1120стр.

2 Swing руководство для начинающих - М:Издательский дом «Вильямс»,2009, 697стр.

3 С. Орлик Многоуровневые модели в архитектуре клиент-сервер http://ods.com.ua/win/rus/db/kbd97/22.htm

ПРИЛОЖЕНИЯ

Приложение А Листинг исходного кода SQL-спринтов для создания базы данных create table ADMIN.Employee

(

Id int Primary Key NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), Name varchar(100) not null CHECK(LENGTH(Name) > 0), CONSTRAINT UK_Employee_Name UNIQUE (Name)

);

create table ADMIN.Product

(

Id int Primary Key NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), Name varchar(100) not null CHECK(LENGTH(Name) > 0), Manufacturer varchar(100), QUANTITYINSTOCK int not null default 0, CONSTRAINT UK_Product_Name UNIQUE (Name)

);

create table ADMIN.Shipment

(

Id int Primary Key NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), PRODUCTID int not null, Quantity int not null, DATETIME Timestamp, RESPONSIBLEPERSONID int not null, CONSTRAINT FK_Shiment_Product Foreign Key (PRODUCTID) References Product(Id), CONSTRAINT FK_Shiment_Employee Foreign Key (RESPONSIBLEPERSONID) References Employee(Id)

);

insert into ADMIN.EMPLOYEE (Name) values ("James Winkles");

insert into ADMIN.EMPLOYEE (Name) values ("John Snipes");

insert into ADMIN.EMPLOYEE (Name) values ("Gregory House");

insert into ADMIN.EMPLOYEE (Name) values ("Jessica Gamilton");

insert into ADMIN.EMPLOYEE (Name) values ("Sarah Daniels");

insert into ADMIN.PRODUCT (Name, Manufacturer, QUANTITYINSTOCK) values ("Strepsils", "Ecoemical Inc.", 500);

insert into ADMIN.PRODUCT (Name, Manufacturer, QUANTITYINSTOCK) values ("Tera Flu", "Bio Pharm", 700);

insert into ADMIN.PRODUCT (Name, Manufacturer, QUANTITYINSTOCK) values ("Vikodin", "Biogeticals", 300);

insert into ADMIN.PRODUCT (Name, Manufacturer, QUANTITYINSTOCK) values ("Coldrex", "Green Generation", 1000);

insert into ADMIN.PRODUCT (Name, Manufacturer, QUANTITYINSTOCK) values ("Ascorbic acid", "Ecoemical Inc.", 2000);

insert into ADMIN.Shipment (PRODUCTID, Quantity, DATETIME, RESPONSIBLEPERSONID) values (1, 200, TIMESTAMP("20.03.2011", "12:00:00"), 1);

insert into ADMIN.Shipment (PRODUCTID, Quantity, DATETIME, RESPONSIBLEPERSONID) values (2, 400, TIMESTAMP("20.03.2011", "13:00:00"), 1);

insert into ADMIN.Shipment (PRODUCTID, Quantity, DATETIME, RESPONSIBLEPERSONID) values (1, 100, TIMESTAMP("20.03.2011", "14:00:00"), 3);

insert into ADMIN.Shipment (PRODUCTID, Quantity, DATETIME, RESPONSIBLEPERSONID) values (3, 300, TIMESTAMP("20.03.2011", "15:00:00"), 2);

insert into ADMIN.Shipment (PRODUCTID, Quantity, DATETIME, RESPONSIBLEPERSONID) values (5, 500, TIMESTAMP("20.03.2011", "16:00:00"), 5);

Приложение Б

Листинги исходных кодов классов клиентской части ПО

Классы-сущности package Entities;

import java.io.Serializable;

import java.util.List;

import javax.persistence.Basic;

import javax.persistence.CASCADETYPE;

import javax.persistence.Column;

import javax.persistence.Entity;

import javax.persistence.GENERATEDVALUE;

import javax.persistence.GENERATIONTYPE;

import javax.persistence.Id;

import javax.persistence.NAMEDQUERIES;

import javax.persistence.NAMEDQUERY;

import javax.persistence.ONETOMANY;

import 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")}) public class Employee implements Serializable { private static final long SERIALVERSIONUID = 1L;

@Id

@GENERATEDVALUE(strategy = GENERATIONTYPE.IDENTITY)

@Basic(optional = false)

@Column(name = "ID") private Integer id;

@Basic(optional = false)

@Column(name = "NAME") private String name;

@ONETOMANY(cascade = CASCADETYPE.ALL, MAPPEDBY = "responsiblepersonid") private List SHIPMENTLIST;

public Employee() {

} public Employee(Integer id) { this.id = id;

} public Employee(Integer id, String name) { this.id = id;

this.name = name;

} public Integer GETID() { return id;

} public void SETID(Integer id) { this.id = id;

} public String GETNAME() { return name;

} public void SETNAME(String name) { this.name = name;

} public List GETSHIPMENTLIST() { return SHIPMENTLIST;

} public void SETSHIPMENTLIST(List SHIPMENTLIST) { this.SHIPMENTLIST = SHIPMENTLIST;

}

@Override public int HASHCODE() { int hash = 0;

hash = (id != null ? id.HASHCODE() : 0);

return hash;

}

@Override public boolean equals(Object object) {

// TODO: Warning - this method won"t work in the case the id fields are not set if (!(object instanceof Employee)) { return false;

}

Employee other = (Employee) object;

if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { return false;

} return true;

}

@Override public String TOSTRING() { return name;

}

}

/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/ package Entities;

import java.io.Serializable;

import java.util.ARRAYLIST;

import java.util.List;

import javax.persistence.Basic;

import javax.persistence.CASCADETYPE;

import javax.persistence.Column;

import javax.persistence.Entity;

import javax.persistence.GENERATEDVALUE;

import javax.persistence.GENERATIONTYPE;

import javax.persistence.Id;

import javax.persistence.NAMEDQUERIES;

import javax.persistence.NAMEDQUERY;

import javax.persistence.ONETOMANY;

import 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")}) public class Product implements Serializable { private static final long SERIALVERSIONUID = 1L;

@Id

@GENERATEDVALUE(strategy = GENERATIONTYPE.IDENTITY)

@Basic(optional = false)

@Column(name = "ID") private Integer id;

@Basic(optional = false)

@Column(name = "NAME") private String name;

@Column(name = "MANUFACTURER") private String manufacturer;

@Basic(optional = false)

@Column(name = "QUANTITYINSTOCK") private int quantityinstock;

@ONETOMANY(cascade = CASCADETYPE.ALL, MAPPEDBY = "productid") private List SHIPMENTLIST;

public Product() {

} public Product(Integer id) { this.id = id;

this.SHIPMENTLIST = new ARRAYLIST();

} public Product(Integer id, String name, int quantityinstock) { this.id = id;

this.name = name;

this.quantityinstock = quantityinstock;

this.SHIPMENTLIST = new ARRAYLIST();

} public Product(Integer id, String name, String manufacturer, int quantityinstock) { this.id = id;

this.name = name;

this.manufacturer = manufacturer;

this.quantityinstock = quantityinstock;

this.SHIPMENTLIST = new ARRAYLIST();

} public Integer GETID() { return id;

} public void SETID(Integer id) { this.id = id;

} public String GETNAME() { return name;

} public void SETNAME(String name) { this.name = name;

} public String GETMANUFACTURER() { return manufacturer;

} public void SETMANUFACTURER(String manufacturer) { this.manufacturer = manufacturer;

} public int GETQUANTITYINSTOCK() { return quantityinstock;

} public void SETQUANTITYINSTOCK(int quantityinstock) { this.quantityinstock = quantityinstock;

} public List GETSHIPMENTLIST() { return SHIPMENTLIST;

} public void SETSHIPMENTLIST(List SHIPMENTLIST) { this.SHIPMENTLIST = SHIPMENTLIST;

}

@Override public int HASHCODE() { int hash = 0;

hash = (id != null ? id.HASHCODE() : 0);

return hash;

}

@Override public boolean equals(Object object) {

// TODO: Warning - this method won"t work in the case the id fields are not set if (!(object instanceof Product)) { return false;

}

Product other = (Product) object;

if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { return false;

} return true;

}

@Override public String TOSTRING() { return name;

}

}

/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/ package Entities;

import java.io.Serializable;

import java.util.Date;

import javax.persistence.Basic;

import javax.persistence.Column;

import javax.persistence.Entity;

import javax.persistence.GENERATEDVALUE;

import javax.persistence.GENERATIONTYPE;

import javax.persistence.Id;

import javax.persistence.JOINCOLUMN;

import javax.persistence.MANYTOONE;

import javax.persistence.NAMEDQUERIES;

import javax.persistence.NAMEDQUERY;

import javax.persistence.Table;

import javax.persistence.Temporal;

import 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")}) public class Shipment implements Serializable { private static final long SERIALVERSIONUID = 1L;

@Id

@GENERATEDVALUE(strategy = GENERATIONTYPE.IDENTITY)

@Basic(optional = false)

@Column(name = "ID") private Integer id;

@Basic(optional = false)

@Column(name = "QUANTITY") private int quantity;

@Column(name = "DATETIME")

@Temporal(TEMPORALTYPE.TIMESTAMP) private Date datetime;

@JOINCOLUMN(name = "RESPONSIBLEPERSONID", REFERENCEDCOLUMNNAME = "ID")

@MANYTOONE(optional = false) private Employee responsiblepersonid;

@JOINCOLUMN(name = "PRODUCTID", REFERENCEDCOLUMNNAME = "ID")

@MANYTOONE(optional = false) private Product productid;

public Shipment() {

} public Shipment(Integer id) { this.id = id;

} public Shipment(Integer id, int quantity) { this.id = id;

this.quantity = quantity;

} public Integer GETID() { return id;

} public void SETID(Integer id) { this.id = id;

} public int GETQUANTITY() { return quantity;

} public void SETQUANTITY(int quantity) { this.quantity = quantity;

} public Date GETDATETIME() { return datetime;

} public void SETDATETIME(Date datetime) { this.datetime = datetime;

} public Employee GETRESPONSIBLEPERSONID() { return responsiblepersonid;

} public void SETRESPONSIBLEPERSONID(Employee responsiblepersonid) { this.responsiblepersonid = responsiblepersonid;

} public Product GETPRODUCTID() { return productid;

} public void SETPRODUCTID(Product productid) { this.productid = productid;

}

@Override public int HASHCODE() { int hash = 0;

hash = (id != null ? id.HASHCODE() : 0);

return hash;

}

@Override public boolean equals(Object object) {

// TODO: Warning - this method won"t work in the case the id fields are not set if (!(object instanceof Shipment)) { return false;

}

Shipment other = (Shipment) object;

if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { return false;

} return true;

}

@Override public String TOSTRING() { return "Entities.Shipment[id=" id "]";

}

}

Слой доступа к данным

/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/ package DAL;

import Entities.Employee;

import java.util.List;

import javax.persistence.ENTITYMANAGER;

import javax.persistence.ENTITYTRANSACTION;

import javax.persistence.Query;

/**

*

* @author Humanity

*/ public class EMPLOYEEREPOSITORY { private ENTITYMANAGER ENTITYMANAGER;

private String GETALLEMPLOYEESQUERY = "select e from Employee e";

public EMPLOYEEREPOSITORY(ENTITYMANAGER ENTITYMANAGER) { this.ENTITYMANAGER = ENTITYMANAGER;

} public List GETALLEMPLOYEES() {

Query query = ENTITYMANAGER.CREATEQUERY(GETALLEMPLOYEESQUERY);

return query.GETRESULTLIST();

} public Employee GETEMPLOYEEBYID(int EMPLOYEEID) {

Employee employee = ENTITYMANAGER.find(Employee.class, EMPLOYEEID);

return employee;

} public void INSERTEMPLOYEE(Employee employee) {

ENTITYTRANSACTION t = ENTITYMANAGER.GETTRANSACTION();

t.begin();

try {

ENTITYMANAGER.persist(employee);

ENTITYMANAGER.flush();

t.commit();

} catch(Exception ex) { t.rollback();

}

} public void UPDATEEMPLOYEE(Employee employee) {

ENTITYTRANSACTION t = ENTITYMANAGER.GETTRANSACTION();

t.begin();

try {

ENTITYMANAGER.refresh(employee);

ENTITYMANAGER.flush();

t.commit();

} catch(Exception ex) { t.rollback();

}

} public void DELETEEMPLOYEE(int EMPLOYEEID) {

ENTITYTRANSACTION t = ENTITYMANAGER.GETTRANSACTION();

t.begin();

try {

Employee Employee = GETEMPLOYEEBYID(EMPLOYEEID);

ENTITYMANAGER.remove(Employee);

ENTITYMANAGER.flush();

t.commit();

} catch(Exception ex) { t.rollback();

}

}

}

/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/ package DAL;

import Entities.Product;

import java.util.List;

import javax.persistence.ENTITYMANAGER;

import javax.persistence.ENTITYTRANSACTION;

import javax.persistence.Query;

/**

*

* @author Humanity

*/ public class PRODUCTREPOSITORY { private ENTITYMANAGER ENTITYMANAGER;

private String GETALLPRODUCTSQUERY = "select p from Product p";

public PRODUCTREPOSITORY(ENTITYMANAGER ENTITYMANAGER) { this.ENTITYMANAGER = ENTITYMANAGER;

} public List GETALLPRODUCTS() {

Query query = ENTITYMANAGER.CREATEQUERY(GETALLPRODUCTSQUERY);

return query.GETRESULTLIST();

} public Product GETPRODUCTBYID(int PRODUCTID) {

Product product = ENTITYMANAGER.find(Product.class, PRODUCTID);

return product;

} public boolean INSERTPRODUCT(Product product) {

ENTITYTRANSACTION t = ENTITYMANAGER.GETTRANSACTION();

t.begin();

try {

ENTITYMANAGER.merge(product);

//ENTITYMANAGER.persist(product);

t.commit();

return true;

} catch(Exception ex) { t.rollback();

return false;

}

} public void UPDATEPRODUCT(Product product) {

ENTITYTRANSACTION t = ENTITYMANAGER.GETTRANSACTION();

t.begin();

try {

ENTITYMANAGER.refresh(product);

ENTITYMANAGER.flush();

t.commit();

} catch(Exception ex) { t.rollback();

}

} public void DELETEPRODUCT(int PRODUCTID) {

ENTITYTRANSACTION t = ENTITYMANAGER.GETTRANSACTION();

t.begin();

try {

Product Product = GETPRODUCTBYID(PRODUCTID);

ENTITYMANAGER.remove(Product);

ENTITYMANAGER.flush();

t.commit();

} catch(Exception ex) { t.rollback();

}

}

}

/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/ package DAL;

import Entities.Product;

import Entities.Shipment;

import java.lang.Math;

import java.util.List;

import javax.persistence.ENTITYMANAGER;

import javax.persistence.ENTITYTRANSACTION;

import javax.persistence.Query;

/**

*

* @author Humanity

*/ public class SHIPMENTREPOSITORY { private ENTITYMANAGER ENTITYMANAGER;

private String GETALLSHIPMENTSQUERY = "select s from Shipment s";

private String GETSHIPMENTSFORPRODUCTQUERY = "select s from Shipment s where s.productid.id = %1$d";

private String GETSHIPMENTSFORPERSONQUERY = "select s from Shipment s where s.responsiblepersonid.id = %1$d";

private String GETSHIPMENTSFORPERSONANDPRODUCTQUERY =

"select s from Shipment s where s.responsiblepersonid.id = %1$d and s.productid.id = %2$d";

public SHIPMENTREPOSITORY(ENTITYMANAGER ENTITYMANAGER) { this.ENTITYMANAGER = ENTITYMANAGER;

} public List GETALLSHIPMENTS() {

Query query = ENTITYMANAGER.CREATEQUERY(GETALLSHIPMENTSQUERY);

return query.GETRESULTLIST();

} public Shipment GETSHIPMENTBYID(int SHIPMENTID) {

Shipment shipment = ENTITYMANAGER.find(Shipment.class, SHIPMENTID);

return shipment;

} public List GETSHIPMENTFORPRODUCT(int PRODUCTID) {

Query query = ENTITYMANAGER.CREATEQUERY(String.format(GETSHIPMENTSFORPRODUCTQUERY, PRODUCTID));

return query.GETRESULTLIST();

} public List GETSHIPMENTFORPERSON(int PERSONID) {

Query query = ENTITYMANAGER.CREATEQUERY(String.format(GETSHIPMENTSFORPERSONQUERY, PERSONID));

return query.GETRESULTLIST();

} public List GETSHIPMENTLIST(int PERSONID, int PRODUCTID) { if (PRODUCTID == 0){ if (PERSONID == 0) { return GETALLSHIPMENTS();

} else { return GETSHIPMENTFORPERSON(PERSONID);

}

} else { if (PERSONID == 0) { return GETSHIPMENTFORPRODUCT(PRODUCTID);

} else {

Query query = ENTITYMANAGER.CREATEQUERY(String.format(GETSHIPMENTSFORPERSONANDPRODUCTQUERY, PERSONID, PRODUCTID));

return query.GETRESULTLIST();

}

}

} public boolean INSERTSHIPMENT(Shipment shipment) {

Product p = STOCKDATABASE.GETINSTANCE().GETPRODUCTS().GETPRODUCTBYID(shipment.GETPRODUCTID().GETID());

if (shipment.GETQUANTITY() < 0 && p.GETQUANTITYINSTOCK() < Math.abs(shipment.GETQUANTITY())) {

// trying to take TOO MUCH from stock... return false;

} int FINALQUANTITY = p.GETQUANTITYINSTOCK() shipment.GETQUANTITY();

p.SETQUANTITYINSTOCK(FINALQUANTITY);

ENTITYTRANSACTION t = ENTITYMANAGER.GETTRANSACTION();

try { t.begin();

ENTITYMANAGER.persist(shipment);

ENTITYMANAGER.persist(p);

//ENTITYMANAGER.flush();

t.commit();

return true;

} catch(Exception ex) { t.rollback();

return false;

}

} public void UPDATESHIPMENT(Shipment shipment) {

ENTITYTRANSACTION t = ENTITYMANAGER.GETTRANSACTION();

t.begin();

try {

ENTITYMANAGER.refresh(shipment);

ENTITYMANAGER.flush();

t.commit();

} catch(Exception ex) { t.rollback();

}

} public void DELETESHIPMENT(int SHIPMENTID) {

ENTITYTRANSACTION t = ENTITYMANAGER.GETTRANSACTION();

t.begin();

try {

Shipment Shipment = GETSHIPMENTBYID(SHIPMENTID);

ENTITYMANAGER.remove(Shipment);

ENTITYMANAGER.flush();

t.commit();

} catch(Exception ex) { t.rollback();

}

}

}

/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/ package DAL;

import javax.persistence.ENTITYMANAGER;

import javax.persistence.ENTITYMANAGERFACTORY;

import javax.persistence.Persistence;

/**

*

* @author Humanity

*/ public class STOCKDATABASE { private static class SINGLETONHOLDER { public static STOCKDATABASE instance = new STOCKDATABASE();

} public static STOCKDATABASE GETINSTANCE() { return SINGLETONHOLDER.instance;

} private String CONNECTIONNAME = "STOCKDB";

private ENTITYMANAGER ENTITYMANAGER;

EMPLOYEEREPOSITORY employee;

PRODUCTREPOSITORY products;

SHIPMENTREPOSITORY shipments;

protected STOCKDATABASE() { try {

ENTITYMANAGERFACTORY factory = Persistence.CREATEENTITYMANAGERFACTORY(CONNECTIONNAME);

ENTITYMANAGER = factory.CREATEENTITYMANAGER();

employee = new EMPLOYEEREPOSITORY(ENTITYMANAGER);

products = new PRODUCTREPOSITORY(ENTITYMANAGER);

shipments = new SHIPMENTREPOSITORY(ENTITYMANAGER);

} catch (java.lang.EXCEPTIONININITIALIZERERROR ex) {

Throwable a = ex.GETEXCEPTION();

Throwable b = ex.GETCAUSE();

}

} public EMPLOYEEREPOSITORY GETEMPLOYEE() { return employee;

} public PRODUCTREPOSITORY GETPRODUCTS() { return products;

} public SHIPMENTREPOSITORY GETSHIPMENTS() { return shipments;

}

}

Классы пользовательского интерфейса

/*

* STOCKVIEW.java

*/ package stock;

import DAL.STOCKDATABASE;

import Entities.Employee;

import Entities.Product;

import Entities.Shipment;

import Utils.Utils;

import org.jdesktop.application.Action;

import org.jdesktop.application.RESOURCEMAP;

import org.jdesktop.application.SINGLEFRAMEAPPLICATION;

import org.jdesktop.application.FRAMEVIEW;

import org.jdesktop.application.TASKMONITOR;

import java.awt.event.ACTIONEVENT;

import java.awt.event.ACTIONLISTENER;

import java.util.ARRAYLIST;

import java.util.List;

import javax.swing.COMBOBOXMODEL;

import javax.swing.DEFAULTCOMBOBOXMODEL;

import javax.swing.Timer;

import javax.swing.Icon;

import javax.swing.JDIALOG;

import javax.swing.JFRAME;

import javax.swing.table.DEFAULTTABLEMODEL;

import javax.swing.table.TABLEMODEL;

/**

* The application"s main frame.

*/ public class STOCKVIEW extends FRAMEVIEW { public STOCKVIEW(SINGLEFRAMEAPPLICATION app) { super(app);

INITCOMPONENTS();

// status bar initialization - message timeout, idle icon and busy animation, etc

RESOURCEMAP RESOURCEMAP = GETRESOURCEMAP();

int MESSAGETIMEOUT = RESOURCEMAP.GETINTEGER("STATUSBAR.MESSAGETIMEOUT");

MESSAGETIMER = new Timer(MESSAGETIMEOUT, new ACTIONLISTENER() { public void ACTIONPERFORMED(ACTIONEVENT e) {

//STATUSMESSAGELABEL.SETTEXT("");

}

});

MESSAGETIMER.SETREPEATS(false);

int BUSYANIMATIONRATE = RESOURCEMAP.GETINTEGER("STATUSBAR.BUSYANIMATIONRATE");

for (int i = 0; i < BUSYICONS.length; i ) {

BUSYICONS[i] = RESOURCEMAP.GETICON("STATUSBAR.BUSYICONS[" i "]");

}

BUSYICONTIMER = new Timer(BUSYANIMATIONRATE, new ACTIONLISTENER() { public void ACTIONPERFORMED(ACTIONEVENT e) {

BUSYICONINDEX = (BUSYICONINDEX 1) % BUSYICONS.length;

//STATUSANIMATIONLABEL.SETICON(BUSYICONS[BUSYICONINDEX]);

}

});

IDLEICON = RESOURCEMAP.GETICON("STATUSBAR.IDLEICON");

//STATUSANIMATIONLABEL.SETICON(IDLEICON);

//PROGRESSBAR.SETVISIBLE(false);

// connecting action tasks to status bar via TASKMONITOR

TASKMONITOR TASKMONITOR = new TASKMONITOR(GETAPPLICATION().GETCONTEXT());

TASKMONITOR.ADDPROPERTYCHANGELISTENER(new java.beans.PROPERTYCHANGELISTENER() { public void PROPERTYCHANGE(java.beans.PROPERTYCHANGEEVENT evt) {

/*String PROPERTYNAME = evt.GETPROPERTYNAME();

if ("started".equals(PROPERTYNAME)) { if (!BUSYICONTIMER.ISRUNNING()) {

STATUSANIMATIONLABEL.SETICON(BUSYICONS[0]);

BUSYICONINDEX = 0;

BUSYICONTIMER.start();

}

PROGRESSBAR.SETVISIBLE(true);

PROGRESSBAR.SETINDETERMINATE(true);

} else if ("done".equals(PROPERTYNAME)) {

BUSYICONTIMER.stop();

STATUSANIMATIONLABEL.SETICON(IDLEICON);

PROGRESSBAR.SETVISIBLE(false);

PROGRESSBAR.SETVALUE(0);

} else if ("message".equals(PROPERTYNAME)) {

String text = (String)(evt.GETNEWVALUE());

STATUSMESSAGELABEL.SETTEXT((text == null) ? "" : text);

MESSAGETIMER.restart();

} else if ("progress".equals(PROPERTYNAME)) { int value = (Integer)(evt.GETNEWVALUE());

PROGRESSBAR.SETVISIBLE(true);

PROGRESSBAR.SETINDETERMINATE(false);

PROGRESSBAR.SETVALUE(value);

}*/

}

});

//SETRESIZABLE(false);

TABLEPRODUCTS.GETCOLUMNMODEL().GETCOLUMN(0).SETMINWIDTH(0);

TABLEPRODUCTS.GETCOLUMNMODEL().GETCOLUMN(0).SETMAXWIDTH(0);

TABLEPRODUCTS.GETCOLUMNMODEL().GETCOLUMN(0).SETWIDTH(0);

REFILLPRODUCTSTABLE();

REFILLSHIPMENTTABLE();

} private void REFILLPRODUCTSTABLE() {

List products = STOCKDATABASE.GETINSTANCE().GETPRODUCTS().GETALLPRODUCTS();

DEFAULTTABLEMODEL model = (DEFAULTTABLEMODEL) TABLEPRODUCTS.GETMODEL();

model.SETROWCOUNT(0);

for(Product product : products){ model.ADDROW(new Object[]{product, product.GETID(), product.GETNAME(), product.GETMANUFACTURER(), product.GETQUANTITYINSTOCK() });

}

} protected void REFILLSHIPMENTTABLE() {

REFILLSHIPMENTTABLE(STOCKDATABASE.GETINSTANCE().GETSHIPMENTS().GETSHIPMENTLIST(0, 0));

} protected void REFILLSHIPMENTTABLE(List shipments) {

DEFAULTTABLEMODEL model = (DEFAULTTABLEMODEL) TABLESHIPMENTS.GETMODEL();

model.SETROWCOUNT(0);

for(Shipment shipment : shipments){ model.ADDROW(new Object[]{

Utils.CONVERTDATETODATESTRING(shipment.GETDATETIME()), shipment.GETPRODUCTID(), shipment.GETQUANTITY(), shipment.GETRESPONSIBLEPERSONID() });

}

} protected COMBOBOXMODEL GETEMPLOYEEMODEL() {

List people = STOCKDATABASE.GETINSTANCE().GETEMPLOYEE().GETALLEMPLOYEES();

people.add(0, new Employee(0, "No filter"));

COMBOBOXMODEL model = new DEFAULTCOMBOBOXMODEL(people.TOARRAY());

return model;

} protected COMBOBOXMODEL GETPRODUCTSMODEL() {

List products = STOCKDATABASE.GETINSTANCE().GETPRODUCTS().GETALLPRODUCTS();

products.add(0, new Product(0, "No filter", 0));

COMBOBOXMODEL model = new DEFAULTCOMBOBOXMODEL( products.TOARRAY());

return model;

}

@Action public void SHOWABOUTBOX() { if (ABOUTBOX == null) {

JFRAME MAINFRAME = STOCKAPP.GETAPPLICATION().GETMAINFRAME();

ABOUTBOX = new STOCKABOUTBOX(MAINFRAME);

ABOUTBOX.SETLOCATIONRELATIVETO(MAINFRAME);

}

STOCKAPP.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")

// private void INITCOMPONENTS() {

BINDINGGROUP = new org.jdesktop.beansbinding.BINDINGGROUP();

MAINPANEL = new javax.swing.JPANEL();

JTABBEDPANE1 = new javax.swing.JTABBEDPANE();

JPANEL2 = new javax.swing.JPANEL();

JSCROLLPANE1 = new javax.swing.JSCROLLPANE();

TABLEPRODUCTS = new javax.swing.JTABLE();

BTNREFRESH = new javax.swing.JBUTTON();

BTNADDPRODUCT = new javax.swing.JBUTTON();

JPANEL1 = new javax.swing.JPANEL();

BTNINCOMING = new javax.swing.JBUTTON();

BTNOUTCOMING = new javax.swing.JBUTTON();

JSCROLLPANE2 = new javax.swing.JSCROLLPANE();

TABLESHIPMENTS = new javax.swing.JTABLE();

DROPDOWNEMPLOYEEFILTER = new javax.swing.JCOMBOBOX();

JLABEL1 = new javax.swing.JLABEL();

JBUTTON2 = new javax.swing.JBUTTON();

DROPDOWNPRODUCTFILTER = new javax.swing.JCOMBOBOX();

JPOPUPMENU = new javax.swing.JPOPUPMENU();

JMENUITEM1 = new javax.swing.JMENUITEM();

MAINPANEL.SETMINIMUMSIZE(new java.awt.Dimension(507, 434));

MAINPANEL.SETNAME("MAINPANEL"); // NOI18N org.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"));

BINDINGGROUP.ADDBINDING(binding);

JTABBEDPANE1.SETNAME("JTABBEDPANE1"); // NOI18N binding = 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"));

BINDINGGROUP.ADDBINDING(binding);

JTABBEDPANE1.ADDFOCUSLISTENER(new java.awt.event.FOCUSADAPTER() { public void FOCUSGAINED(java.awt.event.FOCUSEVENT evt) {

JTABBEDPANE1FOCUSGAINED(evt);

}

});

JPANEL2.SETNAME("JPANEL2"); // NOI18N

JSCROLLPANE1.SETNAME("JSCROLLPANE1"); // NOI18N

TABLEPRODUCTS.SETMODEL(new javax.swing.table.DEFAULTTABLEMODEL( new Object [][] {

}, new String [] {

"PRODUCTOBJECT", "ID", "Name", "Manufacturer", "Quantity In Stock"

}

) {

Class[] types = new Class [] { java.lang.Object.class, java.lang.Integer.class, java.lang.Object.class, java.lang.String.class, java.lang.Integer.class

};

boolean[] CANEDIT = new boolean [] { false, false, false, false, false

};

public Class GETCOLUMNCLASS(int COLUMNINDEX) { return types [COLUMNINDEX];

} public boolean ISCELLEDITABLE(int ROWINDEX, int COLUMNINDEX) { return CANEDIT [COLUMNINDEX];

}

});

TABLEPRODUCTS.SETNAME("TABLEPRODUCTS"); // NOI18N

JSCROLLPANE1.SETVIEWPORTVIEW(TABLEPRODUCTS);

org.jdesktop.application.RESOURCEMAP RESOURCEMAP = org.jdesktop.application.Application.GETINSTANCE(stock.STOCKAPP.class).GETCONTEXT().GETRESOURCEMAP(STOCKVIEW.class);

TABLEPRODUCTS.GETCOLUMNMODEL().GETCOLUMN(0).SETRESIZABLE(false);

TABLEPRODUCTS.GETCOLUMNMODEL().GETCOLUMN(0).SETPREFERREDWIDTH(0);

TABLEPRODUCTS.GETCOLUMNMODEL().GETCOLUMN(0).SETHEADERVALUE(RESOURCEMAP.GETSTRING("TABLEPRODUCTS.COLUMNMODEL.title4")); // NOI18N

TABLEPRODUCTS.GETCOLUMNMODEL().GETCOLUMN(1).SETPREFERREDWIDTH(50);

TABLEPRODUCTS.GETCOLUMNMODEL().GETCOLUMN(1).SETHEADERVALUE(RESOURCEMAP.GETSTRING("TABLEPRODUCTS.COLUMNMODEL.title0")); // NOI18N

TABLEPRODUCTS.GETCOLUMNMODEL().GETCOLUMN(2).SETHEADERVALUE(RESOURCEMAP.GETSTRING("TABLEPRODUCTS.COLUMNMODEL.title1")); // NOI18N

TABLEPRODUCTS.GETCOLUMNMODEL().GETCOLUMN(3).SETHEADERVALUE(RESOURCEMAP.GETSTRING("TABLEPRODUCTS.COLUMNMODEL.title2")); // NOI18N

TABLEPRODUCTS.GETCOLUMNMODEL().GETCOLUMN(4).SETHEADERVALUE(RESOURCEMAP.GETSTRING("TABLEPRODUCTS.COLUMNMODEL.title3")); // NOI18N

BTNREFRESH.SETTEXT(RESOURCEMAP.GETSTRING("BTNREFRESH.text")); // NOI18N

BTNREFRESH.SETNAME("BTNREFRESH"); // NOI18N

BTNREFRESH.ADDMOUSELISTENER(new java.awt.event.MOUSEADAPTER() { public void MOUSECLICKED(java.awt.event.MOUSEEVENT evt) {

BTNREFRESHMOUSECLICKED(evt);

}

});

BTNADDPRODUCT.SETTEXT(RESOURCEMAP.GETSTRING("BTNADDPRODUCT.text")); // NOI18N

BTNADDPRODUCT.SETNAME("BTNADDPRODUCT"); // NOI18N

BTNADDPRODUCT.ADDMOUSELISTENER(new java.awt.event.MOUSEADAPTER() { public void MOUSECLICKED(java.awt.event.MOUSEEVENT evt) {

BTNADDPRODUCTMOUSECLICKED(evt);

}

});

javax.swing.GROUPLAYOUT JPANEL2Layout = new javax.swing.GROUPLAYOUT(JPANEL2);

JPANEL2.SETLAYOUT(JPANEL2Layout);

JPANEL2Layout.SETHORIZONTALGROUP(

JPANEL2Layout.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())

);

JPANEL2Layout.SETVERTICALGROUP(

JPANEL2Layout.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())

);

JTABBEDPANE1.ADDTAB(RESOURCEMAP.GETSTRING("JPANEL2.TABCONSTRAINTS.TABTITLE"), JPANEL2); // NOI18N

JPANEL1.SETNAME("JPANEL1"); // NOI18N

BTNINCOMING.SETTEXT(RESOURCEMAP.GETSTRING("BTNINCOMING.text")); // NOI18N

BTNINCOMING.SETNAME("BTNINCOMING"); // NOI18N

BTNINCOMING.ADDMOUSELISTENER(new java.awt.event.MOUSEADAPTER() { public void MOUSECLICKED(java.awt.event.MOUSEEVENT evt) {

BTNINCOMINGMOUSECLICKED(evt);

}

});

BTNOUTCOMING.SETTEXT(RESOURCEMAP.GETSTRING("BTNOUTCOMING.text")); // NOI18N

BTNOUTCOMING.SETNAME("BTNOUTCOMING"); // NOI18N

BTNOUTCOMING.ADDMOUSELISTENER(new java.awt.event.MOUSEADAPTER() { public void MOUSECLICKED(java.awt.event.MOUSEEVENT evt) {

BTNOUTCOMINGMOUSECLICKED(evt);

}

});

JSCROLLPANE2.SETNAME("JSCROLLPANE2"); // NOI18N

TABLESHIPMENTS.SETMODEL(new javax.swing.table.DEFAULTTABLEMODEL( new Object [][] {

}, new String [] {

"Date and time", "Product", "Quantity", "Responsible Person"

}

));

TABLESHIPMENTS.SETNAME("TABLESHIPMENTS"); // NOI18N

JSCROLLPANE2.SETVIEWPORTVIEW(TABLESHIPMENTS);

DROPDOWNEMPLOYEEFILTER.SETMODEL(GETEMPLOYEEMODEL());

DROPDOWNEMPLOYEEFILTER.SETMAXIMUMSIZE(new java.awt.Dimension(100, 20));

DROPDOWNEMPLOYEEFILTER.SETMINIMUMSIZE(new java.awt.Dimension(100, 20));

DROPDOWNEMPLOYEEFILTER.SETNAME("DROPDOWNEMPLOYEEFILTER"); // NOI18N

DROPDOWNEMPLOYEEFILTER.SETPREFERREDSIZE(new java.awt.Dimension(100, 20));

JLABEL1.SETTEXT(RESOURCEMAP.GETSTRING("JLABEL1.text")); // NOI18N

JLABEL1.SETNAME("JLABEL1"); // NOI18N

JBUTTON2.SETTEXT(RESOURCEMAP.GETSTRING("JBUTTON2.text")); // NOI18N

JBUTTON2.SETNAME("JBUTTON2"); // NOI18N

JBUTTON2.ADDMOUSELISTENER(new java.awt.event.MOUSEADAPTER() { public void MOUSECLICKED(java.awt.event.MOUSEEVENT evt) {

JBUTTON2MOUSECLICKED(evt);

}

});

DROPDOWNPRODUCTFILTER.SETMODEL(GETPRODUCTSMODEL());

DROPDOWNPRODUCTFILTER.SETMAXIMUMSIZE(new java.awt.Dimension(100, 20));

DROPDOWNPRODUCTFILTER.SETMINIMUMSIZE(new java.awt.Dimension(100, 20));

DROPDOWNPRODUCTFILTER.SETNAME("DROPDOWNPRODUCTFILTER"); // NOI18N

DROPDOWNPRODUCTFILTER.SETPREFERREDSIZE(new java.awt.Dimension(100, 20));

javax.swing.GROUPLAYOUT JPANEL1Layout = new javax.swing.GROUPLAYOUT(JPANEL1);

JPANEL1.SETLAYOUT(JPANEL1Layout);

JPANEL1Layout.SETHORIZONTALGROUP(

JPANEL1Layout.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())

);

JPANEL1Layout.SETVERTICALGROUP(

JPANEL1Layout.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())

);

JTABBEDPANE1.ADDTAB(RESOURCEMAP.GETSTRING("JPANEL1.TABCONSTRAINTS.TABTITLE"), JPANEL1); // NOI18N javax.swing.GROUPLAYOUT MAINPANELLAYOUT = new javax.swing.GROUPLAYOUT(MAINPANEL);

MAINPANEL.SETLAYOUT(MAINPANELLAYOUT);

MAINPANELLAYOUT.SETHORIZONTALGROUP(

MAINPANELLAYOUT.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())

);

MAINPANELLAYOUT.SETVERTICALGROUP(

MAINPANELLAYOUT.CREATEPARALLELGROUP(javax.swing.GROUPLAYOUT.Alignment.LEADING)

.ADDGROUP(MAINPANELLAYOUT.CREATESEQUENTIALGROUP()

.ADDCONTAINERGAP()

.ADDCOMPONENT(JTABBEDPANE1, javax.swing.GROUPLAYOUT.DEFAULT_SIZE, 458, Short.MAX_VALUE)

.ADDCONTAINERGAP())

);

JPOPUPMENU.SETNAME("JPOPUPMENU"); // NOI18N javax.swing.ACTIONMAP ACTIONMAP = org.jdesktop.application.Application.GETINSTANCE(stock.STOCKAPP.class).GETCONTEXT().GETACTIONMAP(STOCKVIEW.class, this);

JMENUITEM1.SETACTION(ACTIONMAP.get("SHOWABOUTBOX")); // NOI18N

JMENUITEM1.SETNAME("JMENUITEM1"); // NOI18N

JPOPUPMENU.add(JMENUITEM1);

SETCOMPONENT(MAINPANEL);

BINDINGGROUP.bind();

}// private void BTNREFRESHMOUSECLICKED(java.awt.event.MOUSEEVENT evt) {

// TODO add your handling code here: REFILLPRODUCTSTABLE();

} private void BTNINCOMINGMOUSECLICKED(java.awt.event.MOUSEEVENT evt) { if (ADDSHIPMENTBOX == null) {

JFRAME MAINFRAME = STOCKAPP.GETAPPLICATION().GETMAINFRAME();

ADDSHIPMENTBOX = new ADDSHIPMENTDIALOG(MAINFRAME);

ADDSHIPMENTBOX.SETLOCATIONRELATIVETO(MAINFRAME);

}

ADDSHIPMENTBOX.Initialize(true);

STOCKAPP.GETAPPLICATION().show(ADDSHIPMENTBOX);

REFILLSHIPMENTTABLE();

REFILLPRODUCTSTABLE();

} private void BTNOUTCOMINGMOUSECLICKED(java.awt.event.MOUSEEVENT evt) { if (ADDSHIPMENTBOX == null) {

JFRAME MAINFRAME = STOCKAPP.GETAPPLICATION().GETMAINFRAME();

ADDSHIPMENTBOX = new ADDSHIPMENTDIALOG(MAINFRAME);

ADDSHIPMENTBOX.SETLOCATIONRELATIVETO(MAINFRAME);

}

ADDSHIPMENTBOX.Initialize(false);

STOCKAPP.GETAPPLICATION().show(ADDSHIPMENTBOX);

REFILLSHIPMENTTABLE();

REFILLPRODUCTSTABLE();

} private void JTABBEDPANE1FOCUSGAINED(java.awt.event.FOCUSEVENT evt) {

}

// Refresh with filter button private void JBUTTON2MOUSECLICKED(java.awt.event.MOUSEEVENT evt) {

Employee EMPLOYEEFILTER = (Employee)DROPDOWNEMPLOYEEFILTER.GETSELECTEDITEM();

Product PRODUCTFILTER = (Product)DROPDOWNPRODUCTFILTER.GETSELECTEDITEM();

REFILLSHIPMENTTABLE(

STOCKDATABASE.GETINSTANCE().GETSHIPMENTS().GETSHIPMENTLIST(

EMPLOYEEFILTER.GETID(), PRODUCTFILTER.GETID()));

} private void BTNADDPRODUCTMOUSECLICKED(java.awt.event.MOUSEEVENT evt) {

// TODO add your handling code here: if (ADDPRODUCTBOX == null) {

JFRAME MAINFRAME = STOCKAPP.GETAPPLICATION().GETMAINFRAME();

ADDPRODUCTBOX = new ADDPRODUCTDIALOG(MAINFRAME);

ADDPRODUCTBOX.SETLOCATIONRELATIVETO(MAINFRAME);

}

STOCKAPP.GETAPPLICATION().show(ADDPRODUCTBOX);

REFILLPRODUCTSTABLE();

DROPDOWNPRODUCTFILTER.SETMODEL(GETPRODUCTSMODEL());

}

// Variables declaration - do not modify private javax.swing.JBUTTON BTNADDPRODUCT;

private javax.swing.JBUTTON BTNINCOMING;

private javax.swing.JBUTTON BTNOUTCOMING;

private javax.swing.JBUTTON BTNREFRESH;

private javax.swing.JCOMBOBOX DROPDOWNEMPLOYEEFILTER;

private javax.swing.JCOMBOBOX DROPDOWNPRODUCTFILTER;

private javax.swing.JBUTTON JBUTTON2;

private javax.swing.JLABEL JLABEL1;

private javax.swing.JMENUITEM JMENUITEM1;

private javax.swing.JPANEL JPANEL1;

private javax.swing.JPANEL JPANEL2;

private javax.swing.JPOPUPMENU JPOPUPMENU;

private javax.swing.JSCROLLPANE JSCROLLPANE1;

private javax.swing.JSCROLLPANE JSCROLLPANE2;

private javax.swing.JTABBEDPANE JTABBEDPANE1;

private javax.swing.JPANEL MAINPANEL;

private javax.swing.JTABLE TABLEPRODUCTS;

private javax.swing.JTABLE TABLESHIPMENTS;

private org.jdesktop.beansbinding.BINDINGGROUP BINDINGGROUP;

// End of variables declaration private final Timer MESSAGETIMER;

private final Timer BUSYICONTIMER;

private final Icon IDLEICON;

private final Icon[] BUSYICONS = new Icon[15];

private int BUSYICONINDEX = 0;

private JDIALOG ABOUTBOX;

private ADDSHIPMENTDIALOG ADDSHIPMENTBOX;

private 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

*/ package stock;

import DAL.STOCKDATABASE;

import Entities.Product;

/**

*

* @author Humanity

*/ public class ADDPRODUCTDIALOG extends javax.swing.JDIALOG {

/** Creates new form LOGINFORM */ public ADDPRODUCTDIALOG(java.awt.Frame parent) { super(parent);

INITCOMPONENTS();

CLEARFORM();

this.SETMODAL(true);

} public ADDPRODUCTDIALOG() {

INITCOMPONENTS();

CLEARFORM();

} private void CLEARFORM() {

TXTNAME.SETTEXT("");

TXTMANUFACTURER.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")

// private void INITCOMPONENTS() {

BTNREGISTER = new javax.swing.JBUTTON();

JLABEL4 = new javax.swing.JLABEL();

LBLSTATUS = new javax.swing.JLABEL();

TXTNAME = new javax.swing.JTEXTFIELD();

TXTMANUFACTURER = new javax.swing.JTEXTFIELD();

JLABEL5 = new javax.swing.JLABEL();

SETTITLE("Add product");

SETMODAL(true);

SETNAME("Form"); // NOI18N

SETRESIZABLE(false);

javax.swing.ACTIONMAP ACTIONMAP = org.jdesktop.application.Application.GETINSTANCE(stock.STOCKAPP.class).GETCONTEXT().GETACTIONMAP(ADDPRODUCTDIALOG.class, this);

BTNREGISTER.SETACTION(ACTIONMAP.get("REGISTERCLICK")); // NOI18N

BTNREGISTER.SETTEXT("Add Product");

BTNREGISTER.SETNAME("BTNREGISTER"); // NOI18N

BTNREGISTER.ADDMOUSELISTENER(new java.awt.event.MOUSEADAPTER() { public void MOUSECLICKED(java.awt.event.MOUSEEVENT evt) {

BTNREGISTERMOUSECLICKED(evt);

}

});

JLABEL4.SETTEXT("Product name");

JLABEL4.SETNAME("JLABEL4"); // NOI18N

LBLSTATUS.SETNAME("LBLSTATUS"); // NOI18N

TXTNAME.SETNAME("TXTNAME"); // NOI18N

TXTMANUFACTURER.SETNAME("TXTMANUFACTURER"); // NOI18N

JLABEL5.SETTEXT("Manufacturer");

JLABEL5.SETNAME("JLABEL5"); // NOI18N javax.swing.GROUPLAYOUT layout = new javax.swing.GROUPLAYOUT(GETCONTENTPANE());

GETCONTENTPANE().SETLAYOUT(layout);

layout.SETHORIZONTALGROUP( layout.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())

);

layout.SETVERTICALGROUP( layout.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())

);

pack();

}// private void BTNREGISTERMOUSECLICKED(java.awt.event.MOUSEEVENT evt) {

String name = TXTNAME.GETTEXT();

String manufacturer = TXTMANUFACTURER.GETTEXT();

if (name.length() == 0) {

LBLSTATUS.SETTEXT("Enter a product name please");

return;

} if (manufacturer.length() == 0) {

LBLSTATUS.SETTEXT("Enter manufacturer"s name please");

return;

}

Product product = new Product(0, name, manufacturer, 0);

if (STOCKDATABASE.GETINSTANCE().GETPRODUCTS().INSERTPRODUCT(product)) {

//success

SETVISIBLE(false);

} else {

LBLSTATUS.SETTEXT("An error occured");

return;

}

}

/**

* @param args the command line arguments

*/ public static void main(String args[]) { java.awt.EVENTQUEUE.INVOKELATER(new Runnable() { public void run() { new ADDSHIPMENTDIALOG().SETVISIBLE(true);

}

});

}

// Variables declaration - do not modify private javax.swing.JBUTTON BTNREGISTER;

private javax.swing.JLABEL JLABEL4;

private javax.swing.JLABEL JLABEL5;

private javax.swing.JLABEL LBLSTATUS;

private javax.swing.JTEXTFIELD TXTMANUFACTURER;

private 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

*/ package stock;

import DAL.STOCKDATABASE;

import Entities.Employee;

import Entities.Product;

import Entities.Shipment;

import java.awt.Component;

import java.util.Date;

import java.util.Vector;

import javax.swing.COMBOBOXMODEL;

import javax.swing.DEFAULTCOMBOBOXMODEL;

import javax.swing.JOPTIONPANE;

import org.jdesktop.application.Action;

/**

*

* @author Humanity

*/ public class ADDSHIPMENTDIALOG extends javax.swing.JDIALOG {

/** Creates new form LOGINFORM */ public ADDSHIPMENTDIALOG(java.awt.Frame parent) { super(parent);

INITCOMPONENTS();

//GETROOTPANE().SETDEFAULTBUTTON(BTNLOGIN);

QUANTITYRATIO = 1;

this.SETMODAL(true);

} public ADDSHIPMENTDIALOG() {

INITCOMPONENTS();

QUANTITYRATIO = 1;

}

// Positive for incoming goods, negative for outcoming private int QUANTITYRATIO;

public void Initialize(boolean ISINCOMING){

QUANTITYRATIO = ISINCOMING ? 1 : -1;

SETTITLE(ISINCOMING

? "Incoming Shipment"

: "Outcoming Shipment");

} protected COMBOBOXMODEL GETPRODUCTSMODEL() {

COMBOBOXMODEL model = new DEFAULTCOMBOBOXMODEL(

STOCKDATABASE.GETINSTANCE().GETPRODUCTS().GETALLPRODUCTS().TOARRAY());

return model;

} protected COMBOBOXMODEL GETEMPLOYEEMODEL() {

COMBOBOXMODEL model = new DEFAULTCOMBOBOXMODEL(

STOCKDATABASE.GETINSTANCE().GETEMPLOYEE().GETALLEMPLOYEES().TOARRAY());

return model;

}

/** 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")

// private void INITCOMPONENTS() {

BTNREGISTER = new javax.swing.JBUTTON();

JLABEL4 = new javax.swing.JLABEL();

LBLSTATUS = new javax.swing.JLABEL();

DROPDOWNPRODUCT = new javax.swing.JCOMBOBOX();

DATECHOOSER = new com.toedter.calendar.JDATECHOOSER();

SPINQUANTITY = new javax.swing.JSPINNER();

DROPDOWNPERSON = new javax.swing.JCOMBOBOX();

JLABEL1 = new javax.swing.JLABEL();

JLABEL2 = new javax.swing.JLABEL();

JLABEL3 = new javax.swing.JLABEL();

SETTITLE("Incoming Shipment");

SETMODAL(true);

SETNAME("Form"); // NOI18N

SETRESIZABLE(false);

javax.swing.ACTIONMAP ACTIONMAP = org.jdesktop.application.Application.GETINSTANCE(stock.STOCKAPP.class).GETCONTEXT().GETACTIONMAP(ADDSHIPMENTDIALOG.class, this);

BTNREGISTER.SETACTION(ACTIONMAP.get("REGISTERCLICK")); // NOI18N

BTNREGISTER.SETTEXT("Add Shipment");

BTNREGISTER.SETNAME("BTNREGISTER"); // NOI18N

BTNREGISTER.ADDMOUSELISTENER(new java.awt.event.MOUSEADAPTER() { public void MOUSECLICKED(java.awt.event.MOUSEEVENT evt) {

BTNREGISTERMOUSECLICKED(evt);

}

});

JLABEL4.SETTEXT("Product");

JLABEL4.SETNAME("JLABEL4"); // NOI18N

LBLSTATUS.SETNAME("LBLSTATUS"); // NOI18N

DROPDOWNPRODUCT.SETMODEL(GETPRODUCTSMODEL());

DROPDOWNPRODUCT.SETNAME("DROPDOWNPRODUCT"); // NOI18N

DATECHOOSER.SETDATE(new Date());

DATECHOOSER.SETNAME("DATECHOOSER"); // NOI18N

SPINQUANTITY.SETMODEL(new javax.swing.SPINNERNUMBERMODEL(Integer.VALUEOF(1), Integer.VALUEOF(1), null, Integer.VALUEOF(1)));

SPINQUANTITY.SETNAME("SPINQUANTITY"); // NOI18N

DROPDOWNPERSON.SETMODEL(GETEMPLOYEEMODEL());

DROPDOWNPERSON.SETNAME("DROPDOWNPERSON"); // NOI18N

JLABEL1.SETTEXT("Quantity");

JLABEL1.SETNAME("JLABEL1"); // NOI18N

JLABEL2.SETTEXT("Date");

JLABEL2.SETNAME("JLABEL2"); // NOI18N

JLABEL3.SETTEXT("Responsible person");

JLABEL3.SETNAME("JLABEL3"); // NOI18N javax.swing.GROUPLAYOUT layout = new javax.swing.GROUPLAYOUT(GETCONTENTPANE());

GETCONTENTPANE().SETLAYOUT(layout);

layout.SETHORIZONTALGROUP( layout.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())

);

layout.SETVERTICALGROUP( layout.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())

);

pack();

}// private void BTNREGISTERMOUSECLICKED(java.awt.event.MOUSEEVENT evt) {

Product product = (Product) DROPDOWNPRODUCT.GETSELECTEDITEM();

int quantity = (Integer) SPINQUANTITY.GETVALUE();

Date date = DATECHOOSER.GETDATE();

Employee person = (Employee) DROPDOWNPERSON.GETSELECTEDITEM();

if (quantity <= 0) {

LBLSTATUS.SETTEXT("Quantity must be positive");

return;

} if (product == null) {

LBLSTATUS.SETTEXT("Select a product please");

return;

} if (person == null) {

LBLSTATUS.SETTEXT("Select a responsive person please");

return;

}

// Positive for incoming goods, negative for outcoming quantity = QUANTITYRATIO * quantity;

Product p = STOCKDATABASE.GETINSTANCE().GETPRODUCTS().GETPRODUCTBYID(product.GETID());

if (quantity < 0 && p.GETQUANTITYINSTOCK() < Math.abs(quantity)) {

// trying to take TOO MUCH from stock...

LBLSTATUS.SETTEXT("There are only " p.GETQUANTITYINSTOCK() " items of this product in stock.");

return;

}

Shipment shipment = new Shipment();

shipment.SETPRODUCTID(product);

shipment.SETQUANTITY(quantity);

shipment.SETDATETIME(date);

shipment.SETRESPONSIBLEPERSONID(person);

if (STOCKDATABASE.GETINSTANCE().GETSHIPMENTS().INSERTSHIPMENT(shipment)) {

//success

SETVISIBLE(false);

} else {

LBLSTATUS.SETTEXT("An error occured");

return;

}

}

/**

* @param args the command line arguments

*/ public static void main(String args[]) { java.awt.EVENTQUEUE.INVOKELATER(new Runnable() { public void run() { new ADDSHIPMENTDIALOG().SETVISIBLE(true);

}

});

}

// Variables declaration - do not modify private javax.swing.JBUTTON BTNREGISTER;

private com.toedter.calendar.JDATECHOOSER DATECHOOSER;

private javax.swing.JCOMBOBOX DROPDOWNPERSON;

private javax.swing.JCOMBOBOX DROPDOWNPRODUCT;

private javax.swing.JLABEL JLABEL1;

private javax.swing.JLABEL JLABEL2;

private javax.swing.JLABEL JLABEL3;

private javax.swing.JLABEL JLABEL4;

private javax.swing.JLABEL LBLSTATUS;

private javax.swing.JSPINNER SPINQUANTITY;

// End of variables declaration

}

Размещено на .ru
Заказать написание новой работы



Дисциплины научных работ



Хотите, перезвоним вам?