id
stringlengths 12
33
| content
stringlengths 979
35k
| summary
stringlengths 0
1.65k
| layer
stringclasses 2
values |
|---|---|---|---|
F-GES-01.txt
|
Requisito numero:
F-GES-01
Tipo:
Funzionale
Requisito:
Gestione dei prezzi delle camere.
Descrizione:
Per ogni camera deve essere possibile stabilire il suo prezzo base. Questo
prezzo deve essere impostabile dal gestore dell'albergo ogni qual volta egli lo
ritenga opportuno. Se si desidera modificare il prezzo base di una stanza che
in quel momento risulta occupata, il sistema dovrà avvisare l'operatore con un
messaggio per evitare che il cliente si lamenti di non aver pagato quanto
pattuito.
Input richiesto:
Si dovrà inserire l'identificatore di stanza e il prezzo ad essa relativo.
Output desiderato:
Conferma a video della modifica avvenuta, o eventuali messaggi di errore.
Criterio di accettazione:
Si deve poter accedere alla modifica del listino delle camere in ogni momento,
richiamare ogni stanza attraverso un opportuno identificatore (es. numero di
stanza); se la stanza richiesta non esiste dovrà essere visualizzato un
messaggio d'errore. Se la stanza risulta occupata, dovrà essere avvisato
l'operatore che sta facendo un'operazione rischiosa.
Aspettative collegate:
Supervisione e gestione dei prezzi delle stanze.
Requisiti collegati:
F-SOG-04, F-GES-05.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Finale
2
Richiesto
Stabile
Piena comprensione
Software
Versione: 2.1
Data: 04/04/1998
Compilato da: Martini Roberto
Note:
|
Requirement
|
|
F-GES-02.txt
|
Requisito numero:
F-GES-02
Tipo:
Funzionale
Requisito:
Gestione dei prezzi dei servizi e spese extra.
Descrizione:
Il sistema metterà a disposizione dell'utente le funzionalità necessarie alla
gestione del listino prezzi dei servizi extra. Dovrà quindi essere possibile
visualizzare il listino, apportare delle modifiche ai prezzi e inserire nuove
voci. Verrà anche prevista un campo "jolly" per gestire eventuali voci rare per
le quali non è conveniente prevedere una gestione specifica.
Input richiesto:
Dati del bene o servizio che si intende modificare.
Output desiderato:
Conferma della modifica effettuata e listino completo.
Criterio di
accettazione:
Si deve poter inserire il codice del servizio di cui si intende modificare il
prezzo. Il sistema ritornerà errore nel caso in cui nessuna corrispondenza sia
verificata, altrimenti restituirà i dati relativi al servizio e la possibilità di
modificarne il prezzo.
Aspettative collegate:
Supervisione e gestione dei prezzi dei servizi offerti.
Requisiti collegati:
F-SOG-02.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Finale
2
Richiesto
Stabile
Piena comprensione
Software
Versione: 2.2
Data: 01/04/1998
Compilato da: Vincenti Paola
Note:
|
Requirement
|
|
F-GES-03.txt
|
Requisito numero:
F-GES-03
Tipo:
Funzionale
Requisito:
Gestione archivio storico dei clienti.
Descrizione:
Il sistema deve tenere alcuni dati del cliente per tutto l'anno successivo a
quello di soggiorno. Se un cliente è già presente nell'elenco, dovranno essere
aggiornati i suoi dati. Nell’archivio saranno inseriti: nome, cognome e
indirizzo del cliente e il numero dell’ultima stanza da lui occupata
nell’albergo. Deve inoltre essere possibile recuperare e visualizzare i dati
contenuti nell’archivio storico perché l’albergatore possa avere informazioni a
lui utili in qualsiasi momento ne abbia necessità.
Input richiesto:
I dati del cliente che si ritiene utile salvare verranno presi dall'archivio clienti.
Output desiderato:
Aggiornamento archivio storico clienti.
Criterio di
accettazione:
I dati devono durare nell’archivio almeno fino alla fine dell'anno seguente a
quello di inserimento. Se un cliente è già presente nell'archivio i suoi dati
verranno aggiornati in base all'ultimo soggiorno.
Aspettative collegate:
Poter mantenere il contatto con i clienti più recenti al fine di promuovere e
pubblicizzare le offerte dell'albergo per la stagione seguente.
Requisiti collegati:
nn.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Finale
2
Richiesto
Stabile
Piena comprensione
Software
Versione: 2.1
Data: 10/04/1998
Compilato da: Meneghini Matteo
Note:
|
Requirement
|
|
F-GES-04.txt
|
Requisito numero:
F-GES-04
Tipo:
Funzionale
Requisito:
Configurazione delle opzioni di sistema.
Descrizione:
Alcuni parametri e dati che il sistema utilizza per svolgere le attività per cui è
stato realizzato devono poter essere impostate dal gestore dell'albergo. Dovrà
essere prevista perciò la possibilità di configurare il sistema in base alle
esigenze dell'utente. Ciò che dovrà sicuramente comparire sono le seguenti
impostazioni:
date di inizio e fine delle varie stagionalità
sconti e riduzioni da effettuare a neonati e bambini
durata massima per la quale una stanza può restare bloccata
supplemento per le varie stagionalità
costo di uno scatto telefonico
Input richiesto:
I dati di configurazione con le modifiche ritenute opportune dal gestore.
Output desiderato:
Aggiornamento configurazione di sistema.
Criterio di
accettazione:
I dati dovranno influire sulla gestione dell'albergo in base all'area di
competenza. Es. se viene previsto uno sconto per i bambini tale sconto dovrà
apparire chiaramente nel calcolo del conto finale e nella sua stampa.
Aspettative collegate:
Permettere una maggiore flessibilità al sistema.
Requisiti collegati:
F-PRE-03, F-SOG-03, F-SOG-04, F-GES-01
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Sospeso
2
Opzionale
Stabile
Piena comprensione
Software
Versione: 2.1
Data: 15/04/1998
Compilato da: Martini Roberto
Note:
|
Requirement
|
|
F-PRE-01.txt
|
Requisito numero:
F-PRE-01
Tipo:
Funzionale
Requisito:
Ricerca di camere disponibili.
Descrizione:
Permette di elencare tutte le stanze disponibili nel periodo richiesto dal
cliente. Nel caso non vi siano stanze disponibili esattamente in quel periodo
verrà mostrata la disponibilità di stanze in modo che l'operatore sia in grado
di fornire un suggerimento al cliente su come spostare o ridimensionare il
periodo di permanenza. Tale periodo è un intervallo di tempo espresso come
giorni che intercorrono tra due date. Ad esempio il periodo dal 05/07/1998 al
11/07/1998 implica 7 giorni di permanenza con liberazione della stanza il
giorno 12/07/1998 mattina, quindi già a partire da quel giorno la stanza deve
essere resa disponibile per eventuali altre prenotazioni. La fase di ricerca delle
camere disponibili, dovrà tenere conto dei vincoli imposti come stanze
bloccate, assegnate o commissionate ad agenzie viaggi.
Le prenotazioni fornite da un'agenzia dovranno prima di tutto coprire i
commissionamenti. Quando le stanze commissionate non permettono più
alcuna prenotazione, si potrà ricercare stanze disponibili tra quelle non
commissionate.
Input richiesto:
Periodo scelto per la permanenza.
Output desiderato:
Output a video delle disponibilità dell'albergo o di una tabella che riassuma la
disponibilità dell'albergo.
Criterio di
accettazione:
Dato un intervallo di tempo espresso da due date, il sistema dovrà ritornare
l'elenco di tutte le camere disponibili in quel periodo. Nel caso di nessuna
disponibilità esatta verrà mostrata a video una tabella che metterà in evidenza
le disponibilità dell'albergo.
Nel caso di prenotazione tramite agenzia, dovranno essere visualizzate le
stanze commissionate, ed eventualmente tutte le altre stanze.
Aspettative collegate:
Pronta verifica delle disponibilità dell'albergo.
Requisiti collegati:
F-PRE-02, F-PRE-03, F-PRE-04.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Finale
2
Richiesto
Stabile
Piena comprensione
Software
Versione: 4.0
Data: 16/04/1998
Compilato da: Martini Roberto
Note:
|
Requirement
|
|
F-PRE-02.txt
|
Requisito numero:
F-PRE-02
Tipo:
Funzionale
Requisito:
Prenotazione di camere da parte di un cliente.
Descrizione:
Quando un cliente effettua una prenotazione è necessario poter evidenziare
che la camera che egli desidera e per il periodo da lui scelto venga bloccata.
Nel caso in cui il cliente sia un habitué o un amico deve essere possibile
assegnargli direttamente la camera e quindi accertarsi che essa è stata
assegnata.
Input richiesto:
È necessario conoscere le stanze disponibili che possono soddisfare le richieste
del cliente (disponibilità nel periodo da lui richiesto, possibilità di avere il
letto aggiuntivo, vista mare/valle). Inoltre è necessario conoscere i dati forniti
dal cliente stesso e che permettono la sua prenotazione (vedi dati
prenotazione).
Output desiderato:
Registrazione della prenotazione e bloccaggio (o assegnamento) della stanza
per il periodo accordato.
Criterio di
accettazione:
Dopo che una prenotazione viene accettata la stanza dovrà risultare bloccata o
assegnata e perciò sottratta dalle disponibilità dell'albergo per il periodo
relativo alla prenotazione.
Aspettative collegate:
L'albergatore si aspetta in questo modo di avere un quadro generale della
situazione del suo albergo, di poter visualizzare in modo semplice la
situazione delle varie stanze ovvero di vedere se una stanza è bloccata,
assegnata, commissionata o disponibile, di avere un minimo di informazioni
per poter provvedere ad accogliere il cliente in modo adeguato e poter allo
stesso tempo organizzare il suo lavoro. Es.: se il cliente al momento della
prenotazione non ha fatto richiesta del letto aggiuntivo, ma in realtà lo
desidera e al momento del suo arrivo le stanze che permettono di supportare
il letto aggiuntivo sono occupate non si potrà più soddisfare la richiesta del
cliente.
Requisiti collegati:
F-PRE-01, F-PRE-03, F-PRE-04, F-PRE-05, F-PRE-06.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Finale
2
Richiesto
Stabile
Piena comprensione
Software
Versione: 2.0
Data: 30/03/1998
Compilato da: Danzi Francesca
7Note:
|
Requirement
|
|
F-PRE-03.txt
|
Requisito numero:
F-PRE-03
Tipo:
Funzionale
Requisito:
Gestione delle camere bloccate.
Descrizione:
Se al momento della prenotazione una stanza viene bloccata, tale stanza
rimarrà in quello stato per un certo periodo di tempo fissato (vedi F-GES-04)
dalla gestione dell'albergo. Trascorso tale periodo verrà inviato un messaggio
che faccia comprendere che la stanza è bloccata da troppo tempo in modo che
ci si possa informare se il ritardo è dovuto a un contrattempo del cliente
oppure se egli non intende più soggiornare nell'albergo. Nel primo caso si
provvederà a rinnovare il bloccaggio della stanza, mentre nel secondo a
cancellare la prenotazione. Una volta arrivata la caparra del cliente deve
essere possibile passare la stanza da bloccata ad assegnata.
Input richiesto:
Situazione delle stanze.
Output desiderato:
Situazione aggiornata delle stanze.
Criterio di
accettazione:
Trascorso il numero di giorni fissati dall'albergatore a partire dal giorno della
prenotazione il sistema dovrà garantire che:
una stanza bloccata sia passata a stato di assegnata;
venga visualizzato un messaggio che avvisi della situazione di ritardo
di pagamento della caparra.
Aspettative collegate:
L’albergatore si aspetta di poter tenere sotto controllo la situazione delle
stanze bloccate in modo tale che una camera non rimanga troppo a lungo in
tale stato rischiando di far perdere altri potenziali clienti all’albergo.
Requisiti collegati:
F-PRE-02, F-GES-04.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Finale
2
Richiesto
Stabile
Piena Comprensione
Software
Versione: 2.0
Data: 30/03/1998
Compilato da: Danzi Francesca
Note:
|
Requirement
|
|
F-PRE-04.txt
|
Requisito numero:
F-PRE-04
Tipo:
Funzionale
Requisito:
Gestione delle stanze commissionate ad agenzia.
Descrizione:
Alcune delle stanze dell’albergo per determinati periodi potrebbero essere date
in gestione ad una agenzia viaggi, in questo caso tali stanze risulteranno per
quei periodi commissionate, quindi non disponibili. Quando l’agenzia invia
delle prenotazioni deve essere possibile passare le stanze da commissionate ad
assegnate, ovviamente solo per il periodo della prenotazione. Le stanze
commissionate diventeranno disponibili, nel caso in cui nessuna prenotazione
giunga dall'agenzia entro la data concordata al momento della stipulazione del
contratto di commissionamento.
Input richiesto:
Informazioni sugli accordi presi con le agenzie ovvero numero di stanza
commissionata, periodo di commissionamento (data di inizio e di fine), data
dopo la quale la stanza, se non occupata, può essere considerata disponibile.
Output desiderato:
Situazione aggiornata delle stanze.
Criterio di
accettazione:
L’albergatore dovrà poter inserire informazioni relative agli accordi con
l’agenzia (data di inizio e fine commissione delle stanze) e verificare il loro
effettivo commissionamento. Inoltre si deve poter verificare che, se dopo la
data concordata con l’agenzia le stanze non sono ancora state occupate, esse
risultino allora disponibili.
Aspettative collegate:
Si desidera poter dare in gestione alcune stanze ad una agenzia e poter tenere
sotto controllo la situazione in modo tale che se l’agenzia non riesce ad
occuparle, entro la data concordata possano essere considerate disponibili.
Requisiti collegati:
F-PRE-01, F-PRE-02.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Finale
2
Richiesto
Stabile
Piena comprensione
Software
Versione: 2.1
Data: 15/04/1998
Compilato da: Danzi Francesca
Note:
|
Requirement
|
|
F-PRE-05.txt
|
Requisito numero:
F-PRE-05
Tipo:
Funzionale
Requisito:
Cancellazione di una prenotazione.
Descrizione:
A partire dai dati forniti dal cliente deve essere possibile disdire una
prenotazione. In tal caso le stanze che erano in stato di bloccato o assegnato
torneranno ad essere disponibili. Se le stanze per le quali è stato richiesto
l'annullamento della prenotazione erano state date in gestione ad un'agenzia
viaggi esse dovranno:
riassumere lo stato di commissionate nel caso in cui la data di disdetta sia
precedente alla data stabilita tra albergatore e agenzia come scadenza del
commissionamento;
ritornare ad essere disponibili nel caso in cui tale data sia altrepassata.
Input richiesto:
Nominativo del cliente che era stato lasciato al momento della prenotazione.
Output desiderato:
Modifica dello stato delle stanze che erano state prenotate ed eliminazione
della prenotazione dall'elenco delle prenotazioni.
Criterio di
accettazione:
Se i dati forniti corrispondono a quelli di una prenotazione esistente, essa
viene visualizzata e, dopo una richiesta di conferma, cancellata e lo stato delle
stanze coinvolte cambiato in disponibile (o commissionata). Se al contrario
non esiste una corrispondenza nell'elenco viene visualizzato un messaggio di
errore e viene data la possibilità di modificare i dati forniti o di annullare
l'operazione.
Aspettative collegate:
Cancellazione della prenotazione con conseguente aggiornamento a stanza
disponibile. Se la prenotazione da eliminare risulta inesistente un messaggio a
video ci avviserà dell'errore verificatosi.
Requisiti collegati:
F-PRE-02.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Finale
1
Richiesto
Stabile
Piena comprensione
Software
Versione: 1.2
Data: 31/03/1998
Compilato da: Colombari Andrea
Note:
|
Requirement
|
|
F-PRE-06.txt
|
Requisito numero:
F-PRE-06
Tipo:
Funzionale
Requisito:
Modifica di una prenotazione.
Descrizione:
Deve essere possibile apportare delle modifiche ad una prenotazione già
registrata nel sistema. Tali modifiche dovranno naturalmente aggiornare la
prenotazione del cliente nonché le disponibilità dell'albergo nel caso in cui sia
stato ritoccato il periodo di soggiorno.
Input richiesto:
Sarà richiesto il nominativo del cliente fornito al momento della prenotazione
e il tipo di modifica che vuole apportare.
Output desiderato:
Modifica della prenotazione esistente ed eventualmente delle disponibilità
dell'albergo.
Criterio di
accettazione:
Quando si cerca un prenotazione da modificare, se essa non esiste deve essere
mostrato un messaggio d'errore altrimenti devono essere mostrati i dati della
prenotazione precedente. Effettuate tutte le modifiche verrà richiesta la loro
conferma.
Aspettative collegate:
Modifica della prenotazione esistente.
Requisiti collegati:
F-PRE-02, F-PRE-05.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Finale
1
Opzionale
Stabile
Piena comprensione
Software
Versione: 1.2
Data: 09/04/1998
Compilato da: Martini Roberto
Note:
|
Requirement
|
|
F-RIS-01.txt
|
Requisito numero:
F-RIS-01
Tipo:
Funzionale
Requisito:
Gestione del servizio ristorante per clienti esterni.
Descrizione:
Il sistema dovrà essere in grado di gestire la contabilità immediata di un
normale ristorante i cui clienti non sono necessariamente soggiornanti
nell’hotel.
Il sistema dovrà essere quindi in grado di:
fornire i prezzi delle portate singole perché il cliente esterno non sia
vincolato alla scelta del menù fisso previsto per i soggiornanti;
accettare in ingresso le varie portate consumate;
stampare la ricevuta in base all'elenco delle consumazioni.
Input richiesto:
Dati relativi al cliente (numero persone, portate e bevande consumate,
modalità di pagamento).
Output desiderato:
Stampa del conto relativo alle consumazioni.
Criterio di
accettazione:
Tale requisito è soddisfatto se il sistema fornisce all’utente la possibilità di
visualizzare, modificare, aggiornare e stampare il conto del servizio di
ristorazione.
Aspettative collegate:
Semplice gestione dell'attività di ristorazione.
Requisiti collegati:
nn.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Stabile
2
Richiesto
Stabile
Piena comprensione
Organizzazione
Versione: 2.2
Data: 29/03/1998
Compilato da: Girelli Daria
Note:
|
Requirement
|
|
F-SOG-01.txt
|
Requisito numero:
F-SOG-01
Tipo:
Funzionale
Requisito:
Gestione dell'arrivo di un cliente.
Descrizione:
All'arrivo di un cliente possono verificarsi le seguenti eventualità:
1. se il cliente ha precedentemente prenotato allora dalla prenotazione si
risale al numero delle camere che andrà ad occupare e la prenotazione verrà
cancellata dall'elenco delle prenotazioni;
2. se il cliente non ha precedentemente prenotato si procederà come se fosse
in atto una prenotazione, cioè:
a) si ricerca una camera disponibile;
b) nel caso l'esito sia favorevole, la si assegna al cliente per il periodo
specificato.
1. Il nuovo cliente richiede di aggiungersi a coloro che già occupano una
certa stanza.
A questo punto a partire dalle stanze assegnate (o tramite prenotazione o al
momento), si inseriscono nell'archivio degli ospiti, camera per camera, i dati
delle persone che vi soggiorneranno. Tali dati comprenderanno, oltre ai dati
personali (facoltativi per neonati, bambini e ragazzi che soggiornano con
adulti), il tipo di pensionamento (questo permette di avere persone con tipo di
pensionamento diverso in una stessa stanza). Deve essere anche possibile
distinguere i clienti che rientrano nelle categorie di neonati e bambini per
rendere possibile l'applicazione di eventuali sconti. Alle varie stanze che
vengono così ad essere utilizzate verrà dato l'appellativo di occupate.
Input richiesto:
Dati personali dei vari occupanti.
Output desiderato:
Aggiornamento archivio dei clienti e modifica dello stato delle stanze.
Criterio di
accettazione:
Se dai dati forniti dal cliente non si riesce a risalire alla prenotazione verrà
visualizzato un messaggio di errore e verrà chiesto di ripetere l'operazione o
annullarla. Se si tenta di inserire in una stanza piena un'ulteriore persona
apparirà un messaggio di avvertimento.
Aspettative collegate:
Conoscere per ogni stanza i dati di coloro che vi alloggiano.
Requisiti collegati:
F-PRE-01, F-PRE-02.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Finale
2
Richiesto
Stabile
Piena comprensione
Software
Versione: 2.1
Data: 04/04/1998
Compilato da: Colombari Andrea
Note:
|
Requirement
|
|
F-SOG-02.txt
|
Requisito numero:
F-SOG-02
Tipo:
Funzionale
Requisito:
Addebito servizi e spese extra per stanza.
Descrizione:
Tale requisito permette di valutare le eventuali spese extra effettuate dai
clienti occupanti una certa stanza e di addebitare i relativi prezzi sul conto-
spese previsto per ogni stanza. Il sistema dovrà quindi essere in grado, una
volta fissati i prezzi relativi ad ogni bene o servizio, di fornire al momento
della loro richiesta il relativo costo e di addebitarlo sul conto-spese delle
stanze i cui occupanti hanno usufruito di tale servizio.
Input richiesto:
Tipo e quantità del bene consumato.
Output desiderato:
Addebito sul conto-spese della stanza del consumatore.
Criterio di
accettazione:
Per soddisfare tale requisito il sistema dovrà tenere traccia di ogni spesa o
servizio extra di cui il cliente usufruisce. Tali informazioni dovranno essere
poi recuperate ogni qual volta un cliente richieda l'ammontare del conto.
Aspettative collegate:
Contabilizzazione automatica delle spese straordinarie.
Requisiti collegati:
F-SOG-04.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Finale
2
Richiesto
Stabile
Piena comprensione
Efficienza
Versione: 2.1
Data: 15/04/1998
Compilato da: Vincenti Paola
Note:
|
Requirement
|
|
F-SOG-03.txt
|
Requisito numero:
F-SOG-03
Tipo:
Funzionale
Requisito:
Addebito della spesa telefonica.
Descrizione:
Vista la normativa interna dell’hotel, che prevede il servizio telefonico in
camera indipendentemente dal tipo di soggiorno, deve essere possibile tener
conto del numero di scatti effettuati dal cliente a partire dall’inizio del
soggiorno. Tale numero moltiplicato al costo del singolo scatto, stabilito dal
proprietario, fornirà l’addebito della spesa telefonica che andrà poi ad
aggiungersi al conto totale del soggiorno.
Input richiesto:
Dati telefonate forniti dal centralino telefonica.
Output desiderato:
Addebito spesa telefonica.
Criterio di
accettazione:
Il sistema deve essere in grado di comunicare con il centralino e tener traccia
delle informazioni di una telefonata effettuata dal cliente durante il soggiorno
con relativo addebito della spesa. Tali informazioni dovranno essere
reperibili al momento della richiesta del conto.
Aspettative collegate:
L’albergatore si aspetta di poter controllare il sistema telefonico dell’hotel
ricavandone il vantaggio di disporre del costo telefonico da aggiungere al
conto totale del soggiorno al termine di quest’ultimo.
Requisiti collegati:
F-SOG-04, F-GES-05.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Finale
2
Richiesto
Stabile
Piena comprensione
Software
Versione: 2.1
Data: 16/04/98
Compilato da: Girelli Daria
Note: Non è richiesta l'interfaccia con il centralino perché questa per ordine di chi ha commissionato la
realizzazione di questo progetto verrà simulata con una piccola routine software.
|
Requirement
|
|
F-SOG-04.txt
|
Requisito numero:
F-SOG-04
Tipo:
Funzionale
Requisito:
Calcolo del conto complessivo.
Descrizione:
Al momento in cui lo si richiede si devono recuperare:
1. ammontare spese di soggiorno
2. ammontare spese telefoniche
3. ammontare spese per servizi extra
Successivamente si deve fornire a video l’ammontare parziale per ogni voce
sopraindicata e l'ammontare totale. Si deve inoltre poter facilmente
distinguere i tre totali parziali in modo da fornire al cliente l’informazione che
desidera. All’interno delle spese dei pernottamenti sono compresi i pasti
concordati in base al tipo di soggiorno.
Si distinguono 4 diversi casi:
- Calcolo totale del conto su un’unica stanza.
- Calcolo del conto separato nel caso in cui uno (o alcuni) tra gli
occupanti una certa stanza debba, per qualche motivo, lasciare l'albergo
in anticipo rispetto alla data prevista. In questo caso deve poter essere
applicato un supplemento per stanze parzialmente utilizzate. Nel conto
saranno escluse le spese extra che verranno poi riversate nel conto finale.
- Calcolo totale del conto su più stanze.
- Calcolo del conto per clienti mandati da un'agenzia. In questo caso il
conto consisterà solamente delle spese telefoniche e delle spese per
servizi e spese extra.
Input richiesto:
Dati di uno o più clienti, o numeri di una o più stanze.
Output desiderato:
Stampa a video del conto richiesto.
Criterio di
accettazione:
Si richiede la visualizzazione delle spese accumulate da parte dei clienti
dell’albergo quando se ne necessita.
Aspettative collegate:
Immediato resoconto del debito accumulato dal cliente fino al momento della
richiesta del conto.
Requisiti collegati:
F-SOG-02, F-SOG-03, F-SOG-05, F-GES-01.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Finale
1
Richiesto
Stabile
Piena comprensione
Software
Versione: 2.0
Data: 02/04/1998
Compilato da: Meneghini Matteo
Note:
|
Requirement
|
|
F-SOG-05.txt
|
Requisito numero:
F-SOG-05
Tipo:
Funzionale
Requisito:
Stampa dell'ammontare conto.
Descrizione:
Al momento in cui il cliente sta per lasciare l'albergo si deve recuperare il
conto finale e provvedere alla sua stampa con questa forma:
VOCE NUM. AMM. L.
Persone #
Notti # ###
Scatti tel. # ###
PARZIALE1 #####
Desc. extra # ###
... ... ...
PARZIALE2 #####
-----------------------------------------------------------------------
TOTALE #######
Input richiesto:
Dati relativi al pernottamento presi dall'archivio dei clienti e delle stanze.
Output desiderato:
Stampa del conto.
Criterio di
accettazione:
La stampa deve riportare i dati visualizzati a video.
Aspettative collegate:
Chiara rappresentazione delle spese del cliente.
Requisiti collegati:
F-SOG-04.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Finale
1
Richiesto
Volatile
Piena comprensione
Software
Versione: 1
Data: 02/04/1998
Compilato da: Meneghini Matteo
Note:
|
Requirement
|
|
F-SOG-06.txt
|
Requisito numero:
F-SOG-06
Tipo:
Funzionale
Requisito:
Gestione del cambio di stanza.
Descrizione:
Nel caso in cui il cliente desideri o sia costretto (es. per un guasto) a cambiare
stanza di soggiorno, il sistema dovrà fornire tutti gli strumenti necessari
affinché ciò sia possibile.
Input richiesto:
Numero di stanza da lasciare, numero della nuova stanza da occupare
Output desiderato:
Modifica dell’informazione che indicava la stanza che occupavano i clienti
con il nuovo dato, modifica dello status delle stanze.
Criterio di
accettazione:
Quando viene accolta una richiesta di cambio di stanza si dovrà poter
verificare che i dati degli occupanti non si riferiscono più alla stanza in
precedenza occupata ma alla nuova stanza in cui soggiornano. Il
cambiamento di stanza coinvolgerà lo stato delle stanze modificandolo
opportunamente
Aspettative collegate:
Permettere un eventuale spostamento di stanza.
Requisiti collegati:
nn.
Stato
Release
Priorità
Stabilità
Livello di comprensione
Categoria
Finale
1
Richiesto
Stabile
Piena comprensione
Software
Versione: 1
Data: 28/04/1998
Compilato da: Martini Roberto
Note:
|
Requirement
|
|
AggiungiBeneServizio.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import moduli.*;
public class AggiungiBeneServizio extends InserisciBeniServizi
{
Button annulla1, annulla2, conferma1, conferma2;
TextField tf_supp, tf_rid, tf_stanza_supp, tf_stanza_rid, tf_mot_supp, tf_mot_rid;
Label label_supp, label_rid, label_stanza_supp, label_stanza_rid, label_mot_supp, label_mot_rid;
public AggiungiBeneServizio(Frame parent)
{
super("Creazione di un nuovo bene/servizio/riduzione/supplemento");
padre = parent;
padre.setEnabled(false);
setupNuovi();
inizializza();
setSize(450,600);
setVisible(true);
}
void setupNuovi()
{
//Creo i pannelli
remove(panel[0]);
panel[0] = new Panel();
panel[0].setLayout(grid1);
panel[0].setVisible(false);
//Creo il pannello in alto
label = new Label("Tipi");
label.setFont(ConfigurazioneSistema.font_titolo);
tipi = new CheckboxGroup();
panel[0].add(label);
panel[0].add(prima_scelta[0]);
panel[0].add(prima_scelta[1]);
panel[0].add(prima_scelta[2]);
panel[0].add(prima_scelta[3]);
panel[0].add(prima_scelta[4]);
panel[0].setVisible(true);
//Attacco il pannello in alto al frame
this.setLayout(grid);
this.add(panel[0]);
//Creo il pannello supplemento
panel[11].setLayout(gridbag);
label_supp = new Label("Ammontare del supplemento "+(Principale.config).getValuta()+".");
tf_supp = new TextField("", 10);
label_stanza_supp = new Label("A carico della stanza numero");
tf_stanza_supp = new TextField("", 6);
if (padre instanceof MascheraContoRistorazione)
tf_stanza_supp.setEnabled(false);
label_mot_supp = new Label("Motivazione");
tf_mot_supp = new TextField("", 35);
annulla1 = new Button("Annulla");
conferma1 = new Button("Conferma");
Utils.constrain(panel[11], label_supp, 0, 0, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[11], tf_supp, 1, 0, 4, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[11], label_stanza_supp, 0, 1, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[11], tf_stanza_supp, 1, 1, 4, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[11], label_mot_supp, 0, 2, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[11], tf_mot_supp, 1, 2, 4, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[11], annulla1, 1, 3, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.EAST, 0.0, 0.0, 5, 0, 5, 10);
Utils.constrain(panel[11], conferma1, 3, 3, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 5, 10, 5, 0);
//Creo il pannello riduzione
panel[12].setLayout(gridbag);
label_rid = new Label("Ammontare della riduzione "+(Principale.config).getValuta()+".");
tf_rid = new TextField("",10);
label_stanza_rid = new Label("A carico della stanza numero");
tf_stanza_rid = new TextField("", 6);
if (padre instanceof MascheraContoRistorazione)
tf_stanza_rid.setEnabled(false);
label_mot_rid = new Label("Motivazione");
tf_mot_rid = new TextField("", 35);
annulla2 = new Button("Annulla");
conferma2 = new Button("Conferma");
Utils.constrain(panel[12], label_rid, 0, 0, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[12], tf_rid, 1, 0, 4, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[12], label_stanza_rid, 0, 1, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[12], tf_stanza_rid, 1, 1, 4, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[12], label_mot_rid, 0, 2, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[12], tf_mot_rid, 1, 2, 4, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[12], annulla2, 1, 3, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.EAST, 0.0, 0.0, 5, 5, 5, 0);
Utils.constrain(panel[12], conferma2, 2, 3, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 0);
}
public void inizializza()
{
prima_scelta[3].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(prima_scelta[3].getState())
{
inComuneDE(11, BeneServizio.SUPPLEMENTI);
}
}
});
prima_scelta[4].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(prima_scelta[4].getState())
{
inComuneDE(12, BeneServizio.RIDUZIONI);
}
}
});
annulla1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
annulla2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
conferma1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
scriviSuDB( tf_supp.getText(), tf_stanza_supp.getText(), tf_mot_supp.getText() );
}
});
conferma2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
scriviSuDB( new String("-"+tf_rid.getText()), tf_stanza_rid.getText(), tf_mot_rid.getText() );
}
});
} // init
void inComuneDE(int numero_pannello, char c)
{
level = 0;
for(int i=1;i<13;++i)
{
if(panel[i].isVisible())
remove(panel[i]);
}
this.add(panel[numero_pannello]);
panel[numero_pannello].setVisible(true);
setVisible(true);
codice = composeCode(level, c);
}
void scriviSuDB(String sup_rid, String stanza, String mot)
{
MessageDialog msg;
completeCode();
Float px = Float.valueOf(sup_rid);
extra = new BeneServizio((new String(codice)) + tornaCodId((Principale.config).getIdBeneservizio()),
mot, px.floatValue());
if (padre instanceof MascheraAddebiti)
{
if ( ((Principale.db).readStanza(stanza) != null) && Utils.isFloatPos(sup_rid) && (mot.length() < 33) )
{
ListaSoggiornanti L_sogg = (Principale.db).foundSoggiornanti(stanza, false);
if (L_sogg != null)
{
if (!L_sogg.isEmpty())
{
int j;
if ((j = (Principale.db).newIdBeneservizio()) == DataBase.OK)
{
(Principale.config).updateIdBeneservizio();
if ((j = (Principale.db).writeBeneServizio(extra)) == DataBase.OK)
{
Addebito da_addebitare = new Addebito(stanza, extra.getCodExtra(),
1, px.floatValue());
if ((j = (Principale.db).writeAddebito(da_addebitare)) == DataBase.OK)
{
dispose();
if ( stanza.equals(((MascheraAddebiti) padre).stanza_prec) )
{
(((MascheraAddebiti) padre).elenco_addebiti).addAddebito(da_addebitare);
(((MascheraAddebiti) padre).elenco_extra_addebitati).addBeneServizio(extra);
/* travaso delle quantita modificate nel nuovo array per poi
aggiungere il supplemento o riduzione appena inseriti */
int nuove_quantita_mod[] = new int[((MascheraAddebiti) padre).elenco_addebiti.length()];
for (int i = 0; i < ((MascheraAddebiti) padre).quantita_mod.length; i++)
nuove_quantita_mod[i] = ((MascheraAddebiti) padre).quantita_mod[i];
nuove_quantita_mod[nuove_quantita_mod.length-1] = 0;
((MascheraAddebiti) padre).quantita_mod = nuove_quantita_mod;
((MascheraAddebiti) padre).continuaAggiornamento();
/* se il numero di stanza era stato cambiato senza addebiti
allora rimetto il precedente numero di stanza nel textfield
della finestra Addebiti */
}
if ( !(((MascheraAddebiti) padre).num_stanza.getText()).equals(((MascheraAddebiti) padre).stanza_prec) )
((MascheraAddebiti) padre).num_stanza.setText( ((MascheraAddebiti) padre).stanza_prec );
padre.setEnabled(true);
}
else
msg = new MessageDialog(this, "Errore nell'addebitare: "+DataBase.strErrore(j));
}
else
msg = new MessageDialog(this, "Problemi con il database: "+DataBase.strErrore(j));
}
else
msg = new MessageDialog(this, "Errore nell'aggiornamento: "+DataBase.strErrore(j));
}
else
msg = new MessageDialog(this, " La stanza inserita non e' occupata! ");
}
else
msg = new MessageDialog(this, " Problemi con il database! ");
}
else
msg = new MessageDialog(this, "Errore nei parametri!");
}
else
{ // si tratta della maschera del conto ristorazione
dispose();
Addebito da_addebitare = new Addebito("RIST", extra.getCodExtra(),
1, px.floatValue());
(((MascheraContoRistorazione) padre).elenco_addebiti).addAddebito(da_addebitare);
(((MascheraContoRistorazione) padre).elenco_extra_addebitati).addBeneServizio(extra);
/* travaso delle quantita modificate nel nuovo array per poi
aggiungere il supplemento o riduzione appena inseriti */
int nuove_quantita_mod[] = new int[((MascheraContoRistorazione) padre).elenco_addebiti.length()];
for (int i = 0; i < ((MascheraContoRistorazione) padre).quantita_mod.length; i++)
nuove_quantita_mod[i] = ((MascheraContoRistorazione) padre).quantita_mod[i];
nuove_quantita_mod[nuove_quantita_mod.length-1] = 1;
((MascheraContoRistorazione) padre).quantita_mod = nuove_quantita_mod;
((MascheraContoRistorazione) padre).continuaAggiornamento();
padre.setEnabled(true);
}
}
}
|
This code provides users with the ability to create new `goods/services/reductions/supplements` within the software system. The user can access this functionality through a graphical user interface (GUI) that is launched as a separate window. The GUI allows the user to select the type of item they want to create and then enter the required information, such as the amount, the room number, and the motivation. Once the user has entered the necessary details, they can click the `Confirm` button to save the new item to the database. If the user decides to cancel the operation, they can click the "Cancel" button to close the window.
The code also includes additional functionality, such as automatically generating a unique code for the new item, updating the database with the new information, and updating the parent window with the new details. Overall, this code provides users with a user-friendly way to create new goods, services, reductions, and supplements within the software system.
|
Code
|
AggiungiSoggiornante.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import moduli.*;
import common.utility.*;
import common.def.*;
import interfacce.*;
import java.util.Date;
public class AggiungiSoggiornante extends MascheraSoggiorno
{
Prenotazione prenotazione;
int num_sogg;
Stanza stanza;
public AggiungiSoggiornante(RicercaPrenotazione parent, Prenotazione p, Stanza s, int num)
{
super("Inserimento dati del soggiornante","Aggiungi agli altri", p.getPensionamento(), Flag.ADULTO);
padre = parent;
stanza = s;
num_sogg= num;
prenotazione = p;
inizializza();
}
public void inizializza()
{
testo1.setText(stanza.getNumStanza());
testo1.setEditable(false);
testo13.setText(DateUtils.giveStringOfDate(new Date()));
testo13.setEditable(false);
testo14.setText(DateUtils.giveStringOfDate(prenotazione.getFineSogg()));
testo14.setEditable(false);
Conferma.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startConferma();
}
});
}
void startConferma()
{
Frame msg;
if (!errori())
{
Soggiornante sogg = readDatiSogg(prenotazione, num_sogg+1);
sogg.setInizioSogg(new Date());
sogg.setFineSogg(prenotazione.getFineSogg());
sogg.setNumStanza(stanza.getNumStanza());
int j;
if ( (j = (Principale.db).writeSoggiornante(sogg)) == DataBase.OK )
{ // Modifico la prenotazione relativa
if (stanza.getPostiLetto() > num_sogg)
prenotazione.setNumPers(num_sogg+1);
else
if ( (stanza.getPostiLetto() == num_sogg) && (stanza.getDispLettoAgg() == Const.SI) )
prenotazione.setRichLettoAgg(Const.SI);
(Principale.db).changePrenotazione(prenotazione.getIdPrenotazione(), prenotazione.getNumStanza(),
prenotazione.getNumPers(),prenotazione.getNome(),prenotazione.getCognome(),
prenotazione.getNumTel(), prenotazione.getInizioSogg(), prenotazione.getFineSogg(), prenotazione.getDataPren(),
prenotazione.getCaparra(), prenotazione.getRichLettoAgg(), prenotazione.getPensionamento(),
prenotazione.getTramiteAgenzia(), prenotazione.getNomeAgenzia(), prenotazione.getRichParticolari());
msg = new AvvisoLocale(this, " Nuovo soggiornante registrato! ");
}
else
msg = new MessageDialog(this, "Problemi con il database: "+DataBase.strErrore(j));
}
}
}
class AvvisoLocale extends Frame
{
Button OK;
AggiungiSoggiornante padre;
public AvvisoLocale(AggiungiSoggiornante parent, String testo)
{
super("Avviso");
padre = parent;
padre.setEnabled(false);
this.setFont(ConfigurazioneSistema.font_titolo);
Panel textPanel = new Panel();
Panel buttonPanel = new Panel();
textPanel.add(new Label(testo));
OK = new Button("OK");
buttonPanel.add(OK);
add("North",textPanel);
add("Center",buttonPanel);
init();
pack();
//setSize(250,100);
setVisible(true);
}
public void init()
{
OK.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
setVisible(false);
dispose();
padre.dispose();
padre.padre.setEnabled(true);
}
});
}
}
|
The provided code allows users to add a new guest to an existing reservation. The "AggiungiSoggiornante" class serves as the user interface, displaying details about the reservation, such as the room number, start and end dates, and the current number of guests. Users can then input information about the new guest and confirm the addition, which will update the reservation in the database. If the new guest is successfully added, a confirmation message is displayed to the user through the "AvvisoLocale" class. If any issues arise with the database, an error message is shown instead. This functionality enables users to easily manage guest information and update reservations as needed, providing a seamless experience for handling changes to existing bookings.
|
Code
|
AskChiudiConto.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import interfacce.MascheraVisualizzazioneConto;
public class AskChiudiConto extends Frame
{
Button button1, button2, button3;
MascheraVisualizzazioneConto padre;
Panel panel1, panel2;
Label message;
GridBagLayout gridbag = new GridBagLayout();
public AskChiudiConto(MascheraVisualizzazioneConto parent)
{
super("Cosa devo fare?");
padre = parent;
padre.setEnabled(false);
setupPanel();
init();
pack();
setVisible(true);
}
void setupPanel()
{
message = new Label("ATTENZIONE: questa operazione comporta comporta la chiusura del soggiorno.");
button1 = new Button(" Annulla ");
button2 = new Button(" Stampa e chiudi ");
this.setFont(ConfigurazioneSistema.font_titolo);
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, message, 0, 0, 4, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
//Creo il pannello in basso con due pulsanti
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, button1, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 0, 0, 0, 15);
Utils.constrain(panel2, button2, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 0, 15, 0, 0);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel1, 0, 1, 4, 2, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel2, 0, 14, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
}
public void init()
{
button1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startAzione();
}
});
button2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
padre.startChiusura();
startAzione();
}
});
}
void startAzione()
{
setVisible(false);
dispose();
padre.dispose();
padre.conto.setEnabled(true);
}
}
|
The "AskChiudiConto" code provides a user interface that allows the user to close their current account or session. The interface displays a warning message to the user, informing them that the operation will result in the closure of their session. The user is presented with two options: "Annulla" (Cancel) and "Stampa e chiudi" (Print and Close).
If the user selects the "Annulla" option, the interface is closed, and the user is returned to the previous state. If the user selects the "Stampa e chiudi" option, the code initiates the closure of the account or session by calling a method on an instance of the "MascheraVisualizzazioneConto" class. After the closure is initiated, the code performs additional cleanup tasks, such as hiding the current GUI frame, disposing of it, and re-enabling the parent "MascheraVisualizzazioneConto" instance.
The code sets up event listeners for the two buttons, which handle the user's interactions with the GUI and trigger the appropriate actions based on the button clicked. This allows the user to easily navigate the account closure process and make an informed decision about whether to proceed with the closure or cancel the operation.
|
Code
|
AskChiudiSingoloConAgenzia.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import interfacce.MascheraVisualizzazioneConto;
public class AskChiudiSingoloConAgenzia extends Frame
{
Button button1, button2, button3;
MascheraCalcoloConto padre;
Panel panel1, panel2;
Label message;
GridBagLayout gridbag = new GridBagLayout();
public AskChiudiSingoloConAgenzia(MascheraCalcoloConto parent)
{
super("Cosa devo fare?");
padre = parent;
padre.setEnabled(false);
setupPanel();
init();
pack();
setVisible(true);
}
void setupPanel()
{
message = new Label("Calcolare il conto di un soggiornante venuto con agenzia implica cambiare la sua data di partenza.");
button1 = new Button(" Annulla ");
button2 = new Button(" Cambia data ");
this.setFont(ConfigurazioneSistema.font_titolo);
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, message, 0, 0, 4, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
//Creo il pannello in basso con due pulsanti
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, button1, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 0, 0, 0, 15);
Utils.constrain(panel2, button2, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 0, 15, 0, 0);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel1, 0, 1, 4, 2, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel2, 0, 14, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
}
public void init()
{
button1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startAzione();
}
});
button2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
padre.startChiudiSingoloConAgenzia();
startAzione();
}
});
}
void startAzione()
{
setVisible(false);
dispose();
padre.setEnabled(true);
}
}
|
The "AskChiudiSingoloConAgenzia" component provides a user interface that allows the user to either cancel or proceed with changing the departure date of a guest who has booked their stay through an agency. This is necessary because calculating the bill for such a guest requires modifying their departure date.
The component presents the user with a message explaining the situation and two buttons: "Annulla" (Cancel) and "Cambia data" (Change date). If the user clicks "Annulla", the component is closed, and the parent component is re-enabled. If the user clicks "Cambia data", the parent component's "startChiudiSingoloConAgenzia" method is called, and the component is then closed, and the parent component is re-enabled.
The component is designed to be part of a larger software system, and its purpose is to provide a clear and intuitive way for the user to handle the specific scenario of calculating the bill for a guest who has booked through an agency. By giving the user the option to either cancel or proceed with the change, the component ensures that the user can make an informed decision and take the appropriate action.
|
Code
|
CancellaBeniServizi.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import moduli.BeneServizio;
import moduli.DataBase;
import moduli.ListaBeniServizi;
public class CancellaBeniServizi extends MascheraBeneServizio
{
BeneServizio extra = null;
Label elenco_extra1, elenco_extra2, desc_extra, px_extra;
TextField desc, prezzo;
Button annulla3, annulla_canc, conferma_canc;
public CancellaBeniServizi()
{
super("Cancellazione di un bene o servizio");
setupPannello();
initialize();
}
void setupPannello()
{
panel[11].setLayout(gridbag);
elenco_extra1 = new Label("Scegliere il bene o servizio, appartenente");
elenco_extra2 = new Label("alla categoria selezionata, da cancellare");
annulla3 = new Button(" Fine ");
Utils.constrain(panel[11], elenco_extra1, 0, 0, 5, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel[11], elenco_extra2, 0, 1, 5, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 0, 0, 5, 0);
Utils.constrain(panel[11], elenco, 0, 2, 5, 1,GridBagConstraints.HORIZONTAL,
GridBagConstraints.CENTER, 1.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[11], annulla3, 2, 3, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.CENTER, 1.0, 0.0, 5, 5, 5, 5);
panel[12].setLayout(gridbag);
desc_extra = new Label("Nome del bene");
px_extra = new Label("Prezzo del bene");
desc = new TextField("",40);
prezzo = new TextField("",10);
desc.setEditable(false);
prezzo.setEditable(false);
annulla_canc = new Button("Annulla");
conferma_canc = new Button("Conferma");
Utils.constrain(panel[12], desc_extra, 0, 0, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[12], desc, 1, 0, 4, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[12], px_extra, 0, 1, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 5, 5, 5, 0);
Utils.constrain(panel[12], prezzo, 1, 1, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 0);
Utils.constrain(panel[12], annulla_canc, 1, 2, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.EAST, 1.0, 0.0, 5, 5, 0, 5);
Utils.constrain(panel[12], conferma_canc, 2, 2, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 0, 5);
}
public void initialize()
{
scelta_piatto[4].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_piatto[4].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.DESSERT);
p();
}
}
});
scelta_piatto[5].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_piatto[5].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.FRUTTA);
p();
}
}
});
scelta_servizio[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_servizio[0].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.RICREATIVI);
o();
}
}
});
scelta_servizio[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_servizio[1].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.ALTRO);
o();
}
}
});
scelta_bevanda[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_bevanda[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.CAFFETTERIA);
o();
}
}
});
scelta_bevanda[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_bevanda[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.ANALCOLICI);
o();
}
}
});
scelta_bevanda[2].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_bevanda[2].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.ALCOLICI);
o();
}
}
});
scelta_cibo[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_cibo[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.DOLCI);
o();
}
}
});
scelta_cibo[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_cibo[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.SALATI);
o();
}
}
});
scelta_antipasto[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_antipasto[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.FREDDI);
o();
}
}
});
scelta_antipasto[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_antipasto[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.CALDI);
o();
}
}
});
scelta_primo[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_primo[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.SOLIDI);
o();
}
}
});
scelta_primo[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_primo[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.LIQUIDI);
o();
}
}
});
scelta_secondo[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_secondo[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.CARNE);
o();
}
}
});
scelta_secondo[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_secondo[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.PESCE);
o();
}
}
});
scelta_contorno[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_contorno[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.VERDURA_COTTA);
o();
}
}
});
scelta_contorno[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_contorno[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.VERDURA_CRUDA);
o();
}
}
});
scelta_contorno[2].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_contorno[2].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.FORMAGGIO);
o();
}
}
});
conferma_canc.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startConfermaCanc();
}
});
annulla_canc.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
goBack();
}
});
annulla3.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
elenco.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
beneSelezionato();
}
});
} // init
void startConfermaCanc()
{
int id;
MessageDialog msg;
// questa e' una forzatura sporca
testo3 = desc;
testo4 = prezzo;
int j;
if ((j = (Principale.db).delBeneServizio(extra.getCodExtra())) == DataBase.OK)
{
for(int i=1;i<13;++i)
if(panel[i].isVisible())
remove(panel[i]);
panel[0].setVisible(true);
}
else
msg = new MessageDialog(this, "Problemi con il data base: "+DataBase.strErrore(j));
}
void beneSelezionato()
{
extra = L.getBeneServizio((elenco.getSelectedIndexes())[0]+1);
remove(panel[11]);
this.add(panel[12]);
desc.setText(extra.getDescrizione());
prezzo.setText(extra.getPxUnitario()+"");
panel[12].setVisible(true);
setVisible(true);
}
void goBack()
{
remove(panel[12]);
this.add(panel[11]);
panel[11].setVisible(true);
setVisible(true);
}
}
|
The CancellaBeniServizi class provides users with the ability to cancel a good or service from a database. Users can navigate through a series of checkboxes to select the category of the item they wish to cancel, such as desserts, fruits, recreational services, or other categories. Once the appropriate category is selected, a list of the available goods or services within that category is displayed, and the user can choose the specific item they wish to cancel.
After selecting the item, the user is presented with additional details about the selected good or service, including its description and price. The user is then given the option to either confirm the cancellation or go back to the previous screen. If the user confirms the cancellation, the item is removed from the database, and the user is returned to the main screen. If the user chooses to go back, they are returned to the previous screen without making any changes.
The code also includes error handling functionality, which displays a message dialog to the user if any issues occur during the cancellation process, such as problems with the database.
|
Code
|
CancellaCommissioni.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
import moduli.Commissionamento;
public class CancellaCommissioni extends MascheraCommissioni
{
Commissionamento commissione;
public CancellaCommissioni()
{
super("","","Cancella dati delle commissioni","Cancella", 3);
init();
}
public void init()
{
nome_agenzia.setEditable(true);
num_stanza.setEditable(false);
num_tel_agenzia.setEditable(false);
inizio_comm.setEditable(false);
fine_comm.setEditable(false);
scadenza_comm.setEditable(false);
num_stanza.setEditable(false);
Azione.setEnabled(false);
lista.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
commissione = L.getCommissionamento((lista.getSelectedIndexes())[0]+1);
writeDatiComm(commissione);
Azione.setEnabled(true);
panel5.setVisible(false);
pack();
}
});
nome_agenzia.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
creaLista();
}
});
Cerca.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
creaLista();
}
});
Azione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startAzione();
}
});
}
void startAzione()
{
Frame msg;
if ( !errori() )
{
int j;
if ( (j = (Principale.db).delCommissionamento(commissione.getIdCommissionamento())) == DataBase.OK)
{
aggiornaDisp(commissione, Flag.DISPONIBILE);
num_tel_agenzia.setEditable(false);
scadenza_comm.setEditable(false);
Azione.setEnabled(false);
cleanFields();
nome_agenzia.setEditable(true);
}
else
msg = new MessageDialog(this, "Problemi con il database: "+DataBase.strErrore(j));
}
}
}
|
The provided code implements a user interface for canceling commissions within a software system. The "CancellaCommissioni" class allows users to view and edit the details of a selected commission, including the agency name, room number, telephone number, start date, end date, and expiration date. Users can select a commission from a list, which populates the corresponding fields. Once a commission is selected, the user can click the "Azione" button to cancel the selected commission.
The code includes error handling, where if there are no issues, the commission is deleted from the database, and the availability of the commission is updated. If there are any problems with the database, a message dialog is displayed to the user. Additionally, the code provides functionality to create a list of commissions based on the agency name entered by the user or by clicking the "Cerca" button.
Overall, this code enables users to efficiently manage and cancel commissions within the software system, providing a user-friendly interface and robust error handling to ensure a seamless experience.
|
Code
|
CancellaPrenotazione.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import java.util.Date;
import moduli.*;
public class CancellaPrenotazione extends MascheraPrenotazione
{
Prenotazione p;
RicercaPrenotazione parent;
public CancellaPrenotazione(Prenotazione pren, Stanza room, RicercaPrenotazione papa)
{
super(room,"","","Cancellazione della prenotazione","Cancella",3, pren.getPensionamento());
p = pren;
parent = papa;
init();
}
public void init()
{
writeDatiPren(p);
for(int i=0; i<11; i++)
testo[i].setEditable(false);
myCheckbox.setEnabled(false);
myCheckbox1.setEnabled(false);
for (int i=0; i<checkboxes.length; i++)
checkboxes[i].setEnabled(false);
testo[9].setText(DateUtils.parseDate(DateUtils.giveStringOfDate(p.getDataPren())));
Azione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startCancella();
}
});
}
void startCancella()
{
Frame msg;
(Principale.db).delPrenotazione(p.getIdPrenotazione());
aggiornaDisp(p, Flag.DISPONIBILE);
Utils.restoreCommissioni(p.getNumStanza());
parent.creaLista(1);
dispose();
padre.setEnabled(true);
}
}
|
This code provides users with the ability to cancel an existing hotel reservation. The user is presented with a window that displays the details of the reservation, including the room, dates, and other relevant information. While the user cannot edit any of the reservation details, they can initiate the cancellation process by clicking the "Cancella" (Cancel) button.
When the user clicks the "Cancella" button, the code first removes the reservation from the database, then updates the availability status of the room to "available", and finally restores any commissions associated with the reservation. After these actions are completed, the code refreshes the list of reservations displayed in the parent window, and then closes the current window, returning control to the parent window. This allows the user to easily cancel a reservation and see the updated list of available reservations.
|
Code
|
CancellaStanze.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
public class CancellaStanze extends DescrittoreStanze
{
public CancellaStanze()
{
super("Cancellazione delle stanze", "Cancella", 3);
init();
}
public void init()
{
testo1.setEditable(true);
testo2.setEditable(false);
testo3.setEditable(false);
testo4.setEditable(false);
mycheckboxes.setEnabled(false);
Azione.setEnabled(false);
Azione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startAzione();
}
});
testo1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startTesto1();
}
});
Cerca.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startTesto1();
}
});
} // init
void startAzione()
{
MessageDialog msg;
int j;
if ( (j = (Principale.db).delStanza(testo1.getText())) != DataBase.OK )
msg = new MessageDialog(this, "Problemi con il data base: "+DataBase.strErrore(j));
else
{
cleanFields();
Azione.setEnabled(false);
}
testo1.setEditable(true);
}
void startTesto1()
{
MessageDialog msg;
Stanza room;
if ((room = (Principale.db).readStanza(testo1.getText())) != null)
{
writeDatiStanza(room);
testo1.setEditable(false);
Azione.setEnabled(true);
}
else
msg = new MessageDialog(this, "Stanza inesistente!");
}
}
|
This code provides a user interface for a system that allows users to cancel or delete rooms or spaces. The user can enter the name of a room in the first text field, and the system will retrieve the details of that room and display them in the other text fields. Once the room details are displayed, the user can then initiate the deletion of that room by clicking the "Azione" button.
The interface is designed to guide the user through the process of deleting a room. The first text field is initially editable, allowing the user to enter a room name. When the user enters a room name and presses Enter or clicks the "Cerca" button, the system will attempt to retrieve the details of that room from a database. If the room is found, its details will be displayed in the other text fields, and the "Azione" button will be enabled, allowing the user to initiate the deletion process.
When the user clicks the "Azione" button, the system will attempt to delete the room from the database. If the deletion is successful, the fields will be cleared, and the "Azione" button will be disabled. If there are any issues with the database, an error message will be displayed to the user, providing feedback and guidance to the user.
|
Code
|
ConfigurazioneSistema.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import java.lang.String;
import common.utility.*;
import common.def.*;
import moduli.*;
public class ConfigurazioneSistema extends Frame
{
// font costanti per uniformare l'aspetto delle finestre
public static final Font font_base = new Font("TimesRoman", Font.PLAIN, 12);
public static final Font font_sub = new Font("Courier", Font.BOLD, 18);
public static final Font font_titolo = new Font("Courier", Font.BOLD, 12);
public static final Font font_allineato = new Font("Courier", Font.PLAIN, 12);
// componenti della finestra di configurazione
TextField giorni_blocco, sup_bassissima, sup_bassa, sup_media, sup_alta,sup_letto_agg,
costo_x_scatto, sup_neonato, rid_bambino, rid_ragazzo, rid_comitiva,
password, num_max_stanze, px_colazione, px_mezza, px_intera, coperto,
min_pers_comitiva, cambio, albergo, indirizzo_alb, comune_alb,
citta_alb, rag_soc, licenza;
Label cambio_L_E;
Label etichetta, etich1, etich2, etich3, etich4, etich5, etich6, etich7, etich8,
etich9, etich10, etich11 ,etich11_1, etich12, etich13, etich14, etich15, etich16, etich17,
etich18, etich19, etich20, etichetta1, etichetta2, etichetta3,etichetta4,
etichetta5, etich21, etich22, etichetta6, etich23,etich24,etich25, etichetta7;
Panel panel0, panel1, panel2, panel3, panel4;
GridBagLayout gridbag = new GridBagLayout();
CheckboxGroup checkbox;
Checkbox[] checkboxes;
Button Annulla, Passwd, Conferma, Stagioni;
DefinizioneStagionalita def_stag;
// per il cambio di password e stagionalita
static String new_passwd;
static char[] new_stag_anno_corr, new_stag_anno_prox;
// per la gerarchia delle finestre
SubGestione padre = new SubGestione();
// per fregare l'ascoltatore
static Configurazione this_config;
DataBase db;
boolean first_start;
public ConfigurazioneSistema(Configurazione config, boolean prima_volta, DataBase archivio)
{
super("Configurazione di sistema");
this_config = config;
db = archivio;
new_passwd = this_config.getPassword();
new_stag_anno_corr = this_config.getStagionalita(Const.ANNO_CORRENTE);
new_stag_anno_prox = this_config.getStagionalita(Const.ANNO_PROSSIMO);
first_start = prima_volta;
setupPanels(prima_volta);
init();
pack();
}
public void setupPanels(boolean prima_volta)
{
this.setFont(font_base);
//creo le etichette
cambio_L_E = new Label("Cambio Lira <-> EURO");
etichetta = new Label("Licenza:");
etichetta.setFont(new Font("Courier", Font.BOLD, 12));
etichetta1 = new Label("DATI DI CONFIGURAZIONE");
etichetta1.setFont(new Font("Courier", Font.BOLD, 12));
etichetta2 = new Label("Supplementi dovuto alle stagionionalita'");
etichetta2.setFont(new Font("Courier", Font.BOLD, 12));
etichetta3 = new Label("Riduzioni");
etichetta3.setFont(new Font("Courier", Font.BOLD, 12));
etichetta4 = new Label("Ristorazione");
etichetta4.setFont(new Font("Courier", Font.BOLD, 12));
etichetta5 = new Label("Valuta");
etichetta5.setFont(new Font("Courier", Font.BOLD, 12));
etichetta6 = new Label("Cambio di password utente");
etichetta6.setFont(new Font("Courier", Font.BOLD, 12));
etichetta7 = new Label("Definizione delle stagionalita'");
etichetta7.setFont(new Font("Courier", Font.BOLD, 12));
licenza = new TextField("",35);
albergo = new TextField("",25);
comune_alb =new TextField("",35);
citta_alb = new TextField("",25);
indirizzo_alb = new TextField("",35);
rag_soc = new TextField("",35);
giorni_blocco = new TextField("",4);
sup_bassissima = new TextField("",9);
sup_bassa = new TextField("",9);
sup_media = new TextField("",9);
sup_alta = new TextField("",9);
sup_neonato = new TextField("",9);
sup_letto_agg = new TextField("",9);
rid_bambino = new TextField("",4);
rid_ragazzo = new TextField("",4);
rid_comitiva = new TextField("",4);
min_pers_comitiva = new TextField("",4);
num_max_stanze = new TextField("",4);
num_max_stanze.setEditable(false);
px_colazione = new TextField("",9);
px_mezza = new TextField("",9);
px_intera = new TextField("",9);
coperto = new TextField("",9);
costo_x_scatto = new TextField("",9);
password = new TextField("",20);
cambio = new TextField("",8);
//creo un Checkbox
checkbox = new CheckboxGroup();
checkboxes = new Checkbox[2];
checkboxes[0] = new Checkbox(" Lire",checkbox,true);
checkboxes[1] = new Checkbox(" EURO",checkbox,false);
writeDatiConf();
if (prima_volta)
licenza.setEditable(true);
else
licenza.setEditable(false);
licenza.setForeground(Color.red.darker());
albergo.setForeground(Color.blue);
comune_alb.setForeground(Color.blue);
citta_alb.setForeground(Color.blue);
rag_soc.setForeground(Color.blue);
password.setEchoChar('*');
etich1 = new Label("Dati dell'albergo");
etich1.setFont(new Font("Courier", Font.BOLD, 12));
etich2 = new Label("Nome dell'albergo:");
etich3 = new Label("Indirizzo dell'albergo:");
indirizzo_alb.setForeground(Color.blue);
etich4 = new Label("Comune dell'albergo:");
etich5 = new Label("Citta' dell'albergo:");
etich6 = new Label("Numero di giorni massimo di bloccaggio di una stanza");
etich7 = new Label("Supplemento bassisima stagione");
etich8 = new Label("Supplemento bassa stagione");
etich9 = new Label("Supplemento media stagione");
etich10 = new Label("Supplemento alta stagione");
etich11 = new Label("Supplemento per neonati");
etich11_1 = new Label("Supplemento letto aggiuntivo");
etich12 = new Label("Riduzione per bambini %");
etich13 = new Label("Riduzione per ragazzi %");
etich14 = new Label("Riduzione per comitive %");
etich15 = new Label("Numero minimo di persone per comitiva");
etich16 = new Label("Numero di stanze");
etich17 = new Label("Supplemento prima colazione");
etich18 = new Label("Supplemento mezza pensione");
etich19 = new Label("Supplemento pensione completa");
etich20 = new Label("Coperto per la ristorazione");
etich21 = new Label("Costo di uno scatto telefonico");
etich22 = new Label("Password utente");
etich23 = new Label("Lire");
etich24 = new Label("Dollari");
etich25 = new Label("Ragione sociale");
//creo i pulsanti
Annulla = new Button("Annulla");
Passwd = new Button("Cambio di password");
Conferma = new Button("Conferma");
Stagioni = new Button("Definisci Stagionalita'");
panel0 = new Panel();
panel0.setLayout(gridbag);
Utils.constrain(panel0, etichetta, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel0, licenza, 1, 0, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel0, etich1, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel0, etich2, 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel0, albergo, 1, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel0, etich3, 2, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel0, indirizzo_alb, 3, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel0, etich4, 0, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel0, comune_alb, 1, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel0, etich5, 2, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel0, citta_alb, 3, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel0, etich25, 0, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel0, rag_soc, 1, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, etichetta1, 0, 0, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 5, 5);
Utils.constrain(panel1, etich6, 0, 1, 5, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 5, 5);
Utils.constrain(panel1, giorni_blocco, 5, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 5, 5);
Utils.constrain(panel1, etich21, 7, 1, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 5, 5);
Utils.constrain(panel1, costo_x_scatto, 10, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 5, 5);
Utils.constrain(panel1, etichetta2, 0, 2, 4, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etichetta3, 5, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etichetta4, 8, 2, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
// supplementi
Utils.constrain(panel1, etich7, 0, 3, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, sup_bassissima, 3, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich8, 0, 4, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, sup_bassa, 3, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich9, 0, 5, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, sup_media, 3, 5, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich10, 0, 6, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, sup_alta, 3, 6, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich11, 0, 7, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, sup_neonato, 3, 7, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich11_1, 0, 8, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, sup_letto_agg, 3, 8, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
// riduzioni
Utils.constrain(panel1, etich12, 4, 3, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, rid_bambino, 7, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich13, 4, 4, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, rid_ragazzo, 7, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich14, 4, 5, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, rid_comitiva, 7, 5, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich15, 4, 6, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, min_pers_comitiva, 7, 6, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
// ristorazione
Utils.constrain(panel1, etich17, 8, 3, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, px_colazione, 11, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich18, 8, 4, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, px_mezza, 11, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich19, 8, 5, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, px_intera, 11, 5, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich20, 8, 6, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, coperto, 11, 6, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, cambio_L_E, 5, 7, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, cambio, 7, 7, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich16, 9, 7, 4, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, num_max_stanze, 11, 7, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, etichetta5, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, checkboxes[0], 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, checkboxes[1], 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
panel3 = new Panel();
panel3.setLayout(gridbag);
Utils.constrain(panel3, etichetta6, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel3, Passwd, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel3, etichetta7, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel3, Stagioni, 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
panel4 = new Panel();
panel4.setLayout(gridbag);
Utils.constrain(panel4, Annulla, 8, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTH, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel4, Conferma, 9, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTH, 0.0, 0.0, 5, 5, 5, 5);
this.setLayout(gridbag);
Utils.constrain(this,panel0, 0, 0, 12, 6, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this,panel1, 0, 6, 12, 9, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this,panel2, 0, 15, 1, 3, GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this,panel3, 1, 15, 11, 2, GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this,panel4, 0, 19, 12, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
}
public void init()
{
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
if (!first_start)
padre.setEnabled(true);
else
System.exit(0);
}
});
Conferma.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startConferma();
}
});
checkboxes[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(checkboxes[0].getState())
{
startAvviso(Const.LIRE);
}
}
});
checkboxes[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(checkboxes[1].getState())
{
startAvviso(Const.EURO);
}
}
});
Passwd.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startChangePwd();
}
});
Stagioni.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
setStagioni();
}
});
}
void startAvviso(char nuova_valuta)
{
Frame msg;
if (nuova_valuta != this_config.getValuta() && !first_start)
{
msg = new AvvisoDialog(this, "Attenzione: il cambio LIRA<->EURO effettuato alla conferma modifichera' le cifre della finestra corrente!");
}
}
void startChangePwd()
{
this.setEnabled(false);
CambioPassword cambio = new CambioPassword();
cambio.setVisible(true);
cambio.conf = this;
}
void startConferma()
{
MessageDialog msg;
int j;
if (!errore())
{
char vecchia_valuta = this_config.getValuta();
readDatiConf();
this_config.setPassword(new_passwd);
this_config.setStagionalita(new_stag_anno_corr, new_stag_anno_prox);
if ( (j = (db.writeConfigurazione(this_config))) != DataBase.OK )
{
msg = new MessageDialog(this, "Problemi con il database: "+DataBase.strErrore(j));
}
else
{
if ( vecchia_valuta != this_config.getValuta() && !first_start)
{
j = (Principale.db).startCambioValuta();
if (j != DataBase.OK)
{
msg = new MessageDialog(this, "Errore con il database: "+DataBase.strErrore(j));
return;
}
this_config = (Principale.db).readConfigurazione();
Principale.config = this_config;
}
if (!(first_start))
{
padre.pass.p.setTitle(this_config.getNomeAlbergo());
padre.setEnabled(true);
}
else
{
Frame p = new Principale(this_config, db);
p.setVisible(true);
}
dispose();
}
}
}
void setStagioni()
{
def_stag = new DefinizioneStagionalita(this);
}
boolean errore()
{
Frame msg;
if ( !((licenza.getText()).length() < 33 ) )
{
msg = new MessageDialog(this, " La licenza deve essere composta da al piu' 32 caratteri! ");
return true;
}
if ( !((albergo.getText()).length() < 21 ))
{
msg = new MessageDialog(this, " Il nome dell'albergo deve essere composto da al piu' 20 caratteri! ");
return true;
}
if ( !((comune_alb.getText()).length() < 33 ) )
{
msg = new MessageDialog(this, " Il comune deve essere composto da al piu' 32 caratteri! ");
return true;
}
if ( !((indirizzo_alb.getText()).length() < 33 ) )
{
msg = new MessageDialog(this, " L'indirizzo deve essere composto da al piu' 32 caratteri! ");
return true;
}
if ( !((citta_alb.getText()).length() < 21 ) )
{
msg = new MessageDialog(this, " La citta' deve essere composta da al piu' 20 caratteri! ");
return true;
}
if ( !((rag_soc.getText()).length() < 33 ) )
{
msg = new MessageDialog(this, " La ragione sociale deve essere composta da al piu' 32 caratteri! ");
return true;
}
if ( !Utils.isIntPos(giorni_blocco.getText()) )
{
msg = new MessageDialog(this, " Il numero di giorni di blocco deve essere un numero intero positivo! ");
return true;
}
if ( !Utils.isFloatPos(sup_bassissima.getText()) ||
!Utils.isFloatPos(sup_bassa.getText()) ||
!Utils.isFloatPos(sup_media.getText()) ||
!Utils.isFloatPos(sup_alta.getText()) ||
!Utils.isFloatPos(sup_neonato.getText()) ||
!Utils.isFloatPos(sup_letto_agg.getText()) ||
!Utils.isFloatPos(px_colazione.getText()) ||
!Utils.isFloatPos(px_mezza.getText()) ||
!Utils.isFloatPos(px_intera.getText()) )
{
msg = new MessageDialog(this, " I supplementi devono essere numeri positivi! ");
return true;
}
if ( !Utils.isIntPos(rid_bambino.getText()) ||
!Utils.isIntPos(rid_ragazzo.getText()) ||
!Utils.isIntPos(rid_comitiva.getText()) )
{
msg = new MessageDialog(this, " deve essere un numero intero! ");
return true;
}
if ( !Utils.isIntPos(min_pers_comitiva.getText()) )
{
msg = new MessageDialog(this, " Il numero di persone comitiva deve essere un numero intero positivo! ");
return true;
}
if ( !Utils.isIntPos(num_max_stanze.getText()) )
{
msg = new MessageDialog(this, " Il numero di stanze deve essere un numero intero positivo! ");
return true;
}
if ( !Utils.isFloatPos(coperto.getText()) )
{
msg = new MessageDialog(this, " Il coperto deve essere un numero positivo! ");
return true;
}
if ( !Utils.isFloatPos(costo_x_scatto.getText()) )
{
msg = new MessageDialog(this, " Il costo dello scatto telefonico deve essere un numero positivo! ");
return true;
}
if ( !Utils.isFloatPos(cambio.getText()) )
{
msg = new MessageDialog(this, " Il coefficiente di cambio LIRE<->EURO deve essere un numero positivo e diverso da zero! ");
return true;
}
else
if ( !((Float.valueOf(cambio.getText())).floatValue() > 0) )
{
msg = new MessageDialog(this, " Il coefficiente di cambio LIRE<->EURO deve essere un numero positivo e diverso da zero! ");
return true;
}
return false;
}
void readDatiConf()
{
this_config.setLicenza(licenza.getText());
this_config.setNomeAlbergo(albergo.getText());
this_config.setComuneAlb(comune_alb.getText());
this_config.setIndirizzoAlb(indirizzo_alb.getText());
this_config.setCittaAlb(citta_alb.getText());
this_config.setRagSoc(rag_soc.getText());
this_config.setGiorniBlocco(Integer.parseInt(giorni_blocco.getText()));
this_config.setSupplemento((Float.valueOf(sup_bassissima.getText())).floatValue(),Flag.BASSISSIMA_STAGIONE);
this_config.setSupplemento((Float.valueOf(sup_bassa.getText())).floatValue(),Flag.BASSA_STAGIONE);
this_config.setSupplemento((Float.valueOf(sup_media.getText())).floatValue(),Flag.MEDIA_STAGIONE);
this_config.setSupplemento((Float.valueOf(sup_alta.getText())).floatValue(),Flag.ALTA_STAGIONE);
this_config.setSupNeonato((Float.valueOf(sup_neonato.getText())).floatValue());
this_config.setSupLettoAgg((Float.valueOf(sup_letto_agg.getText())).floatValue());
this_config.setRiduzione(Integer.parseInt(rid_bambino.getText()),Flag.BAMBINO);
this_config.setRiduzione(Integer.parseInt(rid_ragazzo.getText()),Flag.RAGAZZO);
this_config.setRiduzione(Integer.parseInt(rid_comitiva.getText()),Flag.COMITIVA);
this_config.setMinPersComit(Integer.parseInt(min_pers_comitiva.getText()));
this_config.setNumStanze(Integer.parseInt(num_max_stanze.getText()));
this_config.setPxColazione((Float.valueOf(px_colazione.getText())).floatValue());
this_config.setPxMezza((Float.valueOf(px_mezza.getText())).floatValue());
this_config.setPxIntera((Float.valueOf(px_intera.getText())).floatValue());
this_config.setCoperto((Float.valueOf(coperto.getText())).floatValue());
this_config.setCostoXScatto((Float.valueOf(costo_x_scatto.getText())).floatValue());
this_config.setCoeffXCambio((Float.valueOf(cambio.getText())).floatValue());
if (checkboxes[0].getState())
this_config.setValuta(Const.LIRE);
else
this_config.setValuta(Const.EURO);
}
void writeDatiConf()
{
//String s = new String(Principale.simbol);
licenza.setText(""+this_config.getLicenza());
albergo.setText(""+this_config.getNomeAlbergo());
comune_alb.setText(""+this_config.getComuneAlb());
indirizzo_alb.setText(""+this_config.getIndirizzoAlb());
citta_alb.setText(""+this_config.getCittaAlb());
rag_soc.setText(""+this_config.getRagSoc());
giorni_blocco.setText(""+this_config.getGiorniBlocco());
sup_bassissima.setText(""+this_config.getSupplemento(Flag.BASSISSIMA_STAGIONE));
sup_bassa.setText(""+this_config.getSupplemento(Flag.BASSA_STAGIONE));
sup_media.setText(""+this_config.getSupplemento(Flag.MEDIA_STAGIONE));
sup_alta.setText(""+this_config.getSupplemento(Flag.ALTA_STAGIONE));
sup_neonato.setText(""+this_config.getSupNeonato());
sup_letto_agg.setText(""+this_config.getSupLettoAgg());
rid_bambino.setText(""+this_config.getRiduzione(Flag.BAMBINO));
rid_ragazzo.setText(""+this_config.getRiduzione(Flag.RAGAZZO));
rid_comitiva.setText(""+this_config.getRiduzione(Flag.COMITIVA));
min_pers_comitiva.setText(""+this_config.getMinPersComit());
num_max_stanze.setText(""+this_config.getNumStanze());
px_colazione.setText(""+this_config.getPxColazione());
px_mezza.setText(""+this_config.getPxMezza());
px_intera.setText(""+this_config.getPxIntera());
coperto.setText(""+this_config.getCoperto());
costo_x_scatto.setText(""+this_config.getCostoXScatto());
cambio.setText(""+this_config.getCoeffXCambio());
if (this_config.getValuta() == Const.LIRE)
checkbox.setSelectedCheckbox(checkboxes[0]);
else
checkbox.setSelectedCheckbox(checkboxes[1]);
}
}
/****************************************************************************/
class CambioPassword extends Frame
{
TextField testo1, testo2, testo3;
Label label1, label2, label3;
GridBagLayout grid = new GridBagLayout();
Panel pannello, pannello_x_annulla;
Frame conf = new Frame();
Button conferma, cambio, annulla;
MessageDialog dialog;
public CambioPassword()
{
super("Cambio di password");
setupPanels();
init();
pack();
}
void setupPanels()
{
this.setFont(ConfigurazioneSistema.font_base);
//creo le etichette
label1 = new Label("Inserire vecchia password");
label2 = new Label("Inserire nuova password");
label3 = new Label("Reinserire la nuova password");
//creo i textField
testo1 = new TextField("",20);
testo2 = new TextField("",20);
testo1.setEchoChar('*');
testo2.setEchoChar('*');
testo2.setEditable(false);
conferma = new Button("Conferma");
cambio = new Button("Cambio di password");
cambio.setEnabled(false);
annulla = new Button("Annulla");
pannello = new Panel();
pannello.setLayout(grid);
Utils.constrain(pannello, label1, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(pannello, testo1, 2, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(pannello, label2, 0, 1, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(pannello, testo2, 2, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(pannello, conferma, 3, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(pannello, cambio, 3, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
pannello_x_annulla = new Panel();
pannello_x_annulla.setLayout(grid);
Utils.constrain(pannello_x_annulla, annulla, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 1.0, 0.0, 5, 5, 5, 5);
this.setLayout(grid);
Utils.constrain(this,pannello, 0, 0, 4, 2, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this,pannello_x_annulla, 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 1.0, 0.0, 5, 5, 5, 5);
}
void init()
{
annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
conf.setEnabled(true);
}
});
conferma.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
g();
}
});
testo1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
g();
}
});
cambio.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
i();
}
});
testo2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
i();
}
});
}
void g()
{
String tmp = testo1.getText();
if(tmp.equals(ConfigurazioneSistema.new_passwd))
{
testo2.setEditable(true);
testo1.setEditable(false);
cambio.setEnabled(true);
conferma.setEnabled(false);
}
else
{
dialog = new MessageDialog(this,"La password non e' corretta");
dialog.setVisible(true);
testo1.setText("");
}
}
void i()
{
String tmp = testo2.getText();
Messaggio messaggio1 = new Messaggio(tmp);
messaggio1.setVisible(true);
messaggio1.c = this;
this.setEnabled(false);
}
}
/****************************************************************************/
class Messaggio extends Frame
{
Label msg;
Button OK;
CambioPassword c = new CambioPassword();
Avviso dialog;
GridBagLayout gridbag = new GridBagLayout();
TextField testo3;
Panel pannello;
String pwd_passata;
public Messaggio(String text)
{
super("Messaggio per il cambio di password");
setup();
pwd_passata = text;
init();
pack();
}
void setup()
{
this.setFont(ConfigurazioneSistema.font_base);
//creo un pulsante
OK = new Button("OK");
//creo un'etichetta
msg = new Label("Reinserire la nuova password");
//creo un textField
testo3 = new TextField("",20);
testo3.setEchoChar('*');
pannello = new Panel();
pannello.setLayout(gridbag);
Utils.constrain(pannello, msg, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(pannello, testo3, 2, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(pannello, OK, 4, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
this.setLayout(gridbag);
Utils.constrain(this, pannello, 0, 0, 4, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
}
public void init()
{
OK.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startOK();
}
});
testo3.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startOK();
}
});
}
void startOK()
{
if((testo3.getText()).equals(pwd_passata))
{
ConfigurazioneSistema.new_passwd = testo3.getText();
dialog = new Avviso(this,"La password verra' cambiata alla conferma");
}
else
dialog = new Avviso(this,"La nuova password non e' stata accettata");
dialog.setVisible(true);
}
}
/****************************************************************************/
class Avviso extends Frame
{
Button OK;
Messaggio padre;
public Avviso(Messaggio parent, String testo)
{
super("Attenzione");
padre = parent;
padre.setEnabled(false);
this.setFont(ConfigurazioneSistema.font_titolo);
Panel textPanel = new Panel();
Panel buttonPanel = new Panel();
textPanel.add(new Label(testo));
OK = new Button("OK");
buttonPanel.add(OK);
add("North",textPanel);
add("Center",buttonPanel);
init();
pack();
setVisible(true);
}
public void init()
{
OK.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
esci();
}
});
}
void esci()
{
dispose();
padre.dispose();
padre.c.dispose();
padre.c.conf.setEnabled(true);
}
}
|
The provided code allows users to configure various settings and parameters for a hotel management system. Users can access a comprehensive configuration window that enables them to modify a wide range of hotel-related information, including pricing, supplemental charges, discounts, telephone call charges, maximum room capacity, and password management. The configuration window is divided into distinct panels, each focusing on a specific set of settings, allowing users to navigate and make changes efficiently.
Users can define the hotel's seasonality, which affects the supplemental charges, and can also change their password and view the current exchange rate between the local currency and the Euro. The code includes robust error checking to ensure users enter valid values in the text fields, and any changes made are automatically saved to a database for future use. This configuration functionality empowers hotel management to tailor the system to their specific needs, optimizing operations and enhancing the overall guest experience.
|
Code
|
ControllaPrenotazione.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import java.util.Date;
import moduli.*;
public class ControllaPrenotazione extends MascheraPrenotazione
{
Prenotazione p;
PrenotazioniScadute parent;
public ControllaPrenotazione(Prenotazione pren, Stanza room, PrenotazioniScadute papa)
{
super(room,"","","Controlla dei dati della prenotazione"," Rinnova ",5,pren.getPensionamento());
p = pren;
parent = papa;
init();
}
public void init()
{
writeDatiPren(p);
for(int i=0; i<11; i++)
testo[i].setEditable(false);
testo[9].setText(DateUtils.parseDate(DateUtils.giveStringOfDate(p.getDataPren())));
Azione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startRinnova();
dispose();
parent.dispose();
startUpdate();
}
});
Cancella.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startCancella();
dispose();
parent.dispose();
startUpdate();
}
});
}
void startUpdate()
{
Frame supp = (parent.padre).p;
((Principale) supp).updateBloccate();
}
void startCancella()
{
Frame msg;
ListaDisponibilita elenco_disp = (Principale.db).elencoDisponibilita();
if (elenco_disp != null)
{
(Principale.db).delPrenotazione(p.getIdPrenotazione());
Utils.aggiornaDisp(elenco_disp, p.getNumStanza(), p.getInizioSogg(), p.getFineSogg(), Flag.DISPONIBILE, Flag.BLOCCATA, true);
if (p.getTramiteAgenzia() == Const.SI)
Utils.restoreCommissioni(p.getNumStanza());
dispose();
padre.setEnabled(true);
}
else
msg = new MessageDialog(this, " Problemi con il database nella lettura delle disponibilita! ");
}
void startRinnova()
{
p.setDataPren(new Date());
(Principale.db).changePrenotazione(p.getIdPrenotazione(), p.getNumStanza(),
p.getNumPers(),p.getNome(),p.getCognome(),
p.getNumTel(), p.getInizioSogg(), p.getFineSogg(), p.getDataPren(),
p.getCaparra(), p.getRichLettoAgg(), p.getPensionamento(),
p.getTramiteAgenzia(), p.getNomeAgenzia(), p.getRichParticolari());
dispose();
parent.setEnabled(true);
}
}
|
This code provides a user interface for managing hotel reservations. Users can view the details of an existing reservation, including the room number, guest information, dates of stay, and any special requests. The code allows users to renew a reservation by updating the reservation date, or cancel a reservation entirely. When a reservation is canceled, the system automatically updates the room availability and restores any commissions paid through an external agency. The code also ensures that the overall system is updated with the changes made to the reservation, keeping the reservation status accurate across the application. This comprehensive set of features empowers users to fully control the lifecycle of a hotel reservation, from viewing the details to making updates or cancellations as needed.
|
Code
|
DefinizioneStagionalita.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import moduli.*;
import common.def.*;
import common.utility.Utils;
import java.util.Date;
public class DefinizioneStagionalita extends Frame
{
//Dichiaro gli oggetti che mi serviranno per costruire la finestra
Panel panel1, panel2, panel3, panel4, panel5;
Label etichetta1, etichetta2, etichetta3, etichetta, etichetta4;
Button Annulla, Conferma, Aggiungi;
TextField data_inizio, data_fine;
List list;
GridBagLayout gridbag = new GridBagLayout();
CheckboxGroup checkbox_group;
Checkbox[] checkboxes;
// variabili locali di supporto
char conf_stag_corr[], conf_stag_prox[];
Configurazione config_locale;
int anno_corr, anno_prox;
// segue la finestra madre di questa
Frame config;
public DefinizioneStagionalita(Frame parent)
{
super("Definisione delle stagionalita'");
config = parent;
config.setEnabled(false);
setupPanels();
initVectors();
init();
pack();
setVisible(true);
}
void setupPanels()
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo i TextField
data_inizio = new TextField("", 12);
data_fine = new TextField("", 12);
//Creo i pulsanti e ne disabilito due
Annulla = new Button("Annulla");
Conferma = new Button("Conferma");
Aggiungi = new Button("Aggiungi");
Aggiungi.setEnabled(false);
//Creo le etichette
etichetta= new Label("Periodo di soggiorno");
etichetta.setFont(ConfigurazioneSistema.font_titolo);
etichetta1 = new Label("Data inizio:");
etichetta2 = new Label(" Data fine:");
etichetta3 = new Label ("Prospetto della distriduzione delle staginalita':");
etichetta3.setFont(new Font("Courier", Font.BOLD, 12));
Label space = new Label(" ");
//Creo la lista
list = new List(15,false);
//Creo il pannello in alto
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, etichetta, 0, 0, 4, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel1, etichetta1, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, data_inizio, 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST,1.0,0.0,0,0,0,0);
//Utils.constrain(panel1, space, 2, 1, 1, 1, GridBagConstraints.NONE,
//GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, etichetta2, 3, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1,data_fine, 4, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, space, 5, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
//Creo un pannello con due pulsanti
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, Aggiungi, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.3, 0.0, 0, 0, 0, 10);
//Creo un Checkbox ad esclusione
checkbox_group = new CheckboxGroup();
checkboxes = new Checkbox[5];
checkboxes[0] = new Checkbox(" Alta stagione",checkbox_group,false);
checkboxes[1] = new Checkbox(" Media stagione",checkbox_group,false);
checkboxes[2] = new Checkbox(" Bassa stagione",checkbox_group,false);
checkboxes[3] = new Checkbox(" Bassissima stagione",checkbox_group,false);
checkboxes[4] = new Checkbox(" Chiusura",checkbox_group,false);
etichetta4= new Label("Stagionalita' disponibili");
etichetta4.setFont(new Font("Courier", Font.BOLD, 12));
//Creo il pannello
panel3 = new Panel();
panel3.setLayout(gridbag);
Utils.constrain(panel3, etichetta4, 0, 1, 4, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel3, checkboxes[0], 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
Utils.constrain(panel3, checkboxes[1], 0, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
Utils.constrain(panel3, checkboxes[2], 0, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
Utils.constrain(panel3, checkboxes[3], 0, 5, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
Utils.constrain(panel3, checkboxes[4], 0, 6, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
//Creo il pannello contenente la TextArea
panel4 = new Panel();
panel4.setLayout(gridbag);
Utils.constrain(panel4, etichetta3, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel4,list, 0, 1, 4, 3, GridBagConstraints.BOTH,
GridBagConstraints.CENTER, 3.0, 3.0, 0, 0, 0, 0);
//Creo il pannello in basso con due pulsanti
panel5 = new Panel();
panel5.setLayout(gridbag);
Utils.constrain(panel5, Annulla, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.SOUTHEAST, 0.3, 0.0, 0, 0, 0, 10);
Utils.constrain(panel5, Conferma, 1, 1, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.SOUTHWEST, 0.3, 0.0, 0, 0, 0, 0);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel1, 0, 0, 4, 2, GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 15, 10, 10, 10);
Utils.constrain(this, panel3, 0, 2, 4, 1,GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHEAST, 1.0, 0.0, 10, 10, 0, 10);
Utils.constrain(this, panel2, 0, 5, 4, 1,GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHEAST, 1.0, 0.0, 10, 10, 0, 10);
Utils.constrain(this, panel4, 0, 6, 4, 3, GridBagConstraints.BOTH,
GridBagConstraints.CENTER, 2.0, 2.0, 10, 10, 10, 10);
Utils.constrain(this, panel5, 0, 10, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.SOUTHWEST, 1.0, 1.0, 10, 10, 15, 10);
}
//Gestione degli eventi
public void init()
{
//Ascoltatore degli eventi della finestra
checkboxes[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if ( (checkboxes[0].getState()) && (!(data_inizio.getText()).equals("")) && (!(data_fine.getText()).equals("")) )
{
Aggiungi.setEnabled(true);
}
}
});
checkboxes[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if ( (checkboxes[1].getState()) && (!(data_inizio.getText()).equals("")) && (!(data_fine.getText()).equals("")) )
{
Aggiungi.setEnabled(true);
}
}
});
checkboxes[2].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if ( (checkboxes[2].getState()) && (!(data_inizio.getText()).equals("")) && (!(data_fine.getText()).equals("")) )
{
Aggiungi.setEnabled(true);
}
}
});
checkboxes[3].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if ( (checkboxes[3].getState()) && (!(data_inizio.getText()).equals("")) && (!(data_fine.getText()).equals("")) )
{
Aggiungi.setEnabled(true);
}
}
});
checkboxes[4].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if ( (checkboxes[4].getState()) && (!(data_inizio.getText()).equals("")) && (!(data_fine.getText()).equals("")) )
{
Aggiungi.setEnabled(true);
}
}
});
/* Nel caso di annullamento dell'operazione ripristino i vettori
* originali della Configurazione
*/
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
config.setEnabled(true);
}
});
//Ascoltatore del pulsante Conferma, se il pulsante viene premuto si apre
//la finestra riguardante l'inserimento della prenotazione
Aggiungi.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startAggiungi();
}
});
Conferma.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
ConfigurazioneSistema.new_stag_anno_corr = (config_locale.getStagAnnoCorr());
ConfigurazioneSistema.new_stag_anno_prox = (config_locale.getStagAnnoProx());
dispose();
config.setEnabled(true);
}
});
}
void startAggiungi()
{
char flag;
String lista[];
if (Utils.dateEPeriodoCorretti(this, data_inizio.getText(), data_fine.getText()))
{
if (checkboxes[0].getState() == true)
flag = Flag.ALTA_STAGIONE;
else
if (checkboxes[1].getState() == true)
flag = Flag.MEDIA_STAGIONE;
else
if (checkboxes[2].getState() == true)
flag = Flag.BASSA_STAGIONE;
else
if (checkboxes[3].getState() == true)
flag = Flag.BASSISSIMA_STAGIONE;
else
flag = Flag.CHIUSO;
config_locale.setStagione(new Date(DateUtils.invertDate(DateUtils.parseDate(data_inizio.getText()))), new Date(DateUtils.invertDate(DateUtils.parseDate(data_fine.getText()))), flag);
conf_stag_corr = config_locale.getStagionalita(Const.ANNO_CORRENTE);
conf_stag_prox = config_locale.getStagionalita(Const.ANNO_PROSSIMO);
visStagionalita();
data_inizio.setText("");
data_fine.setText("");
for (int i = 0; i<checkboxes.length; i++)
checkboxes[i].setState(false);
Aggiungi.setEnabled(false);
}
}
/* Creo un duplicato dei vettori delle stagionalita per permettere
* l'annullamento delle operazioni
*/
void initVectors()
{
config_locale = new Configurazione();
config_locale.setStagAnnoCorr(ConfigurazioneSistema.new_stag_anno_corr);
config_locale.setStagAnnoProx(ConfigurazioneSistema.new_stag_anno_prox);
conf_stag_corr = config_locale.getStagionalita(Const.ANNO_CORRENTE);
conf_stag_prox = config_locale.getStagionalita(Const.ANNO_PROSSIMO);
Costanti cost = new Costanti();
anno_corr = cost.getAnnoCorr();
anno_prox = cost.getAnnoProx();
visStagionalita();
}
void visStagionalita()
{
String lista[] = reportStagionalita();
if (list.getItemCount() > 0)
list.removeAll();
for (int k = 0; k<lista.length; k++)
list.addItem(lista[k]);
}
String[] reportStagionalita()
{
String lista_loc[] = new String[30];
int index = 0;
String str_aus;
initLista(lista_loc);
//Scansione dei 5 tipi di stagionalita per l'anno corrente
str_aus = Utils.scanVector(Flag.ALTA_STAGIONE, conf_stag_corr, anno_corr);
if ( !( str_aus.equals("") ) )
{
lista_loc[index] = new String("Periodi di alta stagione per l'anno "+anno_corr);
lista_loc[index+1] = new String(str_aus);
index = index+3;
}
str_aus = Utils.scanVector(Flag.MEDIA_STAGIONE, conf_stag_corr, anno_corr);
if ( !( str_aus.equals("") ) )
{
lista_loc[index] = new String("Periodi di media stagione per l'anno "+anno_corr);
lista_loc[index+1] = new String(str_aus);
index = index+3;
}
str_aus = Utils.scanVector(Flag.BASSA_STAGIONE, conf_stag_corr, anno_corr);
if ( !( str_aus.equals("") ) )
{
lista_loc[index] = new String("Periodi di bassa stagione per l'anno "+anno_corr);
lista_loc[index+1] = new String(str_aus);
index = index+3;
}
str_aus = Utils.scanVector(Flag.BASSISSIMA_STAGIONE, conf_stag_corr, anno_corr);
if ( !( str_aus.equals("") ) )
{
lista_loc[index] = new String("Periodi di bassissima stagione per l'anno "+anno_corr);
lista_loc[index+1] = new String(str_aus);
index = index+3;
}
str_aus = Utils.scanVector(Flag.CHIUSO, conf_stag_corr, anno_corr);
if ( !( str_aus.equals("") ) )
{
lista_loc[index] = new String("Periodi di chiusura per l'anno "+anno_corr);
lista_loc[index+1] = new String(str_aus);
index = index+3;
}
// Scansione dei 5 tipi di stagionalita per l'anno seguente
str_aus = Utils.scanVector(Flag.ALTA_STAGIONE, conf_stag_prox, anno_prox);
if ( !( str_aus.equals("") ) )
{
lista_loc[index] = new String("Periodi di alta stagione per l'anno "+anno_prox);
lista_loc[index+1] = new String(str_aus);
index = index+3;
}
str_aus = Utils.scanVector(Flag.MEDIA_STAGIONE, conf_stag_prox, anno_prox);
if ( !( str_aus.equals("") ) )
{
lista_loc[index] = new String("Periodi di media stagione per l'anno "+anno_prox);
lista_loc[index+1] = new String(str_aus);
index = index+3;
}
str_aus = Utils.scanVector(Flag.BASSA_STAGIONE, conf_stag_prox, anno_prox);
if ( !( str_aus.equals("") ) )
{
lista_loc[index] = new String("Periodi di bassa stagione per l'anno "+anno_prox);
lista_loc[index+1] = new String(str_aus);
index = index+3;
}
str_aus = Utils.scanVector(Flag.BASSISSIMA_STAGIONE, conf_stag_prox, anno_prox);
if ( !( str_aus.equals("") ) )
{
lista_loc[index] = new String("Periodi di bassissima stagione per l'anno "+anno_prox);
lista_loc[index+1] = new String(str_aus);
index = index+3;
}
str_aus = Utils.scanVector(Flag.CHIUSO, conf_stag_prox, anno_prox);
if ( !( str_aus.equals("") ) )
{
lista_loc[index] = new String("Periodi di chiusura per l'anno "+anno_prox);
lista_loc[index+1] = new String(str_aus);
index = index+3;
}
return lista_loc;
}
void initLista(String lista[])
{
for (int k = 0; k < lista.length; k++)
lista[k] = new String("");
}
}
|
This code provides a user interface for defining and managing the seasonality of a system. The user can access a window that displays the current and upcoming year's seasonality, including high, medium, low, very low, and closed seasons. The user can add new seasonal periods by specifying a start and end date, and then selecting the appropriate checkbox to indicate the type of season. The added seasonal periods are then displayed in a list within the window. The user can also cancel the operation, which will restore the original seasonality configuration, or confirm the changes, which will update the system's seasonality for the current and upcoming year. The code includes functionality to ensure that the user inputs valid dates and that the "Add" button is only enabled when the required fields are filled out. This user-friendly interface allows the user to easily define and update the seasonal periods as needed, providing a flexible and efficient way to manage the system's seasonality.
|
Code
|
DescrittoreStanze.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
public class DescrittoreStanze extends Frame
{
//Dichiaro gli oggetti che utilizzero' per costruire la finestra
Label etichetta, label1, label2, label3, label4;
TextField testo1, testo2, testo3, testo4;
Button Annulla, Azione, Cerca;
Panel panel1, panel2;
GridBagLayout gridbag = new GridBagLayout();
Checkbox mycheckboxes;
SubStanze stanze = new SubStanze();
int caller;
public DescrittoreStanze(String title, String caption, int c)
{
super(title);
caller = c;
setupPanels(caption);
inizializza();
pack();
}
void setupPanels(String caption)
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo le etichette
etichetta=new Label("Informazioni sulle stanze");
etichetta.setFont(ConfigurazioneSistema.font_titolo);
label1 = new Label("Numero di stanza");
label2 = new Label("Numero di posti letto");
label3 = new Label("Prezzo base della stanza "+(Principale.config).getValuta()+".");
label4 = new Label("Descrizione delle caratteristiche peculiari della stanza");
//Creo i TextField
testo1 = new TextField("", 4);
testo2 = new TextField("", 4);
testo3 = new TextField("", 10);
testo4 = new TextField("", 50);
//Creo i bottoni
Annulla = new Button(" Fine ");
Azione = new Button(caption);
Cerca = new Button(" Cerca ");
mycheckboxes = new Checkbox(" Letto aggiuntivo", null, false);
//Creo il pannello in alto contenente i dati del cliente
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, etichetta, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label1, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo1, 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label2, 2, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 25);
Utils.constrain(panel1, testo2, 3, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label3, 0, 2, 1 ,1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo3, 1, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, mycheckboxes, 2, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label4, 0, 3, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo4, 2, 3, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
//Creo il pannello in basso con due pulsanti
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, Annulla, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, Azione, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0, 0.0, 5, 5, 5, 5);
if ((caller == 2) || (caller==3))
Utils.constrain(panel2, Cerca, 2, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0, 0.0, 5, 5, 5, 5);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel1, 0, 0, 4, 4, GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTH, 1.0, 1.0, 5, 5, 5, 5);
Utils.constrain(this,panel2, 0, 4, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.CENTER, 1.0, 0.0, 5, 5, 5, 5);
}
public void inizializza()
{
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
stanze.setEnabled(true);
}
});
}
protected Stanza readDatiStanza()
{
Stanza room = new Stanza();
room.setNumStanza(testo1.getText());
room.setPostiLetto(Integer.parseInt(testo2.getText()));
Float f = Float.valueOf(testo3.getText());
room.setPxBase(f.floatValue());
room.setDescrizione(testo4.getText());
if (mycheckboxes.getState())
room.setDispLettoAgg(Const.SI);
return room;
}
protected void writeDatiStanza(Stanza room)
{
testo1.setText(room.getNumStanza());
testo2.setText(""+room.getPostiLetto());
testo3.setText(""+room.getPxBase());
testo4.setText(room.getDescrizione());
if ( room.getDispLettoAgg() == Const.SI)
mycheckboxes.setState(true);
else
mycheckboxes.setState(false);
}
protected void cleanFields()
{
testo1.setText("");
testo2.setText("");
testo3.setText("");
testo4.setText("");
mycheckboxes.setState(false);
}
protected boolean errori()
{
Frame msg;
if ( !((testo1.getText()).length() <= 4) )
{
msg = new MessageDialog(this, " Il numero della stanza deve essere composto da al piu' 4 caratteri! ");
return true;
}
if ( ((testo1.getText()).equals("")) )
{
msg = new MessageDialog(this, " Manca il numero della stanza! ");
return true;
}
if ( ((testo2.getText()).equals("")) )
{
msg = new MessageDialog(this, " Manca il numero di posti letto! ");
return true;
}
if ( !Utils.isIntPos(testo2.getText()) )
{
msg = new MessageDialog(this, " Il numero di posti deve essere un numero positivo! ");
return true;
}
if ( ((testo3.getText()).equals("")) )
{
msg = new MessageDialog(this, " Manca il prezzo della stanza! ");
return true;
}
if ( !Utils.isFloatPos(testo3.getText()) )
{
msg = new MessageDialog(this, " Il prezzo della stanza deve essere un numero positivo! ");
return true;
}
if ( !((testo4.getText()).length() <= 52) )
{
msg = new MessageDialog(this, " La descrizione deve essere composta da al piu' 52 caratteri! ");
return true;
}
return false;
}
}
|
This code provides a user interface for managing information about hotel rooms. Users can view, edit, and search for room details, including the room number, number of beds, base price, and a description of the room's features. The interface is divided into two panels, one for displaying the room information and one for the action buttons. Users can also indicate if an additional bed is available in the room.
The code sets up a graphical user interface using Java's Swing library, with various labels, text fields, and buttons for the user to interact with. It includes methods for reading and writing the room information to and from the text fields, as well as validating the user's input to ensure that it meets certain requirements, such as the room number being no more than 4 characters and the number of beds and price being positive numbers. The search functionality is only available in certain contexts, as indicated by the "caller" parameter passed to the constructor.
Overall, this code provides a comprehensive set of tools for managing hotel room information, allowing users to easily view, edit, and search for room details within a user-friendly graphical interface.
|
Code
|
InserisciBeniServizi.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import moduli.BeneServizio;
import moduli.DataBase;
public class InserisciBeniServizi extends MascheraBeneServizio
{
BeneServizio extra = null;
public InserisciBeniServizi(String title)
{
super(title);
initialize();
setSize(350,520);
}
public void initialize()
{
scelta_piatto[4].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_piatto[4].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.DESSERT);
p();
}
}
});
scelta_piatto[5].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_piatto[5].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.FRUTTA);
p();
}
}
});
scelta_servizio[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_servizio[0].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.RICREATIVI);
o();
}
}
});
scelta_servizio[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_servizio[1].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.ALTRO);
o();
}
}
});
scelta_bevanda[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_bevanda[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.CAFFETTERIA);
o();
}
}
});
scelta_bevanda[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_bevanda[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.ANALCOLICI);
o();
}
}
});
scelta_bevanda[2].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_bevanda[2].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.ALCOLICI);
o();
}
}
});
scelta_cibo[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_cibo[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.DOLCI);
o();
}
}
});
scelta_cibo[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_cibo[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.SALATI);
o();
}
}
});
scelta_antipasto[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_antipasto[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.FREDDI);
o();
}
}
});
scelta_antipasto[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_antipasto[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.CALDI);
o();
}
}
});
scelta_primo[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_primo[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.SOLIDI);
o();
}
}
});
scelta_primo[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_primo[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.LIQUIDI);
o();
}
}
});
scelta_secondo[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_secondo[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.CARNE);
o();
}
}
});
scelta_secondo[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_secondo[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.PESCE);
o();
}
}
});
scelta_contorno[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_contorno[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.VERDURA_COTTA);
o();
}
}
});
scelta_contorno[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_contorno[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.VERDURA_CRUDA);
o();
}
}
});
scelta_contorno[2].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_contorno[2].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.FORMAGGIO);
o();
}
}
});
conferma.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startConferma(padre);
}
});
} // init
void startConferma(Frame padre)
{
MessageDialog msg;
if (!errore())
{
Float px = Float.valueOf(testo4.getText());
extra = new BeneServizio((new String(codice))+tornaCodId((Principale.config).getIdBeneservizio()), testo3.getText(), px.floatValue());
int j;
if ( (j = (Principale.db).newIdBeneservizio()) == DataBase.OK )
{
(Principale.config).updateIdBeneservizio();
if ((j = (Principale.db).writeBeneServizio(extra)) == DataBase.OK)
{
if (padre instanceof MascheraAddebiti)
{ // questo serve in quanto l'AggiungiBeneServizio e' una estensione di questa classe
dispose();
padre.setEnabled(true);
((MascheraAddebiti) padre).inizExtra();
}
else
{ // questo serve in quanto AggiungiBeneServizio e' una estensione di questa
// classe ed e' utilizzata dalla maschera del conto ristorazione
if (padre instanceof MascheraContoRistorazione)
{
dispose();
padre.setEnabled(true);
((MascheraContoRistorazione) padre).inizExtra();
}
else
{
testo3.setText("");
testo4.setText("");
panel[10].setVisible(true);
}
}
}
else
msg = new MessageDialog(this, "Problemi con il database: "+DataBase.strErrore(j));
}
else
msg = new MessageDialog(this, "Problemi con il database: "+DataBase.strErrore(j));
}
}
void o()
{
completeCode();
this.add(panel[10]);
panel[10].setVisible(true);
testo3.setText("");
testo4.setText("");
setVisible(true);
}
void p()
{
completeCode();
if(panel[1].isVisible())
remove(panel[1]);
for(int i=3;i<13;++i)
{
if(panel[i].isVisible())
remove(panel[i]);
}
o();
}
String tornaCodId(long id)
{
completeCode();
String str_id = Long.toString(id);
while (str_id.length() < 5)
str_id = new String("0"+str_id);
return str_id;
}
}
|
This code provides a user interface for managing goods and services within a software system, likely related to a restaurant or catering business. Users can select from a variety of categories, including desserts, fruits, recreational services, and others, and create new items by entering a description and price. The code generates a unique identification code for each item based on the selected category and a sequential number, and stores the information in a database. The user interface includes error handling and messaging to provide feedback to the user during the process. This functionality is integrated into a larger software system, allowing the user to seamlessly add, view, and modify goods and services as needed to support the overall business operations.
|
Code
|
InserisciCommissioni.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
public class InserisciCommissioni extends MascheraCommissioni
{
MascheraRicercaStanza mask_ricerca = new MascheraRicercaStanza("",1);
public InserisciCommissioni(Stanza stanza, String data1, String data2)
{
super(data1, data2, "Inserimento dei dati delle commissioni","Inserisci",1);
init(stanza, data1, data2);
}
public void init(Stanza stanza, String data1, String data2)
{
num_stanza.setText(stanza.getNumStanza());
inizio_comm.setText(data1);
fine_comm.setText(data2);
num_stanza.setEditable(false);
inizio_comm.setEditable(false);
fine_comm.setEditable(false);
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
mask_ricerca.setEnabled(true);
}
});
Azione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startAzione();
}
});
}
void startAzione()
{
Frame msg;
if ( !errori() )
{
Commissionamento comm = readDatiComm();
int j;
if ( (j = (Principale.db).newIdCommissionamento()) == DataBase.OK )
{
(Principale.config).updateIdCommissionamento();
if ((j = (Principale.db).writeCommissionamento(comm)) == DataBase.OK)
{
aggiornaDisp(comm, Flag.COMMISSIONATA);
dispose();
mask_ricerca.restartAvvio();
mask_ricerca.setEnabled(true);
}
else
msg = new MessageDialog(this, "Problemi con il database: "+DataBase.strErrore(j) );
}
else
msg = new MessageDialog(this, "Problemi con il database: "+DataBase.strErrore(j) );
}
}
}
|
The provided code allows users to insert and manage commission data for a specific room. Users can access this functionality through the "InserisciCommissioni" class, which extends the "MascheraCommissioni" class. Users can specify a start and end date for the commission, and the room number is automatically populated and made non-editable.
Users have two main actions available: 1) Cancel the commission entry, which will close the current window and re-enable the "MascheraRicercaStanza" window, and 2) Save the commission data, which will create a new commission in the database, update the availability status of the room, and then close the current window and re-enable the "MascheraRicercaStanza" window.
The code also includes error handling, where it will display a message dialog if there are any issues with the database operations. Overall, this code provides a user interface for managing commission data for a specific room, with the ability to save the data to the database and update the room's availability status accordingly.
|
Code
|
InserisciPrenotazione.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import java.util.Date;
import moduli.*;
public class InserisciPrenotazione extends MascheraPrenotazione
{
MascheraRicercaStanza mask_ricerca = new MascheraRicercaStanza("",2);
String agenzia;
public InserisciPrenotazione(Stanza room, String data_i , String data_f, String nome_ag)
{
super(room, data_i, data_f, "Inserimento dei dati della prenotazione", "Inserisci",1, Flag.PENSIONE_COMPLETA);
agenzia = new String(nome_ag);
init(room, data_i, data_f);
}
public void init(Stanza room, String data_i, String data_f)
{
testo[0].setText(room.getNumStanza());
testo[0].setEditable(false);
testo[4].setText(DateUtils.parseDate(data_i));
testo[5].setText(DateUtils.parseDate(data_f));
testo[4].setEditable(false);
testo[5].setEditable(false);
testo[7].setText(room.getDescrizione());
testo[9].setText(DateUtils.parseDate(DateUtils.giveStringOfDate(new Date())));
testo[8].setText(agenzia);
testo[8].setEditable(false);
if (!agenzia.equals(""))
{
testo[6].setEditable(false);
myCheckbox1.setState(true);
}
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
mask_ricerca.setEnabled(true);
}
});
Azione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startAzione();
}
});
}
void startAzione()
{
Frame msg;
AskDialog ask;
int answer = 0;
if ( !errori() )
{
Prenotazione pren = readDatiPren();
pren.setDataPren(new Date());
int j;
if ( (j = (Principale.db).newIdPrenotazione()) == DataBase.OK )
{
(Principale.config).updateIdPrenotazione();
if ((j = (Principale.db).writePrenotazione(pren)) == DataBase.OK)
{
if (!myCheckbox1.getState())
ask = new AskDialog(this, " Assegnare la stanza o Bloccarla fino al ricevimento della caparra? ", " Assegnare ", " Bloccare ", pren);
else
startAggiornaDisp(pren, Flag.ASSEGNATA);
}
else
msg = new MessageDialog(this, "Problemi con il database: "+DataBase.strErrore(j) );
}
else
msg = new MessageDialog(this, "Problemi con il database: "+DataBase.strErrore(j) );
}
}
void startAggiornaDisp(Prenotazione p, char tipo)
{
aggiornaDisp(p, tipo);
dispose();
mask_ricerca.restartAvvio();
mask_ricerca.setEnabled(true);
}
}
|
This code provides a user interface for inserting a new hotel room reservation. The user can input the necessary information, such as the room number, start and end dates, and the agency making the reservation. The code automatically populates some of the fields, such as the current date and the room description, based on the provided information.
The code then handles the creation of the new reservation in the system's database. It checks for any errors in the input data and, if there are no errors, creates a new reservation object and writes it to the database. If the writing to the database is successful, the code provides the user with the option to either assign the room to the reservation or to block the room until the deposit is received. The code then updates the room's availability status accordingly.
If the user chooses to cancel the reservation, the code disposes of the current window and enables the room search window, allowing the user to start a new reservation process.
|
Code
|
InserisciSoggiornante.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import moduli.*;
import common.utility.*;
import common.def.*;
import interfacce.*;
import java.util.Date;
public class InserisciSoggiornante extends MascheraSoggiorno
{
Prenotazione prenotazione;
int counter_ins = 1;
int counter_tot;
public InserisciSoggiornante(RicercaPrenotazione parent, Prenotazione p)
{
super("Inserimento dati", "Inserisci", p.getPensionamento(), Flag.ADULTO);
padre = parent;
padre.setEnabled(false);
prenotazione = p;
inizializza();
}
public void inizializza()
{
testo1.setText(prenotazione.getNumStanza());
testo1.setEditable(false);
testo2.setText(prenotazione.getCognome());
testo3.setText(prenotazione.getNome());
testo7.setText(prenotazione.getNumTel());
testo13.setText(DateUtils.giveStringOfDate(prenotazione.getInizioSogg()));
testo13.setEditable(false);
testo14.setText(DateUtils.giveStringOfDate(prenotazione.getFineSogg()));
testo14.setEditable(false);
counter_tot = prenotazione.getNumPers();
if (prenotazione.getRichLettoAgg() == Const.SI)
counter_tot++;
changeTitle(counter_ins, counter_tot);
Conferma.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startConferma();
}
});
}
void startConferma()
{
Frame msg;
if (!erroriLocale())
{
Soggiornante sogg = readDatiSogg(prenotazione, counter_ins);
int j;
if ( (j = (Principale.db).writeSoggiornante(sogg)) == DataBase.OK )
{
Annulla.setEnabled(false);
cleanFields();
if (counter_ins == counter_tot)
{
aggiornaDisp(sogg, Flag.OCCUPATA );
dispose();
padre.creaLista(1);
padre.setEnabled(true);
}
counter_ins++;
changeTitle(counter_ins, counter_tot);
}
else
msg = new MessageDialog(this, "Problemi con il database: "+DataBase.strErrore(j));
}
}
boolean erroriLocale()
{
if (!errori())
{
if (counter_ins == 1)
{
Frame msg;
if ( (testo2.getText()).equals("") )
{
msg = new MessageDialog(this, " Per il primo soggiornante inserito deve essere digitato il cognome! ");
return true;
}
if ( (testo3.getText()).equals("") )
{
msg = new MessageDialog(this, " Per il primo soggiornante inserito deve essere digitato il nome! ");
return true;
}
if ( (testo6.getText()).equals("") )
{
msg = new MessageDialog(this, " Per il primo soggiornante inserito deve essere digitato il numero di documento! ");
return true;
}
if ( (testo7.getText()).equals("") )
{
msg = new MessageDialog(this, " Per il primo soggiornante inserito deve essere digitato il numero telefonico! ");
return true;
}
if ( (testo8.getText()).equals("") )
{
msg = new MessageDialog(this, " Per il primo soggiornante inserito deve essere digitato l'indirizzo! ");
return true;
}
if ( (testo9.getText()).equals("") )
{
msg = new MessageDialog(this, " Per il primo soggiornante inserito deve essere digitato il C.A.P.! ");
return true;
}
if ( (testo10.getText()).equals("") )
{
msg = new MessageDialog(this, " Per il primo soggiornante inserito deve essere digitato il comune! ");
return true;
}
if ( (testo11.getText()).equals("") )
{
msg = new MessageDialog(this, " Per il primo soggiornante inserito deve essere digitata la citta! ");
return true;
}
if ( (testo12.getText()).equals("") )
{
msg = new MessageDialog(this, " Per il primo soggiornante inserito deve essere digitata la nazione! ");
return true;
}
}
return false;
}
return true;
}
}
|
The provided code allows users to manage guest information for a hotel or similar accommodation. The "InserisciSoggiornante" class presents a graphical user interface (GUI) that enables users to input and save details about guests, such as their name, contact information, document number, and address. The code retrieves relevant reservation details, such as the room number, check-in and check-out dates, and the number of people in the party, and pre-populates this information in the GUI.
The code includes input validation to ensure that required fields are filled out correctly before allowing the user to save the guest information. If any errors are detected, the code displays appropriate error messages to the user. Once the user has entered all the necessary information and confirmed the details, the code saves the guest information to a database and updates the availability of the room, marking it as "occupied" in the system.
The code also includes functionality to handle multiple guests in a single reservation, allowing the user to input information for each guest in a sequential manner. The GUI is updated to display the current guest number and the total number of guests, making it easy for the user to keep track of their progress.
|
Code
|
InserisciStanze.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
public class InserisciStanze extends DescrittoreStanze
{
public InserisciStanze()
{
super("Inserimento dei dati delle stanze", "Inserisci",1);
init();
}
public void init()
{
Cerca.setEnabled(false);
Azione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startAzione();
}
});
} // init
void startAzione()
{
Frame msg;
ListaStanze L_st = (Principale.db).elencoStanze();
if ( L_st.length() < (Principale.config).getNumStanze() )
{
if ( !errori() )
{
Stanza room = readDatiStanza();
int j;
if ((j = (Principale.db).writeStanza(room)) == DataBase.OK)
{
cleanFields();
}
else
msg = new MessageDialog(this, "Problemi con il data base: "+DataBase.strErrore(j));
}
}
else
msg = new AvvisoDialog(this, "Impossibile inserire la stanza: e' stato raggiunto il numero massimo di stanze gestibile");
}
}
|
This code provides users with the ability to add new rooms or spaces to a larger software system. The "InserisciStanze" class serves as the user interface for this functionality, allowing users to input data about a new room and submit it to the system. When the user clicks the "Azione" (Action) button, the code checks if the maximum number of rooms has been reached, validates the user's input, and then writes the new room data to a database. If the write is successful, the input fields are cleared, and if any errors occur, appropriate messages are displayed to the user. This functionality allows users to expand the set of rooms or spaces managed by the overall software system.
|
Code
|
MascheraAddebiti.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
public class MascheraAddebiti extends MascheraPerAddebitare
{
// variabili per il travaso del database in memoria
String stanza_prec = new String("");
// oggetti per la costruzione della finestra
Label etich1, etich2, etich3;
TextField num_stanza;
public MascheraAddebiti(Frame parent)
{
super("Addebito spese e servizi extra", "Conferma l'addebito");
padre = parent;
padre.setEnabled(false);
inizExtra();
setupPanello();
inizializza();
pack();
setVisible(true);
}
// Travaso dati degli extra nelle strutture dati apposite
void inizExtra()
{
MessageDialog msg;
elenco_extra = (Principale.db).elencoSenzaSuppRid();
if (elenco_extra != null)
{
if (extra.getItemCount() > 0)
extra.removeAll();
int i=1;
while (i <= elenco_extra.length())
{
extra.addItem( (elenco_extra.getBeneServizio(i)).toString() );
i++;
}
}
}
// Creazione della finestra
void setupPanello()
{
num_stanza = new TextField("", 4);
num_stanza.setEditable(true);
// creo le label
etich1 = new Label("Gestione degli addebiti ");
etich1.setFont(ConfigurazioneSistema.font_titolo);
etich2 = new Label("Scegliere l'extra da addebitare ");
etich3 = new Label("Addebitare alla stanza numero ");
// creo pannello di sinistra
this.remove(panel1);
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, etich1, 0, 0, 6, 1);
Utils.constrain(panel1, etich2, 0, 1, 6, 1, 10, 0, 0, 0);
Utils.constrain(panel1, extra, 0, 2, 6, 4, GridBagConstraints.BOTH,
GridBagConstraints.WEST, 1.0, 1.0, 0, 20, 0, 20);
this.remove(panel4);
panel4 = new Panel();
panel4.setLayout(gridbag);
Utils.constrain(panel4, etich3, 0, 0, 1, 1, 5, 5, 5, 5);
Utils.constrain(panel4, num_stanza, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
// aggiungo i pannelli appena creati al resto
Utils.constrain(this, panel1, 0, 0, 1, 1, GridBagConstraints.VERTICAL,
GridBagConstraints.WEST, 0.5, 0.5, 5, 5, 5, 5);
Utils.constrain(this, panel4, 0, 2, 1, 1, GridBagConstraints.VERTICAL,
GridBagConstraints.WEST, 0.5, 0.5, 5, 5, 5, 5);
}
// Per la gestione degli eventi della finestra
void inizializza()
{
conferma.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
scriviSuDB(num_stanza.getText());
dispose();
padre.setEnabled(true);
}
});
addebita.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (!errore())
{
addebito = true;
aggiornaAddebiti();
}
}
});
deaddebita.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (!errore())
{
addebito = false;
aggiornaAddebiti();
}
}
});
num_stanza.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (!errore())
{
addebito = true;
aggiornaAddebiti();
}
}
});
extra.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (!errore())
{
addebito = true;
aggiornaAddebiti();
}
}
});
}
// Ritorna false se si sta' cercando di addebitare un extra in
// mancanza dei dati necessari per l'addebito: num_stanza e extra.
boolean errore()
{
if ((num_stanza.getText()).equals("") && (extra.getSelectedIndex() == -1))
{
MessageDialog p = new MessageDialog(this, "Manca stanza e selezione!");
return true;
}
else if ((num_stanza.getText()).equals(""))
{
MessageDialog p = new MessageDialog(this, "Manca stanza!");
return true;
}
else if (extra.getSelectedIndex() == -1)
{
MessageDialog p = new MessageDialog(this, "Manca selezione!");
return true;
}
else if ( (num_stanza.getText()).length() > 4 )
{
MessageDialog p = new MessageDialog(this, "Errore nel numero di stanza!");
return true;
}
else
return false;
}
void annullaAddebitiStanzaPrec()
{
stanza_prec = new String(num_stanza.getText());
aggiornaAvideo();
}
// Aggiorna il panel2, che e' quello di informazione sugli addebiti
// di una data stanza, in modo che contenga le informazioni
// aggiornate sugli addebiti.
void aggiornaAddebiti()
{
if ( !(stanza_prec.equals(num_stanza.getText())) )
AltraStanza();
else
aggiornaAvideo();
}
boolean thereIsModifiche()
{
boolean modifiche = false;
for (int i = 0; i < quantita_mod.length; i++)
modifiche = modifiche || (quantita_mod[i] != 0);
return modifiche;
}
// Reinizzializza l'array degli addebiti in quanto si cambia stanza
// e chiede se gli addebiti fatti alla stanza precedente vanno
// confermati o meno.
void AltraStanza()
{
Frame msg;
FinModifiche p;
if ( (Principale.db).readStanza(num_stanza.getText()) != null )
{
ListaSoggiornanti L;
if ( (L = (Principale.db).foundSoggiornanti(num_stanza.getText(), false) ) != null )
{
if (!L.isEmpty())
{
if (!stanza_prec.equals("") && thereIsModifiche())
{
p = new FinModifiche(this, "Attenzione: cambio di stanza!");
}
else
{
riscriviElencoAddebiti();
annullaAddebitiStanzaPrec();
}
}
else
{
msg = new AvvisoDialog(this, "Nessun soggiornante occupa la stanza!");
num_stanza.setText(stanza_prec);
}
}
else
{
msg = new MessageDialog(this, "Problemi con il database: errore.");
}
}
else
{
msg = new MessageDialog(this, "Stanza inesistente!");
num_stanza.setText(stanza_prec);
}
}
void riscriviElencoAddebiti()
{
MessageDialog msg;
elenco_addebiti = (Principale.db).foundAddebiti(num_stanza.getText());
elenco_extra_addebitati = new ListaBeniServizi();
if (elenco_addebiti != null)
{
// inizializzo l'array delle modifiche e degli extra addebitati
quantita_mod = new int[elenco_addebiti.length()];
BeneServizio extra;
for (int i=0; i<quantita_mod.length; i++)
{
quantita_mod[i] = 0;
extra = (Principale.db).readBeneServizio( (elenco_addebiti.getAddebito(i+1)).getCodExtra() );
if (extra == null)
{
msg = new MessageDialog(this, "Uno degli extra addebitati non e' stato trovato!");
extra = new BeneServizio( (elenco_addebiti.getAddebito(i+1)).getCodExtra(), "Sconosciuto", 0 );
}
elenco_extra_addebitati.addBeneServizio( extra );
}
}
else
msg = new MessageDialog(this, "Errore nel database!");
}
int posExtraInAddebiti(BeneServizio b)
{
for (int i = 1; i <= elenco_addebiti.length(); i++)
if ( ((elenco_addebiti.getAddebito(i)).getCodExtra()).equals(b.getCodExtra()) )
return i;
return -1;
}
void aggiornaAvideo()
{
Frame msg;
int supp[];
BeneServizio extra_scelto = elenco_extra.getBeneServizio( extra.getSelectedIndex() + 1 );
int pos;
if ((pos = posExtraInAddebiti(extra_scelto)) < 0 && addebito)
{
Addebito a = new Addebito(num_stanza.getText(), extra_scelto.getCodExtra(), 0, 0);
elenco_addebiti.addAddebito( a );
elenco_extra_addebitati.addBeneServizio( extra_scelto );
// allungo l'array delle quantita' modificate
supp = new int[elenco_addebiti.length()];
for (int i = 0; i<quantita_mod.length; i++)
supp[i] = quantita_mod[i];
supp[supp.length - 1] = 1;
quantita_mod = supp;
pos = quantita_mod.length;
extra_add.setText(extra.getSelectedItem());
continuaAggiornamento();
}
else
{
if (pos < 0)
{
// sto cercando di togliere da un addebito inesistente
msg = new AvvisoDialog(this, "Stai cercando di togliere da un addebito ormai inesistente!");
}
else
{
// aggiorno tale array per contenere l'addebito appena effettuato
if (addebito)
{
quantita_mod[pos - 1]++;
extra_add.setText(extra.getSelectedItem());
continuaAggiornamento();
}
else
if ( (quantita_mod[pos - 1]+(elenco_addebiti.getAddebito(pos)).getQuantita()) > 0)
{
quantita_mod[pos - 1]--;
extra_add.setText(extra.getSelectedItem());
continuaAggiornamento();
}
else
msg = new AvvisoDialog(this, "Stai cercando di togliere da un addebito ormai inesistente!");
}
}
}
void continuaAggiornamento()
{
int i = 1;
BeneServizio e;
float conto = 0;
if (addebiti.getItemCount() > 0)
addebiti.removeAll();
while ( i <= elenco_addebiti.length() )
{
if ( ((elenco_addebiti.getAddebito(i)).getQuantita() + quantita_mod[i-1]) > 0 )
{
e = elenco_extra_addebitati.getBeneServizio(i);
if ( Integer.parseInt(e.getCodExtra()) >= 40000000 && Integer.parseInt(e.getCodExtra()) < 50000000)
addebiti.addItem("S "+Utils.completaStringa(e.getDescrizione(), 32)+" "+(Principale.config).getValuta()+"."+(elenco_addebiti.getAddebito(i)).getTotAddebito());
else if ( Integer.parseInt(e.getCodExtra()) >= 50000000)
addebiti.addItem("R "+Utils.completaStringa(e.getDescrizione(), 32)+" "+(Principale.config).getValuta()+"."+(elenco_addebiti.getAddebito(i)).getTotAddebito());
else
addebiti.addItem(Utils.completaStringa(e.getDescrizione(), 10)+
Utils.completaStringa(" x "+(elenco_addebiti.getAddebito(i)).getQuantita(), 5)+" +("+quantita_mod[i-1]+")");
conto = conto + (elenco_addebiti.getAddebito(i)).getTotAddebito() + quantita_mod[i-1]*e.getPxUnitario();
}
i++;
}
totale.setText((Principale.config).getValuta()+"."+conto);
}
void scriviSuDB(String stanza)
{
for (int i = 1; i <= elenco_addebiti.length(); i++)
{
if (quantita_mod[i-1] != 0)
{
if ( (quantita_mod[i - 1]+(elenco_addebiti.getAddebito(i)).getQuantita()) > 0)
{
int j = (Principale.db).addAddebito(stanza, (elenco_addebiti.getAddebito(i)).getCodExtra(), quantita_mod[i-1] );
if (j < 0)
DataBase.visErrore(j);
}
else
{
int j = (Principale.db).delAddebito(stanza, (elenco_addebiti.getAddebito(i)).getCodExtra() );
if (j < 0)
DataBase.visErrore(j);
}
}
}
}
}
/****************************************************************************/
class FinModifiche extends Frame
{
Button ok, annulla;
Label msg = new Label("Si vogliono salvare le modifiche degli addebiti della stanza precedente?");
GridBagLayout gridbag = new GridBagLayout();
String titolo;
MascheraAddebiti padre = null;
public FinModifiche(MascheraAddebiti parent, String title)
{
super(title);
padre = parent;
padre.setEnabled(false);
titolo = new String(title);
this.setLayout(gridbag);
ok = new Button("Salva le modifiche");
annulla = new Button("Annulla le modifiche");
Utils.constrain(this, msg, 0, 0, 5, 2, GridBagConstraints.BOTH,
GridBagConstraints.CENTER, 1.0, 1.0, 20, 20, 20, 20);
Utils.constrain(this, annulla, 1, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 1.0, 1.0, 20, 20, 20, 20);
Utils.constrain(this, ok, 3, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 1.0, 1.0, 20, 20, 20, 20);
this.pack();
init();
setVisible(true);
}
public void init()
{
ok.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
padre.scriviSuDB(padre.stanza_prec);
inComune();
}
});
annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
inComune();
}
});
}
void inComune()
{
padre.riscriviElencoAddebiti();
padre.annullaAddebitiStanzaPrec();
padre.setEnabled(true);
dispose();
}
}
|
This code provides a comprehensive system for managing the billing of extra services and charges for hotel guests. The user can access a graphical interface that allows them to view a list of available extra services, select a room number and extra service to be billed, and add or remove the billing of the extra service to the room. The system handles various error cases, such as missing information or attempting to bill a non-existent room, and prompts the user to save or discard any unsaved billing changes when switching rooms. The code also displays a detailed summary of the current billing for a room, including the description, quantity, and total cost of each extra service billed. This functionality allows hotel staff to efficiently manage the billing of additional services and charges, ensuring accurate and up-to-date records for their guests.
|
Code
|
MascheraBeneServizio.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import moduli.BeneServizio;
import moduli.ListaBeniServizi;
public class MascheraBeneServizio extends Frame
{
//Dichiarazioni di oggetti che ci serviranno per definire la finestra
protected Label label, label1, label2, label3, label4, label5, label6, label7, label8,
label9, label12, label13;
protected TextField testo3, testo4;
protected Panel panel[], buttons;
protected Button annulla, conferma;
protected CheckboxGroup tipi, bar, ristorante, servizi, bevande, cibi, antipasti,
primi, secondi, contorni;
protected Checkbox[] prima_scelta, scelta_bar, scelta_piatto, scelta_servizio,
scelta_bevanda, scelta_cibo, scelta_antipasto, scelta_primo,
scelta_secondo, scelta_contorno;
protected GridLayout grid = new GridLayout(4,1);
protected GridLayout grid1 = new GridLayout(7,1);
protected GridBagLayout gridbag = new GridBagLayout();
// i seguenti due campi sono condivisi da cancellazione e modifica
protected List elenco = new List(3, false);
protected ListaBeniServizi L;
// il seguente attributo e' necessario per la gerarchia delle finestre
Frame padre = new Frame();
// i seguenti gestiscono la formazione dei primi tre caratteri del cod_extra
int level = -1;
char codice[] = new char[3];
public MascheraBeneServizio(String title)
{
super(title);
setup();
init();
setSize(350,600);
}
void setup()
{
this.setFont(ConfigurazioneSistema.font_base);
elenco.setFont(ConfigurazioneSistema.font_allineato);
//Creo i pannelli
panel = new Panel[13];
for(int i=0;i<10;++i)
{
panel[i] = new Panel();
panel[i].setLayout(grid1);
panel[i].setVisible(false);
}
for(int i=10; i<13; ++i)
{
panel[i] = new Panel();
panel[i].setVisible(false);
}
//Creo il pannello in alto
label = new Label("Tipi");
label.setFont(ConfigurazioneSistema.font_titolo);
tipi = new CheckboxGroup();
prima_scelta = new Checkbox[5]; // mi serve piu' lungo per l'aggiungi
prima_scelta[0] = new Checkbox("BAR", tipi, false);
prima_scelta[1] = new Checkbox("RISTORANTE", tipi, false);
prima_scelta[2] = new Checkbox("SERVIZI", tipi, false);
prima_scelta[3] = new Checkbox("SUPPLEMENTI", tipi, false);
prima_scelta[4] = new Checkbox("RIDUZIONI", tipi, false);
panel[0].add(label);
panel[0].add(prima_scelta[0]);
panel[0].add(prima_scelta[1]);
panel[0].add(prima_scelta[2]);
panel[0].setVisible(true);
//Attacco il pannello in alto al frame
this.setLayout(grid);
this.add(panel[0]);
//Creo il pannello del bar
label1 = new Label("Bar");
label1.setFont(ConfigurazioneSistema.font_titolo);
bar = new CheckboxGroup();
scelta_bar = new Checkbox[2];
scelta_bar[0] = new Checkbox("Bevande", bar, false);
scelta_bar[1] = new Checkbox("Cibi", bar, false);
panel[1].add(label1);
panel[1].add(scelta_bar[0]);
panel[1].add(scelta_bar[1]);
//Creo il pannello dal ristorante
label2 = new Label("Ristorante");
label2.setFont(ConfigurazioneSistema.font_titolo);
ristorante = new CheckboxGroup();
scelta_piatto = new Checkbox[6];
scelta_piatto[0] = new Checkbox("Antipasti", ristorante, false);
scelta_piatto[1] = new Checkbox("Primi", ristorante, false);
scelta_piatto[2] = new Checkbox("Secondi", ristorante, false);
scelta_piatto[3] = new Checkbox("Contorni", ristorante, false);
scelta_piatto[4] = new Checkbox("Dessert", ristorante, false);
scelta_piatto[5] = new Checkbox("Frutta", ristorante, false);
panel[2].add(label2);
panel[2].add(scelta_piatto[0]);
panel[2].add(scelta_piatto[1]);
panel[2].add(scelta_piatto[2]);
panel[2].add(scelta_piatto[3]);
panel[2].add(scelta_piatto[4]);
panel[2].add(scelta_piatto[5]);
label3 = new Label("Servizi");
label3.setFont(ConfigurazioneSistema.font_titolo);
servizi = new CheckboxGroup();
scelta_servizio = new Checkbox[2];
scelta_servizio[0] = new Checkbox("Ricreativi", servizi, false);
scelta_servizio[1] = new Checkbox("Altro", servizi, false);
panel[3].add(label3);
panel[3].add(scelta_servizio[0]);
panel[3].add(scelta_servizio[1]);
label4 = new Label("Bevande");
label4.setFont(ConfigurazioneSistema.font_titolo);
bevande = new CheckboxGroup();
scelta_bevanda = new Checkbox[3];
scelta_bevanda[0] = new Checkbox("Caffetteria", bevande, false);
scelta_bevanda[1] = new Checkbox("Analcolici", bevande, false);
scelta_bevanda[2] = new Checkbox("Alcolici", bevande, false);
panel[4].add(label4);
panel[4].add(scelta_bevanda[0]);
panel[4].add(scelta_bevanda[1]);
panel[4].add(scelta_bevanda[2]);
//Creo il pannello dei cibi
label5 = new Label("Cibi");
label5.setFont(ConfigurazioneSistema.font_titolo);
cibi = new CheckboxGroup();
scelta_cibo = new Checkbox[3];
scelta_cibo[0] = new Checkbox("Dolci", cibi, false);
scelta_cibo[1]= new Checkbox("Salati", cibi, false);
panel[5].add(label5);
panel[5].add(scelta_cibo[0]);
panel[5].add(scelta_cibo[1]);
//Creo il pannello degli antipasti
label6 = new Label("Antipasti");
label6.setFont(ConfigurazioneSistema.font_titolo);
antipasti = new CheckboxGroup();
scelta_antipasto = new Checkbox[3];
scelta_antipasto[0] = new Checkbox("Freddi", antipasti, false);
scelta_antipasto[1] = new Checkbox("Caldi", antipasti, false);
panel[6].add(label6);
panel[6].add(scelta_antipasto[0]);
panel[6].add(scelta_antipasto[1]);
//Creo il pannello dei primi
label7=new Label("Primi");
label7.setFont(ConfigurazioneSistema.font_titolo);
primi=new CheckboxGroup();
scelta_primo=new Checkbox[3];
scelta_primo[0]=new Checkbox("Solidi",primi,false);
scelta_primo[1]=new Checkbox("Liquidi",primi,false);
panel[7].add(label7);
panel[7].add(scelta_primo[0]);
panel[7].add(scelta_primo[1]);
//Creo il pannello dei secondi
label8=new Label("Secondi");
label8.setFont(ConfigurazioneSistema.font_titolo);
secondi=new CheckboxGroup();
scelta_secondo=new Checkbox[3];
scelta_secondo[0]=new Checkbox("Carne",secondi,false);
scelta_secondo[1]=new Checkbox("Pesce",secondi,false);
panel[8].add(label8);
panel[8].add(scelta_secondo[0]);
panel[8].add(scelta_secondo[1]);
//Creo il pannello dei contorni
label9 = new Label("Contorni");
label9.setFont(ConfigurazioneSistema.font_titolo);
contorni = new CheckboxGroup();
scelta_contorno = new Checkbox[3];
scelta_contorno[0] = new Checkbox("Verdura cotta", contorni, false);
scelta_contorno[1] = new Checkbox("Verdura cruda", contorni, false);
scelta_contorno[2] = new Checkbox("Formaggio", contorni, false);
panel[9].add(label9);
panel[9].add(scelta_contorno[0]);
panel[9].add(scelta_contorno[1]);
panel[9].add(scelta_contorno[2]);
//Creo il pannello BAR-Bevande
panel[10].setLayout(gridbag);
label12 = new Label("Nome del bene");
label13 = new Label("Prezzo del bene "+(Principale.config).getValuta()+".");
testo3 = new TextField("",40);
testo4 = new TextField("",10);
annulla = new Button("Annulla");
conferma = new Button("Conferma");
Utils.constrain(panel[10], label12, 0, 0, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[10], testo3, 1, 0, 4, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[10], label13, 0, 1, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 5, 5, 5, 0);
Utils.constrain(panel[10], testo4, 1, 1, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 0);
Utils.constrain(panel[10], annulla, 1, 2, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.EAST, 1.0, 0.0, 5, 5, 0, 5);
Utils.constrain(panel[10], conferma, 2, 2, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 0, 5);
}
public void init()
{
prima_scelta[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(prima_scelta[0].getState())
{
inComuneABC(scelta_bar, 1, BeneServizio.BAR);
}
}
});
prima_scelta[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(prima_scelta[1].getState())
{
inComuneABC(scelta_piatto, 2, BeneServizio.RISTORANTE);
}
}
});
prima_scelta[2].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(prima_scelta[2].getState())
{
inComuneABC(scelta_servizio, 3, BeneServizio.SERVIZI);
}
}
});
scelta_bar[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_bar[0].getState())
{
inComuneGH(scelta_bevanda, 4, BeneServizio.BEVANDE);
}
}
});
scelta_bar[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_bar[1].getState())
{
inComuneGH(scelta_cibo, 5, BeneServizio.CIBI);
}
}
});
scelta_piatto[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_piatto[0].getState())
{
inComuneILMN(scelta_antipasto, 6, BeneServizio.ANTIPASTI);
}
}
});
scelta_piatto[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_piatto[1].getState())
{
inComuneILMN(scelta_primo, 7, BeneServizio.PRIMI);
}
}
});
scelta_piatto[2].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_piatto[2].getState())
{
inComuneILMN(scelta_secondo, 8, BeneServizio.SECONDI);
}
}
});
scelta_piatto[3].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_piatto[3].getState())
{
inComuneILMN(scelta_contorno, 9, BeneServizio.CONTORNI);
}
}
});
annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
} // init
void inComuneABC(Checkbox[] scelte, int numero_pannello, char c)
{
level = 0;
for(int i=1;i<13;++i)
{
if(panel[i].isVisible())
remove(panel[i]);
}
this.add(panel[numero_pannello]);
panel[numero_pannello].setVisible(true);
setVisible(true);
codice = composeCode(level, c);
}
void inComuneGH(Checkbox[] scelte, int numero_pannello, char c)
{
level = 1;
for(int i=2;i<13;++i)
{
if(panel[i].isVisible())
remove(panel[i]);
}
this.add(panel[numero_pannello]);
panel[numero_pannello].setVisible(true);
setVisible(true);
codice = composeCode(level, c);
}
void inComuneILMN(Checkbox[] scelte, int numero_pannello, char c)
{
level = 1;
if (panel[1].isVisible())
remove(panel[1]);
for (int i = 3; i < 13; i++)
if (panel[i].isVisible())
remove(panel[i]);
this.add(panel[numero_pannello]);
panel[numero_pannello].setVisible(true);
setVisible(true);
codice = composeCode(level, c);
}
boolean errore()
{
Frame msg;
if ( !((testo3.getText()).length() < 33 ) )
{
msg = new MessageDialog(this, " La descrizione del bene o servizio deve essere di al piu' 32 caratteri! ");
return true;
}
if ( (testo3.getText()).equals("") )
{
msg = new MessageDialog(this, " Manca la descrizione del bene o servizio! ");
return true;
}
if ( (testo4.getText()).equals("") )
{
msg = new MessageDialog(this, " Manca il prezzo del bene o servizio! ");
return true;
}
if ( !(Utils.isFloatPos(testo4.getText())) )
{
msg = new MessageDialog(this, " Il prezzo deve essere un numero positivo! ");
return true;
}
return false;
}
char[] composeCode(int index, char tipo)
{
codice[index] = tipo;
for ( int i = index+1; i < 3; ++i)
codice[i] = ' ';
return codice;
}
char[] completeCode()
{
if (codice[1] == ' ')
codice[1] = '0';
if (codice[2] == ' ')
codice[2] = '0';
return codice;
}
void o()
{
if (panel[10].isVisible()) // necessario nella finestra di modifica
remove(panel[10]);
if (panel[12].isVisible()) // necessario nella finestra di cancellazione
remove(panel[12]);
inComuneOP();
}
void p() // Frutta o dessert
{
if(panel[1].isVisible())
remove(panel[1]);
for(int i=3;i<13;++i)
{
if(panel[i].isVisible())
remove(panel[i]);
}
inComuneOP();
}
void inComuneOP()
{
completeCode();
if (elenco.getItemCount() > 0) //per evitare warning
elenco.removeAll();
creaLista();
this.add(panel[11]);
panel[11].setVisible(true);
setVisible(true);
}
void creaLista()
{
int i=1;
BeneServizio b;
L = (Principale.db).elencoBeniServizi(new String(codice));
if (L != null)
{
while (i <= L.length())
{
b = L.getBeneServizio(i);
elenco.addItem(b.toString());
i++;
}
}
}
}
|
This Java GUI application provides a comprehensive interface for managing a database of goods and services. The main window allows the user to select the type of item they want to work with, such as a bar, restaurant, service, supplement, or reduction. Depending on the selection, the application displays additional panels that enable the user to further specify the details of the item, such as the type of food, drink, or service.
The application also includes a panel that allows the user to enter the name and price of a new good or service, with buttons to confirm or cancel the entry. Additionally, the application maintains a list of the existing goods and services, which the user can view and potentially modify or delete.
The code includes input validation to ensure that the user's entries are valid, such as the name not being too long and the price being a positive number. If the user attempts to enter invalid data, the application will display an error message.
Overall, this application provides a user-friendly and efficient way for the user to manage a database of goods and services, allowing them to easily add, modify, and view the available items.
|
Code
|
MascheraCalcoloConto.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import java.util.Date;
import common.utility.*;
import common.def.*;
import moduli.*;
public class MascheraCalcoloConto extends Frame
{
Button Annulla, Visualizza;
TextField testo[];
Label etichetta1, etichetta2, etichetta3, etichetta4, etichetta5, stanza,
stanza1, nome, cognome, stanza2;
Panel panel[];
CheckboxGroup checkbox_group;
Checkbox[] checkboxes;
GridBagLayout gridbag =new GridBagLayout();
// per la gerarchia
Frame padre;
MascheraVisualizzazioneConto visual;
// variabili locali
Soggiornante sogg_x_conto_sing;
String L_st[];
Date date_fine[]; // questo array e' necessario per la chiusura della comitiva
// infatti per poter ripristinare le disponibilita della
// stanza correttamente ho bisogno delle date di fine corrette
Date date_inizio[];
Date data_fine_magg;
Date fine_sogg_anticipato;
int tipo_conto;
boolean qualcuno_tramite_agenzia;
boolean qualcuno_senza_agenzia;
public MascheraCalcoloConto(Frame parent)
{
super("Calcolo del Conto");
padre = parent;
padre.setEnabled(false);
setupPanels();
init();
pack();
}
void setupPanels()
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo i pulsanti
Annulla = new Button(" Annulla ");
//Annulla.setFont(new Font("Courier", Font.PLAIN, 12));
Visualizza = new Button(" Calcola ");
//Visualizza.setFont(new Font("Courier", Font.PLAIN, 12));
Visualizza.setEnabled(false);
//Creo le etichette
etichetta1 = new Label("Selezionare il tipo di conto che si desidera calcolare:");
etichetta1.setFont(ConfigurazioneSistema.font_titolo);
etichetta2 = new Label("Conto su una stanza:");
etichetta2.setFont(ConfigurazioneSistema.font_titolo);
etichetta3 = new Label("Conto su un cliente:");
etichetta3.setFont(ConfigurazioneSistema.font_titolo);
etichetta4 = new Label("Conto su piu' stanze:");
etichetta4.setFont(ConfigurazioneSistema.font_titolo);
stanza = new Label("Stanza numero");
cognome = new Label("Cognome");
nome = new Label("Nome");
stanza1 = new Label("Stanza");
stanza2 = new Label("Stanze Numero");
//Creo i TextField e li rendo non editabili
testo=new TextField[6];
testo[0] = new TextField("", 4);
testo[1] = new TextField("", 20);
testo[2] = new TextField("", 20);
testo[3] = new TextField("", 4);
testo[4] = new TextField("", 30);
testo[5] = new TextField("",10);
for(int i=0;i<6;++i)
testo[i].setEditable(false);
//Creo un Checkbox ad esclusione
checkbox_group = new CheckboxGroup();
checkboxes = new Checkbox[4];
checkboxes[0] = new Checkbox(" Conto su una stanza",checkbox_group, false);
checkboxes[1] = new Checkbox(" Conto su un cliente",checkbox_group, false);
checkboxes[2] = new Checkbox(" Conto su piu'stanze",checkbox_group, false);
checkboxes[3] = new Checkbox(" Partenza anticipata", false);
panel=new Panel[5];
for(int i=0;i<5;++i)
{
panel[i]=new Panel();
panel[i].setLayout(gridbag);
}
//Creo il pannello in alto a sinistra
Utils.constrain(panel[1], etichetta1, 0, 0, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[1], checkboxes[0], 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
Utils.constrain(panel[1], checkboxes[1], 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
Utils.constrain(panel[1], checkboxes[2], 0, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
Utils.constrain(panel[1], checkboxes[3], 0, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
Utils.constrain(panel[1], testo[5], 1, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
//Creo il pannello in alto a destra
Utils.constrain(panel[0], Annulla, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.3, 0.0, 20, 0, 5, 20);
Utils.constrain(panel[0], Visualizza, 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.3, 0.0, 5, 0, 0, 20);
//Creo il pannello conto su una stanza
Utils.constrain(panel[2], etichetta2, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[2], stanza, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 0, 20);
Utils.constrain(panel[2], testo[0], 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
//Creo il pannello conto su un cliente
Utils.constrain(panel[3], etichetta3, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[3], cognome, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 0, 20);
Utils.constrain(panel[3], testo[1], 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel[3], nome, 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.SOUTHWEST, 0.0, 0.0, 20, 5, 0, 20);
Utils.constrain(panel[3], testo[2], 1, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.SOUTHWEST, 1.0, 0.0, 20, 0, 0, 0);
Utils.constrain(panel[3], stanza1, 4, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 0, 20);
Utils.constrain(panel[3], testo[3], 5, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
//Creo il pannello conto su piu' stanze
Utils.constrain(panel[4], etichetta4, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[4], stanza2, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 0, 20);
Utils.constrain(panel[4], testo[4], 1, 1, 1, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 5);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel[1], 0, 0, 6, 4, GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel[0], 6, 0, 1, 4, GridBagConstraints.BOTH,
GridBagConstraints.SOUTHEAST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel[2], 0, 4, 7, 2, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 1.0, 5, 5, 5, 5);
Utils.constrain(this, panel[3], 0, 6, 7, 3,GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 1.0, 5, 5, 5, 5);
Utils.constrain(this,panel[4], 0, 9, 7, 2,GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 1.0, 5, 5, 5, 5);
}
public void init()
{
checkboxes[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(checkboxes[0].getState())
{
tipo_conto = 1;
testo[0].setEditable(true);
Visualizza.setEnabled(true);
for(int i=1;i<5;++i)
{
testo[i].setEditable(false);
testo[i].setText("");
}
}
}
});
checkboxes[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(checkboxes[1].getState())
{
tipo_conto = 2;
Visualizza.setEnabled(true);
for(int i=1;i<4;++i)
testo[i].setEditable(true);
testo[0].setEditable(false);
testo[0].setText("");
testo[4].setEditable(false);
testo[4].setText("");
}
}
});
checkboxes[2].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(checkboxes[2].getState())
{
tipo_conto = 3;
Visualizza.setEnabled(true);
testo[4].setEditable(true);
for(int i=0;i<4;++i)
{
testo[i].setEditable(false);
testo[i].setText("");
}
}
}
});
checkboxes[3].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if (!checkboxes[3].getState())
{
testo[5].setEditable(false);
testo[5].setText("");
}
else
{
testo[5].setEditable(true);
testo[5].setText(DateUtils.parseDate(DateUtils.giveStringOfDate(new Date())));
}
}
});
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
Visualizza.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startVisualizza();
}
});
}
void startVisualizza()
{
if (!errori())
{
this.setEnabled(false);
if (checkboxes[0].getState())
startContoStanza();
else
{
if (checkboxes[1].getState())
{
startContoSingolo();
}
else
startContoComitiva();
}
displayConto();
}
}
void displayConto()
{
visual = new MascheraVisualizzazioneConto(testo[0].getText(),testo[1].getText(),
testo[2].getText(),testo[3].getText(),testo[4].getText(),tipo_conto);
visual.setVisible(true);
visual.conto = this;
}
boolean problemiStanza(String stanza)
{
Frame msg;
ListaSoggiornanti L_sogg;
if ((stanza).equals("") )
{
msg = new AvvisoDialog(this, " Inserire il numero di stanza ");
return true;
}
else
if ((Principale.db).readStanza(stanza) == null )
{
msg = new MessageDialog(this, " La stanza "+stanza+" e' inesistente! ");
return true;
}
else
{
L_sogg = (Principale.db).foundSoggiornanti(stanza, false);
if (L_sogg == null)
{
msg = new MessageDialog(this, " Problemi con il database! ");
return true;
}
else
if (L_sogg.length() == 0)
{
msg = new MessageDialog(this, " La stanza "+stanza+" non e' attualmente occupata ");
return true;
}
}
return false;
}
// controlla che nella lista non vi siano stanze ripetute piu' volte
int chkDouble()
{
for(int i = 0; i<L_st.length; i++)
for(int j = 0; j<L_st.length; j++)
if ( (!L_st[i].equals("")) && (!L_st[j].equals("")) && (i!=j)
&& (L_st[i].equals(L_st[j])) )
return j;
return -1;
}
Date[] tornaDateFineMagg(String elenco[])
{
Date data_fine_stanza = null;
Date fine_sogg = null;
Date date_fine_loc[] = new Date[elenco.length];
for (int i = 0; i < elenco.length; i++)
{
ListaSoggiornanti L_sogg = (Principale.db).foundSoggiornanti(elenco[i], false);
if (L_sogg != null)
{
data_fine_stanza = new Date(0, 0, 1);
for (int j = 1; j <= L_sogg.length(); j++)
{
fine_sogg = L_sogg.getSoggiornante(j).getFineSogg();
if ( Utils.data1MaggioreData2( fine_sogg, data_fine_stanza ) )
data_fine_stanza = new Date(fine_sogg.getYear(), fine_sogg.getMonth(), fine_sogg.getDate());
}
date_fine_loc[i] = data_fine_stanza;
}
else
return null;
}
return date_fine_loc;
}
Date[] tornaDateInizioMin(String elenco[])
{
Date data_inizio_stanza = null;
Date inizio_sogg = null;
Date date_inizio_loc[] = new Date[elenco.length];
for (int i = 0; i < elenco.length; i++)
{
ListaSoggiornanti L_sogg = (Principale.db).foundSoggiornanti(elenco[i], false);
if (L_sogg != null)
{
data_inizio_stanza = new Date(3000, 0, 1);
for (int j = 1; j <= L_sogg.length(); j++)
{
inizio_sogg = L_sogg.getSoggiornante(j).getInizioSogg();
if ( Utils.data1MinoreData2( inizio_sogg, data_inizio_stanza ) )
data_inizio_stanza = new Date(inizio_sogg.getYear(), inizio_sogg.getMonth(), inizio_sogg.getDate());
}
date_inizio_loc[i] = data_inizio_stanza;
}
else
return null;
}
return date_inizio_loc;
}
boolean aggiornamentoFlagsEffettuato(String elenco[])
{
qualcuno_tramite_agenzia = false;
qualcuno_senza_agenzia = false;
Prenotazione pren;
for (int i = 0; i<elenco.length; i++)
{
ListaSoggiornanti L_sogg = (Principale.db).foundSoggiornanti(elenco[i], false);
if (L_sogg != null)
{
for (int j = 1; j <= L_sogg.length(); j++)
{
pren = (Principale.db).readPrenotazione((L_sogg.getSoggiornante(j)).getIdPrenotazione());
if (pren == null)
return false;
else
{
if (pren.getTramiteAgenzia() == Const.SI)
qualcuno_tramite_agenzia = qualcuno_tramite_agenzia || true;
else
qualcuno_senza_agenzia = qualcuno_tramite_agenzia || true;
}
}
}
else
return false;
}
return true;
}
boolean errori()
{
Frame msg;
Soggiornante sogg = new Soggiornante();
if (checkboxes[0].getState())
{
if (problemiStanza(testo[0].getText()))
return true;
L_st = new String[1];
L_st[0] = new String(testo[0].getText());
}
else
if (checkboxes[1].getState())
{
L_st = new String[1];
L_st[0] = new String(testo[3].getText());
sogg = (Principale.db).foundSoggiornante(testo[3].getText(),testo[2].getText(),testo[1].getText());
if (sogg == null)
{
msg = new AvvisoDialog(this, " Nessun soggiornante presente nella stanza "+testo[3].getText()+ " risponde al nominativo inserito! ");
return true;
}
ListaSoggiornanti L_sogg = (Principale.db).foundSoggiornanti(testo[3].getText(), false);
if (L_sogg == null)
{
msg = new MessageDialog(this, " Problemi con il database! ");
return true;
}
if (sogg.getPagato() == Const.SI)
{
msg = new AvvisoDialog(this, " Il soggiornante selezionato o ha gia' pagato o se ne e' gia' andato! ");
return true;
}
else
{
// procedo con il verificare se il cliente e' l'ultimo rimasto
ListaSoggiornanti sogg_no_pagato = new ListaSoggiornanti();
for (int i=1; i<=L_sogg.length(); i++)
if (L_sogg.getSoggiornante(i).getPagato() == Const.NO)
sogg_no_pagato.addSoggiornante(L_sogg.getSoggiornante(i));
if (sogg_no_pagato.length() == 1)
{
msg = new AvvisoDialog(this, " Il soggiornante e' l'ultimo rimasto. Scegliere 'conto per stanza'! ");
return true;
}
sogg_x_conto_sing = sogg;
}
}
else
if (checkboxes[2].getState())
{
L_st = Utils.parseStanze(testo[4].getText());
if (L_st == null)
{
msg = new MessageDialog(this, " Errore nell'elenco delle stanze. Inserire le stanze nell'elenco nel modo seguente: 101,102,103,...");
return true;
}
else
{
Stanza room;
for (int i = 0; i < L_st.length; i++)
if (problemiStanza(L_st[i]))
return true;
int res = chkDouble();
if ( res != -1)
{
msg = new MessageDialog(this, " Errore nell'elenco delle stanze. La stanza "+L_st[res]+" e presente piu' volte nell'elenco! ");
return true;
}
}
}
if (checkboxes[0].getState() || checkboxes[2].getState())
{
date_fine = tornaDateFineMagg(L_st);
date_inizio = tornaDateInizioMin(L_st);
}
else
{
Prenotazione pren = (Principale.db).readPrenotazione(sogg.getIdPrenotazione());
if (pren != null)
{
date_fine = new Date[1];
date_inizio = new Date[1];
date_fine[0] = sogg.getFineSogg();
date_inizio[0] = sogg.getInizioSogg();
}
else
date_fine = null;
}
if (date_fine == null || date_inizio == null)
{
msg = new MessageDialog(this, " Problemi con il database! ");
return true;
}
// la variabile data_fine contiene le date di fine corrette
data_fine_magg = new Date(0, 0, 1);
for (int i=0; i<date_fine.length; i++)
if (Utils.data1MaggioreData2(date_fine[i], data_fine_magg))
data_fine_magg = date_fine[i];
// ora la variabile data_fine_magg contiene la data di fine maggiore
if (!aggiornamentoFlagsEffettuato(L_st))
{
msg = new MessageDialog(this, " Problemi con il database! ");
return true;
}
// da ora in poi le flags per l'agenzia contengono valori significativi
// questo if deve essere messo prima di quello che segue
if (qualcuno_tramite_agenzia && qualcuno_senza_agenzia)
{
msg = new MessageDialog(this, " L'elenco delle stanze include stanze commissionate e non! Procedere al calcolo separato. ");
return true;
}
// L'if che segue deve essere posto dopo a quello che precede
if (checkboxes[2].getState() && qualcuno_tramite_agenzia)
{
msg = new MessageDialog(this, " Il conto comitiva non e' possibile per le agenzie! ");
return true;
}
// se arrivo qui significa che si puo' fare il conto normale,
// rimane da verificare se si desidera fare una partenza anticipata
// e in tal caso verificare che la data inserita sia corretta!
if ( (checkboxes[3].getState()) && (DateUtils.dataCorretta(testo[5].getText())) )
{
Date data = DateUtils.convertDate(testo[5].getText());
Date data_oggi = new Date();
// controllo che la data di partenza anticipata abbia senso:
// 1) controllo che il cliente abbia soggiornato almento un giorno
for (int i=0; i<date_inizio.length; i++)
if (Utils.data1MaggioreData2(date_inizio[i], DateUtils.giornoPrimaDi(data)))
{
msg = new MessageDialog(this, " I clienti devono soggiornare almeno un giorno prima di partire! ");
return true;
}
// 2) controllo che la partenza anticipata non sia prima di oggi
if (Utils.data1MinoreData2(data, data_oggi))
{
msg = new AvvisoDialog(this, " La data non puo' essere precedente a quella odierna! ");
testo[5].setText(DateUtils.parseDate(DateUtils.giveStringOfDate(data_oggi)));
return true;
}
else
// 3) controllo che il fine soggiorno anticipato (ossia il giorno prima della
// partenza anticipata) non sia dopo il fine soggiorno effettivo
for (int i=0; i<date_fine.length; i++)
if (Utils.data1MaggioreData2(data, date_fine[i]))
{
msg = new AvvisoDialog(this, " Non si tratta di una partenza anticipata per la stanza "+L_st[i]+" con tale data! ");
testo[5].setText(DateUtils.parseDate(DateUtils.giveStringOfDate(data_oggi)));
return true;
}
fine_sogg_anticipato = DateUtils.giornoPrimaDi(data);
}
else
{
if ( (checkboxes[3].getState()) && !DateUtils.dataCorretta(testo[5].getText()))
{
msg = new MessageDialog(this, " La data di partenza anticipata e' errata! ");
return true;
}
else
{
// il checkboxes[3] non e' attivo
fine_sogg_anticipato = data_fine_magg;
if (qualcuno_tramite_agenzia && checkboxes[1].getState())
{
msg = new MessageDialog(this, " Il cliente e' in una stanza di agenzia! Se deve andarsene scegliere 'partenza anticipata'. ");
return true;
}
}
}
return false;
} // errori
void startContoStanza()
{
Frame msg;
if (!qualcuno_tramite_agenzia)
{
if (checkboxes[3].getState())
CalcoloConto.calcolaContoStanza(testo[0].getText(), 1, false, fine_sogg_anticipato);
else
CalcoloConto.calcolaContoStanza(testo[0].getText(), 1, false, null);
}
else
{
CalcoloConto.calcolaContoStanzaAgenzia(testo[0].getText());
}
}
void startContoSingolo()
{
if (qualcuno_tramite_agenzia)
{
Frame msg;
Date fine_effettiva;
if (checkboxes[3].getState())
fine_effettiva = fine_sogg_anticipato;
else
fine_effettiva = data_fine_magg;
if ( Utils.data1MinoreData2(fine_effettiva, new Date()) )
msg = new AskChiudiSingoloConAgenzia(this);
else
msg = new MessageDialog(this, " La data e' posteriore ad oggi: non e' possibile chiudere! ");
return;
}
else
if ( (checkboxes[3].getState()) )
CalcoloConto.calcolaContoSingolo(sogg_x_conto_sing, fine_sogg_anticipato);
else
CalcoloConto.calcolaContoSingolo(sogg_x_conto_sing, null);
}
void startContoComitiva()
{
if ( (checkboxes[3].getState()) )
CalcoloConto.calcolaContoComitiva(L_st, fine_sogg_anticipato);
else
CalcoloConto.calcolaContoComitiva(L_st, null);
}
void startChiudiSingoloConAgenzia()
{
if (checkboxes[3].getState())
{
Date new_data = DateUtils.convertDate(testo[5].getText());
new_data = DateUtils.giornoPrimaDi(new_data);
(Principale.db).anticipaFineSogg(sogg_x_conto_sing.getNumStanza(),
sogg_x_conto_sing.getIdSoggiornante(),
new_data);
}
(Principale.db).reversePagato(sogg_x_conto_sing.getNumStanza(),
sogg_x_conto_sing.getIdSoggiornante());
for (int i=0; i<testo.length-1; i++)
testo[i].setText("");
}
}
|
This code provides a user interface for calculating hotel bills or accounts. The system offers three main options for calculating the bill: for a single room, for a single customer, or for a group of customers across multiple rooms. For the single room option, the user can enter the room number, and the system will calculate the bill based on the occupancy and stay duration for that room. For the single customer option, the user can enter the customer's last name, first name, and room number, and the system will calculate the bill for that individual customer. For the group option, the user can enter a list of room numbers, and the system will calculate the bill for the entire group across those rooms.
The code also includes an option for handling early departures, where the user can enter a date for the customer's early departure, and the system will adjust the bill accordingly. Additionally, the code checks for various error conditions, such as invalid room numbers, non-existent customers, and overlapping stays, and provides appropriate error messages to the user. Overall, this code provides a comprehensive system for calculating hotel bills, with options for handling a variety of scenarios and ensuring the accuracy of the calculations.
|
Code
|
MascheraCambio.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import java.util.Date;
import common.def.*;
import common.utility.Utils;
import common.utility.DateUtils;
import moduli.*;
public class MascheraCambio extends Frame
{
TextField stanza1, stanza2;
Button Annulla, Conferma, Ricerca;
Label etichetta1, etichetta2;
Panel panel1, panel2;
GridBagLayout gridbag = new GridBagLayout();
Prenotazione p;
Frame padre;
MascheraRicercaStanza figlio;
public MascheraCambio(Frame parent)
{
super("Cambio di stanza");
padre = parent;
padre.setEnabled(false);
setup();
init();
pack();
this.setVisible(true);
}
void setup()
{
this.setFont(ConfigurazioneSistema.font_base);
stanza1 = new TextField("", 4);
stanza2 = new TextField("", 4);
stanza2.setEditable(false);
etichetta1 = new Label("Stanza attuale");
etichetta2 = new Label(" Nuova stanza");
Annulla = new Button(" Annulla ");
Ricerca = new Button(" Ricerca ");
Conferma = new Button("Conferma");
Conferma.setEnabled(false);
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, etichetta1, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, stanza1, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, etichetta2, 2, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, stanza2, 3, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, Annulla, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel2, Ricerca, 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel2, Conferma, 2, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 0, 0, 0, 0);
this.setLayout(gridbag);
Utils.constrain(this, panel1, 0, 0, 1, 1, GridBagConstraints.BOTH,
GridBagConstraints.WEST, 1.0, 1.0, 10, 10, 10, 10);
Utils.constrain(this, panel2, 0, 1, 1, 1, GridBagConstraints.BOTH,
GridBagConstraints.EAST, 1.0, 1.0, 10, 10, 10, 10);
}
public void init()
{
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
Conferma.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startConferma();
}
});
Ricerca.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (noErrors())
{
//stanza1.setEditable(false);
startRicerca();
}
}
});
}
void startConferma()
{
Frame msg;
ListaDisponibilita elenco_disp = (Principale.db).elencoDisponibilita();
if (elenco_disp == null)
{
msg = new MessageDialog(this, " Problemi con il database nella lettura delle disponibilita'! ");
return;
}
else
{
if (ctrlPosti())
{
int ris;
if ( (ris = (Principale.db).changeStanzaSoggiornanti(stanza1.getText(), stanza2.getText())) > 0 )
{
if ( (ris = (Principale.db).changeStanzaAddebiti(stanza1.getText(), stanza2.getText())) < 0 )
msg = new MessageDialog(this, "Problemi con il database: "+DataBase.strErrore(ris));
if ( (ris = (Principale.db).changeStanzaTelefonate(stanza1.getText(), stanza2.getText())) < 0 )
msg = new MessageDialog(this, "Problemi con il database: "+DataBase.strErrore(ris));
Utils.aggiornaDisp(elenco_disp,stanza1.getText(),p.getInizioSogg(),p.getFineSogg(),Flag.DISPONIBILE,Flag.OCCUPATA,true);
Utils.aggiornaDisp(elenco_disp,stanza2.getText(),p.getInizioSogg(),p.getFineSogg(),Flag.OCCUPATA,Flag.DISPONIBILE,true);
Utils.aggiornaDisp(elenco_disp,stanza2.getText(),p.getInizioSogg(),p.getFineSogg(),Flag.OCCUPATA,Flag.COMMISSIONATA,true);
Utils.aggiornaDisp(elenco_disp,stanza2.getText(),p.getInizioSogg(),p.getFineSogg(),Flag.OCCUPATA,Flag.DISPONIBILE,true);
Utils.aggiornaDisp(elenco_disp,stanza2.getText(),p.getInizioSogg(),p.getFineSogg(),Flag.OCCUPATA,Flag.COMMISSIONATA,true);
if (p.getTramiteAgenzia() == Const.SI)
{
Utils.restoreCommissioni(stanza1.getText());
}
msg = new AvvisoDialog(this,"La stanza e' stata cambiata e tutti i dati riferiti ad essa aggiornati");
Conferma.setEnabled(false);
}
else
if ( (ris != 0) && (!(ris == DataBase.DONT_EXISTS_STANZA) ) )
msg = new MessageDialog(this, "Problemi con il database: "+DataBase.strErrore(ris));
}
}
}
boolean ctrlPosti()
{
Frame msg;
ListaSoggiornanti L_sogg = (Principale.db).foundSoggiornanti(stanza1.getText(),false);
Stanza room2 = (Principale.db).readStanza(stanza2.getText());
if ( !(room2 ==null) && !(L_sogg == null))
if (L_sogg.length() > contaPosti(room2))
{
msg = new AvvisoDialog(this,"La stanza scelta e' troppo piccola per "+L_sogg.length()+" persone");
return false;
}
else
return true;
else
{
msg = new MessageDialog(this," Problemi con il database! ");
return false;
}
}
int contaPosti(Stanza s)
{
int c = s.getPostiLetto();
if (s.getDispLettoAgg() == Const.SI)
c++;
return c;
}
void startRicerca()
{
this.setEnabled(false);
figlio = new MascheraRicercaStanza("Ricerca di stanze disponibili per cambio stanza",3);
Soggiornante sogg = (Principale.db).readSoggiornante(stanza1.getText(),1);
p = (Principale.db).readPrenotazione(sogg.getIdPrenotazione());
if ( !(p == null))
{
figlio.data_inizio.setText(DateUtils.parseDate(DateUtils.giveStringOfDate(new Date())));
figlio.data_inizio.setEditable(false);
figlio.data_fine.setText(DateUtils.parseDate(DateUtils.giveStringOfDate(p.getFineSogg())));
figlio.save_date = p.getFineSogg();
if (p.getTramiteAgenzia() == Const.SI)
{
figlio.con_ag.setState(true);
figlio.con_ag.setEnabled(false);
figlio.nome_ag.setText(p.getNomeAgenzia());
figlio.nome_ag.setEditable(false);
}
figlio.setVisible(true);
figlio.father = this;
}
}
boolean noErrors()
{
Frame msg;
Disponibilita disp = new Disponibilita();
ListaDisponibilita elenco_disp = (Principale.db).elencoDisponibilita();
if (elenco_disp == null)
{
msg = new MessageDialog(this, " Problemi con il database nella lettura delle disponibilita'! ");
return false;
}
if ((stanza1.getText().equals("")) )
{
msg = new AvvisoDialog(this," Inserire il numero della stanza da cambiare! ");
return false;
}
else
{
if( (Principale.db).readStanza(stanza1.getText()) == null )
{
msg = new MessageDialog(this," La stanza inserita e' inesistente! ");
return false;
}
else
{
disp = Utils.getDispOfRoom(elenco_disp, stanza1.getText(), true);
if (disp != null)
{
if ( disp.getStatusGiorno(DateUtils.dataTogiorni(new Date()),Const.ANNO_CORRENTE) != Flag.OCCUPATA )
{
msg = new MessageDialog(this," La stanza inserita non e' attualmente occupata! ");
return false;
}
}
}
}
return true;
}
}
|
This code provides a user interface for performing a room change operation within a hotel or similar accommodation system. The user can view the current room number, select a new room number to change to, and initiate a search for available rooms that can accommodate the current occupants. Once a suitable new room is found, the user can confirm the room change, which updates the database with the new room information for the occupants, their associated charges, and telephone records. The code performs various checks to ensure the room change is valid, such as verifying the current room is occupied, the new room has enough capacity for the occupants, and updating the availability status of the rooms in the database. The code also handles error cases and displays appropriate messages to the user. This functionality is integrated with other modules in the system, such as the main application and the database, to retrieve and update the necessary information for the room change operation.
|
Code
|
MascheraCommissioni.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
public class MascheraCommissioni extends Frame
{
TextField num_stanza, nome_agenzia, inizio_comm, fine_comm, scadenza_comm ,num_tel_agenzia;
Label etichetta3, etich1, etich2, etich3, etich4, etich5, etich6, etich7;
Panel panel1, panel2, panel3, panel4, panel5;
List lista;
Button Annulla, Azione, Cerca;
GridBagLayout gridbag = new GridBagLayout();
SubCommissioni padre = new SubCommissioni();
ListaCommissionamenti L;
int caller;
public MascheraCommissioni(String data1, String data2, String title, String caption, int c)
{
super(title);
caller = c;
setupPanels(data1, data2, caption);
inizializza();
pack();
}
void setupPanels(String data1, String data2, String caption)
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo le etichette
etichetta3 = new Label("Inserimento dati della commissione");
etichetta3.setFont(ConfigurazioneSistema.font_titolo);
etich1 = new Label("Nome Agenzia");
etich2 = new Label("Numero Stanza");
etich3 = new Label("Data inizio Commissione");
etich4 = new Label("Data fine Commissione");
etich5 = new Label("Data scadenza Commissione");
etich6 = new Label("Numero telefonico Agenzia");
etich7 = new Label("Risultato della ricerca");
etich7.setFont(ConfigurazioneSistema.font_titolo);
//Creo i TextField e ne rendo alcuni non editabili
nome_agenzia = new TextField("",20);
num_stanza = new TextField("",4);
inizio_comm = new TextField("",12);
fine_comm = new TextField("",12);
scadenza_comm = new TextField("",12);
num_tel_agenzia = new TextField("",16);
//Creo i pulsanti
Annulla = new Button(" Fine ");
Azione = new Button(caption);
Cerca = new Button(" Cerca ");
//Creo il pannello
panel3 = new Panel();
panel3.setLayout(gridbag);
Utils.constrain(panel3, etichetta3, 0, 0, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel3, etich1, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel3,nome_agenzia , 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel3, etich2, 2, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel3,num_stanza, 3, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel3, etich3, 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel3,inizio_comm , 1, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel3, etich4, 2, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel3,fine_comm , 3, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel3, etich5, 0, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel3,scadenza_comm , 1, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel3, etich6, 0, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel3,num_tel_agenzia , 1, 4, 4, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
panel4 = new Panel();
panel4.setLayout(gridbag);
Utils.constrain(panel4, Annulla, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 15);
Utils.constrain(panel4, Azione, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
if ((caller == 2) || (caller == 3) )
Utils.constrain(panel4,Cerca, 2, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
lista = new List(10, false);
lista.setFont(ConfigurazioneSistema.font_allineato);
panel5 = new Panel();
panel5.setLayout(gridbag);
Utils.constrain(panel5, etich7, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel5,lista, 0, 1, 4, 3, GridBagConstraints.BOTH,
GridBagConstraints.CENTER, 3.0, 3.0, 0, 0, 0, 0);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel3, 0, 0, 6, 5, GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel4, 0, 5, 6, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel5, 0, 6, 6, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
panel5.setVisible(false);
pack();
}
public void inizializza()
{
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
}
Commissionamento readDatiComm()
{
Commissionamento comm = new Commissionamento();
comm.setIdCommissionamento((Principale.config).getIdCommissionamento());
comm.setNomeAgenzia(nome_agenzia.getText());
comm.setNumStanza(num_stanza.getText());
comm.setInizioComm(DateUtils.convertDate(inizio_comm.getText()));
comm.setFineComm(DateUtils.convertDate(fine_comm.getText()));
comm.setScadenzaComm(DateUtils.convertDate(scadenza_comm.getText()));
comm.setNumTel(num_tel_agenzia.getText());
return comm;
}
void writeDatiComm(Commissionamento comm)
{
nome_agenzia.setText(comm.getNomeAgenzia());
num_stanza.setText(comm.getNumStanza());
inizio_comm.setText(DateUtils.giveStringOfDate(comm.getInizioComm()));
fine_comm.setText(DateUtils.giveStringOfDate(comm.getFineComm()));
scadenza_comm.setText(DateUtils.giveStringOfDate(comm.getScadenzaComm()));
num_tel_agenzia.setText(comm.getNumTel());
}
protected boolean errori()
{
Frame msg;
if (!((num_stanza.getText()).length() <= 4))
{
msg = new MessageDialog(this, " Il numero della stanza deve avere al piu' 4 caratteri! ");
return true;
}
if ((num_stanza.getText()).equals(""))
{
msg = new MessageDialog(this, " Manca il numero di stanza! ");
return true;
}
if ((nome_agenzia.getText()).equals(""))
{
msg = new MessageDialog(this, " Manca il nome dell'agenzia! ");
return true;
}
if (!((nome_agenzia.getText()).length() <= 20))
{
msg = new MessageDialog(this, " Il nome dell'agenzia deve avere al piu' 20 caratteri! ");
return true;
}
if ((scadenza_comm.getText()).equals(""))
{
msg = new MessageDialog(this, " Manca la data di scadenza! ");
return true;
}
if (!(DateUtils.dataCorretta(scadenza_comm.getText()) ))
{
msg = new MessageDialog(this, " La data di scadenza e' non corretta! ");
return true;
}
if ((num_tel_agenzia.getText()).equals(""))
{
msg = new MessageDialog(this, " Manca il numero di telefono! ");
return true;
}
if (!((num_tel_agenzia.getText()).length() <= 16))
{
msg = new MessageDialog(this, " Il numero di telefono deve avere al piu' 16 caratteri! ");
return true;
}
return false;
}
void cleanFields()
{
nome_agenzia.setText("");
num_stanza.setText("");
inizio_comm.setText("");
fine_comm.setText("");
scadenza_comm.setText("");
num_tel_agenzia.setText("");
}
// procedura utilizzata da Modifica e Cancella
void creaLista()
{
Frame msg;
Commissionamento c;
L = (Principale.db).foundCommissionamenti(new String(nome_agenzia.getText()));
if (L != null)
{
if (lista.getItemCount() > 0)
lista.removeAll();
if (!L.isEmpty())
{
panel5.setVisible(true);
pack();
for (int i = 1; i<=L.length(); i++)
lista.addItem((L.getCommissionamento(i)).toString());
}
else
msg = new AvvisoDialog(this, "Agenzia "+nome_agenzia.getText()+" non trovata!");
}
else
msg = new MessageDialog(this, "Problemi con il database!");
}
void aggiornaDisp(Commissionamento comm, char tipo)
{
Disponibilita disp_da_cambiare = new Disponibilita();
ListaDisponibilita elenco_disp = (Principale.db).elencoDisponibilita();
if (elenco_disp == null)
{
Frame msg = new MessageDialog(this, " Problemi con il database nella lettura delle disponibilita'! ");
return;
}
disp_da_cambiare = Utils.getDispOfRoom(elenco_disp,comm.getNumStanza(),true);
if (tipo == Flag.COMMISSIONATA)
disp_da_cambiare.setDisponibilita(comm.getInizioComm(), comm.getFineComm(), tipo, Flag.DISPONIBILE);
else
disp_da_cambiare.setDisponibilita(comm.getInizioComm(), comm.getFineComm(), tipo, Flag.COMMISSIONATA);
(Principale.db).changeDisponibilita( disp_da_cambiare.getNumStanza(),
disp_da_cambiare.getDispAnnoCorr(),
disp_da_cambiare.getDispAnnoProx() );
}
}
|
This code provides a user interface for managing commissions within a software system. Users can view and edit the details of a commission, including the agency name, room number, commission dates, and agency phone number. The system validates the input data to ensure it meets certain criteria, such as character limits and valid date formats, and displays error messages if any issues are found.
Users can also retrieve a list of commissions based on the agency name, allowing them to select a specific commission to view or modify. The system updates the availability of the room associated with a commission, marking it as either available or commissioned based on the commission's start and end dates. Finally, users can cancel the current operation and close the window, returning control to the parent window.
Overall, this code provides a comprehensive set of features for managing commissions within the software system, allowing users to efficiently track and update commission information as needed.
|
Code
|
MascheraContoRistorazione.java
|
package interfacce;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
public class MascheraContoRistorazione extends MascheraPerAddebitare
{
// oggetti per la costruzione della finestra
Label etich1, etich2, etich3;
TextField num_coperti;
public MascheraContoRistorazione(Frame parent)
{
super("Servizio ristorazione", "Stampa del conto");
padre = parent;
padre.setEnabled(false);
inizExtra();
setupPanello();
inizializza();
pack();
setVisible(true);
}
// Travaso dati degli extra nelle strutture dati apposite
void inizExtra()
{
MessageDialog msg;
elenco_extra = (Principale.db).menuRistorante();
if (elenco_extra != null)
{
if (extra.getItemCount() > 0)
extra.removeAll();
int i=1;
while (i <= elenco_extra.length())
{
extra.addItem( (elenco_extra.getBeneServizio(i)).toString() );
i++;
}
}
}
// Creazione della finestra
void setupPanello()
{
num_coperti = new TextField("", 4);
num_coperti.setEditable(true);
// creo le label
etich1 = new Label("Gestione degli addebiti ");
etich1.setFont(ConfigurazioneSistema.font_titolo);
etich2 = new Label("Scegliere l'extra da addebitare ");
etich3 = new Label("Numero di coperti ");
// creo pannello di sinistra
this.remove(panel1);
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, etich1, 0, 0, 6, 1);
Utils.constrain(panel1, etich2, 0, 1, 6, 1, 10, 0, 0, 0);
Utils.constrain(panel1, extra, 0, 2, 6, 4, GridBagConstraints.BOTH,
GridBagConstraints.WEST, 1.0, 1.0, 0, 20, 0, 20);
// creo pannello per coperti
this.remove(panel4);
panel4 = new Panel();
panel4.setLayout(gridbag);
Utils.constrain(panel4, etich3, 0, 0, 1, 1, 5, 5, 5, 5);
Utils.constrain(panel4, num_coperti, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
// aggiungo il pannello appena creato al resto
Utils.constrain(this, panel1, 0, 0, 1, 1, GridBagConstraints.VERTICAL,
GridBagConstraints.WEST, 0.5, 0.5, 5, 5, 5, 5);
Utils.constrain(this, panel4, 0, 2, 1, 1, GridBagConstraints.VERTICAL,
GridBagConstraints.WEST, 0.5, 0.5, 5, 5, 5, 5);
}
// Per la gestione degli eventi della finestra
void inizializza()
{
conferma.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
stampaConto();
}
});
addebita.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (!errore())
{
aggiornaAvideo(true);
}
}
});
deaddebita.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (!errore())
{
aggiornaAvideo(false);
}
}
});
extra.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (!errore())
{
aggiornaAvideo(true);
}
}
});
}
// Ritorna false se si sta' cercando di addebitare un extra in
// mancanza dei dati necessari per l'addebito: coperti e extra.
boolean errore()
{
Frame msg;
if ((num_coperti.getText()).equals(""))
{
msg = new MessageDialog(this, "Inserire il numero di coperti!");
return true;
}
else if ( !Utils.isIntPos(num_coperti.getText()) )
{
msg = new MessageDialog(this, "Il numero dei coperti deve essere un numero intero!");
return true;
}
else if (extra.getSelectedIndex() == -1)
{
msg = new MessageDialog(this, "Manca selezione!");
return true;
}
else
return false;
}
int posExtraInAddebiti(BeneServizio b)
{
for (int i = 1; i <= elenco_addebiti.length(); i++)
if ( ((elenco_addebiti.getAddebito(i)).getCodExtra()).equals(b.getCodExtra()) )
return i;
return -1;
}
void aggiornaAvideo(boolean addebito)
{
Frame msg;
int supp[];
BeneServizio extra_scelto = elenco_extra.getBeneServizio( extra.getSelectedIndex() + 1 );
int pos;
if ((pos = posExtraInAddebiti(extra_scelto)) < 0 && addebito)
{
Addebito a = new Addebito("RIST", extra_scelto.getCodExtra(), 0, 0);
elenco_addebiti.addAddebito( a );
elenco_extra_addebitati.addBeneServizio( extra_scelto );
// allungo l'array delle quantita' modificate
supp = new int[elenco_addebiti.length()];
for (int i = 0; i<quantita_mod.length; i++)
supp[i] = quantita_mod[i];
supp[supp.length - 1] = 1;
quantita_mod = supp;
pos = quantita_mod.length;
extra_add.setText(extra.getSelectedItem());
continuaAggiornamento();
}
else
{
if (pos < 0)
{
// sto cercando di togliere da un addebito inesistente
msg = new AvvisoDialog(this, "Stai cercando di togliere da un addebito ormai inesistente!");
}
else
{
// aggiorno tale array per contenere l'addebito appena effettuato
if (addebito)
{
quantita_mod[pos - 1]++;
extra_add.setText(extra.getSelectedItem());
continuaAggiornamento();
}
else
if ( quantita_mod[pos - 1] > 0)
{
quantita_mod[pos - 1]--;
extra_add.setText(extra.getSelectedItem());
continuaAggiornamento();
}
else
msg = new AvvisoDialog(this, "Stai cercando di togliere da un addebito ormai inesistente!");
}
}
}
void continuaAggiornamento()
{
int i = 1;
BeneServizio e;
float conto = 0;
float conto_di_questo_extra;
if (addebiti.getItemCount() > 0)
addebiti.removeAll();
while ( i <= elenco_addebiti.length() )
{
if (quantita_mod[i-1] != 0)
{
e = elenco_extra_addebitati.getBeneServizio(i);
conto_di_questo_extra = quantita_mod[i-1]*e.getPxUnitario();
if ( Integer.parseInt(e.getCodExtra()) >= 40000000 && Integer.parseInt(e.getCodExtra()) < 50000000)
addebiti.addItem("S "+Utils.completaStringa(e.getDescrizione(), 32)+" "+(Principale.config).getValuta()+"."+(elenco_addebiti.getAddebito(i)).getTotAddebito());
else if ( Integer.parseInt(e.getCodExtra()) >= 50000000)
addebiti.addItem("R "+Utils.completaStringa(e.getDescrizione(), 32)+" "+(Principale.config).getValuta()+"."+(elenco_addebiti.getAddebito(i)).getTotAddebito());
else
addebiti.addItem( Utils.completaStringa(e.getDescrizione(),10)+Utils.completaStringa(" x "+quantita_mod[i-1], 5)+(Principale.config).getValuta()+"."+conto_di_questo_extra );
conto = conto + conto_di_questo_extra;
}
i++;
}
totale.setText((Principale.config).getValuta()+"."+conto);
}
void stampaConto()
{
if (!errore())
{
writeFile();
dispose();
padre.setEnabled(true);
}
}
private void writeFile()
{
Frame msg;
float costo_coperti;
DataOutputStream outStream;
try
{
outStream = new DataOutputStream(new FileOutputStream("conto.abg"));
}
catch (IOException ex)
{
msg = new MessageDialog(this,"Errore nell'apertura del file del conto");
return;
}
try
{
outStream.writeBytes( (Principale.config).getNomeAlbergo()+"\n" );
outStream.writeBytes( "\n" );
outStream.writeBytes( (Principale.config).getRagSoc()+"\n" );
outStream.writeBytes( (Principale.config).getIndirizzoAlb()+"\n" );
outStream.writeBytes( (Principale.config).getComuneAlb()+"\n" );
outStream.writeBytes( (Principale.config).getCittaAlb()+"\n" );
outStream.writeBytes( "\n" );
BeneServizio extra;
Addebito a;
int num;
String supporto;
float conto_totale;
for(int i=1; i<=elenco_addebiti.length(); i++)
{
if (quantita_mod[i-1] != 0)
{
a = elenco_addebiti.getAddebito(i);
extra = elenco_extra_addebitati.getBeneServizio(i);
num = quantita_mod[i-1];
if ( (extra.getCodExtra()).compareTo("40000000") < 0 )
supporto = new String(extra.getDescrizione()+" x "+num+" ");
else if ( (extra.getCodExtra()).compareTo("50000000") < 0 )
supporto = new String("Supplemento per "+extra.getDescrizione()+" ");
else
supporto = new String("Riduzione per "+extra.getDescrizione()+" ");
while (supporto.length() < 52)
supporto = new String(supporto+" ");
outStream.writeBytes(supporto+(Principale.config).getValuta()+"."+
num*extra.getPxUnitario()+"\n" );
}
}
supporto = new String("Coperto x "+num_coperti.getText());
while (supporto.length() < 52)
supporto = new String(supporto+" ");
costo_coperti = Integer.parseInt(num_coperti.getText())*(Principale.config).getCoperto();
outStream.writeBytes(supporto+(Principale.config).getValuta()+"."+costo_coperti+"\n");
outStream.writeBytes("\n");
supporto = new String("Totale");
while (supporto.length() < 52)
supporto = new String(supporto+" ");
conto_totale = (Float.valueOf( new String((totale.getText()).substring(2)) )).floatValue()+costo_coperti;
outStream.writeBytes( supporto+(Principale.config).getValuta()+"."+conto_totale );
outStream.close();
}
catch (IOException ex)
{
msg = new MessageDialog(this,"Errore nella scrittura del file del conto");
return;
}
}
}
|
This code provides a user interface for managing a restaurant bill or check. The user can select various food and beverage items from a menu, add or remove them from the bill, and specify the number of covers (diners). The code then calculates the total bill amount, including the cost of the selected extras and the cover charge, and allows the user to print the bill to a file. The code includes error handling to ensure that the user provides valid input, and appears to be part of a larger software system that includes other classes and modules. Overall, this code gives the user a comprehensive tool for managing and finalizing restaurant bills, with a user-friendly interface and robust functionality.
|
Code
|
MascheraDisponibilita.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.ListaDisponibilita;
import moduli.Disponibilita;
import moduli.ListaCommissionamenti;
import moduli.Commissionamento;
public class MascheraDisponibilita extends Frame
{
Button Indietro, Visualizza;
TextField testo;
Label etichetta1, etichetta2, etichetta3, label3, label5, label1;
Panel panel[];
CheckboxGroup checkbox_group;
Checkbox[] checkboxes;
GridBagLayout gridbag = new GridBagLayout();
List lista_disp;
Frame padre;
Costanti cost;
int anno_corr, anno_prox;
String agenzia;
ListaDisponibilita L;
public MascheraDisponibilita(Frame parent, String nome_ag)
{
super("Disponibilita delle stanze");
padre = parent;
agenzia = new String(nome_ag);
padre.setEnabled(false);
setupPanels();
pack();
init();
this.setVisible(true);
}
void setupPanels()
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo i pulsanti
Indietro = new Button(" Indietro ");
//Annulla.setFont(new Font("Courier", Font.PLAIN, 12));
Visualizza = new Button("Visualizza disponibilita");
Visualizza.setEnabled(false);
//Conferma.setFont(new Font("Courier", Font.PLAIN, 12));
//Creo le etichette
etichetta1 = new Label("Selezionare il tipo di ricerca che si desidera effettuare:");
etichetta1.setFont(ConfigurazioneSistema.font_titolo);
etichetta2 = new Label("Risultato della ricerca:");
etichetta2.setFont(ConfigurazioneSistema.font_titolo);
etichetta3 = new Label("Ricerca per stanza:");
etichetta3.setFont(ConfigurazioneSistema.font_titolo);
label1 = new Label("Stanza numero");
//Creo un Checkbox ad esclusione
checkbox_group = new CheckboxGroup();
checkboxes = new Checkbox[2];
checkboxes[0] = new Checkbox(" Ricerca per stanza",checkbox_group,false);
checkboxes[1] = new Checkbox(" Ricerca su tutte le stanze",checkbox_group,false);
//Creo il TextField e lo rendo non editabili
testo = new TextField("", 4);
testo.setEditable(false);
//creo una Lista
lista_disp = new List(10, false);
panel=new Panel[5];
for(int i=0;i<panel.length;++i)
{
panel[i]=new Panel();
panel[i].setLayout(gridbag);
}
//Creo il pannello in alto a sinistra
Utils.constrain(panel[1], etichetta1, 0, 0, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[1], checkboxes[0], 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
Utils.constrain(panel[1], checkboxes[1], 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
//Creo il pannello ricerca per stanza
Utils.constrain(panel[2], etichetta3, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[2], label1, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 0, 20);
Utils.constrain(panel[2], testo, 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
//Creo il pannello dei pulsanti
Utils.constrain(panel[0], Indietro, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.EAST, 0.3, 0.0, 10, 0, 10, 5);
Utils.constrain(panel[0], Visualizza, 3, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.3, 0.0, 10, 5, 10, 0);
//Creo il pannello contenente la list_soggiornanti
Utils.constrain(panel[4], etichetta2, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[4], lista_disp, 0, 1, 1, 1, GridBagConstraints.BOTH,
GridBagConstraints.NORTHWEST, 1.0, 1.0, 0, 5, 0, 20);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel[1], 0, 0, 5, 4, GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel[2], 0, 4, 5, 2, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 1.0, 5, 5, 5, 5);
Utils.constrain(this, panel[0], 0, 6, 5, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.SOUTHEAST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel[4], 0, 7, 5, 7, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 1.0, 5, 5, 5, 5);
}
public void init()
{
cost = new Costanti();
anno_corr = cost.getAnnoCorr();
anno_prox = cost.getAnnoProx();
checkboxes[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
testo.setEditable(true);
Visualizza.setEnabled(true);
if (lista_disp.getItemCount() > 0)
lista_disp.removeAll();
}
});
checkboxes[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
testo.setEditable(false);
testo.setText("");
Visualizza.setEnabled(true);
if (lista_disp.getItemCount() > 0)
lista_disp.removeAll();
}
});
Visualizza.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
Disponibilita disp = new Disponibilita();
String str = new String("");
//Tramuto temporaneamente tutti i commissionamenti di una certa agenzia
//in disponibilita
ListaDisponibilita L_disp = (Principale.db).elencoDisponibilita();
if (!agenzia.equals(""))
{
ListaCommissionamenti L_comm = (Principale.db).foundCommissionamenti(agenzia);
Commissionamento comm;
for (int i = 1; i <= L_comm.length(); i++)
{
comm = L_comm.getCommissionamento(i);
disp = Utils.getDispOfRoom(L_disp,comm.getNumStanza(),true);
disp.setDisponibilita(comm.getInizioComm(),comm.getFineComm(),Flag.DISPONIBILE, Flag.COMMISSIONATA);
L_disp.addDisponibilita(disp);
}
str = new String(" --- commissioni "+agenzia);
}
if (L_disp.length() > 0)
lista_disp.addItem("TABELLA DELLE DISPONIBILITA'"+str);
if (checkboxes[0].getState())
showDispOfRoom(L_disp,testo.getText());
else
showDispOfHotel(L_disp);
}
});
Indietro.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
}
void showDispOfRoom(ListaDisponibilita L, String room)
{
Frame msg;
Disponibilita disp;
String aus;
if (room.equals(""))
msg = new MessageDialog(this,"Inserire il numero della stanza per la ricerca delle sue dispoibilita");
else
{
disp = Utils.getDispOfRoom(L, room, false);
if (disp == null)
{
msg = new MessageDialog(this,"La stanza inserita e' inesistente!");
if (lista_disp.getItemCount() > 0)
lista_disp.removeAll();
}
else
{
lista_disp.addItem("");
lista_disp.addItem("Disponibilita' stanza n. "+room+" per l'anno "+anno_corr);
aus = new String(Utils.scanVectorForDisp(disp.getDispAnnoCorr(), anno_corr, (Principale.config).getStagAnnoCorr()));
if (aus.equals(""))
lista_disp.addItem("NESSUNA DISPONIBILITA'");
else
lista_disp.addItem(aus);
lista_disp.addItem("");
lista_disp.addItem("Disponibilita' stanza n. "+room+" per l'anno "+anno_prox);
aus = new String(Utils.scanVectorForDisp(disp.getDispAnnoProx(), anno_prox, (Principale.config).getStagAnnoProx()));
if (aus.equals(""))
lista_disp.addItem("NESSUNA DISPONIBILITA'");
else
lista_disp.addItem(aus);
}
}
}
void showDispOfHotel(ListaDisponibilita L)
{
Frame msg;
if (L.length() == 0)
msg = new AvvisoDialog(this,"Nessuna stanza trovata!");
else
for (int i = 1; i <= L.length(); i++)
showDispOfRoom(L, (L.getDisponibilita(i)).getNumStanza());
}
}
|
The code provided appears to be a graphical user interface (GUI) application that allows users to view the availability of rooms in a hotel or other accommodation facility. The application provides a user-friendly interface where the user can select between searching for availability of a specific room or viewing the availability of all rooms. The application then displays the availability of rooms for the current year and the next year, including any commissions or reservations that have been made. Users can view a list of available rooms and their availability status, which can be filtered by room number. The application also allows users to navigate back to the previous screen or window. The application seems to be part of a larger system, as it references other classes and modules that are not included in the provided code, and it interacts with a database to retrieve the availability information.
|
Code
|
MascheraPerAddebitare.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
public class MascheraPerAddebitare extends Frame
{
// variabili per tenere tutto in memoria
ListaBeniServizi elenco_extra = new ListaBeniServizi();
ListaAddebiti elenco_addebiti = new ListaAddebiti();
ListaBeniServizi elenco_extra_addebitati = new ListaBeniServizi();
// oggetti per la costruzione della finestra
Label etich4, etich5, etich6, etich7;
Panel panel1, panel2, panel3, panel4, panel5, panel6, panel7;
Button conferma, annulla, addebita, deaddebita, aggiungi;
TextField extra_add, totale;
List addebiti, extra;
GridBagLayout gridbag = new GridBagLayout();
// attributi per la gestione della gerarchia delle finestre;
Frame padre = new Frame();
AggiungiBeneServizio nuovo;
// flag per capire se si tratta di un addebito o di un deaddebito
boolean addebito;
// variabili per il travaso del database in memoria
int quantita_mod[] = new int[0]; // quantita aggiunge o tolte a vecchi addebiti
public MascheraPerAddebitare(String titolo, String bottone_conf)
{
super(titolo);
setupPanels(bottone_conf);
init();
pack();
}
// Creazione della finestra
void setupPanels(String bottone_conf)
{
this.setFont(ConfigurazioneSistema.font_base);
// creo l'elenco degli addebiti alla stanza e degli extra
addebiti = new List(10, false);
addebiti.setFont(ConfigurazioneSistema.font_allineato);
extra = new List(10, false);
extra.setFont(ConfigurazioneSistema.font_allineato);
// creo i textfield
extra_add = new TextField("", 40);
totale = new TextField("", 20);
extra_add.setEditable(false);
totale.setEditable(false);
// creo i pulsanti
addebita = new Button("Addebita");
deaddebita = new Button("Togli dall'addebito");
aggiungi = new Button("Aggiungi nuovo bene/servizio");
annulla = new Button("Annulla");
conferma = new Button(bottone_conf);
// creo le label
etich4 = new Label("Informazioni sugli addebiti");
etich4.setFont(ConfigurazioneSistema.font_titolo);
etich5 = new Label("Ultimo addebito effettuato");
etich6 = new Label("Lista degli addebiti");
etich7 = new Label("Totale dell'addebito");
// creo il primo pannello vuoto
panel1 = new Panel();
// creo pannello di informazione degli addebiti
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, etich4, 0, 0, 3, 1);
Utils.constrain(panel2, etich5, 0, 2, 3, 1, 10, 0, 0, 0);
Utils.constrain(panel2, extra_add, 0, 3, 1, 1, 0, 20, 0, 0);
Utils.constrain(panel2, etich6, 0, 5, 3, 1, 10, 0, 0, 0);
Utils.constrain(panel2, addebiti, 0, 6, 2, 4, GridBagConstraints.BOTH,
GridBagConstraints.WEST, 1.0, 1.0, 0, 20, 0, 20);
Utils.constrain(panel2, etich7, 0, 12, 3, 1, 10, 0, 0, 0);
Utils.constrain(panel2, totale, 0, 13, 1, 1, 0, 20, 0, 0);
// creo pannello per addebita
panel3 = new Panel();
panel3.setLayout(gridbag);
Utils.constrain(panel3, addebita, 0, 0, 1, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.CENTER, 1.0, 0.0, 0, 0, 0, 5);
Utils.constrain(panel3, deaddebita, 1, 0, 1, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.CENTER, 1.0, 0.0, 0, 5, 0, 0);
// creo pannello vuoto per num_stanza o coperti
panel4 = new Panel();
// creo pannello per aggiungi
panel5 = new Panel();
panel5.setLayout(gridbag);
Utils.constrain(panel5, aggiungi, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 1.0, 0.0, 5, 5, 5, 5);
// creo pannello per annulla
panel6 = new Panel();
panel6.setLayout(gridbag);
Utils.constrain(panel6, annulla, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 1.0, 0.0, 0, 0, 0, 0);
// creo pannello per conferma
panel7 = new Panel();
panel7.setLayout(gridbag);
Utils.constrain(panel7, conferma, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 1.0, 0.0, 0, 0, 0, 0);
// costruisco la finestra definitiva attaccando i pannelli
this.setLayout(gridbag);
Utils.constrain(this, panel1, 0, 0, 1, 1, GridBagConstraints.VERTICAL,
GridBagConstraints.WEST, 0.5, 0.5, 5, 5, 5, 5);
Utils.constrain(this, panel2, 1, 0, 1, 4, GridBagConstraints.VERTICAL,
GridBagConstraints.WEST, 0.5, 0.5, 5, 5, 5, 5);
Utils.constrain(this, panel3, 0, 1, 1, 1, GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 0, 5, 0);
Utils.constrain(this, panel4, 0, 2, 1, 1, GridBagConstraints.VERTICAL,
GridBagConstraints.WEST, 0.5, 0.5, 5, 0, 5, 0);
Utils.constrain(this, panel5, 0, 3, 1, 1, GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel6, 0, 4, 1, 1, GridBagConstraints.BOTH,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 0, 5, 0);
Utils.constrain(this, panel7, 1, 4, 2, 1, GridBagConstraints.BOTH,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 0, 5, 0);
}
// Per la gestione degli eventi della finestra
void init()
{
annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
aggiungi.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startAggiungi();
}
});
}
void startAggiungi()
{
nuovo = new AggiungiBeneServizio(this);
}
}
|
The provided code appears to be a Java GUI application that allows users to manage and administer various charges or fees associated with a particular entity, such as a room or a set of covers. The application provides a window-based interface with several panels and controls that enable the user to perform a variety of tasks related to these charges or fees.
Users can view and manage a list of existing charges or fees, referred to as "addebiti" in the code. They can see the details of the last charge made, as well as a list of all the current charges. Users can also add new charges or fees to the list by selecting from a list of available "extra" items or services, and remove charges or fees from the list by deducting them from the total. The application calculates and displays the total amount of the current charges or fees, and allows users to add new "extra" items or services to the system, which can then be selected and added to the list of charges or fees.
The application also provides various actions, such as confirming or canceling the current charge or fee management session, through the use of buttons and other controls. The code includes variables and objects to manage the data structures used to store the list of "extra" items or services, the list of charges or fees, and the list of charges or fees that have been applied, suggesting that this application is part of a larger software system.
|
Code
|
MascheraPrenotazione.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import java.util.Date;
import moduli.*;
public class MascheraPrenotazione extends Frame
{
//Dichiarazioni di variabili
Panel panel1, panel2, panel3;
Label etichetta1, label1, label2, label3, label4, label5, label6, label7,
label8, label9, label10, label11, label12, label13;
List lista;
public Button Annulla, Azione, Assegna, Cancella;
TextField testo[];
Choice mychoice;
Checkbox[] checkboxes;
Checkbox myCheckbox, myCheckbox1;
CheckboxGroup pensione;
GridBagLayout gridbag = new GridBagLayout();
Frame padre = new Frame();
ListaPrenotazioni L;
Stanza stanza;
int caller;
public MascheraPrenotazione(Stanza s, String data_i, String data_f, String title, String caption, int c, char pens)
{
super(title);
caller = c;
stanza = s;
setupPanels(data_i, data_f, caption, pens);
inizializza();
pack();
}
void setupPanels(String data_i, String data_f, String caption, char pens)
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo dei pulsanti e ne disabilito due
Annulla = new Button(" Fine ");
Azione = new Button(caption);
Assegna = new Button(" Assegna Stanza ");
Cancella = new Button(" Cancella prenotazione ");
//Creo le etichette
etichetta1 = new Label ("Inserimento dei dati della prenotazione:");
etichetta1.setFont(ConfigurazioneSistema.font_titolo);
label1 = new Label("Numero stanza");
label2 = new Label("Cognome");
label3 = new Label("Nome");
label4 = new Label("Numero telefonico");
label5 = new Label("Numero persone");
label6 = new Label("Data inizio");
label7 = new Label("Data fine");
label8 = new Label("Caparra versata "+(Principale.config).getValuta()+".");
label9 = new Label("Richieste particolari");
label11 = new Label("Nome Agenzia");
label10 = new Label("Tipo di pensionamento:");
label10.setFont(ConfigurazioneSistema.font_titolo);
label12 = new Label("Risultato della ricerca");
label12.setFont(ConfigurazioneSistema.font_titolo);
label13 = new Label("Data di prenotazione");
//Creo i TextField e ne rendo alcuni non editabili
testo=new TextField[11];
testo[0] = new TextField("", 4);
testo[1] = new TextField("", 20);
testo[2] = new TextField("", 20);
testo[3] = new TextField("", 10);
testo[4] = new TextField("", 12);
testo[5] = new TextField("", 12);
testo[6] = new TextField("", 10);
testo[7] = new TextField("", 20);
testo[8] = new TextField("", 20);
testo[8].setEditable(false);
testo[9] = new TextField("", 12);
testo[9].setEditable(false);
testo[10] = new TextField("",3);
//Creo un Checkbox ad esclusione
pensione = new CheckboxGroup();
checkboxes = new Checkbox[4];
checkboxes[0] = new Checkbox(" Solo pernottamento", pensione, false);
checkboxes[1] = new Checkbox(" Prima colazione", pensione, false);
checkboxes[2] = new Checkbox(" Mezza pensione", pensione, false);
checkboxes[3] = new Checkbox(" Pensione completa", pensione, false);
switch (pens)
{
case Flag.SOLO_PERNOTTAMENTO:
checkboxes[0] = new Checkbox(" Solo pernottamento", pensione, true);
break;
case Flag.SOLO_COLAZIONE:
checkboxes[1] = new Checkbox(" Prima colazione", pensione, true);
break;
case Flag.MEZZA_PENSIONE:
checkboxes[2] = new Checkbox(" Mezza pensione", pensione, true);
break;
case Flag.PENSIONE_COMPLETA:
checkboxes[3] = new Checkbox(" Pensione completa", pensione, true);
break;
}
//Creo due Checkbox a se' stanti
myCheckbox = new Checkbox(" Letto aggiuntivo", null, false);
if (stanza != null)
if (stanza.getDispLettoAgg() == Const.NO)
myCheckbox.setEnabled(false);
myCheckbox1 = new Checkbox(" Prenotazione tramite agenzia", null, false);
myCheckbox1.setEnabled(false);
//Creo un Choice
if (caller == 1)
{
mychoice = new Choice();
if (stanza != null)
for (int i=1; i<= stanza.getPostiLetto(); i++)
mychoice.addItem(""+i);
else
mychoice.addItem("1");
}
//Creo il pannello in alto per inserimento dei dati del cliente
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, etichetta1, 0, 0, 4, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, label1, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo[0], 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.5, 5, 5, 5, 5);
Utils.constrain(panel1, label13, 2, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo[9], 3, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.5, 5, 5, 5, 5);
Utils.constrain(panel1, label2, 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo[1], 1, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.5, 5, 5, 5, 5);
Utils.constrain(panel1, label3, 2, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo[2], 3, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label4, 0, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo[3], 1, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label5, 2, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
if (caller == 1)
Utils.constrain(panel1, mychoice, 3, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
else
Utils.constrain(panel1, testo[10], 3, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label6, 0, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo[4], 1, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label7, 2, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo[5], 3, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label8, 0, 5, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo[6], 1, 5, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label9, 0, 6, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo[7], 1, 6, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, myCheckbox, 0, 7, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, myCheckbox1, 1, 7, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label11, 2, 7, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo[8], 3, 7, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label10, 0, 8, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, checkboxes[0], 0, 9, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, checkboxes[1], 0, 10, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, checkboxes[2], 0, 11, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, checkboxes[3], 0, 12, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
//Creo il pannello in basso con due pulsanti
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, Annulla, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, Azione, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
if (caller == 2 )
Utils.constrain(panel2, Assegna, 2, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
if (caller == 5 )
Utils.constrain(panel2, Cancella, 2, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
//Creo il pannello con la lista dei risultati della ricerca
lista = new List(7,false);
lista.setFont(ConfigurazioneSistema.font_allineato);
panel3 = new Panel();
panel3.setLayout(gridbag);
Utils.constrain(panel3, label12, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel3, lista, 0, 1, 4, 3, GridBagConstraints.BOTH,
GridBagConstraints.CENTER, 3.0, 3.0, 0, 0, 0, 0);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel1, 0, 1, 4, 13, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel2, 0, 14, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel3, 0, 15, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
panel3.setVisible(false);
pack();
}
public void inizializza()
{
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
}
public Prenotazione readDatiPren()
{
Prenotazione pren = new Prenotazione();
pren.setNumStanza(testo[0].getText());
pren.setCognome(testo[1].getText());
pren.setNome(testo[2].getText());
pren.setNumTel(testo[3].getText());
if (caller == 1)
pren.setNumPers(Integer.parseInt(mychoice.getSelectedItem())); //Conversione String -> Int
else
pren.setNumPers(Integer.parseInt(testo[10].getText()));
pren.setInizioSogg(DateUtils.convertDate(testo[4].getText()));
pren.setFineSogg(DateUtils.convertDate(testo[5].getText()));
if ( (testo[6].getText().equals("")) )
pren.setCaparra(0);
else
pren.setCaparra((Float.valueOf(testo[6].getText())).floatValue()); // Conversione String -> Float
pren.setRichParticolari(testo[7].getText());
if (myCheckbox.getState() == true)
pren.setRichLettoAgg(Const.SI);
if (myCheckbox1.getState() == true)
{
pren.setTramiteAgenzia(Const.SI);
pren.setNomeAgenzia(testo[8].getText());
}
if (checkboxes[0].getState() == true)
pren.setPensionamento(Flag.SOLO_PERNOTTAMENTO);
else
if (checkboxes[1].getState() == true)
pren.setPensionamento(Flag.SOLO_COLAZIONE);
else
if (checkboxes[2].getState() == true)
pren.setPensionamento(Flag.MEZZA_PENSIONE);
else
pren.setPensionamento(Flag.PENSIONE_COMPLETA);
pren.setIdPrenotazione(Principale.config.getIdPrenotazione());
return pren;
}
public void writeDatiPren(Prenotazione pren)
{
myCheckbox.setState(false);
myCheckbox1.setState(false);
testo[8].setText("");
testo[0].setText(pren.getNumStanza());
testo[1].setText(pren.getCognome());
testo[2].setText(pren.getNome());
testo[3].setText(pren.getNumTel());
testo[4].setText(DateUtils.giveStringOfDate(pren.getInizioSogg()));
testo[5].setText(DateUtils.giveStringOfDate(pren.getFineSogg()));
testo[6].setText(""+pren.getCaparra());
testo[7].setText(pren.getRichParticolari());
testo[8].setText(pren.getNomeAgenzia());
testo[9].setText(DateUtils.giveStringOfDate(pren.getDataPren()));
if (caller != 1)
{
testo[10].setText(""+pren.getNumPers());
}
if (pren.getTramiteAgenzia() == Const.SI)
{
myCheckbox1.setState(true);
testo[8].setText(pren.getNomeAgenzia());
}
}
protected boolean errori()
{
boolean numeri_corretti;
Frame msg;
if (caller != 1)
{
if (Utils.isIntPos(testo[10].getText()))
{
int num = Integer.parseInt(testo[10].getText());
if ( (num > stanza.getPostiLetto()) || (num <= 0) )
{
msg = new MessageDialog(this," La stanza non puo' contenere "+num+" persone! ");
return true;
}
}
else
{
msg = new MessageDialog(this," Inserire correttamente il numero di persone ");
return true;
}
}
if (!((testo[0].getText()).length() <= 4))
{
msg = new MessageDialog(this," Il numero di stanza deve avere al piu' 4 caratteri! ");
return true;
}
if (!((testo[1].getText()).length() <= 20))
{
msg = new MessageDialog(this," Il cognome deve avere al piu' 20 caratteri! ");
return true;
}
if (!((testo[2].getText()).length() <= 20))
{
msg = new MessageDialog(this," Il nome deve avere al piu' 20 caratteri! ");
return true;
}
if (!((testo[3].getText()).length() <= 16))
{
msg = new MessageDialog(this," Il numero di telefono deve avere al piu' 16 caratteri! ");
return true;
}
if ((testo[1].getText()).equals(""))
{
msg = new MessageDialog(this," Manca il cognome! ");
return true;
}
if ((testo[2].getText()).equals(""))
{
msg = new MessageDialog(this," Manca il nome! ");
return true;
}
if ((testo[3].getText()).equals(""))
{
msg = new MessageDialog(this," Manca il numero di telefono! ");
return true;
}
return false;
}
public void cleanFields()
{
testo[0].setText("");
testo[1].setText("");
testo[2].setText("");
testo[3].setText("");
testo[4].setText("");
testo[5].setText("");
testo[6].setText("");
testo[7].setText("");
testo[8].setText("");
}
void creaLista()
{
Frame msg;
Prenotazione p;
L = (Principale.db).foundPrenotazioni(testo[1].getText(),testo[2].getText());
if (L != null)
{
if (!L.isEmpty())
{
if (lista.getItemCount() > 0)
lista.removeAll();
panel3.setVisible(true);
pack();
for(int i = 1; i<=L.length(); i++)
lista.addItem(L.getPrenotazione(i).toString());
}
else
msg = new AvvisoDialog(this, "Prenotazione non trovata!");
}
else
msg = new MessageDialog(this, "Problemi con il DataBase");
}
void aggiornaDisp(Prenotazione pren, char tipo)
{
Disponibilita disp_da_cambiare = new Disponibilita();
ListaDisponibilita elenco_disp = (Principale.db).elencoDisponibilita();
if (elenco_disp == null)
{
Frame msg = new MessageDialog(this, " Problemi con il database nella lettura delle disponibilita'! ");
return;
}
disp_da_cambiare = Utils.getDispOfRoom(elenco_disp, pren.getNumStanza(),true);
if (tipo == Flag.DISPONIBILE) //cancellazione della prenotazione
{
disp_da_cambiare.setDisponibilita(pren.getInizioSogg(), pren.getFineSogg(), tipo, Flag.ASSEGNATA);
disp_da_cambiare.setDisponibilita(pren.getInizioSogg(), pren.getFineSogg(), tipo, Flag.BLOCCATA);
}
else
{
disp_da_cambiare.setDisponibilita(pren.getInizioSogg(), pren.getFineSogg(), tipo, Flag.DISPONIBILE);
disp_da_cambiare.setDisponibilita(pren.getInizioSogg(), pren.getFineSogg(), tipo, Flag.COMMISSIONATA);
}
(Principale.db).changeDisponibilita( disp_da_cambiare.getNumStanza(),
disp_da_cambiare.getDispAnnoCorr(),
disp_da_cambiare.getDispAnnoProx() );
}
}
|
This code provides a user interface for a hotel reservation system, allowing users to perform a variety of actions related to hotel room reservations. Users can create new reservations, modify existing reservations, and cancel reservations. The interface includes various input fields for the user to enter information about the reservation, such as the room number, guest name, contact information, dates of stay, and any special requests. Users can also select the type of meal plan for the reservation.
The system also includes functionality to search for existing reservations based on the guest's name, and to display the results of the search in a list. Users can then select a reservation from the list and view or modify its details. The system also includes functionality to assign a room to a reservation and to cancel a reservation.
Additionally, the system updates the availability of hotel rooms based on the reservations made. When a reservation is created or canceled, the system updates the availability of the corresponding room for the dates of the reservation.
|
Code
|
MascheraRicercaSoggiornante.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.ListaSoggiornanti;
public class MascheraRicercaSoggiornante extends Frame
{
Button Annulla, Conferma;
TextField testo[];
Label etichetta1, etichetta2, etichetta3, etichetta4, etichetta5, label1, label2,
label3, label5;
Panel panel[];
CheckboxGroup checkbox_group;
Checkbox[] checkboxes;
GridBagLayout gridbag = new GridBagLayout();
List list_soggiornanti;
Frame padre, figlio;
// la seguente variabile serve per tenere in memoria la lista dei clienti
// cercati nello storico
ListaSoggiornanti elenco_soggiornanti;
public MascheraRicercaSoggiornante(Frame parent)
{
super("Ricerca soggiornante");
padre = parent;
padre.setEnabled(false);
setupPanels();
pack();
init();
this.setVisible(true);
}
void setupPanels()
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo i pulsanti
Annulla = new Button("Annulla ");
//Annulla.setFont(new Font("Courier", Font.PLAIN, 12));
Conferma = new Button("Conferma");
Conferma.setEnabled(false);
//Conferma.setFont(new Font("Courier", Font.PLAIN, 12));
//Creo le etichette
etichetta1 = new Label("Selezionare il tipo di ricerca che si desidera effettuare:");
etichetta1.setFont(ConfigurazioneSistema.font_titolo);
etichetta2 = new Label("Risultato della ricerca:");
etichetta2.setFont(ConfigurazioneSistema.font_titolo);
etichetta3 = new Label("Ricerca per stanza:");
etichetta3.setFont(ConfigurazioneSistema.font_titolo);
etichetta4 = new Label("Ricerca per nome:");
etichetta4.setFont(ConfigurazioneSistema.font_titolo);
label1 = new Label("Stanza numero");
label2 = new Label("Cognome");
label3 = new Label("Nome");
//Creo un Checkbox ad esclusione
checkbox_group = new CheckboxGroup();
checkboxes = new Checkbox[2];
checkboxes[0] = new Checkbox("Ricerca per stanza",checkbox_group,false);
checkboxes[1] = new Checkbox("Ricerca per nome",checkbox_group,false);
//Creo i TextField e li rendo non editabili
testo = new TextField[3];
testo[0] = new TextField("", 6);
testo[1] = new TextField("", 25);
testo[2] = new TextField("", 25);
for(int i=0;i<testo.length;++i)
testo[i].setEditable(false);
//creo una TextArea
list_soggiornanti = new List(10, false);
list_soggiornanti.setFont(ConfigurazioneSistema.font_allineato);
panel=new Panel[5];
for(int i=0;i<panel.length;++i)
{
panel[i]=new Panel();
panel[i].setLayout(gridbag);
}
//Creo il pannello in alto a sinistra
Utils.constrain(panel[1], etichetta1, 0, 0, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[1], checkboxes[0], 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
Utils.constrain(panel[1], checkboxes[1], 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
//Creo il pannello ricerca per stanza
Utils.constrain(panel[2], etichetta3, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[2], label1, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 0, 20);
Utils.constrain(panel[2], testo[0], 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
//Creo il pannello ricerca per nome e cognome
Utils.constrain(panel[3], etichetta4, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[3], label2, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 0, 20);
Utils.constrain(panel[3], testo[1], 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel[3], label3, 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.SOUTHWEST, 0.0, 0.0, 20, 5, 0, 20);
Utils.constrain(panel[3], testo[2], 1, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.SOUTHWEST, 1.0, 0.0, 20, 0, 0, 0);
//Creo il pannello dei pulsanti
Utils.constrain(panel[0], Annulla, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.EAST, 0.3, 0.0, 10, 0, 10, 5);
Utils.constrain(panel[0], Conferma, 3, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.3, 0.0, 10, 5, 10, 0);
//Creo il pannello contenente la list_soggiornanti
Utils.constrain(panel[4], etichetta2, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[4], list_soggiornanti, 0, 1, 1, 1, GridBagConstraints.BOTH,
GridBagConstraints.NORTHWEST, 1.0, 1.0, 0, 5, 0, 20);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel[1], 0, 0, 5, 4, GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel[2], 0, 4, 5, 2, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 1.0, 5, 5, 5, 5);
Utils.constrain(this, panel[3], 0, 6, 5, 3,GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 1.0, 5, 5, 5, 5);
Utils.constrain(this, panel[0], 0, 11, 5, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.SOUTHEAST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel[4], 0, 12, 5, 7, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 1.0, 5, 5, 5, 5);
}
public void init()
{
checkboxes[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(checkboxes[0].getState())
{
if (list_soggiornanti.getItemCount() > 0)
list_soggiornanti.removeAll();
testo[0].setEditable(true);
for(int i=1;i<testo.length;++i)
{
testo[i].setText("");
testo[i].setEditable(false);
}
Conferma.setEnabled(true);
}
}
});
checkboxes[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(checkboxes[1].getState())
{
if (list_soggiornanti.getItemCount() > 0)
list_soggiornanti.removeAll();
for(int i=1;i<3;++i)
testo[i].setEditable(true);
testo[0].setText("");
testo[0].setEditable(false);
Conferma.setEnabled(true);
}
}
});
Conferma.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startConferma();
}
});
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
list_soggiornanti.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startVediSogg();
}
});
}
void startConferma()
{
int i;
Frame msg;
if (!errori())
{
if(checkboxes[0].getState())
elenco_soggiornanti = (Principale.db).foundSoggiornanti(testo[0].getText(),true);
else if(checkboxes[1].getState())
elenco_soggiornanti = (Principale.db).foundSoggiornanti(testo[1].getText(), testo[2].getText());
else
elenco_soggiornanti = new ListaSoggiornanti();
if (elenco_soggiornanti != null)
{
if (list_soggiornanti.getItemCount() > 0)
list_soggiornanti.removeAll();
for (i = 1; i <= elenco_soggiornanti.length(); i++)
list_soggiornanti.addItem((elenco_soggiornanti.getSoggiornante(i)).toString());
if (list_soggiornanti.getItemCount() == 0)
msg = new AvvisoDialog(this, "Trovata nessuna corrispondenza!");
}
else
msg = new MessageDialog(this, "Problemi con il database!");
}
else
msg = new MessageDialog(this, "Errore nei parametri!");
}
boolean errori()
{
if(checkboxes[0].getState())
return ( (testo[0].getText()).length() > 4 );
else if(checkboxes[1].getState())
return( (testo[1].getText()).length() > 20 || (testo[2].getText()).length() > 20 );
else
return true;
}
void startVediSogg()
{
if ( (elenco_soggiornanti != null) && (elenco_soggiornanti.length()>0) )
figlio = new VediSoggiornante(this,
elenco_soggiornanti.getSoggiornante(list_soggiornanti.getSelectedIndex()+1));
}
}
|
This code provides a user interface for searching hotel guests based on either their room number or their name and surname. The user can select the type of search they want to perform using two mutually exclusive checkboxes, and then enter the relevant information in the corresponding text fields. The system will then display a list of all guests matching the search criteria, and the user can select a specific guest to view more detailed information about them.
The code includes error handling to ensure the user's input is valid, and provides buttons to either confirm the search or cancel the operation. This allows the user to easily and efficiently locate and view information about hotel guests, which is a crucial functionality for hotel management systems.
|
Code
|
MascheraRicercaStanza.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import java.util.Date;
import moduli.*;
public class MascheraRicercaStanza extends Frame
{
//Dichiaro gli oggetti che mi serviranno per costruire la finestra
Panel panel1, panel2, panel3, panel4, panel5;
Label etichetta1, etichetta2, etichetta3, etichetta, etichetta4, etichetta5;
Button Avvio, Annulla, ShowDisp, Annulla1, Conferma;
TextField data_inizio, data_fine, nome_ag;
List lista;
Checkbox con_ag;
GridBagLayout gridbag = new GridBagLayout();
InserisciPrenotazione pren;
InserisciCommissioni comm;
Frame figlio;
Frame padre = new Frame();
MascheraCambio father;
int caller;
ListaStanze stanze_disp;
Date save_date;
String nomi_agenzie[] = new String[0];
// seguono due variabili necessarie per il passaggio dei parametri
// della Inserisci
String data1;
String data2;
public MascheraRicercaStanza(String title, int c)
{
super(title);
caller = c;
setupPanels();
init();
pack();
}
void setupPanels()
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo i TextField
data_inizio = new TextField("", 12);
data_fine = new TextField("", 12);
nome_ag = new TextField("", 20);
nome_ag.setEditable(false);
//Creo i pulsanti e ne disabilito due
Annulla = new Button("Indietro");
Annulla1 = new Button("Annulla");
Conferma = new Button(" Scegli ");
Avvio = new Button("Avvio Ricerca");
ShowDisp = new Button("Disponibilita'");
Annulla1.setEnabled(false);
Conferma.setEnabled(false);
//Creo le etichette
etichetta= new Label("Periodo di soggiorno");
etichetta.setFont(ConfigurazioneSistema.font_titolo);
etichetta1 = new Label("Data inizio:");
etichetta2 = new Label("Data fine:");
etichetta3 = new Label ("Risultato della ricerca:");
etichetta3.setFont(ConfigurazioneSistema.font_titolo);
etichetta4 = new Label(" Nome agenzia");
etichetta5 = new Label ("Prenotazione di stanze commissionate:");
etichetta5.setFont(ConfigurazioneSistema.font_titolo);
//Creo la lista
lista = new List(15, false);
//Creo il checkbox
con_ag = new Checkbox(" Prenotazione tramite agenzia", false);
//Creo il pannello in alto
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, etichetta, 0, 0, 4, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel1, etichetta1, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, data_inizio, 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST,1.0,0.0,0,0,0,0);
Utils.constrain(panel1, etichetta2, 2, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1,data_fine, 3, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
panel5 = new Panel();
panel5.setLayout(gridbag);
Utils.constrain(panel5, etichetta5, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel5, con_ag, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel5, etichetta4, 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel5, nome_ag, 2, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
//Creo un pannello con due pulsanti
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, Annulla, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.3, 0.0, 0, 0, 0, 1);
Utils.constrain(panel2, Avvio, 2, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.3, 0.0, 0, 0, 0, 1);
Utils.constrain(panel2, ShowDisp, 3, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.3, 0.0, 0, 0, 0, 1);
//Creo il pannello contenente la lista
panel3 = new Panel();
panel3.setLayout(gridbag);
Utils.constrain(panel3, etichetta3, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel3,lista, 0, 1, 4, 3, GridBagConstraints.BOTH,
GridBagConstraints.CENTER, 3.0, 3.0, 0, 0, 0, 0);
//Creo il pannello in basso con due pulsanti
panel4 = new Panel();
panel4.setLayout(gridbag);
Utils.constrain(panel4, Annulla1, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.SOUTHEAST, 0.3, 0.0, 0, 0, 0, 10);
Utils.constrain(panel4, Conferma, 1, 1, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.SOUTHWEST, 0.3, 0.0, 0, 0, 0, 0);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel1, 0, 0, 4, 2, GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 15, 10, 10, 10);
Utils.constrain(this, panel5, 0, 2, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 15, 10, 10, 10);
Utils.constrain(this, panel2, 0, 3, 4, 1,GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHEAST, 1.0, 0.0, 10, 10, 0, 10);
Utils.constrain(this, panel3, 0, 4, 4, 3, GridBagConstraints.BOTH,
GridBagConstraints.CENTER, 2.0, 2.0, 10, 10, 10, 10);
Utils.constrain(this, panel4, 0, 7, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.SOUTHWEST, 1.0, 1.0, 10, 10, 15, 10);
if (caller == 1)
{
panel5.setVisible(false);
pack();
}
}
//Gestione degli eventi
public void init()
{
//Ascoltatore del pulsante Avvio,se il pulsante viene premuto viene
//lanciata la procedura di ricerca stanze libere
Avvio.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
ctrlAvvio();
}
});
//Ascoltatore del pulsante Annulla,se il pulsante viene prumeto si torna
//alla maschera precedente
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
if (caller == 3)
father.setEnabled(true);
else
padre.setEnabled(true);
}
});
//Ascoltatore del pulsante ShowDisp,se il pulsante viene premuto si
//mostrera' una maschera con le disponibilita dell'albergo
ShowDisp.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
lookDisp();
}
});
//Ascoltatore del pulsante Annulla1,se il pulsante viene premuto si
//vengono riabilitati i componenti del pannello in alto e
//disabilitati quelli del pannello in basso
Annulla1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startAnnulla1();
}
});
//Ascoltatore del pulsante Conferma, se il pulsante viene premuto si apre
//la finestra riguardante l'inserimento della prenotazione
Conferma.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startInserimento();
}
});
lista.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startInserimento();
}
});
con_ag.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if (con_ag.getState())
nome_ag.setEditable(true);
else
{
nome_ag.setEditable(false);
nome_ag.setText("");
}
}
});
}
boolean dataInizioIsNotBeforeToday()
{
Date inizio_pren = DateUtils.convertDate(data_inizio.getText());
Date today = new Date();
if (inizio_pren.getYear() < today.getYear())
return false;
else
if (inizio_pren.getYear() > today.getYear())
return true;
else // l'anno e' il medesimo
if (inizio_pren.getMonth() < today.getMonth())
return false;
else
if (inizio_pren.getMonth() > today.getMonth())
return true;
else // l'anno e il mese sono i medesimi
if (inizio_pren.getDate() < today.getDate())
return false;
else
return true;
}
/* se la ricerca viene lanciata per un cambio stanza (caller = 3) si deve
* impedire che la data di fine venga posticipata rispetto la fine del soggiorno
* o anticipata rispetto la data del cambio stanza.
*/
void ctrlAvvio()
{
Frame msg;
if (Utils.dateEPeriodoCorretti(this, data_inizio.getText(), data_fine.getText()))
{
if (con_ag.getState() && nome_ag.getText().equals(""))
{
msg = new MessageDialog(this, " Manca il nome dell'agenzia! ");
return;
}
ListaDisponibilita L_disp = (Principale.db).elencoDisponibilita();
if (L_disp == null)
{
msg = new MessageDialog(this, " Problemi con il database nella lettura delle disponibilita'! ");
return;
}
if (caller == 3)
{
if (Utils.data1MaggioreData2(DateUtils.convertDate(data_fine.getText()), save_date) )
{
msg = new AvvisoDialog(this, "ATTENZIONE: la data non puo' essere posticipata");
data_fine.setText(DateUtils.parseDate(DateUtils.giveStringOfDate(save_date)));
}
else
if (Utils.data1MinoreData2(DateUtils.convertDate(data_fine.getText()), DateUtils.convertDate(data_inizio.getText()) ) )
{
msg = new AvvisoDialog(this, "ATTENZIONE: la data non puo' essere precedente alla data di inizio");
data_fine.setText(DateUtils.parseDate(DateUtils.giveStringOfDate(save_date)));
}
else
{
stanze_disp = new ListaStanze();
startAvvio(L_disp, 0);
}
}
else
{
if (dataInizioIsNotBeforeToday())
{
stanze_disp = new ListaStanze();
startAvvio(L_disp, 0);
}
else
msg = new MessageDialog(this, " La data di inizio deve essere maggiore o uguale di quella odierna! ");
}
}
}
void startAnnulla1()
{
data_inizio.setEditable(true);
data_fine.setEditable(true);
con_ag.setEnabled(true);
if ( con_ag.getState() )
nome_ag.setEditable(true);
Annulla.setEnabled(true);
Avvio.setEnabled(true);
Annulla1.setEnabled(false);
Conferma.setEnabled(false);
if (lista.getItemCount() > 0)
lista.removeAll();
stanze_disp = new ListaStanze();
}
void startAvvio(ListaDisponibilita L_disp, int k)
{
if (con_ag.getState())
startSearchComm(L_disp, k);
// le date sono corrette se si arriva qui in quanto controllate in ctrlAvvio()
Frame msg;
String str = new String("");
ListaCommissionamenti L_comm = new ListaCommissionamenti();
ListaStanze elenco_stanze_disp = new ListaStanze();
// variabili necessarie per passaggio dei parametri della Inserisci
data1 = DateUtils.parseDate(data_inizio.getText());
data2 = DateUtils.parseDate(data_fine.getText());
// scansione delle disponibilita
Stanza stanza = null;
Disponibilita disp_attuale = null;
for (int i = 1; i <= L_disp.length(); i++)
{
disp_attuale = L_disp.getDisponibilita(i);
if ( disp_attuale.isDisponibile( DateUtils.convertDate(data_inizio.getText()), DateUtils.convertDate(data_fine.getText()), Flag.DISPONIBILE) )
{
stanza = (Principale.db).readStanza(disp_attuale.getNumStanza());
if (stanza != null)
{
elenco_stanze_disp.addStanza(stanza);
stanze_disp.addStanza(stanza);
}
else
msg = new MessageDialog(this, " Problemi con il database! ");
}
}
if (!stanze_disp.isEmpty())
{
Avvio.setEnabled(false);
Annulla.setEnabled(false);
data_inizio.setEditable(false);
data_fine.setEditable(false);
Annulla1.setEnabled(true);
Conferma.setEnabled(true);
con_ag.setEnabled(false);
nome_ag.setEditable(false);
for (int i = 1; i <= elenco_stanze_disp.length(); i++)
lista.addItem(str+(elenco_stanze_disp.getStanza(i)).toString());
}
else
if (k == 0)
if (!con_ag.getState())
msg = new AvvisoDialog(this, " Nessuna stanza disponibile in tale periodo! ");
else
msg = new AvvisoDialog(this, " Nessuna stanza disponibile o commisionata in tale periodo! ");
}
void startSearchComm(ListaDisponibilita L_disp, int k)
{
// le date sono corrette se si arriva qui in quanto controllate in ctrlAvvio()
Frame msg;
Commissionamento c;
Stanza stanza = null;
Disponibilita disp_loc = null;
ListaCommissionamenti L_comm = new ListaCommissionamenti();;
ListaStanze elenco_stanze_disp = new ListaStanze();
Date d1 = DateUtils.convertDate(data_inizio.getText());
Date d2 = DateUtils.convertDate(data_fine.getText());
data1 = DateUtils.parseDate(data_inizio.getText());
data2 = DateUtils.parseDate(data_fine.getText());
L_comm = (Principale.db).foundCommissionamentiSenzaLike(nome_ag.getText());
if (L_comm == null)
{
msg = new MessageDialog(this, " Problemi con il database nella lettura delle commissioni! ");
return;
}
if ( !L_comm.isEmpty() )
{
nomi_agenzie = new String[L_comm.length()];
int indice_nomi = 0;
for (int i = 1; i <= L_comm.length(); i++)
{
c = L_comm.getCommissionamento(i);
// Controllo che le date inserite appartengano al periodo commissionato
if( (!Utils.data1MaggioreData2(c.getInizioComm(), d1)) && (!(c.getFineComm()).before(d2)))
{
disp_loc = Utils.getDispOfRoom(L_disp, c.getNumStanza(), false);
if (disp_loc.isDisponibile(d1, d2, Flag.COMMISSIONATA))
{
stanza = (Principale.db).readStanza(disp_loc.getNumStanza());
if (stanza != null)
{
elenco_stanze_disp.addStanza(stanza);
stanze_disp.addStanza(stanza);
nomi_agenzie[indice_nomi] = new String(c.getNomeAgenzia());
indice_nomi++;
}
else
{
msg = new MessageDialog(this, " Problemi con il database! ");
return;
}
}
}
}
}
if (!stanze_disp.isEmpty())
{
Avvio.setEnabled(false);
Annulla.setEnabled(false);
data_inizio.setEditable(false);
data_fine.setEditable(false);
Annulla1.setEnabled(true);
Conferma.setEnabled(true);
for (int i = 1; i <= elenco_stanze_disp.length(); i++)
lista.addItem("COMMISSIONATA A "+nomi_agenzie[i-1]+" "+(elenco_stanze_disp.getStanza(i)).toString());
}
} // startSearchComm
void restartAvvio()
{
Frame msg;
ListaDisponibilita L_disp = (Principale.db).elencoDisponibilita();
if (L_disp == null)
{
msg = new MessageDialog(this, " Problemi con il database nella lettura delle disponibilita'! ");
return;
}
startAnnulla1();
startAvvio(L_disp, 1);
}
void startInserimento()
{
Frame msg;
if (lista.getSelectedIndex() != -1)
switch (caller)
{
case 1: visualInsertComm(); break;
case 2: visualInsertPren(); break;
case 3: returnFreeRoom(); break;
}
else
msg = new MessageDialog(this, " Manca la selezione! ");
}
void lookDisp()
{
figlio = new MascheraDisponibilita(this, nome_ag.getText());
}
void visualInsertPren()
{
this.setEnabled(false);
Stanza stanza = stanze_disp.getStanza(lista.getSelectedIndex()+1);
if (con_ag.getState())
pren = new InserisciPrenotazione(stanza, data1, data2, nome_ag.getText());
else
pren = new InserisciPrenotazione(stanza, data1, data2, "");
pren.setVisible(true);
pren.mask_ricerca = this;
}
void visualInsertComm()
{
this.setEnabled(false);
Stanza stanza = stanze_disp.getStanza(lista.getSelectedIndex()+1);
comm = new InserisciCommissioni(stanza, data1, data2);
comm.setVisible(true);
comm.mask_ricerca = this;
}
void returnFreeRoom()
{
Stanza stanza = stanze_disp.getStanza(lista.getSelectedIndex()+1);
father.stanza2.setText(stanza.getNumStanza());
father.setEnabled(true);
father.stanza1.setEditable(false);
father.Ricerca.setEnabled(false);
father.Conferma.setEnabled(true);
dispose();
}
}
|
This code provides a user interface for managing hotel room reservations and commissions. Users can search for available rooms within a specified date range, filter the results by whether the room was booked through an agency, and view the overall availability of rooms at the hotel. If a suitable room is found, the user can book the room or, if changing an existing booking, ensure the new dates do not conflict with the existing reservation. The code also allows users to view and manage room commissions, providing a comprehensive system for handling hotel room management tasks.
|
Code
|
MascheraRicercaStorico.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.ListaClienti;
import moduli.Cliente;
public class MascheraRicercaStorico extends Frame
{
Button Annulla, Conferma;
TextField testo[];
Label etichetta1, etichetta2, etichetta3, etichetta4, etichetta5, label1, label2,
label3, label5;
Panel panel[];
CheckboxGroup checkbox_group;
Checkbox[] checkboxes;
GridBagLayout gridbag =new GridBagLayout();
List list_clienti;
Frame padre;
VediCliente figlio;
Cliente cliente;
// la seguente variabile serve per tenere in memoria la lista dei clienti
// cercati nello storico
ListaClienti elenco_clienti;
public MascheraRicercaStorico(Frame parent)
{
super("Ricerca nello storico");
padre = parent;
padre.setEnabled(false);
setupPanels();
pack();
init();
this.setVisible(true);
}
void setupPanels()
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo i pulsanti
Annulla = new Button("Annulla ");
//Annulla.setFont(new Font("Courier", Font.PLAIN, 12));
Conferma = new Button("Conferma");
Conferma.setEnabled(false);
//Conferma.setFont(new Font("Courier", Font.PLAIN, 12));
//Creo le etichette
etichetta1 = new Label("Selezionare il tipo di ricerca che si desidera effettuare:");
etichetta1.setFont(ConfigurazioneSistema.font_titolo);
etichetta2 = new Label("Risultato della ricerca:");
etichetta2.setFont(ConfigurazioneSistema.font_titolo);
etichetta3 = new Label("Ricerca per stanza:");
etichetta3.setFont(ConfigurazioneSistema.font_titolo);
etichetta4 = new Label("Ricerca per nome:");
etichetta4.setFont(ConfigurazioneSistema.font_titolo);
etichetta5 = new Label("Ricerca per data:");
etichetta5.setFont(ConfigurazioneSistema.font_titolo);
label1 = new Label("Stanza numero");
label2 = new Label("Cognome");
label3 = new Label("Nome");
label5 = new Label("Data di soggiorno desiderata");
//Creo un Checkbox ad esclusione
checkbox_group = new CheckboxGroup();
checkboxes = new Checkbox[3];
checkboxes[0] = new Checkbox("Ricerca per stanza",checkbox_group,false);
checkboxes[1] = new Checkbox("Ricerca per nome",checkbox_group,false);
checkboxes[2] = new Checkbox("Ricerca per data",checkbox_group,false);
//Creo i TextField e li rendo non editabili
testo = new TextField[4];
testo[0] = new TextField("", 6);
testo[1] = new TextField("", 25);
testo[2] = new TextField("", 25);
testo[3] = new TextField("", 12);
for(int i=0;i<testo.length;++i)
testo[i].setEditable(false);
//creo una TextArea
list_clienti = new List(10, false);
panel=new Panel[6];
for(int i=0;i<6;++i)
{
panel[i]=new Panel();
panel[i].setLayout(gridbag);
}
//Creo il pannello in alto a sinistra
Utils.constrain(panel[1], etichetta1, 0, 0, 3, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[1], checkboxes[0], 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
Utils.constrain(panel[1], checkboxes[1], 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
Utils.constrain(panel[1], checkboxes[2], 0, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 5, 0, 0);
//Creo il pannello ricerca per stanza
Utils.constrain(panel[2], etichetta3, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[2], label1, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 0, 20);
Utils.constrain(panel[2], testo[0], 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
//Creo il pannello ricerca per nome e cognome
Utils.constrain(panel[3], etichetta4, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[3], label2, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 0, 20);
Utils.constrain(panel[3], testo[1], 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel[3], label3, 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.SOUTHWEST, 0.0, 0.0, 20, 5, 0, 20);
Utils.constrain(panel[3], testo[2], 1, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.SOUTHWEST, 1.0, 0.0, 20, 0, 0, 0);
//Creo il pannnello ricerca per data
Utils.constrain(panel[4], etichetta5, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[4], label5, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 5, 0, 20);
Utils.constrain(panel[4], testo[3], 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 5);
//Creo il pannello dei pulsanti
Utils.constrain(panel[0], Annulla, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.EAST, 0.3, 0.0, 10, 0, 10, 5);
Utils.constrain(panel[0], Conferma, 3, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.3, 0.0, 10, 5, 10, 0);
//Creo il pannello contenente la list_clienti
Utils.constrain(panel[5], etichetta2, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 10, 0);
Utils.constrain(panel[5], list_clienti, 0, 1, 1, 1, GridBagConstraints.BOTH,
GridBagConstraints.NORTHWEST, 1.0, 1.0, 0, 5, 0, 20);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel[1], 0, 0, 5, 4, GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel[2], 0, 4, 5, 2, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 1.0, 5, 5, 5, 5);
Utils.constrain(this, panel[3], 0, 6, 5, 3,GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 1.0, 5, 5, 5, 5);
Utils.constrain(this,panel[4], 0, 9, 5, 2,GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 1.0, 5, 5, 5, 5);
Utils.constrain(this, panel[0], 0, 11, 5, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.SOUTHEAST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel[5], 0, 12, 5, 7, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 1.0, 5, 5, 5, 5);
}
public void init()
{
checkboxes[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(checkboxes[0].getState())
{
if (list_clienti.getItemCount() > 0)
list_clienti.removeAll();
testo[0].setEditable(true);
for(int i=1;i<=3;++i)
testo[i].setEditable(false);
Conferma.setEnabled(true);
}
}
});
checkboxes[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(checkboxes[1].getState())
{
if (list_clienti.getItemCount() > 0)
list_clienti.removeAll();
for(int i=1;i<3;++i)
testo[i].setEditable(true);
testo[0].setEditable(false);
testo[3].setEditable(false);
Conferma.setEnabled(true);
}
}
});
checkboxes[2].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(checkboxes[2].getState())
{
if (list_clienti.getItemCount() > 0)
list_clienti.removeAll();
testo[3].setEditable(true);
for(int i=0;i<3;++i)
testo[i].setEditable(false);
Conferma.setEnabled(true);
}
}
});
Conferma.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startConferma();
}
});
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
list_clienti.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startVediCliente();
}
});
}
void startConferma()
{
int i;
Frame msg;
Conferma.setEnabled(false);
if (!errori())
{
if(checkboxes[0].getState())
elenco_clienti = (Principale.db).foundStorico(testo[0].getText());
else if(checkboxes[1].getState())
elenco_clienti = (Principale.db).foundStorico(testo[1].getText(), testo[2].getText());
else if(checkboxes[2].getState())
elenco_clienti = (Principale.db).foundStorico(DateUtils.convertDate(testo[3].getText()));
else
elenco_clienti = new ListaClienti();
if (elenco_clienti != null)
{
if (list_clienti.getItemCount() > 0)
list_clienti.removeAll();
for (i = 1; i <= elenco_clienti.length(); i++)
list_clienti.addItem((elenco_clienti.getCliente(i)).toString());
if (list_clienti.getItemCount() == 0)
msg = new AvvisoDialog(this, "Trovata nessuna corrispondenza!");
}
else
msg = new MessageDialog(this, "Problemi con il database!");
}
else
msg = new MessageDialog(this, "Errore nei parametri!");
for (i = 0; i<testo.length; i++)
{
testo[i].setText("");
testo[i].setEditable(false);
}
for (i = 0; i<checkboxes.length; i++)
checkboxes[i].setEnabled(true);
}
boolean errori()
{
if(checkboxes[0].getState())
return ( (testo[0].getText()).length() > 4 );
else if(checkboxes[1].getState())
return( (testo[1].getText()).length() > 20 || (testo[2].getText()).length() > 20 );
else if(checkboxes[2].getState())
return( !DateUtils.dataCorretta(testo[3].getText()) );
else
return true;
}
void startVediCliente()
{
cliente = elenco_clienti.getCliente((list_clienti.getSelectedIndexes())[0]+1);
figlio = new VediCliente(this,cliente);
}
}
|
This code provides a user interface for searching the historical records of clients in a hotel management system. The user can select the type of search they want to perform, such as by room number, name, or date of stay, and enter the relevant search parameters. The code then retrieves the matching client records from the database and displays them in a list. If no matching records are found, the user is notified. The user can also view more details about a specific client by selecting them from the list. The interface also includes a "Cancel" button that allows the user to close the search window and return to the parent frame. Overall, this code gives the user a flexible and intuitive way to search and access the historical records of clients in the hotel management system.
|
Code
|
MascheraSoggiorno.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import moduli.*;
import common.utility.*;
import common.def.*;
import java.util.Date;
public class MascheraSoggiorno extends Frame
{
//Dichiaro gli oggetti che utilizzero' per costruire la finestra
Label etichetta, etichetta1, label1, label2, label3, label4, label5,
label6, label7, label8, label9, label10, label11, label12, label13,
label14, label15, label16;
TextField testo1, testo2, testo3, testo4, testo5, testo6, testo7, testo8,
testo9, testo10, testo11, testo12, testo13, testo14;
Button Annulla, Conferma;
CheckboxGroup pensione, cliente;
Checkbox[] checkboxes, checkboxes1;
Panel panel1, panel2, panel3;
GridBagLayout gridbag=new GridBagLayout();
RicercaPrenotazione padre = new RicercaPrenotazione("",3);
public MascheraSoggiorno(String title, String caption, char pens, char status)
{
super(title);
padre.setEnabled(false);
setupPanels(caption, pens, status);
init();
pack();
this.setVisible(true);
}
void setupPanels(String caption, char pens, char status)
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo le etichette
etichetta=new Label("Dati del cliente");
etichetta.setFont(ConfigurazioneSistema.font_titolo);
label1 = new Label("Stanza numero");
label2 = new Label("Cognome");
label3 = new Label("Nome");
label4 = new Label("Luogo di nascita");
label5 = new Label("Data di nascita");
label6 = new Label("Documento di identita'");
label7 = new Label("Numero telefonico");
label8 = new Label("Indirizzo");
label9 = new Label("C.A.P");
label10 = new Label("Comune di residenza");
label11 = new Label("Citta'");
label12 = new Label("Nazione");
etichetta1 = new Label("Dati del soggiorno");
etichetta1.setFont(ConfigurazioneSistema.font_titolo);
label13 = new Label("Data inizio soggiorno");
label14 = new Label("Data fine soggiorno");
label15 = new Label("Tipo di pensionamento");
label15.setFont(ConfigurazioneSistema.font_titolo);
label16 = new Label("Status cliente");
label16.setFont(ConfigurazioneSistema.font_titolo);
//Creo i TextField
testo1 = new TextField("", 4);
testo2 = new TextField("", 20);
testo3 = new TextField("", 20);
testo4 = new TextField("", 32);
testo5 = new TextField("", 10);
testo6 = new TextField("", 16);
testo7 = new TextField("", 16);
testo8 = new TextField("", 52);
testo9 = new TextField("", 8);
testo10 = new TextField("", 32);
testo11 = new TextField("", 20);
testo12 = new TextField("", 20);
testo13 = new TextField("", 10);
testo14 = new TextField("", 10);
//Creo i bottoni
Annulla = new Button("Annulla");
Conferma = new Button(caption);
//Creo i Checkbox ad esclusione
pensione = new CheckboxGroup();
checkboxes = new Checkbox[4];
checkboxes[0] = new Checkbox(" Solo pernottamento", pensione, false);
checkboxes[1] = new Checkbox(" Prima colazione", pensione, false);
checkboxes[2] = new Checkbox(" Mezza pensione", pensione, false);
checkboxes[3] = new Checkbox(" Pensione completa", pensione, false);
switch (pens)
{
case Flag.SOLO_PERNOTTAMENTO:
checkboxes[0] = new Checkbox(" Solo pernottamento", pensione, true);
break;
case Flag.SOLO_COLAZIONE:
checkboxes[1] = new Checkbox(" Prima colazione", pensione, true);
break;
case Flag.MEZZA_PENSIONE:
checkboxes[2] = new Checkbox(" Mezza pensione", pensione, true);
break;
case Flag.PENSIONE_COMPLETA:
checkboxes[3] = new Checkbox(" Pensione completa", pensione, true);
break;
}
cliente = new CheckboxGroup();
checkboxes1 = new Checkbox[4];
checkboxes1[0] = new Checkbox(" Neonato (0-2 anni)", cliente, false);
checkboxes1[1] = new Checkbox(" Bambino (3-12 anni)", cliente, false);
checkboxes1[2] = new Checkbox(" Ragazzo (12-17 anni)", cliente, false);
checkboxes1[3] = new Checkbox(" Adulto (>=18 anni)", cliente, false);
switch (status)
{
case Flag.NEONATO:
checkboxes1[0] = new Checkbox(" Neonato (0-2 anni)", cliente, true);
break;
case Flag.BAMBINO:
checkboxes1[1] = new Checkbox(" Bambino (3-12 anni)", cliente, true);
break;
case Flag.RAGAZZO:
checkboxes1[2] = new Checkbox(" Ragazzo (12-17 anni)", cliente, true);
break;
case Flag.ADULTO:
checkboxes1[3] = new Checkbox(" Adulto (>=18 anni)", cliente, true);
break;
}
//Creo il pannello in alto contenente i dati del cliente
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, etichetta, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label1, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo1, 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label2, 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo2, 1, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label3, 2, 2, 1 ,1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo3, 3, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label4, 0, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo4, 1, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label5, 2, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo5, 3, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label6, 0, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo6, 1, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label7, 2, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo7, 3, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label8, 0, 5, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo8, 1, 5, 4, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label9, 0, 6, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo9, 1, 6, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label10, 2, 6, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo10, 3, 6, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label11, 0, 7, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo11, 1, 7, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label12, 2, 7, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo12, 3, 7, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
//Creo il pannello centrale con i dati del soggiorno
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, etichetta1, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, label13, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHEAST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, testo13, 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, label14, 2, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHEAST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, testo14, 3, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, label15, 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, checkboxes[0], 0, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, checkboxes[1], 0, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, checkboxes[2], 0, 5, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, checkboxes[3], 0, 6, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, label16, 1, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, checkboxes1[0], 1, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, checkboxes1[1], 1, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, checkboxes1[2], 1, 5, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, checkboxes1[3], 1, 6, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
//Creo il pannello in basso con due pulsanti
panel3 = new Panel();
panel3.setLayout(gridbag);
Utils.constrain(panel3, Annulla, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.EAST, 0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel3, Conferma, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.WEST, 0, 0.0, 5, 5, 5, 5);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel1, 0, 0, 4, 8, GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTH, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this,panel2, 0, 8, 4, 7, GridBagConstraints.HORIZONTAL,
GridBagConstraints.CENTER, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this,panel3,0, 15, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.SOUTH, 1.0, 0.0, 5, 5, 5, 5);
}
public void init()
{
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
}
public Soggiornante readDatiSogg(Prenotazione pren, int cont)
{
Frame msg;
String data_inizio,data_fine;
Date data1, data2;
Soggiornante sogg = new Soggiornante();
sogg.setNumStanza(pren.getNumStanza());
sogg.setCognome(testo2.getText());
sogg.setNome(testo3.getText());
sogg.setLuogoNasc(testo4.getText());
sogg.setDataNasc(DateUtils.convertDate(testo5.getText()));
sogg.setNumDoc(testo6.getText());
sogg.setNumTel(testo7.getText());
sogg.setIndirizzo(testo8.getText());
sogg.setCap(testo9.getText());
sogg.setComune(testo10.getText());
sogg.setCitta(testo11.getText());
sogg.setNazione(testo12.getText());
sogg.setInizioSogg(pren.getInizioSogg());
sogg.setFineSogg(pren.getFineSogg());
sogg.setIdPrenotazione(pren.getIdPrenotazione());
sogg.setIdSoggiornante(cont);
if (checkboxes[0].getState() == true)
sogg.setPensionamento(Flag.SOLO_PERNOTTAMENTO);
else
if (checkboxes[1].getState() == true)
sogg.setPensionamento(Flag.SOLO_COLAZIONE);
else
if (checkboxes[2].getState() == true)
sogg.setPensionamento(Flag.MEZZA_PENSIONE);
else
if (checkboxes[3].getState() == true)
sogg.setPensionamento(Flag.PENSIONE_COMPLETA);
if (checkboxes1[0].getState() == true)
sogg.setStatus(Flag.NEONATO);
else
if (checkboxes1[1].getState() == true)
sogg.setStatus(Flag.BAMBINO);
else
if (checkboxes1[2].getState() == true)
sogg.setStatus(Flag.RAGAZZO);
else
sogg.setStatus(Flag.ADULTO);
return sogg;
}
public void writeDatiSogg(Soggiornante sogg)
{
testo1.setText(sogg.getNumStanza());
testo2.setText(sogg.getCognome());
testo3.setText(sogg.getNome());
testo4.setText(sogg.getLuogoNasc());
testo5.setText(DateUtils.parseDate(DateUtils.giveStringOfDate(sogg.getDataNasc())));
testo6.setText(sogg.getNumDoc());
testo7.setText(sogg.getNumTel());
testo8.setText(sogg.getIndirizzo());
testo9.setText(sogg.getCap());
testo10.setText(sogg.getComune());
testo11.setText(sogg.getCitta());
testo12.setText(sogg.getNazione());
testo13.setText(DateUtils.parseDate(DateUtils.giveStringOfDate(sogg.getInizioSogg())));
testo14.setText(DateUtils.parseDate(DateUtils.giveStringOfDate(sogg.getFineSogg())));
}
void changeTitle(int parz, int tot)
{
this.setTitle("Inserimento dei dati del soggiornante ("+parz+"/"+tot+")");
}
void cleanFields()
{
testo2.setText("");
testo3.setText("");
testo4.setText("");
testo5.setText("");
testo6.setText("");
testo7.setText("");
testo8.setText("");
testo9.setText("");
testo10.setText("");
testo11.setText("");
testo12.setText("");
}
void aggiornaDisp(Soggiornante sogg, char tipo)
{
Disponibilita disp_da_cambiare = new Disponibilita();
ListaDisponibilita elenco_disp = (Principale.db).elencoDisponibilita();
if (elenco_disp == null)
{
Frame msg = new MessageDialog(this, " Problemi con il database nella lettura delle disponibilita'! ");
return;
}
disp_da_cambiare = Utils.getDispOfRoom(elenco_disp, sogg.getNumStanza(), true);
disp_da_cambiare.setDisponibilita(sogg.getInizioSogg(), sogg.getFineSogg(), tipo, Flag.ASSEGNATA) ;
(Principale.db).changeDisponibilita( disp_da_cambiare.getNumStanza(),
disp_da_cambiare.getDispAnnoCorr(),
disp_da_cambiare.getDispAnnoProx() );
}
boolean errori()
{
Frame msg;
String data_nasc = new String();
//Controllo data di nascita
if ( (testo5.getText().equals("")) )
{
msg = new AvvisoDialog(this," Inserire la data di nascita! ");
return true;
}
else
data_nasc = DateUtils.parseDate(testo5.getText());
if ( data_nasc.equals(Errore.DATA_NON_CORRETTA))
{
msg = new MessageDialog(this," Data Nascita Errata! ");
return true;
}
else
{
if ( !( DateUtils.isDataRight(data_nasc)) )
{
msg = new MessageDialog(this,"Data Nascita Insensata");
return true;
}
}
if ( !((testo2.getText()).length() <= 20) )
{
msg = new MessageDialog(this, " Il cognome deve essere composto da al piu' 20 caratteri! ");
return true;
}
if ( !((testo3.getText()).length() <= 20) )
{
msg = new MessageDialog(this, " Il nome deve essere composto da al piu' 20 caratteri! ");
return true;
}
if ( !((testo4.getText()).length() <= 32) )
{
msg = new MessageDialog(this, " Il luogo di nascita deve essere composto da al piu' 32 caratteri! ");
return true;
}
if ( !((testo6.getText()).length() <= 16) )
{
msg = new MessageDialog(this, " Il documento di identita' deve essere composto da al piu' 16 caratteri! ");
return true;
}
if ( !((testo7.getText()).length() <= 16) )
{
msg = new MessageDialog(this, " Il numero telefonico deve essere composto da al piu' 16 caratteri! ");
return true;
}
if ( !((testo8.getText()).length() <= 32) )
{
msg = new MessageDialog(this, " L'indirizzo deve essere composto da al piu' 32 caratteri! ");
return true;
}
if ( !((testo9.getText()).length() <= 5) )
{
msg = new MessageDialog(this, " Il C.A.P. deve essere composto da al piu' 5 caratteri! ");
return true;
}
if ( !((testo10.getText()).length() <= 32) )
{
msg = new MessageDialog(this, " Il comune deve essere composto da al piu' 32 caratteri! ");
return true;
}
if ( !((testo11.getText()).length() <= 20) )
{
msg = new MessageDialog(this, " La citta deve essere composto da al piu' 20 caratteri! ");
return true;
}
if ( !((testo12.getText()).length() <= 20) )
{
msg = new MessageDialog(this, " La nazione deve essere composto da al piu' 20 caratteri! ");
return true;
}
return false;
}
}
|
This code provides a comprehensive graphical user interface (GUI) for hotel staff to manage guest check-in and check-out. The interface allows users to capture detailed information about a guest, including their personal details, stay details, and meal plan preferences. The code includes various input fields, labels, and buttons to facilitate the data entry process, as well as validation checks to ensure the integrity of the entered information.
The key features of this interface include the ability to:
- Record guest details such as name, date of birth, identification document, contact information, and address
- Enter details about the guest's stay, including the room number, start and end dates, and type of meal plan
- Select the guest's age category using checkboxes (e.g., infant, child, teenager, adult)
- Cancel the current operation or confirm the guest's information
- Update the hotel's availability records to reflect the new guest's stay
By providing a user-friendly and efficient interface for managing guest check-in and check-out, this code helps hotel staff streamline the guest registration process, maintain data consistency, and ensure the hotel's availability records are accurately updated. The inclusion of validation checks further enhances the reliability and accuracy of the data entered, contributing to the overall effectiveness of the hotel's guest management system.
|
Code
|
MascheraTelefonate.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
public class MascheraTelefonate extends Frame
{
TextField num_stanza, data_tel, ora_i, ora_f, numero, durata, scatti, costo,
tot_scatti, tot_costo;
Label etich1, etich2, etich3, etich4, etich5, etich6, etich7, etich8, etich9,
etich10, etich11, etich12;
Panel panel1, panel2;
Button Annulla;
GridBagLayout gridbag = new GridBagLayout();
Frame padre = new Frame();
Telefonata phone;
int scatti_totali;
public MascheraTelefonate(Frame p, Telefonata t, int tot)
{
super("Visualizzazione dei dati delle telefonate");
padre = p;
phone = t;
scatti_totali = tot;
padre.setEnabled(false);
setupPanels();
inizializza();
pack();
setVisible(true);
}
void setupPanels()
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo le etichette
etich1 = new Label("Dati della telefonata");
etich1.setFont(ConfigurazioneSistema.font_titolo);
etich2 = new Label("Numero Stanza");
etich3 = new Label("Data Telefonata");
etich4 = new Label("Ora di Inizio");
etich5 = new Label("Ora di Fine");
etich6 = new Label("Durata");
etich7 = new Label("Numero Chiamato");
etich8 = new Label("Scatti Addebitati");
etich9 = new Label("Spesa Addebitata");
etich10 = new Label("Totale Scatti");
etich10.setFont(ConfigurazioneSistema.font_titolo);
etich11 = new Label("Totale Spesa");
etich11.setFont(ConfigurazioneSistema.font_titolo);
etich12 = new Label("Riassunto totali stanza "+phone.getNumStanza());
etich12.setFont(ConfigurazioneSistema.font_titolo);
//Creo i TextField e ne rendo alcuni non editabili
data_tel = new TextField("",12);
num_stanza = new TextField("",4);
ora_i = new TextField("",12);
ora_f = new TextField("",12);
durata = new TextField("",12);
scatti = new TextField("",4);
numero = new TextField("",18);
costo = new TextField("",12);
tot_scatti = new TextField("",4);
tot_costo = new TextField("",14);
//Disabilita i TextField
data_tel.setEditable(false);
num_stanza.setEditable(false);
ora_i.setEditable(false);
ora_f.setEditable(false);
durata.setEditable(false);
scatti.setEditable(false);
numero.setEditable(false);
costo.setEditable(false);
tot_scatti.setEditable(false);
tot_costo.setEditable(false);
//Creo i pulsanti
Annulla = new Button(" Indietro ");
//Creo il pannello
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, etich1, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, etich2, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1,num_stanza, 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich3, 2, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1,data_tel, 3, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich4, 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1,ora_i , 1, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich5, 2, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1,ora_f , 3, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich6, 4, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1,durata, 5, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich7, 0, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1,numero , 1, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich8, 0, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1,scatti, 1, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich9, 2, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1,costo, 3, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1,etich12, 0, 5, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich10, 0, 6, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1,tot_scatti, 1, 6, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich11, 2, 6, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1,tot_costo, 3, 6, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, Annulla, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 0, 0, 0, 15);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel1, 0, 0, 6, 7, GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel2, 0, 7, 6, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
}
public void inizializza()
{
writeDatiTel();
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
}
void writeDatiTel()
{
data_tel.setText(DateUtils.giveStringOfDate(phone.getDataTel()));
num_stanza.setText(phone.getNumStanza());
ora_i.setText(""+phone.getInizioTel());
ora_f.setText(""+phone.getFineTel());
durata.setText(""+phone.getDurataTel());
scatti.setText(""+phone.getNumScatti());
numero.setText(phone.getNumChiamato());
costo.setText(""+((Principale.config).getCostoXScatto())*phone.getNumScatti());
tot_scatti.setText(""+scatti_totali);
tot_costo.setText(""+((Principale.config).getCostoXScatto())*scatti_totali);
}
}
|
The code provided implements a Java GUI application that allows users to view and interact with information related to telephone calls made from a specific room or location. The application presents a window with various text fields and labels that display details about a specific telephone call, such as the room number, the date and time of the call, the duration of the call, the number called, the number of call units (or "scatti") charged, and the total cost of the call. Users can also view the total number of call units and the total cost for all calls made from the room.
The application is part of a larger system, as it references other classes and modules from the "common" and "moduli" packages. The "MascheraTelefonate" class extends the "Frame" class from the Java Swing library, indicating that it is a graphical user interface component. The code sets up the various GUI elements, including text fields, labels, and a button, and arranges them using a GridBagLayout. The text fields are set to be non-editable, suggesting that the user can only view the information, not modify it. The "Annulla" (Cancel) button allows the user to close the window and return to the previous frame.
The "inizializza()" method is responsible for populating the text fields with the relevant data, which is likely retrieved from the "Telefonata" object passed to the constructor. The "writeDatiTel()" method is used to update the text fields with the call details. Overall, this code provides a user interface for viewing and interacting with information related to telephone calls made from a specific location or room within a larger system.
|
Code
|
MascheraVisualizzazioneConto.java
|
package interfacce;
import java.awt.*;
import java.io.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
import java.util.Date;
import java.util.Properties;
public class MascheraVisualizzazioneConto extends Frame
{
Button Stampa,OK,Partenza;
TextField testo1, testo2, testo3, testo4;
Label etichetta, label1, label2, label3, label4;
Panel panel1, panel2, panel3;
GridBagLayout gridbag = new GridBagLayout();
TextArea text;
BufferedReader inStream;
int chiusura;
MascheraCalcoloConto conto = new MascheraCalcoloConto(new Frame());
public MascheraVisualizzazioneConto(String t0, String t1, String t2, String t3,
String t4, int tipo)
{
super("Visualizzazione del conto");
chiusura = tipo;
setup(t0,t1,t2,t3,t4);
readConto();
init();
pack();
}
void setup(String t0, String t1, String t2, String t3, String t4)
{
for (int i=0; i<conto.testo.length-1; i++)
conto.testo[i].setText("");
this.setFont(ConfigurazioneSistema.font_base);
etichetta = new Label("Intestazione");
etichetta.setFont(ConfigurazioneSistema.font_titolo);
label1 = new Label("Stanza numero");
label2 = new Label("Cognome");
label3 = new Label("Nome");
label4 = new Label("Lista stanze");
Stampa = new Button(" Stampa ");
OK = new Button(" Indietro ");
Partenza = new Button(" Chiudi conto ");
testo1 = new TextField("",4);
testo2 = new TextField("",20);
testo3 = new TextField("",20);
testo4 = new TextField("",30);
testo1.setText(t0+t3);
testo2.setText(t1);
testo3.setText(t2);
testo4.setText(t4);
testo1.setEditable(false);
testo2.setEditable(false);
testo3.setEditable(false);
testo4.setEditable(false);
text = new TextArea(25,50);
text.setEditable(false);
text.setFont(ConfigurazioneSistema.font_allineato);
panel1=new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1,etichetta,0,0,1,1,GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST,1.0,0.0,0,0,5,0);
Utils.constrain(panel1,label1,0,1,1,1,GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST,0.0,0.0,5,0,5,0);
Utils.constrain(panel1,testo1,1,1,1,1,GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST,1.0,0.0,5,0,5,0);
Utils.constrain(panel1,label2,0,2,1,1,GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST,0.0,0.0,5,0,5,0);
Utils.constrain(panel1,testo2,1,2,1,1,GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST,1.0,0.0,5,0,5,0);
Utils.constrain(panel1,label3,2,2,1,1,GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST,1.0,0.0,5,0,5,0);
Utils.constrain(panel1,testo3,3,2,1,1,GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST,1.0,0.0,5,0,5,0);
Utils.constrain(panel1,label4,0,3,1,1,GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST,1.0,0.0,5,0,5,0);
Utils.constrain(panel1,testo4,1,3,1,1,GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST,1.0,0.0,5,0,5,0);
panel2=new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2,text,0,0,4,4,GridBagConstraints.BOTH,
GridBagConstraints.NORTHWEST,1.0,1.0,5,0,5,0);
panel3=new Panel();
panel3.setLayout(gridbag);
Utils.constrain(panel3,Stampa,0,0,1,1,GridBagConstraints.NONE,
GridBagConstraints.SOUTHEAST,0,0.0,5,5,5,5);
Utils.constrain(panel3,Partenza,1,0,1,1,GridBagConstraints.NONE,
GridBagConstraints.CENTER,0,0.0,5,5,5,5);
Utils.constrain(panel3,OK,2,0,1,1,GridBagConstraints.NONE,
GridBagConstraints.SOUTHWEST,0.0,0.0,5,5,5,5);
this.setLayout(gridbag);
Utils.constrain(this,panel1,0,0,4,3,GridBagConstraints.HORIZONTAL,
GridBagConstraints.NORTHWEST,1.0,0.0,10,10,10,10);
Utils.constrain(this,panel2,0,3,4,6,GridBagConstraints.BOTH,
GridBagConstraints.NORTHWEST,1.0,1.0,10,10,10,10);
Utils.constrain(this,panel3,0,9,4,1,GridBagConstraints.HORIZONTAL,
GridBagConstraints.SOUTHWEST,1.0,0.0,10,10,10,10);
}
public void init()
{
OK.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
conto.setEnabled(true);
}
});
Stampa.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startStampa();
}
});
Partenza.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startChiudiConto();
}
});
}
void readConto()
{
Frame msg;
DataInputStream inStream;
try
{
inStream = new DataInputStream(new FileInputStream("conto.abg"));
}
catch (IOException ex)
{
msg = new MessageDialog(this, " Errore nell'apertura del file del conto! ");
return;
}
try
{
String newText="";
String line;
while((line=inStream.readLine())!=null)
newText=newText+line+"\n";
text.setText(newText);
inStream.close();
}
catch (IOException ex)
{
msg = new MessageDialog(this, " Errore durante la lettura del file del conto! ");
}
}
void startChiudiConto()
{
Frame msg;
AskChiudiConto ask;
Date today = new Date();
Date fine_effettiva;
if (conto.checkboxes[3].getState())
fine_effettiva = conto.fine_sogg_anticipato;
else
fine_effettiva = conto.data_fine_magg;
if ( Utils.data1MinoreData2( fine_effettiva, today ) )
ask = new AskChiudiConto(this);
else
{
msg = new AvvisoDialog(this, " Non e' possibile chiudere il conto fino al giorno della partenza! ");
}
}
void startChiusura()
{
switch (chiusura)
{
case 1: chiudiStanza(testo1.getText(), conto.date_inizio[0], conto.date_fine[0],1); break;
case 2: chiudiSingolo(); break;
case 3: chiudiComitiva(); break;
}
}
void chiudiStanza(String stanza, Date data_inizio, Date data_fine,int caller)
{
long id;
Soggiornante sogg;
ListaSoggiornanti L_sogg = (Principale.db).foundSoggiornanti(stanza, false);
id = (L_sogg.getSoggiornante(1)).getIdPrenotazione();
ListaDisponibilita L_disp = (Principale.db).elencoDisponibilita();
Frame msg;
if (L_disp == null)
{
msg = new MessageDialog(this, " Problemi con il database nella lettura delle disponibilita'! ");
return;
}
// cancellazione della prenotazione
(Principale.db).delPrenotazione(id);
// spostamento nello storico e cancellazione dei soggiornanti
for(int i = 1; i <= L_sogg.length(); i++)
{
sogg = L_sogg.getSoggiornante(i);
if ( !(sogg.getCognome()).equals("") &&
!(sogg.getNome()).equals("") &&
!(sogg.getIndirizzo()).equals("") &&
!(sogg.getComune()).equals("") &&
!(sogg.getCitta()).equals("") &&
!(sogg.getNumTel()).equals("") &&
!(sogg.getCap()).equals("") &&
!(sogg.getNumDoc()).equals("") )
{
int j = (Principale.db).writeStorico(sogg.toCliente());
if (j != DataBase.OK)
{
msg = new MessageDialog(this, " Problemi con il database nella scrittura nello storico! ");
return;
}
}
(Principale.db).delSoggiornante(stanza,sogg.getIdSoggiornante());
}
// cancellazione degli addebiti
(Principale.db).delAddebito(stanza);
// cancellazione dei supp e rid dai beni/servizi
(Principale.db).delSuppRid(stanza);
// cancellazione delle telefonate
(Principale.db).delTelefonate(stanza);
// aggiornamento delle disponibilita: questo devono essere fatto affinche'
// le informazioni riportate dalla machera di visualizzazione delle disponibilita'
// sia coerente
if (conto.qualcuno_tramite_agenzia)
{
Utils.aggiornaDisp(L_disp, stanza, data_inizio, data_fine, Flag.DISPONIBILE, Flag.OCCUPATA, true);
Utils.restoreCommissioni(stanza);
}
else
{
Disponibilita disp = (Principale.db).readDisponibilita(stanza);
if (disp != null)
{
disp.setDisponibilita(data_inizio, data_fine, Flag.DISPONIBILE, Flag.OCCUPATA);
(Principale.db).changeDisponibilita(disp.getNumStanza(), disp.getDispAnnoCorr(), disp.getDispAnnoProx());
}
}
if (caller == 1)
startStampa();
}
void chiudiSingolo()
{
if (conto.checkboxes[3].getState())
{
(Principale.db).anticipaFineSogg(conto.sogg_x_conto_sing.getNumStanza(),
conto.sogg_x_conto_sing.getIdSoggiornante(),
conto.fine_sogg_anticipato);
}
(Principale.db).reversePagato(conto.sogg_x_conto_sing.getNumStanza(),
conto.sogg_x_conto_sing.getIdSoggiornante());
}
void chiudiComitiva()
{
for (int i=0; i < conto.L_st.length; i++)
chiudiStanza(conto.L_st[i], conto.date_inizio[i], conto.date_fine[i],2);
startStampa();
}
void startStampa()
{
Properties prop = new Properties();
Toolkit tk = Toolkit.getDefaultToolkit();
PrintJob pj = tk.getPrintJob(this,"Stampa del conto",prop);
if (pj != null)
{
Graphics g = pj.getGraphics();
text.printAll(g);
g.dispose();
pj.end();
}
}
}
|
The provided code allows hotel staff to manage the details of a guest's stay, including viewing the guest's information, printing a summary of the guest's account, and closing out the guest's stay. The graphical user interface (GUI) displays key details about the guest, such as the room number, guest name, and a list of rooms, as well as a text area that shows the full details of the guest's stay, including any charges or payments made.
The user can perform several actions through the GUI, including printing a summary of the guest's account, which generates a printout of the details displayed in the text area, and closing out the guest's stay, which involves removing the guest's information from the system and updating the availability of the room(s) used during the stay. The code also includes error handling and validation to ensure that the user's actions are performed correctly and that any issues with the underlying data are properly reported to the user.
Overall, the code provides hotel staff with a comprehensive tool for managing the details of a guest's stay, allowing them to efficiently track and record the guest's information, generate reports, and update the hotel's records as needed.
|
Code
|
ModificaBeniServizi.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import moduli.BeneServizio;
import moduli.DataBase;
import moduli.ListaBeniServizi;
public class ModificaBeniServizi extends MascheraBeneServizio
{
BeneServizio extra = null;
Label elenco_extra1, elenco_extra2;
Button annulla3;
public ModificaBeniServizi()
{
super("Modifica dei dati di un bene o servizio");
setupPannello();
initialize();
}
void setupPannello()
{
panel[11].setLayout(gridbag);
elenco_extra1 = new Label("Scegliere il bene o servizio, appartenente");
elenco_extra2 = new Label("alla categoria selezionata, da modificare");
elenco = new List(3, false);
annulla3 = new Button(" Fine ");
Utils.constrain(panel[11], elenco_extra1, 0, 0, 5, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel[11], elenco_extra2, 0, 1, 5, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 0, 0, 5, 0);
Utils.constrain(panel[11], elenco, 0, 2, 5, 1,GridBagConstraints.HORIZONTAL,
GridBagConstraints.CENTER, 1.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[11], annulla3, 2, 3, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.CENTER, 1.0, 0.0, 5, 5, 5, 5);
}
public void initialize()
{
scelta_piatto[4].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_piatto[4].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.DESSERT);
p();
}
}
});
scelta_piatto[5].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_piatto[5].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.FRUTTA);
p();
}
}
});
scelta_servizio[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_servizio[0].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.RICREATIVI);
o();
}
}
});
scelta_servizio[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_servizio[1].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.ALTRO);
o();
}
}
});
scelta_bevanda[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_bevanda[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.CAFFETTERIA);
o();
}
}
});
scelta_bevanda[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_bevanda[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.ANALCOLICI);
o();
}
}
});
scelta_bevanda[2].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_bevanda[2].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.ALCOLICI);
o();
}
}
});
scelta_cibo[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_cibo[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.DOLCI);
o();
}
}
});
scelta_cibo[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_cibo[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.SALATI);
o();
}
}
});
scelta_antipasto[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_antipasto[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.FREDDI);
o();
}
}
});
scelta_antipasto[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_antipasto[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.CALDI);
o();
}
}
});
scelta_primo[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_primo[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.SOLIDI);
o();
}
}
});
scelta_primo[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_primo[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.LIQUIDI);
o();
}
}
});
scelta_secondo[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_secondo[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.CARNE);
o();
}
}
});
scelta_secondo[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_secondo[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.PESCE);
o();
}
}
});
scelta_contorno[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_contorno[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.VERDURA_COTTA);
o();
}
}
});
scelta_contorno[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_contorno[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.VERDURA_CRUDA);
o();
}
}
});
scelta_contorno[2].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_contorno[2].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.FORMAGGIO);
o();
}
}
});
conferma.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startConferma();
}
});
annulla3.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
elenco.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
beneSelezionato();
}
});
} // init
void startConferma()
{
int id;
MessageDialog msg;
if (!errore())
{
Float px = Float.valueOf(testo4.getText());
int j;
if ((j = (Principale.db).changeBeneServizio(extra.getCodExtra(),
testo3.getText(), px.floatValue())) == DataBase.OK)
{
for(int i=1;i<13;++i)
if(panel[i].isVisible())
remove(panel[i]);
panel[0].setVisible(true);
}
else
msg = new MessageDialog(this, "Problemi con il data base: "+DataBase.strErrore(j));
}
}
void beneSelezionato()
{
extra = L.getBeneServizio((elenco.getSelectedIndexes())[0]+1);
remove(panel[11]);
this.add(panel[10]);
testo3.setText(extra.getDescrizione());
testo4.setText(extra.getPxUnitario()+"");
panel[10].setVisible(true);
setVisible(true);
}
}
|
This Java program provides a user interface for modifying the details of goods and services stored in a database. The user can navigate through a hierarchical menu of categories and subcategories to select a specific good or service, and then update its description and unit price. The program handles the database interaction, ensuring that any changes made by the user are properly reflected in the underlying data. The user can also cancel the modification process and close the application if desired. The program's intuitive GUI and robust functionality allow users to efficiently manage the details of the goods and services in the system.
|
Code
|
ModificaCommissioni.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
import moduli.Commissionamento;
public class ModificaCommissioni extends MascheraCommissioni
{
Commissionamento commissione;
public ModificaCommissioni()
{
super("", "", "Modifica i dati delle commissioni", "Modifica", 2);
nome_agenzia.setEditable(true);
deabilita();
init();
}
public void init()
{
lista.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
commissione = L.getCommissionamento(lista.getSelectedIndex()+1);
writeDatiComm(commissione);
abilita();
panel5.setVisible(false);
pack();
}
});
nome_agenzia.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
creaLista();
}
});
Azione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startAzione();
}
});
Cerca.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
creaLista();
}
});
}
void deabilita()
{
num_stanza.setEditable(false);
num_tel_agenzia.setEditable(false);
inizio_comm.setEditable(false);
fine_comm.setEditable(false);
scadenza_comm.setEditable(false);
num_stanza.setEditable(false);
Azione.setEnabled(false);
}
void abilita()
{
num_tel_agenzia.setEditable(true);
scadenza_comm.setEditable(true);
Azione.setEnabled(true);
}
void startAzione()
{
Frame msg;
if ( !errori() )
{
Commissionamento comm = readDatiComm();
int j;
if (( j = (Principale.db).changeCommissionamento(commissione.getIdCommissionamento(), comm.getNumStanza(), comm.getNomeAgenzia(),comm.getNumTel(),
comm.getInizioComm(), comm.getFineComm(), comm.getScadenzaComm(), comm.getScaduto())) == DataBase.OK)
{
cleanFields();
deabilita();
}
else
msg = new MessageDialog(this, "Problemi con il database: "+DataBase.strErrore(j));
}
}
}
|
This code provides a user interface for modifying the details of commissions in the system. The user can select a specific commission from a list, which will populate the corresponding fields in the user interface. The user can then edit the commission details, such as the room number, agency name, phone number, start and end dates, and expiration date. Once the user has made the desired changes, they can save the modified commission details to the database, which will update the existing commission information.
The user interface also allows the user to create a new list of commissions by entering the agency name, which will populate the list of commissions associated with that agency. The code includes various buttons and actions, such as "Modify", "Search", and "Action", which allow the user to perform these tasks.
Additionally, the code includes functionality to validate the input data and display error messages if there are any issues with the data, ensuring the integrity of the commission information in the system.
|
Code
|
ModificaPrenotazione.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import java.util.Date;
import moduli.*;
public class ModificaPrenotazione extends MascheraPrenotazione
{
Prenotazione p;
RicercaPrenotazione parent;
public ModificaPrenotazione(Prenotazione pren, Stanza room, RicercaPrenotazione papa)
{
super(room,"","","Modifica dei dati della prenotazione","Modifica",2, pren.getPensionamento());
p= pren;
parent = papa;
init();
}
public void init()
{
Frame msg;
writeDatiPren(p);
testo[0].setEditable(false);
testo[4].setEditable(false);
testo[5].setEditable(false);
testo[9].setText(DateUtils.parseDate(DateUtils.giveStringOfDate(p.getDataPren())));
if (!p.getNomeAgenzia().equals(""))
{
testo[6].setEditable(false);
myCheckbox1.setState(true);
}
Azione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if ( !errori() )
{
Prenotazione pren = readDatiPren();
pren.setIdPrenotazione(p.getIdPrenotazione());
pren.setDataPren(p.getDataPren());
int j ;
j = (Principale.db).changePrenotazione(pren.getIdPrenotazione(), pren.getNumStanza(),
pren.getNumPers(),pren.getNome(),pren.getCognome(),
pren.getNumTel(), pren.getInizioSogg(), pren.getFineSogg(), pren.getDataPren(),
pren.getCaparra(), pren.getRichLettoAgg(), pren.getPensionamento(),
pren.getTramiteAgenzia(), pren.getNomeAgenzia(), pren.getRichParticolari());
dispose();
parent.creaLista(1);
parent.setEnabled(true);
}
}
});
Assegna.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startAssegnazione();
}
});
}
void startAssegnazione()
{
Frame msg;
ListaDisponibilita elenco_disp = (Principale.db).elencoDisponibilita();
if (elenco_disp == null)
{
msg = new MessageDialog(this, " Problemi con il database nella lettura delle disponibilita'! ");
return;
}
Utils.aggiornaDisp(elenco_disp,p.getNumStanza(),p.getInizioSogg(),p.getFineSogg(),Flag.ASSEGNATA,Flag.BLOCCATA,true);
msg = new AvvisoDialog(this, " Assegnata la stanza "+p.getNumStanza()+" alla prenotazione ");
}
}
|
The code provided allows users to modify an existing hotel reservation. The "ModificaPrenotazione" class serves as the main interface for this functionality, allowing users to view and update the details of a specific reservation. The class retrieves the necessary information from the database and populates the corresponding text fields, some of which are made non-editable to prevent unauthorized changes.
Users can update the reservation details, such as the number of guests, the start and end dates of the stay, and any special requests. The code also handles cases where the reservation was made through an agency, ensuring that the agency name is displayed and locked from editing.
When the user submits the changes, the code validates the input and updates the reservation in the database. After a successful update, the system refreshes the list of reservations to reflect the changes. Additionally, the code includes functionality to assign a room to the reservation, which involves updating the availability of the associated room in the system.
Overall, this code provides a comprehensive solution for users to modify existing hotel reservations, ensuring that the system maintains accurate and up-to-date information about the reservations.
|
Code
|
ModificaStanze.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
public class ModificaStanze extends DescrittoreStanze
{
public ModificaStanze()
{
super("Modifica dei dati delle stanze", "Modifica", 2);
init();
}
public void init()
{
testo1.setEditable(true);
testo2.setEditable(false);
testo3.setEditable(false);
testo4.setEditable(false);
mycheckboxes.setEnabled(false);
Azione.setEnabled(false);
Azione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startAzione();
}
});
testo1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startTesto1();
}
});
Cerca.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startTesto1();
}
});
} // init
void startAzione()
{
MessageDialog msg;
if (!errori())
{
Stanza room = readDatiStanza();
int j;
if( (j = (Principale.db).changeStanza(room.getNumStanza(), room.getPostiLetto(),
room.getDispLettoAgg(), room.getPxBase(),
room.getDescrizione())) == DataBase.OK)
{
cleanFields();
testo1.setEditable(true);
testo2.setEditable(false);
testo3.setEditable(false);
testo4.setEditable(false);
mycheckboxes.setEnabled(false);
Azione.setEnabled(false);
}
else
msg = new MessageDialog(this, "Problemi con il data base: "+DataBase.strErrore(j));
}
}
void startTesto1()
{
MessageDialog msg;
Stanza room;
if ((room = (Principale.db).readStanza(testo1.getText())) != null)
{
writeDatiStanza(room);
testo1.setEditable(false);
testo2.setEditable(true);
testo3.setEditable(true);
testo4.setEditable(true);
mycheckboxes.setEnabled(true);
Azione.setEnabled(true);
}
else
msg = new MessageDialog(this, "Stanza inesistente!");
}
}
|
The code provides a user interface that allows the modification of room data within a larger system. Users can search for a specific room by entering its number, which will populate the interface with the room's details such as the number of beds, additional bed capacity, base dimensions, and description. Once the room details are displayed, users can edit the values in the editable text fields and click an "Action" button to save the changes to the database. If the changes are successfully saved, the text fields are cleared, and the user can search for another room to modify. If the room does not exist or there is an issue saving the changes to the database, an error message is displayed to the user, informing them of the problem. This functionality allows users to maintain and update the room data as needed within the system.
|
Code
|
PrenotazioniScadute.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import java.util.Date;
import moduli.*;
public class PrenotazioniScadute extends Frame
{
Prenotazione prenotazione;
//Dichiarazioni di variabili
Panel panel2, panel3;
Label label3;
List lista;
Button Annulla, Scegli;
GridBagLayout gridbag = new GridBagLayout();
SubPrenotazione padre = new SubPrenotazione();
ListaPrenotazioni L_pren;
Frame figlio;
int to_call;
boolean first_time = true;
public PrenotazioniScadute (SubPrenotazione p, ListaPrenotazioni L)
{
super("Prenotazioni in scadenza");
padre = p;
L_pren = L;
setupPanels();
init();
pack();
}
void setupPanels()
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo dei pulsanti e ne disabilito due
Annulla = new Button(" Fine ");
Scegli = new Button(" Visualizza ");
//Creo le etichette
label3 = new Label("Elenco delle prenotazioni non confermate ");
label3.setFont(ConfigurazioneSistema.font_titolo);
//Creo il pannello in basso con due pulsanti
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, Annulla, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, Scegli, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
//Creo il pannello con la lista dei risultati della ricerca
lista = new List(10,false);
panel3 = new Panel();
panel3.setLayout(gridbag);
Utils.constrain(panel3, label3, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel3, lista, 0, 1, 4, 3, GridBagConstraints.BOTH,
GridBagConstraints.CENTER, 3.0, 3.0, 0, 0, 0, 0);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel3, 0, 0, 4, 10, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel2, 0, 10, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
pack();
}
public void init()
{
if (lista.getItemCount() != 0)
lista.removeAll();
for(int i = 1; i<=L_pren.length(); i++)
lista.addItem((L_pren.getPrenotazione(i)).toString());
lista.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
prenotazione = L_pren.getPrenotazione((lista.getSelectedIndexes())[0]+1);
startControllaPren(prenotazione);
}
});
Scegli.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (!noSelection())
{
prenotazione = L_pren.getPrenotazione((lista.getSelectedIndexes())[0]+1);
startControllaPren(prenotazione);
}
}
});
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
if ( (SubPrenotazione.ric_stanza == null) && (SubPrenotazione.ric_stanza == null) )
padre.setEnabled(true);
}
});
}
void startControllaPren(Prenotazione pren)
{
this.setEnabled(false);
Stanza stanza = (Principale.db).readStanza(pren.getNumStanza());
ControllaPrenotazione ctrl = new ControllaPrenotazione(pren, stanza, this);
ctrl.setVisible(true);
ctrl.padre = this;
}
boolean noSelection()
{
Frame msg;
if (lista.getSelectedIndex() == -1)
{
msg = new AvvisoDialog(this," Selezionare una prenotazione dalla lista e ripremere il tasto");
return true;
}
return false;
}
}
|
The code provided appears to be a Java GUI application that allows users to manage expired or expiring reservations. The main class, PrenotazioniScadute, provides a user interface with various components such as panels, labels, buttons, and a list. Users can access this application through the SubPrenotazione class, which likely serves as the main entry point.
Within the PrenotazioniScadute application, users can view a list of expired or expiring reservations, select a reservation from the list, and view its details. The application also includes various utility methods and classes, such as the Utils class for layout management and the ConfigurazioneSistema class for system-wide configuration settings.
The application's behavior is designed to provide users with a comprehensive tool for managing their reservation system, allowing them to easily identify and address expired or expiring reservations. The user interface is intuitive and straightforward, making it accessible to a wide range of users.
|
Code
|
RicercaAddebiti.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import java.util.Date;
import moduli.*;
public class RicercaAddebiti extends Frame
{
//Dichiarazioni di variabili
Panel panel1, panel2, panel3;
Label etichetta1, label1, label3;
List lista;
Button Annulla, Cerca;
TextField stanza;
GridBagLayout gridbag = new GridBagLayout();
Frame padre = new Frame();
Frame figlio;
ListaAddebiti L;
Addebito add;
float totale_add;
public RicercaAddebiti(Frame p)
{
super("Ricerca degli addebiti");
padre = p;
padre.setEnabled(false);
setupPanels();
init();
pack();
setVisible(true);
}
void setupPanels()
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo due pulsanti
Annulla = new Button(" Fine ");
Cerca = new Button(" Cerca ");
//Creo le etichette
etichetta1 = new Label ("Inserire la stanza addebitata ");
etichetta1.setFont(ConfigurazioneSistema.font_titolo);
label1 = new Label("Numero Stanza ");
label3 = new Label("Risultato della ricerca");
label3.setFont(ConfigurazioneSistema.font_titolo);
//Creo i TextField e ne rendo alcuni non editabili
stanza = new TextField("", 4);
//Creo il pannello in alto per inserimento dei dati del cliente
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, etichetta1, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, label1, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, stanza, 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
//Creo il pannello in basso con due pulsanti
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, Annulla, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, Cerca, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
//Creo il pannello con la lista dei risultati della ricerca
lista = new List(10,false);
lista.setFont(ConfigurazioneSistema.font_allineato);
panel3 = new Panel();
panel3.setLayout(gridbag);
Utils.constrain(panel3, label3, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel3, lista, 0, 1, 4, 3, GridBagConstraints.BOTH,
GridBagConstraints.CENTER, 3.0, 3.0, 0, 0, 0, 0);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel1, 0, 1, 4, 2, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel2, 0, 14, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel3, 0, 15, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
panel3.setVisible(false);
pack();
}
public void init()
{
lista.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (lista.getSelectedIndex() < (lista.getItemCount()-1))
{
add = L.getAddebito((lista.getSelectedIndexes())[0]+1);
startVediAddebito(add);
}
}
});
stanza.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (noErrors())
creaLista();
}
});
Cerca.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (noErrors())
creaLista();
}
});
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
}
void startVediAddebito(Addebito add)
{
figlio = new VediAddebito(this, add, totale_add);
}
public void creaLista()
{
Frame msg;
BeneServizio extra;
Addebito addebito;
String desc = new String();
totale_add = 0;
L = (Principale.db).foundAddebiti(stanza.getText());
if (L != null)
{
if (!L.isEmpty())
{
if (lista.getItemCount() > 0)
lista.removeAll();
panel3.setVisible(true);
pack();
for(int i = 1; i<=L.length(); i++)
{
addebito = L.getAddebito(i);
extra = (Principale.db).readBeneServizio(addebito.getCodExtra());
if (extra != null)
lista.addItem("DESCRIZIONE:"+Utils.completaStringa(extra.getDescrizione(), 10)+
" QUANTITA':"+Utils.completaStringa((""+addebito.getQuantita()), 2)+
" TOTALE ADDEBITO:"+
(Principale.config).getValuta()+"."+
addebito.getTotAddebito());
totale_add += addebito.getTotAddebito();
}
lista.addItem("L'ADDEBITO TOTALE DELLA STANZA "+stanza.getText()+" E' DI "+
(Principale.config).getValuta()+"."+totale_add);
}
else
msg = new AvvisoDialog(this, " Nessun addebitato trovato. ");
}
else
msg = new MessageDialog(this, " Problemi con il database! ");
}
boolean noErrors()
{
Frame msg;
//Disponibilita disp = new Disponibilita();
if ((stanza.getText().equals("")) )
{
msg = new AvvisoDialog(this,"Inserire il numero della stanza");
return false;
}
else
if( (Principale.db).readStanza(stanza.getText()) == null )
{
msg = new MessageDialog(this,"La stanza inserita e' inesistente!");
return false;
}
return true;
}
}
|
This code provides a user interface for searching and viewing room charges (addebiti) in a hotel or similar establishment. The user can enter a room number, and the system will display a list of all the charges associated with that room, including details such as the description of the charged item, the quantity, and the total charge amount. The user can then select an individual charge from the list to view more detailed information about it.
The interface consists of three main panels: the top panel for entering the room number, the middle panel with buttons to initiate the search and cancel the operation, and the bottom panel that displays the list of charges found for the specified room. The code also includes error handling, ensuring that the user enters a valid room number and that the system can successfully retrieve the charge information from the database.
Overall, this code provides a user-friendly interface for hotel staff to quickly search for and view room charges, which can be useful for tasks such as billing guests or investigating discrepancies.
|
Code
|
RicercaPrenotazione.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import java.util.Date;
import moduli.*;
public class RicercaPrenotazione extends Frame
{
Prenotazione prenotazione;
//Dichiarazioni di variabili
Panel panel1, panel2, panel3, panel4;
Label etichetta1, label1, label2, label3, label4;
List lista;
Button Annulla, Cerca, Scegli, Aggiungi;
TextField t_nome, t_cognome;
Checkbox chbx1, chbx2, chbx3;
CheckboxGroup filtri;
GridBagLayout gridbag = new GridBagLayout();
Frame padre = new Frame();
ListaPrenotazioni L, L_visual;
Frame figlio;
int to_call;
boolean first_time = true;
public RicercaPrenotazione(String titolo,int k)
{
super(titolo);
to_call = k;
setupPanels();
init();
pack();
}
void setupPanels()
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo dei pulsanti e ne disabilito due
Annulla = new Button(" Fine ");
Cerca = new Button(" Cerca ");
Scegli = new Button(" Scegli ");
Aggiungi = new Button(" Aggiungi a stanza ");
Scegli.setEnabled(false);
Aggiungi.setEnabled(false);
Cerca.setEnabled(true);
//Creo le etichette
etichetta1 = new Label ("Inserire il nominativo della prenotazione");
etichetta1.setFont(ConfigurazioneSistema.font_titolo);
label1 = new Label("Cognome");
label2 = new Label("Nome");
label3 = new Label("Risultato della ricerca");
label3.setFont(ConfigurazioneSistema.font_titolo);
label4 = new Label("Cercare le prenotazioni reletive a:");
label4.setFont(ConfigurazioneSistema.font_titolo);
//Creo i TextField e ne rendo alcuni non editabili
t_nome = new TextField("", 20);
t_cognome = new TextField("", 20);
//creo il pannello con i filtri per la ricerca
filtri = new CheckboxGroup();
chbx1 = new Checkbox(" Arrivi odierni",filtri, true);
chbx2 = new Checkbox(" Soggiornanti attuali",filtri, false);
chbx3 = new Checkbox(" Prenotazioni future", filtri,false);
//Creo il pannello in alto per inserimento dei dati del cliente
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, etichetta1, 0, 0, 4, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, label1, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.5, 5, 5, 5, 5);
Utils.constrain(panel1, t_cognome,1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label2, 2, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.5, 5, 5, 5, 5);
Utils.constrain(panel1, t_nome, 3, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label4, 0, 2, 4, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, chbx1, 0, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.5, 5, 5, 5, 5);
if (to_call != 2 && to_call != 1)
Utils.constrain(panel1, chbx2, 0, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
if (to_call != 3)
Utils.constrain(panel1, chbx3, 0, 5, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.5, 5, 5, 5, 5);
//Creo il pannello in basso con due pulsanti
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, Annulla, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, Cerca, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, Scegli, 2, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
if (to_call ==3)
Utils.constrain(panel2, Aggiungi, 3, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
//Creo il pannello con la lista dei risultati della ricerca
lista = new List(10,false);
lista.setFont(ConfigurazioneSistema.font_allineato);
panel3 = new Panel();
panel3.setLayout(gridbag);
Utils.constrain(panel3, label3, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel3, lista, 0, 1, 4, 3, GridBagConstraints.BOTH,
GridBagConstraints.CENTER, 3.0, 3.0, 0, 0, 0, 0);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel1, 0, 1, 4, 6, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel2, 0, 14, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.CENTER, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel3, 0, 15, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
panel3.setVisible(false);
pack();
}
public void init()
{
lista.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
prenotazione = L_visual.getPrenotazione((lista.getSelectedIndexes())[0]+1);
switch (to_call)
{
case 1: startModifica(prenotazione); break;
case 2: startCancella(prenotazione); break;
case 3:
if (!chbx2.getState())
startInsSoggiornante(prenotazione);
else
startAggiungi();
break;
case 4: startVediPrenotazione(prenotazione); break;
}
}
});
Scegli.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (!noSelection())
{
prenotazione = L_visual.getPrenotazione((lista.getSelectedIndexes())[0]+1);
switch (to_call)
{
case 1: startModifica(prenotazione); break;
case 2: startCancella(prenotazione); break;
case 3: startInsSoggiornante(prenotazione); break;
case 4: startVediPrenotazione(prenotazione); break;
}
}
}
});
Aggiungi.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startAggiungi();
}
});
t_nome.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
creaLista(0);
}
});
t_cognome.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
creaLista(0);
}
});
Cerca.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
creaLista(0);
}
});
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
chbx1.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if (!first_time)
creaLista(0);
}
});
chbx2.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if (!first_time)
creaLista(0);
}
});
chbx3.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if (!first_time)
creaLista(0);
}
});
}
void startAggiungi()
{
if (!noSelection())
{
this.setEnabled(false);
prenotazione = L_visual.getPrenotazione((lista.getSelectedIndexes())[0]+1);
startAddSoggiornante(prenotazione);
}
}
void startModifica(Prenotazione pren)
{
this.setEnabled(false);
Stanza stanza = (Principale.db).readStanza(pren.getNumStanza());
ModificaPrenotazione modify = new ModificaPrenotazione(pren, stanza, this);
modify.setVisible(true);
modify.padre = this;
notifyRoomBlocked(pren, modify, null);
}
void startCancella(Prenotazione pren)
{
this.setEnabled(false);
Stanza stanza = (Principale.db).readStanza(pren.getNumStanza());
CancellaPrenotazione cancel = new CancellaPrenotazione(pren, stanza, this);
cancel.setVisible(true);
cancel.padre = this;
}
void startVediPrenotazione(Prenotazione pren)
{
this.setEnabled(false);
Stanza stanza = (Principale.db).readStanza(pren.getNumStanza());
VediPrenotazione visual = new VediPrenotazione(pren, stanza, this);
visual.setVisible(true);
visual.padre = this;
notifyRoomBlocked(pren, null, visual);
}
void startInsSoggiornante(Prenotazione pren)
{
Disponibilita disp;
Frame msg;
disp = (Principale.db).readDisponibilita(pren.getNumStanza());
if (disp == null)
msg = new MessageDialog(this," Inconsistenze sul database! ");
else
{
if ( disp.getStatusGiorno(DateUtils.dataTogiorni(pren.getInizioSogg()),Const.ANNO_CORRENTE) == Flag.BLOCCATA )
msg = new AvvisoDialog(this," La stanza "+pren.getNumStanza()+" non e' assegnata a tale prenotazione. Modificare la prenotazione. ");
else
figlio = new InserisciSoggiornante(this, pren);
}
}
void notifyRoomBlocked(Prenotazione pren, ModificaPrenotazione father1, VediPrenotazione father2)
{
char flag;
Frame msg;
ListaDisponibilita elenco_disp = (Principale.db).elencoDisponibilita();
if (elenco_disp == null)
{
msg = new MessageDialog(this, " Problemi con il database nella lettura delle disponibilita'! ");
return;
}
Disponibilita disp = Utils.getDispOfRoom(elenco_disp, pren.getNumStanza(), false);
Costanti cost = new Costanti();
if ( (((pren.getInizioSogg()).getYear())+1900 ) == cost.getAnnoCorr())
flag = Const.ANNO_CORRENTE;
else
flag = Const.ANNO_PROSSIMO;
if (father2 == null)
if (disp.getStatusGiorno(DateUtils.dataTogiorni(pren.getInizioSogg()), flag) == Flag.BLOCCATA)
msg = new AvvisoDialog(father1," ATTENZIONE: per questa prenotazione non e' ancora stata assegnata la stanza!!");
else
(father1.Assegna).setEnabled(false);
else
if (disp.getStatusGiorno(DateUtils.dataTogiorni(pren.getInizioSogg()), flag) == Flag.BLOCCATA)
msg = new AvvisoDialog(father2," ATTENZIONE: per questa prenotazione non e' ancora stata assegnata la stanza!!");
else
(father2.Assegna).setEnabled(false);
}
public void creaLista(int back)
{
Frame msg;
Prenotazione p;
Date today = new Date();
L_visual = new ListaPrenotazioni();
L = (Principale.db).foundPrenotazioni(t_cognome.getText(), t_nome.getText());
if (L != null)
{
if (!L.isEmpty())
{
if (lista.getItemCount() > 0)
lista.removeAll();
for(int i = 1; i <= L.length(); i++)
{
p = L.getPrenotazione(i);
ListaSoggiornanti L_sogg = (Principale.db).foundSoggiornanti(p.getIdPrenotazione());
if (chbx3.getState())
{
if ( Utils.data1MaggioreData2( p.getInizioSogg(), today ) )
{
lista.addItem(p.toString());
L_visual.addPrenotazione(p);
}
}
else
{
if (chbx1.getState())
{
if (L_sogg.isEmpty())
{
if (((p.getInizioSogg()).getDate() == today.getDate())
&& ((p.getInizioSogg()).getMonth() == today.getMonth())
&& ((p.getInizioSogg()).getYear() == today.getYear()) )
{
lista.addItem(p.toString());
L_visual.addPrenotazione(p);
}
}
}
else
{
if ( !( Utils.data1MaggioreData2( p.getInizioSogg(), today ) ) &&
!( Utils.data1MinoreData2( p.getFineSogg(), today) ) )
{
//controllo che sia un soggiornante gia registrato
if (!L_sogg.isEmpty())
{
lista.addItem(p.toString());
L_visual.addPrenotazione(p);
}
}
}
}
}
if (lista.getItemCount() == 0)
{
if (back == 0)
msg = new AvvisoDialog(this, " Nessuna prenotazione trovata! ");
Scegli.setEnabled(false);
Aggiungi.setEnabled(false);
panel3.setVisible(false);
pack();
if (to_call == 3)
Aggiungi.setEnabled(false);
}
else
{
if (chbx1.getState())
{
Aggiungi.setEnabled(false);
Scegli.setEnabled(true);
}
if (chbx2.getState())
{
Aggiungi.setEnabled(true);
if (to_call == 3)
Scegli.setEnabled(false);
else
Scegli.setEnabled(true);
}
if (chbx3.getState())
{
Scegli.setEnabled(true);
}
panel3.setVisible(true);
pack();
}
if (first_time)
first_time = false;
}
else
{
if (back == 0)
msg = new AvvisoDialog(this, " Prenotazione non trovata! ");
else
{
if (back == 1)
{
if (lista.getItemCount() > 0)
lista.removeAll();
panel3.setVisible(false);
pack();
}
}
}
}
else
msg = new MessageDialog(this, " Problemi con il database! ");
}
boolean noSelection()
{
Frame msg;
if (lista.getSelectedIndex() == -1)
{
msg = new AvvisoDialog(this," Selezionare una prenotazione dalla lista e ripremere il tasto");
return true;
}
return false;
}
void startAddSoggiornante(Prenotazione pren)
{
ListaSoggiornanti L_sogg = (Principale.db).foundSoggiornanti(pren.getIdPrenotazione());
if (L_sogg != null)
if (L_sogg.length() > 0)
{
Soggiornante sogg = L_sogg.getSoggiornante(1);
Stanza room = (Principale.db).readStanza(sogg.getNumStanza());
if ( (room.getPostiLetto() > L_sogg.length()) ||
( (room.getPostiLetto() == L_sogg.length()) && (room.getDispLettoAgg() == Const.SI) ) )
figlio = new AggiungiSoggiornante(this, pren, room, L_sogg.length());
else
figlio = new AvvisoDialog(this," Nessun posto disponibile nella stanza n. "+room.getNumStanza());
}
else
figlio = new AvvisoDialog(this," La prenotazione non e' adempiuta. Premere 'Scegli' per gestire l'arrivo clienti");
else
figlio = new MessageDialog(this," Problemi con il database!");
}
}
|
This code provides a comprehensive user interface for managing hotel room reservations. Users can search for reservations based on customer names and filter the results to show arrivals, current guests, or future reservations. Once a reservation is selected, the user can perform various actions, such as modifying the reservation, canceling the reservation, or adding an additional guest to the reservation. The code handles the underlying logic for these actions, including retrieving and updating reservation data from a database and notifying the user of any issues or errors. The user interface is designed to be intuitive and user-friendly, allowing hotel staff to efficiently manage the reservation process.
|
Code
|
RicercaTelefonate.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import java.util.Date;
import moduli.*;
public class RicercaTelefonate extends Frame
{
Prenotazione prenotazione;
//Dichiarazioni di variabili
Panel panel1, panel2, panel3;
Label etichetta1, label1, label3;
List lista;
Button Annulla, Cerca;
TextField stanza;
GridBagLayout gridbag = new GridBagLayout();
Frame padre = new Frame();
Frame figlio;
ListaTelefonate L;
Telefonata tel;
int tot_scatti = 0;
public RicercaTelefonate(Frame p)
{
super("Ricerca delle telefonate");
padre = p;
padre.setEnabled(false);
setupPanels();
init();
pack();
setVisible(true);
}
void setupPanels()
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo due pulsanti
Annulla = new Button(" Fine ");
Cerca = new Button(" Cerca ");
//Creo le etichette
etichetta1 = new Label ("Inserire la stanza addebitata ");
etichetta1.setFont(ConfigurazioneSistema.font_titolo);
label1 = new Label("Numero Stanza");
label3 = new Label("Risultato della ricerca");
label3.setFont(ConfigurazioneSistema.font_titolo);
//Creo i TextField e ne rendo alcuni non editabili
stanza = new TextField("", 4);
//Creo il pannello in alto per inserimento dei dati del cliente
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, etichetta1, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, label1, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, stanza, 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
//Creo il pannello in basso con due pulsanti
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, Annulla, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel2, Cerca, 1, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 5, 5, 5, 5);
//Creo il pannello con la lista dei risultati della ricerca
lista = new List(10,false);
lista.setFont(ConfigurazioneSistema.font_allineato);
panel3 = new Panel();
panel3.setLayout(gridbag);
Utils.constrain(panel3, label3, 0, 0, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel3, lista, 0, 1, 4, 3, GridBagConstraints.BOTH,
GridBagConstraints.CENTER, 3.0, 3.0, 0, 0, 0, 0);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel1, 0, 1, 4, 2, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel2, 0, 14, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel3, 0, 15, 4, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
panel3.setVisible(false);
pack();
}
public void init()
{
lista.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
tel = L.getTelefonata((lista.getSelectedIndexes())[0]+1);
startVediTelefonata(tel);
}
});
stanza.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (noErrors())
creaLista();
}
});
Cerca.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (noErrors())
creaLista();
}
});
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
}
void startVediTelefonata(Telefonata tel)
{
figlio = new MascheraTelefonate(this, tel, tot_scatti);
}
public void creaLista()
{
Frame msg;
tot_scatti = 0;
L = (Principale.db).foundTelefonate(stanza.getText());
if (L != null)
{
if (!L.isEmpty())
{
if (lista.getItemCount() > 0)
lista.removeAll();
panel3.setVisible(true);
pack();
for(int i = 1; i<=L.length(); i++)
{
lista.addItem(L.getTelefonata(i).toString());
tot_scatti += L.getTelefonata(i).getNumScatti();
}
}
else
msg = new AvvisoDialog(this, " Nessuna telefonata addebitata ");
}
else
msg = new MessageDialog(this, "Problemi con il DataBase!");
}
boolean noErrors()
{
Frame msg;
//Disponibilita disp = new Disponibilita();
if ((stanza.getText().equals("")) )
{
msg = new AvvisoDialog(this,"Inserire il numero della stanza");
return false;
}
else
if( (Principale.db).readStanza(stanza.getText()) == null )
{
msg = new MessageDialog(this,"La stanza inserita e' inesistente!");
return false;
}
return true;
}
}
|
The code provided implements a Java GUI application that allows users to search for and view telephone call records associated with a specific hotel room. The application provides a user-friendly interface with various panels and components, including an input field for entering a room number, a search button to initiate the lookup, and a panel to display the results.
When the user enters a room number and initiates the search, the application retrieves the corresponding telephone call records from a database. If any records are found, they are displayed in a list, along with the total number of call charges or "scatti" associated with those records. The user can then select a specific telephone call record from the list to view more detailed information about that call.
The application includes validation to ensure that the user enters a valid room number before initiating the search, and it also handles cases where no records are found or there are issues connecting to the database, displaying appropriate error messages. Overall, this code provides a comprehensive solution for managing and accessing telephone call records within a hotel or similar environment, allowing users to easily search, review, and analyze this information.
|
Code
|
SubBeniServizi.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import common.utility.*;
import java.util.Random;
public class SubBeniServizi extends Frame
{
Label label;
Panel panel0, panel1;
Button Inserimento, Modifica ,Cancellazione, Ricerca, Annulla ;
GridBagLayout gridbag=new GridBagLayout();
SubGestione s = new SubGestione();
CancellaBeniServizi call_3;
ModificaBeniServizi call_2;
InserisciBeniServizi call_1;
VediBeniServizi call_4;
public SubBeniServizi()
{
super("Gestione dei Beni&Servizi");
setup();
init();
pack();
}
void setup()
{
this.setFont(ConfigurazioneSistema.font_sub);
panel0=new Panel();
panel0.setLayout(gridbag);
panel0.setBackground(Color.white);
//Caricamento di un'immagine scelta a caso tra quelle disponibili
Random rnd = new Random();
int num;
if ((num = (rnd.nextInt() % 5) ) < 0)
num = num * -1;
num ++;
String file_name = new String("servizi"+num+".jpg");
Immagine figura = new Immagine(file_name);
Etichetta etich = new Etichetta("Beni&Servizi.gif");
Utils.constrain(panel0,etich, 0, 0, 2, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.5, 1.0,0,0,0,0);
Utils.constrain(panel0,figura, 2, 0, 10, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.5, 1.0,0,0,0,0);
panel1 = new Panel();
panel1.setLayout(new GridLayout(5,1));
Inserimento = new Button(" Inserimento ");
Modifica = new Button("Modifica");
Cancellazione = new Button(" Cancellazione ");
Ricerca = new Button("Ricerca...");
Annulla = new Button("Indietro");
panel1.add(Inserimento);
panel1.add(Modifica);
panel1.add(Cancellazione);
panel1.add(Ricerca);
panel1.add(Annulla);
this.setLayout(gridbag);
Utils.constrain(this,panel0, 0, 0, 12, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
Utils.constrain(this,panel1, 12, 0, 1, 12,GridBagConstraints.BOTH,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
}
void init()
{
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
s.setEnabled(true);
}
});
Inserimento.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
insBeneServizio();
}
});
Modifica.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
modBeneServizio();
}
});
Cancellazione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
cancBeneServizio();
}
});
Ricerca.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
vediBeneServizio();
}
});
}
void insBeneServizio()
{
this.setEnabled(false);
call_1 = new InserisciBeniServizi("Inserimento di beni e servizi");
call_1.padre = this;
call_1.setVisible(true);
}
void modBeneServizio()
{
this.setEnabled(false);
call_2 = new ModificaBeniServizi();
call_2.padre = this;
call_2.setVisible(true);
}
void cancBeneServizio()
{
this.setEnabled(false);
call_3 = new CancellaBeniServizi();
call_3.padre = this;
call_3.setVisible(true);
}
void vediBeneServizio()
{
this.setEnabled(false);
call_4 = new VediBeniServizi();
call_4.padre = this;
call_4.setVisible(true);
}
}
|
This code provides a user interface for managing a system of goods and services. The main window displays a title, an image, and a set of buttons that allow the user to perform various operations on the goods and services. When the user clicks on a button, a new window is opened to handle the specific operation, such as inserting, modifying, canceling, or viewing the goods and services. The code also includes references to several other classes that likely provide additional functionality for the management of the goods and services system. Overall, this code allows users to interact with and manage a system of goods and services through a graphical user interface.
|
Code
|
SubCommissioni.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import common.utility.*;
public class SubCommissioni extends Frame
{
Label label;
Panel panel0, panel1;
Button Inserimento, Modifica, Cancellazione, Ricerca, Annulla;
GridBagLayout gridbag=new GridBagLayout();
Frame p = new Frame();
MascheraRicercaStanza mask_ric;
ModificaCommissioni mask_mod;
CancellaCommissioni mask_canc;
VediCommissione mask_vis;
public SubCommissioni()
{
super("Commissioni");
setup();
init();
pack();
}
void setup()
{
this.setFont(ConfigurazioneSistema.font_sub);
panel0=new Panel();
panel0.setLayout(gridbag);
panel0.setBackground(Color.white);
Immagine figura = new Immagine("camera2.jpg");
Etichetta etich = new Etichetta("Commissioni.gif");
Utils.constrain(panel0,etich, 0, 0, 2, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.5, 1.0,0,0,0,0);
Utils.constrain(panel0,figura, 2, 0, 10, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.5, 1.0,0,0,0,0);
panel1 = new Panel();
panel1.setLayout(new GridLayout(5,1));
Inserimento = new Button(" Inserimento ");
Modifica = new Button(" Modifica ");
Cancellazione = new Button(" Cancellazione ");
Ricerca = new Button(" Ricerca... ");
Annulla = new Button(" Indietro ");
panel1.add(Inserimento);
panel1.add(Modifica);
panel1.add(Cancellazione);
panel1.add(Ricerca);
panel1.add(Annulla);
this.setLayout(gridbag);
Utils.constrain(this,panel0, 0, 0, 12, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
Utils.constrain(this,panel1, 12, 0, 1, 12,GridBagConstraints.BOTH,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
}
void init()
{
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
p.setEnabled(true);
}
});
Inserimento.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startRic();
}
});
Modifica.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startMod();
}
});
Cancellazione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startCanc();
}
});
Ricerca.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startVis();
}
});
}
void startRic()
{
this.setEnabled(false);
mask_ric = new MascheraRicercaStanza("Ricerca stanze per commissioni",1);
mask_ric.setVisible(true);
mask_ric.padre = this;
}
void startMod()
{
this.setEnabled(false);
mask_mod = new ModificaCommissioni();
mask_mod.setVisible(true);
mask_mod.padre = this;
}
void startCanc()
{
this.setEnabled(false);
mask_canc = new CancellaCommissioni();
mask_canc.setVisible(true);
mask_canc.padre = this;
}
void startVis()
{
this.setEnabled(false);
mask_vis = new VediCommissione();
mask_vis.setVisible(true);
mask_vis.padre = this;
}
}
|
The code provides a user interface for managing commissions within a software system. Users can perform a variety of actions, including inserting new commissions, modifying existing ones, canceling commissions, and searching for commissions based on specific criteria. The interface presents the user with a set of buttons, each corresponding to one of these key functionalities. When a user clicks a button, the code opens a new window or dialog box tailored to that specific action, allowing the user to input or update the necessary information. The interface also includes a "Back" button, enabling users to navigate back to the previous screen. Overall, this code offers a comprehensive set of tools for managing commissions, empowering users to efficiently perform common commission-related tasks within the software system.
|
Code
|
SubGestione.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import common.utility.*;
public class SubGestione extends Frame
{
Label label;
Panel panel0, panel1;
Button Stanze, BeniServizi, Configurazione, Annulla ;
GridBagLayout gridbag=new GridBagLayout();
Frame p1 = new Frame();
Password pass = new Password();
SubStanze call_stanze;
SubBeniServizi call_beniservizi;
ConfigurazioneSistema call_config;
public SubGestione()
{
super("Gestione albergo");
setup();
init();
pack();
}
void setup()
{
this.setFont(ConfigurazioneSistema.font_sub);
panel0=new Panel();
panel0.setLayout(gridbag);
panel0.setBackground(Color.white);
Immagine figura = new Immagine("alb1.jpg");
Etichetta etich = new Etichetta("Gestione.gif");
Utils.constrain(panel0,etich, 0, 0, 2, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.5, 1.0,0,0,0,0);
Utils.constrain(panel0,figura, 2, 0, 10, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.5, 1.0,0,0,0,0);
panel1 = new Panel();
panel1.setLayout(new GridLayout(4,1));
Stanze = new Button("Stanze");
BeniServizi = new Button(" Beni & Servizi ");
Configurazione = new Button(" Configurazione ");
Annulla = new Button(" Indietro ");
panel1.add(Stanze);
panel1.add(BeniServizi);
panel1.add(Configurazione);
panel1.add(Annulla);
this.setLayout(gridbag);
Utils.constrain(this,panel0, 0, 0, 12, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
Utils.constrain(this,panel1, 12, 0, 1, 12,GridBagConstraints.BOTH,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
}
void init()
{
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
pass.setEnabled(true);
pass.p.setEnabled(true);
}
});
Stanze.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
gestioneStanze();
}
});
BeniServizi.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
gestioneBeniServizi();
}
});
Configurazione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startConfigurazione();
}
});
}
void gestioneStanze()
{
this.setEnabled(false);
call_stanze = new SubStanze();
call_stanze.setVisible(true);
call_stanze.s = this;
}
void gestioneBeniServizi()
{
this.setEnabled(false);
call_beniservizi = new SubBeniServizi();
call_beniservizi.setVisible(true);
call_beniservizi.s = this;
}
void startConfigurazione()
{
this.setEnabled(false);
call_config = new ConfigurazioneSistema(Principale.config, false, Principale.db);
call_config.setVisible(true);
call_config.padre = this;
}
}
|
This code provides a comprehensive hotel management system interface that allows users to access and manage various aspects of the hotel's operations. The main "Gestione" (Management) screen serves as a central hub, giving users the ability to navigate to three key areas: Stanze (Rooms), Beni & Servizi (Goods & Services), and Configurazione (Configuration).
In the Stanze area, users can view and update information related to the hotel's rooms, such as room status and availability. The Beni & Servizi area allows users to manage the hotel's inventory and pricing for goods and services. The Configurazione area provides access to system-wide settings and preferences, enabling users to customize the hotel management system to their needs.
The code also includes functionality to allow users to exit the "Gestione" interface and return to a previous state, such as the main login or password entry screen. Overall, this system provides a comprehensive and user-friendly interface for managing the various aspects of a hotel's operations, empowering users to efficiently oversee and maintain the hotel's resources and services.
|
Code
|
SubPrenotazione.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import common.utility.*;
public class SubPrenotazione extends Frame
{
Label label;
Panel panel0, panel1;
Button Inserimento, Modifica, Cancellazione, Ricerca, Annulla ;
GridBagLayout gridbag = new GridBagLayout();
Frame p = new Frame();
static public MascheraRicercaStanza ric_stanza = null;
static public RicercaPrenotazione ric_pren = null;
public SubPrenotazione()
{
super("Prenotazione");
setup();
init();
pack();
}
void setup()
{
Immagine figura = new Immagine("camera2.jpg");
Etichetta etich = new Etichetta("Prenotazioni.gif");
this.setFont(ConfigurazioneSistema.font_sub);
panel0=new Panel();
panel0.setLayout(gridbag);
panel0.setBackground(Color.white);
Utils.constrain(panel0,etich, 0, 0, 2, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.5, 1.0,0,0,0,0);
Utils.constrain(panel0,figura, 2, 0, 10, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.5, 1.0,0,0,0,0);
panel1 = new Panel();
panel1.setLayout(new GridLayout(5,1));
Inserimento = new Button(" Inserimento ");
Modifica = new Button(" Modifica ");
Cancellazione = new Button(" Cancellazione ");
Ricerca = new Button(" Ricerca... ");
Annulla = new Button(" Indietro ");
panel1.add(Inserimento);
panel1.add(Modifica);
panel1.add(Cancellazione);
panel1.add(Ricerca);
panel1.add(Annulla);
this.setLayout(gridbag);
Utils.constrain(this,panel0, 0, 0, 12, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
Utils.constrain(this,panel1, 12, 0, 1, 12,GridBagConstraints.BOTH,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
}
void init()
{
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
if (Principale.call_list != null)
(Principale.call_list).dispose();
p.setEnabled(true);
}
});
Inserimento.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
insPrenotazione();
}
});
Modifica.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
modPrenotazione();
}
});
Cancellazione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
cancPrenotazione();
}
});
Ricerca.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
vediPrenotazione();
}
});
}
void insPrenotazione()
{
this.setEnabled(false);
ric_stanza = new MascheraRicercaStanza("Ricerca stanze per prenotazioni",2);
ric_stanza.setVisible(true);
ric_stanza.padre = this;
}
void modPrenotazione()
{
this.setEnabled(false);
ric_pren = new RicercaPrenotazione("Ricerca prenotazione per modifica",1);
ric_pren.setVisible(true);
ric_pren.padre = this;
}
void cancPrenotazione()
{
this.setEnabled(false);
ric_pren = new RicercaPrenotazione("Ricerca prenotazione per cancellazione",2);
ric_pren.setVisible(true);
ric_pren.padre = this;
}
void vediPrenotazione()
{
this.setEnabled(false);
ric_pren = new RicercaPrenotazione("Ricerca prenotazione per visualizzazione",4);
ric_pren.setVisible(true);
ric_pren.padre = this;
}
}
|
This code provides a comprehensive hotel reservation management system, allowing users to perform a variety of operations related to hotel room reservations. The graphical user interface (GUI) offers a user-friendly experience, enabling users to easily insert new reservations, modify existing ones, cancel reservations, and view detailed information about their bookings. The system utilizes various utility classes and methods to manage the layout, images, and labels, creating a visually appealing and intuitive interface for the user. By interacting with the different buttons and options presented, users can efficiently manage their hotel reservations, ensuring a seamless and convenient booking experience.
|
Code
|
SubRistorazione.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import common.utility.*;
import AlberGate;
public class SubRistorazione extends Frame
{
Label label;
Panel panel0, panel1;
Button Calcolo, Annulla;
GridBagLayout gridbag=new GridBagLayout();
Frame p = new Frame();
MascheraContoRistorazione rist;
public SubRistorazione()
{
super("Ristorazione");
setup();
init();
pack();
}
void setup()
{
this.setFont(ConfigurazioneSistema.font_sub);
panel0=new Panel();
panel0.setLayout(gridbag);
panel0.setBackground(Color.white);
Immagine figura = new Immagine("ristorazione.jpg");
Etichetta etich = new Etichetta("Ristorazione.gif");
Utils.constrain(panel0,etich, 0, 0, 2, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.5, 1.0,0,0,0,0);
Utils.constrain(panel0,figura, 2, 0, 10, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.5, 1.0,0,0,0,0);
panel1 = new Panel();
panel1.setLayout(new GridLayout(2,1));
Calcolo = new Button(" Calcolo conto ");
Annulla = new Button(" Indietro ");
panel1.add(Calcolo);
panel1.add(Annulla);
this.setLayout(gridbag);
Utils.constrain(this,panel0, 0, 0, 12, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
Utils.constrain(this,panel1, 12, 0, 1, 12,GridBagConstraints.BOTH,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
}
void init()
{
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
p.setEnabled(true);
}
});
Calcolo.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startCalcolo();
}
});
}
void startCalcolo()
{
this.setEnabled(false);
rist = new MascheraContoRistorazione(this);
rist.setVisible(true);
rist.padre = this;
}
}
|
The code provided appears to be a Java GUI application that allows users to interact with a restaurant management system. The main class, `SubRistorazione`, provides a graphical user interface for the user to perform various restaurant-related tasks, such as calculating bills and navigating back to a parent application.
The application's setup includes two panels: one that displays an image and a label, and another that contains two buttons, "Calcolo conto" (Calculate Bill) and "Indietro" (Back). When the user clicks the "Calcolo conto" button, the application creates a new instance of the `MascheraContoRistorazione` class and makes it visible, suggesting that the user can perform some kind of calculation or operation related to the restaurant's billing or accounting.
The "Indietro" button allows the user to close the current window and re-enable a parent frame, indicating that this application is likely part of a larger system or application. Overall, the code provides a user-friendly interface for managing various aspects of a restaurant's operations, such as billing and accounting.
|
Code
|
SubSoggiorno.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.Random;
import common.utility.*;
import moduli.*;
public class SubSoggiorno extends Frame
{
Label label;
Panel panel0, panel1;
Button Arrivo, Cambio, Addebito, Telefonate, Calcolo, Ricerca, BeniServizi,Annulla;
GridBagLayout gridbag=new GridBagLayout();
Frame p = new Frame();
RicercaPrenotazione ric_pren;
Frame figlio;
public SubSoggiorno()
{
super("Soggiorno");
setup();
init();
pack();
}
void setup()
{
this.setFont(ConfigurazioneSistema.font_sub);
panel0=new Panel();
panel0.setLayout(gridbag);
panel0.setBackground(Color.white);
Random rnd = new Random();
int num;
if ((num = (rnd.nextInt() % 5) ) < 0)
num = num * -1;
num ++;
String file_name = new String("servizi"+num+".jpg");
Immagine figura = new Immagine(file_name);
Etichetta etich = new Etichetta("Soggiorno.gif");
Utils.constrain(panel0,etich, 0, 0, 2, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.5, 1.0,0,0,0,0);
Utils.constrain(panel0,figura, 2, 0, 10, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.5, 1.0,0,0,0,0);
panel1 = new Panel();
panel1.setLayout(new GridLayout(8,1));
Arrivo = new Button(" Arrivo clienti ");
Cambio = new Button(" Cambio stanza ");
Addebito = new Button(" Addebito spese ");
Telefonate = new Button(" Telefonate ");
Calcolo = new Button(" Calcolo conto ");
Ricerca = new Button(" Ricerca... ");
BeniServizi = new Button(" Beni & Servizi ");
Annulla = new Button(" Indietro ");
panel1.add(Arrivo);
panel1.add(Addebito);
panel1.add(BeniServizi);
panel1.add(Telefonate);
panel1.add(Cambio);
panel1.add(Calcolo);
panel1.add(Ricerca);
panel1.add(Annulla);
this.setLayout(gridbag);
Utils.constrain(this,panel0, 0, 0, 12, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
Utils.constrain(this,panel1, 12, 0, 1, 12,GridBagConstraints.BOTH,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
}
void init()
{
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
p.setEnabled(true);
}
});
Arrivo.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
insSoggiornante();
}
});
Calcolo.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
calcoloConto();
}
});
Addebito.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
addebitaBeneServizio();
}
});
BeniServizi.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
visitaBeneServizio();
}
});
Telefonate.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
ricercaTelefonate();
}
});
Cambio.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
cambiaStanza();
}
});
Ricerca.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startRicerca();
}
});
}
void insSoggiornante()
{
this.setEnabled(false);
ric_pren = new RicercaPrenotazione("Arrivo clienti",3);
ric_pren.setVisible(true);
ric_pren.padre = this;
}
void addebitaBeneServizio()
{
figlio = new MascheraAddebiti(this);
}
void visitaBeneServizio()
{
figlio = new RicercaAddebiti(this);
}
void ricercaTelefonate()
{
figlio = new RicercaTelefonate(this);
}
void calcoloConto()
{
figlio = new MascheraCalcoloConto(this);
figlio.setVisible(true);
}
void cambiaStanza()
{
figlio = new MascheraCambio(this);
}
void startRicerca()
{
figlio = new MascheraRicercaSoggiornante(this);
}
}
|
This code provides a comprehensive graphical user interface (GUI) that allows hotel staff to manage various aspects of guest stays. Users can handle guest arrivals, manage guest billing and charges, view and manage guest telephone usage, facilitate room changes, calculate final bills, search for and retrieve guest information, and access and manage the hotel's inventory of goods and services. The GUI offers a streamlined and efficient way for hotel staff to handle the various tasks and processes involved in providing a high-quality guest experience, from check-in to check-out. By integrating these features into a single, user-friendly interface, the code enables hotel staff to effectively and efficiently manage the complex operations of a hotel.
|
Code
|
SubStanze.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import common.utility.*;
public class SubStanze extends Frame
{
Label label;
Panel panel0, panel1;
Button Inserimento, Modifica, Cancellazione, Ricerca, Annulla;
GridBagLayout gridbag=new GridBagLayout();
SubGestione s = new SubGestione();
InserisciStanze call_1;
ModificaStanze call_2;
CancellaStanze call_3;
VediStanza call_4;
public SubStanze()
{
super("Gestione delle stanze");
setup();
init();
pack();
}
void setup()
{
this.setFont(ConfigurazioneSistema.font_sub);
panel0=new Panel();
panel0.setLayout(gridbag);
panel0.setBackground(Color.white);
Immagine figura = new Immagine("camera1.jpg");
Etichetta etich = new Etichetta("Stanze.gif");
Utils.constrain(panel0,etich, 0, 0, 2, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.5, 1.0,0,0,0,0);
Utils.constrain(panel0,figura, 2, 0, 10, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 0.5, 1.0,0,0,0,0);
panel1 = new Panel();
panel1.setLayout(new GridLayout(5,1));
Inserimento = new Button("Inserimento");
Modifica = new Button("Modifica");
Cancellazione = new Button("Cancellazione");
Ricerca = new Button("Ricerca...");
Annulla = new Button("Indietro");
panel1.add(Inserimento);
panel1.add(Modifica);
panel1.add(Cancellazione);
panel1.add(Ricerca);
panel1.add(Annulla);
this.setLayout(gridbag);
Utils.constrain(this,panel0, 0, 0, 12, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
Utils.constrain(this,panel1, 12, 0, 1, 12,GridBagConstraints.BOTH,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
}
void init()
{
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
s.setEnabled(true);
}
});
Inserimento.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
insStanza();
}
});
Modifica.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
modStanza();
}
});
Cancellazione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
cancStanza();
}
});
Ricerca.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
vediStanza();
}
});
}
void insStanza()
{
this.setEnabled(false);
call_1 = new InserisciStanze();
call_1.setVisible(true);
call_1.stanze = this;
}
void modStanza()
{
this.setEnabled(false);
call_2 = new ModificaStanze();
call_2.setVisible(true);
call_2.stanze = this;
}
void cancStanza()
{
this.setEnabled(false);
call_3 = new CancellaStanze();
call_3.setVisible(true);
call_3.stanze = this;
}
void vediStanza()
{
this.setEnabled(false);
call_4 = new VediStanza();
call_4.setVisible(true);
call_4.stanze = this;
}
}
|
This code provides a comprehensive user interface for managing the rooms or spaces of a building or facility. The graphical user interface (GUI) allows users to perform a variety of operations, including inserting new rooms, modifying existing rooms, deleting rooms, and searching for specific rooms. The GUI is divided into two main panels: one with an image and a label, and another with five buttons that correspond to the available operations.
When the user interacts with these buttons, the code opens new windows that enable the user to perform the selected operation. For example, clicking the "Inserimento" button opens a window for inserting a new room, while the "Modifica" button opens a window for modifying an existing room. The "Annulla" button allows the user to close the current window and return to the main GUI.
The code also includes various utility classes and methods, such as a GridBagLayout for arranging the GUI elements and a ConfigurazioneSistema class that likely contains system-wide configuration settings. Overall, this code provides a user-friendly and comprehensive interface for managing the rooms or spaces of a building or facility.
|
Code
|
SubStorico.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import common.utility.*;
public class SubStorico extends Frame
{
Label label;
Panel panel0, panel1;
Button Ricerca, Annulla;
GridBagLayout gridbag = new GridBagLayout();
Frame p = new Frame();
Frame figlio;
public SubStorico()
{
super("Storico Clienti");
setup();
init();
pack();
//setVisible(true);
}
void setup()
{
this.setFont(ConfigurazioneSistema.font_sub);
panel0=new Panel();
panel0.setLayout(gridbag);
panel0.setBackground(Color.white);
Immagine figura = new Immagine("servizi5.jpg");
Etichetta etich = new Etichetta("Storico.gif");
Utils.constrain(panel0,etich, 0, 0, 2, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 1.0, 1.0,0,0,0,0);
Utils.constrain(panel0,figura, 2, 0, 10, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.CENTER, 1.0, 1.0,0,0,0,0);
panel1 = new Panel();
panel1.setLayout(new GridLayout(2,1));
Ricerca = new Button(" Ricerca ");
Annulla = new Button(" Annulla ");
panel1.add(Ricerca);
panel1.add(Annulla);
this.setLayout(gridbag);
Utils.constrain(this,panel0, 0, 0, 12, 12,GridBagConstraints.VERTICAL,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
Utils.constrain(this,panel1, 12, 0, 1, 12,GridBagConstraints.BOTH,
GridBagConstraints.WEST, 1.0, 1.0, 0, 0, 0, 0);
}
void init()
{
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
p.setEnabled(true);
}
});
Ricerca.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
start_ricerca();
}
});
}
void start_ricerca()
{
figlio = new MascheraRicercaStorico(this);
}
}
|
The code provided implements a graphical user interface (GUI) application that allows users to interact with a system related to customer history. The main window of the application, titled "Storico Clienti" (Customer History), presents a visually appealing layout with an image and a label. The GUI is divided into two main panels: one for displaying the visual elements and another for housing the interactive buttons.
Users can access the core functionality of the application through the two buttons: "Ricerca" (Search) and "Annulla" (Cancel). The "Ricerca" button triggers the creation of a new window, "MascheraRicercaStorico" (Search History Mask), which likely provides the interface for searching and viewing customer history information. The "Annulla" button, on the other hand, allows users to cancel the current operation and return to the parent window.
By providing this GUI-based interface, the application aims to offer users a streamlined and intuitive way to interact with the customer history system, enabling them to efficiently search for and access relevant information.
|
Code
|
VediAddebito.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
public class VediAddebito extends Frame
{
TextField num_stanza, desc, quantita, tot, tot_addebiti;
Label etich1, etich2, etich3, etich4, etich5, etich6;
Panel panel1, panel2;
Button Annulla;
GridBagLayout gridbag = new GridBagLayout();
Frame padre = new Frame();
Addebito add;
float addebiti_totali;
public VediAddebito(Frame p, Addebito a, float tot)
{
super("Visualizzazione dei dati dell'addebito scelto");
padre = p;
add = a;
addebiti_totali = tot;
padre.setEnabled(false);
setupPanels();
inizializza();
pack();
setVisible(true);
}
void setupPanels()
{
this.setFont(ConfigurazioneSistema.font_base);
//Creo le etichette
etich1 = new Label("Dati dell'addebito");
etich1.setFont(ConfigurazioneSistema.font_titolo);
etich2 = new Label("Numero Stanza");
etich3 = new Label("Descrizione");
etich4 = new Label("Quantita");
etich5 = new Label("Addebito relativo");
etich6 = new Label("Totale addebiti sulla stanza "+add.getNumStanza());
etich6.setFont(ConfigurazioneSistema.font_titolo);
//Creo i TextField e ne rendo alcuni non editabili
num_stanza = new TextField("",4);
desc = new TextField("",32);
quantita = new TextField("",6);
tot = new TextField("",8);
tot_addebiti = new TextField("",10);
//Disabilita i TextField
num_stanza.setEditable(false);
desc.setEditable(false);
quantita.setEditable(false);
tot.setEditable(false);
tot_addebiti.setEditable(false);
//Creo i pulsanti
Annulla = new Button(" Indietro ");
//Creo il pannello
panel1 = new Panel();
panel1.setLayout(gridbag);
Utils.constrain(panel1, etich1, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel1, etich2, 0, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1,num_stanza, 1, 1, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich3, 0, 2, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1,desc, 1, 2, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich4, 0, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1,quantita , 1, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich5, 2, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1,tot , 3, 3, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, etich6, 0, 4, 2, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 15, 5, 5, 5);
Utils.constrain(panel1, tot_addebiti, 2, 4, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 15, 5, 5, 5);
panel2 = new Panel();
panel2.setLayout(gridbag);
Utils.constrain(panel2, Annulla, 0, 0, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.CENTER, 0.0, 0.0, 0, 0, 0, 15);
//Attacco i pannelli al frame
this.setLayout(gridbag);
Utils.constrain(this, panel1, 0, 0, 6, 5, GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(this, panel2, 0, 5, 6, 1, GridBagConstraints.HORIZONTAL,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 5);
}
public void inizializza()
{
writeDatiTel();
Annulla.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
}
void writeDatiTel()
{
String d = new String("");
BeneServizio extra = (Principale.db).readBeneServizio(add.getCodExtra());
if (extra == null)
d = new String("");
else
d = new String(extra.getDescrizione());
num_stanza.setText(add.getNumStanza());
desc.setText(d);
quantita.setText(""+add.getQuantita());
tot.setText(""+add.getTotAddebito());
tot_addebiti.setText(""+addebiti_totali);
}
}
|
This code provides a user interface that allows hotel staff to view detailed information about a specific charge or "addebito" that has been applied to a hotel room. The interface displays the room number, a description of the charge, the quantity, the total amount of the charge, and the total of all charges for that room. This information is presented in a graphical window with various text fields and labels. The user can easily navigate back to the previous screen by clicking the "Annulla" (Cancel) button. This functionality gives hotel staff the ability to quickly and easily access and review the details of charges applied to a guest's room, which can be useful for addressing customer inquiries or resolving billing issues. The code sets up the user interface, initializes the data to be displayed, and handles the user's interaction with the Cancel button, providing a seamless and intuitive experience for the hotel staff.
|
Code
|
VediBeniServizi.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import moduli.BeneServizio;
import moduli.DataBase;
import moduli.ListaBeniServizi;
public class VediBeniServizi extends MascheraBeneServizio
{
BeneServizio extra = null;
Label elenco_extra1, elenco_extra2, desc_extra, px_extra;
TextField desc, prezzo;
Button annulla3, annulla_canc;
public VediBeniServizi()
{
super("Visualizzazione dei dati di un bene o servizio");
setupPannello();
initialize();
}
void setupPannello()
{
panel[11].setLayout(gridbag);
elenco_extra1 = new Label("Scegliere il bene o servizio, appartenente");
elenco_extra2 = new Label("alla categoria selezionata, da visualizzare");
annulla3 = new Button(" Fine ");
Utils.constrain(panel[11], elenco_extra1, 0, 0, 5, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 0, 0, 0, 0);
Utils.constrain(panel[11], elenco_extra2, 0, 1, 5, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 0, 0, 5, 0);
Utils.constrain(panel[11], elenco, 0, 2, 5, 1,GridBagConstraints.HORIZONTAL,
GridBagConstraints.CENTER, 1.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[11], annulla3, 2, 3, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.CENTER, 1.0, 0.0, 5, 5, 5, 5);
panel[12].setLayout(gridbag);
desc_extra = new Label("Nome del bene");
px_extra = new Label("Prezzo del bene");
desc = new TextField("",40);
prezzo = new TextField("",10);
desc.setEditable(false);
prezzo.setEditable(false);
annulla_canc = new Button(" Indietro ");
Utils.constrain(panel[12], desc_extra, 0, 0, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[12], desc, 1, 0, 4, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 0, 5, 5, 0);
Utils.constrain(panel[12], px_extra, 0, 1, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 0.0, 0.0, 5, 5, 5, 0);
Utils.constrain(panel[12], prezzo, 1, 1, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.WEST, 1.0, 0.0, 5, 5, 5, 0);
Utils.constrain(panel[12], annulla_canc, 1, 2, 1, 1,GridBagConstraints.NONE,
GridBagConstraints.EAST, 1.0, 0.0, 5, 5, 0, 5);
}
public void initialize()
{
scelta_piatto[4].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_piatto[4].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.DESSERT);
p();
}
}
});
scelta_piatto[5].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_piatto[5].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.FRUTTA);
p();
}
}
});
scelta_servizio[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_servizio[0].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.RICREATIVI);
o();
}
}
});
scelta_servizio[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_servizio[1].getState())
{
level = 1;
codice = composeCode(level, BeneServizio.ALTRO);
o();
}
}
});
scelta_bevanda[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_bevanda[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.CAFFETTERIA);
o();
}
}
});
scelta_bevanda[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_bevanda[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.ANALCOLICI);
o();
}
}
});
scelta_bevanda[2].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_bevanda[2].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.ALCOLICI);
o();
}
}
});
scelta_cibo[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_cibo[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.DOLCI);
o();
}
}
});
scelta_cibo[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_cibo[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.SALATI);
o();
}
}
});
scelta_antipasto[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_antipasto[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.FREDDI);
o();
}
}
});
scelta_antipasto[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_antipasto[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.CALDI);
o();
}
}
});
scelta_primo[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_primo[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.SOLIDI);
o();
}
}
});
scelta_primo[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_primo[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.LIQUIDI);
o();
}
}
});
scelta_secondo[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_secondo[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.CARNE);
o();
}
}
});
scelta_secondo[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_secondo[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.PESCE);
o();
}
}
});
scelta_contorno[0].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_contorno[0].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.VERDURA_COTTA);
o();
}
}
});
scelta_contorno[1].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_contorno[1].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.VERDURA_CRUDA);
o();
}
}
});
scelta_contorno[2].addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(scelta_contorno[2].getState())
{
level = 2;
codice = composeCode(level, BeneServizio.FORMAGGIO);
o();
}
}
});
annulla_canc.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
goBack();
}
});
annulla3.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
elenco.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
beneSelezionato();
}
});
} // init
void beneSelezionato()
{
extra = L.getBeneServizio((elenco.getSelectedIndexes())[0]+1);
remove(panel[11]);
this.add(panel[12]);
desc.setText(extra.getDescrizione());
prezzo.setText(extra.getPxUnitario()+"");
panel[12].setVisible(true);
setVisible(true);
}
void goBack()
{
remove(panel[12]);
this.add(panel[11]);
panel[11].setVisible(true);
setVisible(true);
}
}
|
This code provides a user interface for browsing and viewing a list of goods and services. The user can select from a set of predefined categories, such as desserts, fruits, recreational services, and others, which will populate a list of corresponding items. When the user selects an item from the list, the code will display detailed information about that item, including its description and price. The user can then navigate back to the main list view. The application also includes functionality to close the window, which will enable the parent window. This allows the user to easily navigate and view information about the available goods and services, providing a convenient way to browse and access the details of specific items.
|
Code
|
VediCliente.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import moduli.*;
import common.utility.*;
import common.def.*;
import java.util.Date;
public class VediCliente extends MascheraSoggiorno
{
Frame padre;
public VediCliente(Frame p, Cliente cli)
{
super("Visualizzazione dei dati del cliente"," Fine ",' ',' ');
padre=p;
padre.setEnabled(false);
inizializza(cli);
pack();
}
public void inizializza(Cliente cli)
{
remove(panel2);
Utils.constrain(panel1, label13, 0, 8, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo13, 1, 8, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, label14, 2, 8, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 0.0, 0.0, 5, 5, 5, 5);
Utils.constrain(panel1, testo14, 3, 8, 1, 1, GridBagConstraints.NONE,
GridBagConstraints.NORTHWEST, 1.0, 0.0, 5, 5, 5, 5);
panel3.remove(Annulla);
pack();
disableFields();
writeDatiCliente(cli);
this.setVisible(true);
Conferma.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
}
void disableFields()
{
testo1.setEditable(false);
testo2.setEditable(false);
testo3.setEditable(false);
testo4.setEditable(false);
testo5.setEditable(false);
testo6.setEditable(false);
testo7.setEditable(false);
testo8.setEditable(false);
testo9.setEditable(false);
testo10.setEditable(false);
testo11.setEditable(false);
testo12.setEditable(false);
testo13.setEditable(false);
testo14.setEditable(false);
}
public void writeDatiCliente(Cliente cliente)
{
testo1.setText(cliente.getNumStanza());
testo2.setText(cliente.getCognome());
testo3.setText(cliente.getNome());
testo4.setText(cliente.getLuogoNasc());
testo5.setText(DateUtils.giveStringOfDate(cliente.getDataNasc()));
testo6.setText(cliente.getNumDoc());
testo7.setText(cliente.getNumTel());
testo8.setText(cliente.getIndirizzo());
testo9.setText(cliente.getCap());
testo10.setText(cliente.getComune());
testo11.setText(cliente.getCitta());
testo12.setText(cliente.getNazione());
testo13.setText(DateUtils.giveStringOfDate(cliente.getInizioSogg()));
testo14.setText(DateUtils.giveStringOfDate(cliente.getFineSogg()));
}
}
|
The code provides a user interface for viewing and managing client information in a hotel or similar accommodation system. The VediCliente class creates a new window that displays detailed information about a specific client, including their room number, name, date of birth, contact information, and the dates of their stay. The text fields in the window are disabled, preventing the user from modifying the client's information directly. Instead, the user can only view the information, which is populated using the writeDatiCliente method. When the user clicks the Conferma (Confirm) button, the window is closed, and the parent frame is re-enabled, suggesting that the VediCliente window is a modal dialog or a separate window that is opened from a larger application. This functionality allows the user to easily access and review a client's information without the ability to make changes, which is likely an important feature for maintaining data integrity and security in the system.
|
Code
|
VediCommissione.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
import moduli.Commissionamento;
public class VediCommissione extends MascheraCommissioni
{
Commissionamento commissione;
public VediCommissione()
{
super("","","Visualizzazione dati delle commissioni"," Cerca ",4);
init();
}
public void init()
{
nome_agenzia.setEditable(true);
num_stanza.setEditable(false);
num_tel_agenzia.setEditable(false);
inizio_comm.setEditable(false);
fine_comm.setEditable(false);
scadenza_comm.setEditable(false);
num_stanza.setEditable(false);
lista.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
commissione = L.getCommissionamento((lista.getSelectedIndexes())[0]+1);
writeDatiComm(commissione);
Azione.setEnabled(true);
pack();
}
});
nome_agenzia.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
creaLista();
}
});
Azione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
creaLista();
}
});
}
}
|
The code provided implements a user interface for a software system that allows users to view and manage commission data. The main class, `VediCommissione`, extends the `MascheraCommissioni` class and provides a graphical user interface (GUI) for the user to interact with.
The GUI includes various fields and components that allow the user to view and interact with commission data. The `nome_agenzia` field is editable, allowing the user to enter an agency name, while other fields such as `num_stanza`, `num_tel_agenzia`, `inizio_comm`, `fine_comm`, and `scadenza_comm` are non-editable and display the corresponding commission details.
The code sets up event listeners for various GUI components, such as the `lista` component, which is likely a list or dropdown. When the user selects an item from the list, the corresponding `Commissionamento` object is retrieved and its data is displayed in the GUI. The `Azione` component, which is likely a button or other interactive element, triggers the `creaLista()` method, which presumably populates the `lista` component with available commissions.
Additionally, the `nome_agenzia` field has an `ActionListener` that also calls the `creaLista()` method, likely to update the list of available commissions based on the agency name entered by the user.
Overall, this code provides a user interface for viewing and managing commission data, allowing the user to select a specific commission and view its details, as well as potentially perform other actions related to commissions.
|
Code
|
VediPrenotazione.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import java.util.Date;
import moduli.*;
public class VediPrenotazione extends MascheraPrenotazione
{
Prenotazione p;
RicercaPrenotazione parent;
char flag;
public VediPrenotazione(Prenotazione pren, Stanza room, RicercaPrenotazione papa)
{
super(room,"","","Visualizzazione dei dati della prenotazione","",4, pren.getPensionamento());
p = pren;
parent = papa;
init();
}
public void init()
{
Frame msg;
writeDatiPren(p);
for(int i=0; i<11; i++)
testo[i].setEditable(false);
myCheckbox.setEnabled(false);
myCheckbox1.setEnabled(false);
for (int i=0; i<checkboxes.length; i++)
checkboxes[i].setEnabled(false);
testo[9].setText(DateUtils.parseDate(DateUtils.giveStringOfDate(p.getDataPren())));
panel2.remove(Azione);
}
}
|
The code provided appears to be part of a larger hotel reservation management system, where the `VediPrenotazione` class is responsible for displaying the details of a specific reservation to the user. The class takes in the necessary objects to represent the reservation, the associated room, and the parent class that initiated the display of the reservation details.
The `init()` method of the `VediPrenotazione` class sets up the user interface by populating it with the details of the reservation, such as the reservation date, room information, and other relevant details. It then makes the text fields non-editable and disables the checkboxes, effectively making the reservation details read-only. This suggests that the user is not able to modify or interact with the reservation from this interface, but rather can only view the details.
The removal of the "Azione" panel further reinforces the read-only nature of the interface, indicating that the user is not able to perform any actions on the reservation from this particular screen. This functionality is likely part of a larger hotel reservation management system, where the user can view the details of a reservation but cannot directly modify or interact with it from this interface.
|
Code
|
VediSoggiornante.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import moduli.*;
import common.utility.*;
import common.def.*;
import java.util.Date;
public class VediSoggiornante extends MascheraSoggiorno
{
Frame padre;
public VediSoggiornante(Frame p, Soggiornante sogg)
{
super("Visualizzazione dei dati del soggiornante"," Fine ", sogg.getPensionamento(), sogg.getStatus() );
padre=p;
padre.setEnabled(false);
inizializza(sogg);
pack();
this.setVisible(true);
}
public void inizializza(Soggiornante sogg)
{
panel3.remove(Annulla);
disableFields();
writeDatiSogg(sogg);
Conferma.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
dispose();
padre.setEnabled(true);
}
});
}
void disableFields()
{
testo1.setEditable(false);
testo2.setEditable(false);
testo3.setEditable(false);
testo4.setEditable(false);
testo5.setEditable(false);
testo6.setEditable(false);
testo7.setEditable(false);
testo8.setEditable(false);
testo9.setEditable(false);
testo10.setEditable(false);
testo11.setEditable(false);
testo12.setEditable(false);
testo13.setEditable(false);
testo14.setEditable(false);
for (int i=0; i<checkboxes.length; i++)
checkboxes[i].setEnabled(false);
for (int i=0; i<checkboxes1.length; i++)
checkboxes1[i].setEnabled(false);
}
}
|
The code provides a user interface for viewing the details of a Soggiornante (a person staying at a location). When the user creates an instance of the VediSoggiornante class, it opens a GUI window that displays the Soggiornante's information, such as their retirement status and current status. The window is pre-populated with the Soggiornante's data, and all the fields are disabled to prevent the user from modifying the information.
The user can interact with the window by clicking the "Finish" button, which will close the window and re-enable the parent Frame. This functionality allows the user to easily view the details of a Soggiornante without the ability to make any changes to the data.
|
Code
|
VediStanza.java
|
package interfacce;
import java.awt.*;
import java.awt.event.*;
import common.utility.*;
import common.def.*;
import moduli.*;
public class VediStanza extends DescrittoreStanze
{
public VediStanza()
{
super("Visualizzazione dei dati delle stanze", "Cerca",4);
init();
}
public void init()
{
testo1.setEditable(true);
testo2.setEditable(false);
testo3.setEditable(false);
testo4.setEditable(false);
mycheckboxes.setEnabled(false);
Azione.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startCerca();
}
});
testo1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
startCerca();
}
});
} // init
void startCerca()
{
MessageDialog msg;
Stanza room;
if ((room = (Principale.db).readStanza(testo1.getText())) != null)
{
writeDatiStanza(room);
Azione.setEnabled(true);
}
else
msg = new MessageDialog(this, "Stanza inesistente!");
}
}
|
The VediStanza class provides users with the ability to search for and view information about rooms or spaces within a larger system. Users can enter a room name into a text field, and the system will retrieve the corresponding room data from a database. If the room is found, the system will display its name, description, and other relevant details in a read-only format. This allows users to easily access and review information about specific rooms without the ability to directly modify the data. If the user enters a room name that does not exist in the database, the system will display an error message to inform the user. Overall, this functionality gives users a straightforward way to search for and view information about the various rooms or spaces within the larger system.
|
Code
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.