Professional Documents
Culture Documents
* GiroEditAction.java
* Part of project Vega
*
* Author: Tantowi Mustofa. tantowi@spjbaut.com
*/
package com.tantowi.vega.finance;
import com.tantowi.nebula.DbConnection;
import com.tantowi.nebula.Forms;
import com.tantowi.nebula.HttpNotFoundException;
import com.tantowi.nebula.HttpBadRequestException;
import com.tantowi.vega.VegaAction;
import java.io.IOException;
import java.sql.SQLException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import javax.servlet.ServletException;
/**
*
* @author dhanang
*/
public class GiroEditAction extends VegaAction {
int fid = 0;
String fnomor = "";
LocalDate ftanggal = LocalDate.now();
LocalDate fjtempo = LocalDate.now();
int fbank = 0;
String fmtu = "";
String fket = "";
String fkepada = "";
double fjumlah = 0;
@Override
public void doGet() throws ServletException, IOException, SQLException {
try (DbConnection db = this.getDbConnection()) {
String cnomor = (String) request.getAttribute("nomor");
if (cnomor == null || cnomor.isEmpty()) {
throw new HttpNotFoundException("");
}
if (!cnomor.equals("~")) {
db.query("select
id,nomor,tanggal,jtempo,kepada,jumlah,bank_id,keterangan,mtu from finance_giro_req
where nomor=?");
db.setString(1, cnomor);
db.execute();
if (!db.next()) {
throw new HttpNotFoundException("Nomor Not found" + cnomor);
}
fid = db.getInt(1);
fnomor = db.getString(2);
ftanggal = db.getLocalDate(3);
fjtempo = db.getLocalDate(4);
fkepada = db.getString(5);
fjumlah = db.getDouble(6);
fbank = db.getInt(7);
fket = db.getString(8);
fmtu = db.getString(9);
}
display(db);
}
}
@Override
public void doPost() throws ServletException, IOException, SQLException {
try (DbConnection db = this.getDbConnection()) {
fid = form.getInt("id");
fnomor = form.getString("nomor").toUpperCase();
ftanggal = form.getLocalDate("tanggal");
fjtempo = form.getLocalDate("jtempo");
fkepada = form.getString("kepada");
fbank = form.getInt("bank");
fjumlah = form.getDouble("jumlah");
fmtu = form.getString("mtu");
fket = form.getString("keterangan");
String[] errors = form.getErrors();
if (errors.length > 0) {
for (String fld : errors) {
request.setAttribute(fld + "_status", "has Error");
}
display(db);
return;
return true;
}
}
return Forms.buildSelectItems(ids, texts, String.valueOf(def));
}