Skip to content
Snippets Groups Projects
Commit c949c952 authored by Johannes Wilhelm's avatar Johannes Wilhelm
Browse files

sdfsdf

parent fae11ac3
No related branches found
No related tags found
No related merge requests found
[InternetShortcut]
URL=http://localhost:8080/welcome
IDList=
HotKey=0
IconIndex=0
......@@ -60,6 +60,7 @@ public class BuchungController {
@RequestMapping(value="/save2", method=RequestMethod.GET)
public ModelAndView save(Buchung buchung, Model model) {
buchung.setBelegtsum(buchung.daysbetween(buchung.getBelegtvon(), buchung.getBelegtbis())+1);
buchungService.save(buchung);
model.addAttribute("statusMessageKey", "buchung.form.msg.success");
......@@ -72,7 +73,9 @@ public class BuchungController {
Buchung b = buchungService.findById(buchungid);
Zimmer z = zimmerService.findById(b.getZimmerid());
b.setPreissum(z.getPreisErw()*b.getErwa_anz()+z.getPreisKind()*b.getKind_anz()) ;
int days = b.longtoint(b.getBelegtsum());
//b.setBelegtsum(b.daysbetween(b.getBelegtvon(), b.getBelegtbis()));
b.setPreissum((z.getPreisErw()*b.getErwa_anz()+z.getPreisKind()*b.getKind_anz())*days) ;
buchungService.save(b);
mv.addObject("buchung", buchungService.findById(buchungid));
......@@ -102,5 +105,7 @@ public class BuchungController {
kundeService.delete(b.getKundenid());
return "redirect:/welcome";
}
}
package de.thd.pms.model;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
......@@ -11,6 +17,7 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.springframework.format.annotation.DateTimeFormat;
@Entity
......@@ -25,8 +32,7 @@ public class Buchung {
private LocalDate belegtvon;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate belegtbis;
private int belegtsum;
private int kundsum;
private Long belegtsum;
private int erwa_anz;
private int kind_anz;
private Long kundenid;
......@@ -47,9 +53,21 @@ public class Buchung {
zimmerid = id2;
}
public Long daysbetween(LocalDate belegtvon, LocalDate belegtbis) {
long daysBetween = ChronoUnit.DAYS.between(belegtvon, belegtbis);
return daysBetween;
}
public int longtoint(Long days) {
int i;
return i = (int) (long) days;
}
@Id
@GeneratedValue
public Long getId() {
......@@ -71,10 +89,10 @@ public class Buchung {
public void setBelegtbis(LocalDate blegetbis) {
this.belegtbis = blegetbis;
}
public int getBelegtsum() {
public Long getBelegtsum() {
return belegtsum;
}
public void setBelegtsum(int belegtsum) {
public void setBelegtsum(Long belegtsum) {
this.belegtsum = belegtsum;
}
public Long getZimmerid() {
......@@ -90,15 +108,7 @@ public class Buchung {
this.kundenid = kundenid;
}
public int getKundsum() {
return kundsum;
}
public void setKundsum(int kundsum) {
this.kundsum = kundsum;
}
public int getErwa_anz() {
return erwa_anz;
......@@ -129,4 +139,5 @@ public class Buchung {
this.preissum = preissum;
}
}
......@@ -2,6 +2,7 @@
import java.sql.Date;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -26,7 +27,7 @@ public class BuchungService {
buchungRepository.save(b);
}
public void createBuchung(Long zimmerid, LocalDate belegtvon, LocalDate belegtbis, Integer belegtsum, Integer erwa_anz, Integer kind_anz, Long kundenid ) {
public void createBuchung(Long zimmerid, LocalDate belegtvon, LocalDate belegtbis, Long belegtsum, Integer erwa_anz, Integer kind_anz, Long kundenid ) {
Buchung b = new Buchung();
b.setZimmerid(zimmerid);
b.setBelegtvon(belegtvon);
......
......@@ -5,4 +5,4 @@ spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.initialization-mode=always
spring.datasource.data=classpath:data-zimmer.sql
server.port=3333
\ No newline at end of file
#server.port=4444
\ No newline at end of file
......@@ -53,6 +53,10 @@
<td>&nbsp;</td>
<th>Check-out Datum</th>
<td>&nbsp;</td>
<td>&nbsp;</td>
<th>Gebuchte Tage</th>
</tr>
<tr>
<td>
......@@ -68,6 +72,15 @@
name="belegtbis" th:text="*{belegtbis}">
</output>
</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>
<output class="form-control" id="belegtsum"
name="belegtsum" th:text="*{belegtsum}">
</output>
</td>
</tr>
</table>
......
......@@ -19,9 +19,12 @@ Check-Out: <b>$buchung.belegtvon</b>
<br/>
Check-In: <b>$buchung.belegtbis</b>
<br/>
Gebuchte Tage: <b>$buchung.belegtsum</b>
<br/>
<br/>
Buchungsbest&auml;tigungsnummer: <b>$buchung.id</b>
<br/>
This file is generated on : $genDateTime
Dieses Dokument wurde am $genDateTime erstellt:
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment