0% found this document useful (0 votes)
3 views12 pages

Java Sales Transaction Form Guide

This document presents the instructions for developing a Java application with a transaction form for the sales process. The form will allow operations such as creating a new sales record, searching for a customer or product, adding them to the sale, and recording the sale. Five steps are explained: 1) design the form, 2) code general elements, 3) program searches for customers and products, 4) program sales registration, and 5) include utilities such as updating stock. The objective is

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views12 pages

Java Sales Transaction Form Guide

This document presents the instructions for developing a Java application with a transaction form for the sales process. The form will allow operations such as creating a new sales record, searching for a customer or product, adding them to the sale, and recording the sale. Five steps are explained: 1) design the form, 2) code general elements, 3) program searches for customers and products, 4) program sales registration, and 5) include utilities such as updating stock. The objective is

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Unit: Concurrent Programming Workshop JAVA

Guide No. 8 Transaction Form

TRANSACTION FORM
SALES FORM

Contents

In this guide, the student will learn to develop/compile an application that


will present a transaction form of the sales process, which will allow
perform basic operations such as creating a new sales record, searching for a
customer, search and add products, record a sale, etc.

Specific Objectives

Learn about the use of JavaSQL libraries.


Know the SQL commands for performing a secure update.
Create several queries of different types.
Generate a new code based on the data from the database.
Use global variables to share information between methods.
Create a report in iReport and display it in the Java application.

Materials and Equipment

Regarding the necessary tools and software:

JDK
XAMPP
NetBeans
iReport

For this practice, it is necessary to have the mysql library or rather the JDBC.
MySql driver, associate it with the iReport plugin.

Theoretical Foundation

A transaction form is a form that allows not only to carry out tasks
specific but often combines functions from another Form, this means that
to have direct access to the fields of the table of a specific record. In addition to
allow to perform the most delicate operations such as updates.

Application with Transaction Form with data access

Page 1
Unit. Concurrent programming workshop JAVA
Guide No. 8 Transaction Form

First, we will create the Sales JFrame form. Then we will create the JFrame form.
See Report, which complements the form to display the sale in a format prior to the
impression.

Step 1: Create a Master Detail Sales Form

1. Create a JFrame Form named frmMaestroDetalleVentas.


2. Design the form in the following way.

Component Variable Name


Search Customer Panel
JTextField Customer Name txtBuscarCliente
JTable Search customer ClientTable
Button Add customer addClientButton
Product Search Panel
Text Field Product Name txtBuscarProducto
JTable Search client ClientTable
Add product button addProductBtn
Unit price JTextField txtPrecio
JTextField Quantity Quantity
Sales register panel
JTextField Registration No. searchProduct
Ballot JRadioButton optTicket
Ballot JRadioButton optInvoice

Page 2
[Link] Programming Workshop JAVA
Guide No. 8 Transaction Form

JTextField Receipt/Invoice No. txtNumComprobante


Label date lblFechaCompra
Client JTextField txtClient
Document JTextField documentTxt
JTextField Address txtDireccion
Text Area Phone txtTelefono
New Button btnNew
Save Button btnSave
Print Button btnImprimir
JButton Cancelar btnCancelar
JTable Sales Detail DetailTable
Remove product button btnRemove
JTextField Sub Total txtSubTotal
JTextField IGV txtIgv
JTextField Total to pay total to pay
JTextArea Import txtAmount
Change JTextField Change

Step 2: General coding to use the objects.

● We are going to proceed to program. We start by using the sql package, which
will allow us to access the database, then we will use the swing package,
specifically to the JOptionPane classes to display dialog boxes and
for the DefaultTableModel, DefaultComboBoxModel for the models of the
JTable and JComboBox controls.

● Then we proceed to create the general use variables for the connection and for the
management
of the table This lo we do inside of the class
frmSalesDetailMaster.

Page 3
[Link] programming workshop JAVA
Guide No. 8 Transaction Form

● In the constructor method, we program the following (just write what is indicated)
the red key)

Page 4
[Link] Programming Workshop JAVA
Guide No. 8 Transaction Form

Con este código configuramos los títulos y asociamos los modelos de las tablas sus
respective JTables. Then we will create the connection to the database.

Step 3: Programming the basic operations of customer search and


products.

● First, we will program the method to search for clients, we do this


directly in the eventKeyReleased of controltxtBuscarCliente. This
method will allow querying the database for customer records that
match the search parameters and will display them in the clients table.

Page 5
Unit: Concurrent Programming Workshop JAVA
Guide No. 8 Transaction Form

● Then we will program the part where the user selects an item.
resulting from clicking on the table. We do this in the event
MouseClicked delete controlTableClient.

● Finally, we will program the action of adding the customer to the sales record.

Page 6
Unit: Concurrent Programming Workshop JAVA
Guide No. 8 Transaction Form

● Second: just like the find client method, we will program the method to
search products, we do this directly in the eventKeyReleased
controltxtBuscarProducto.

● Then we will program the part where the user selects an element.

Page 7
[Link] de programación concurrente JAVA
Guide No. 8 Transaction form

resulting from clicking on the table. We do this in the event


MouseClicked del control TableProduct.

● Finally, we will program the action of adding the products to the sales detail.

● So far, the functionality to add products is working correctly, but

Page 8
Unit: Concurrent Programming Workshop JAVA
Guide No. 8 Transaction Form

we need to know how much we are adding to the total when each one is added
the products, that is why we implemented a method to calculate the totals.

● Likewise, we need a method to remove those products that were


entered by mistake, or that the customer wishes to cancel. For this we use a button
callbtnQuit which we will program within its eventActionPerformed.

Step 4: Programming the main operations of the sales register.

● First: every sale generates a new record and simultaneously controls the number
sequential of the payment vouchers, if it is a receipt, it will have a number
sequential and if it is an invoice it will have a different numbering. Such numbering will

they are found in the same table, so a prior filter must be made on the
insertion of a new sale. We do this through the button btnGuardar,
eventActionPerformed, in which we will code the following:

Page 9
[Link] Programming Workshop JAVA
Guide No. 8 Transaction Form

Page 10
[Link] Programming Workshop JAVA
Guide No. 8 Transaction Form

● In the button btnGuardar, event ActionPerformed, we will code the actions of


keep the sales record and its details:

● This button btnGuardar depends on a procedure created in the event


formWindowsActivated del JFrame Form, event that occurs when the
The form is activated.

Page 11
[Link] Programming Workshop JAVA
Guide No. 8 Transaction Form

Step 4: Programming some reusable utilities.

● We will create a method to remove the rows of the models from the tables.

● We will create another method to update the stock in the product table, this will happen
Every time a sales detail is saved, that is, a product.

Step 5: Test.

● Now we can test the application

Page 12

You might also like