Add files via upload

This commit is contained in:
gopi17701 2018-07-31 15:55:47 -04:00 committed by GitHub
parent c27ef42baf
commit c43cfdf562
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 63 deletions

View File

@ -100,7 +100,7 @@ public abstract class DAO {
public abstract void updatePODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, Double fee, int serviceTypeId) throws AstuteException; public abstract void updatePODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, Double fee, int serviceTypeId) throws AstuteException;
public abstract void createPOMaster(String PONum, String contractNum, java.sql.Date PODate, Double contractAmt, int customerId, String astuteProjectNumber) throws AstuteException; public abstract void createPOMaster(String PONum, String contractNum, java.sql.Date PODate, Double contractAmt, String customerId, String astuteProjectNumber) throws AstuteException;
public abstract void createPODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, Double fee, int serviceTypeId) throws AstuteException; public abstract void createPODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, Double fee, int serviceTypeId) throws AstuteException;
@ -127,11 +127,11 @@ public abstract class DAO {
public abstract String dupliateInvoice(String InvoiceNumber) throws AstuteException; public abstract String dupliateInvoice(String InvoiceNumber) throws AstuteException;
public abstract List<Customer> getCustomers(int customerId) throws AstuteException; public abstract List<Customer> getCustomers(String customerId) throws AstuteException;
public abstract int createCustomer(String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, int phone, int fax) throws AstuteException; public abstract String createCustomer(String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, Long phone, Long fax) throws AstuteException;
public abstract void updateCustomer(int customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, int phone, int fax) throws AstuteException; public abstract void updateCustomer(String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, Long phone, Long fax) throws AstuteException;
// User and session method implementation // User and session method implementation

View File

@ -56,7 +56,7 @@ public class SqlDAO extends DAO {
String poNum = rs.getString(1); String poNum = rs.getString(1);
String cntrctNum = rs.getString(2); String cntrctNum = rs.getString(2);
Date poDate = rs.getDate(3); Date poDate = rs.getDate(3);
Integer customerId = rs.getInt(4); String customerId = rs.getString(4);
Double contractAmt = rs.getDouble(5); Double contractAmt = rs.getDouble(5);
String astuteProjectNum = rs.getString(6); String astuteProjectNum = rs.getString(6);
PO po = new PO(poNum, cntrctNum, poDate, customerId, contractAmt,astuteProjectNum); PO po = new PO(poNum, cntrctNum, poDate, customerId, contractAmt,astuteProjectNum);
@ -183,14 +183,14 @@ public class SqlDAO extends DAO {
} }
} }
public void createPOMaster(String PONum, String contractNum, Date PODate, Double contractAmt, int customerId, String astuteProjectNumber) throws AstuteException { public void createPOMaster(String PONum, String contractNum, Date PODate, Double contractAmt, String customerId, String astuteProjectNumber) throws AstuteException {
try { try {
CallableStatement stmt = conn.prepareCall("{call create_PO(?,?,?,?,?,?)}"); CallableStatement stmt = conn.prepareCall("{call create_PO(?,?,?,?,?,?)}");
stmt.setString(1, PONum); stmt.setString(1, PONum);
stmt.setString(2, contractNum); stmt.setString(2, contractNum);
stmt.setDate(3, PODate); stmt.setDate(3, PODate);
stmt.setDouble(4, contractAmt); stmt.setDouble(4, contractAmt);
stmt.setInt(5, customerId); stmt.setString(5, customerId);
stmt.setString(6, astuteProjectNumber); stmt.setString(6, astuteProjectNumber);
stmt.executeUpdate(); stmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
@ -261,7 +261,7 @@ public class SqlDAO extends DAO {
String PONo = invoice.getPoNum(); String PONo = invoice.getPoNum();
List<InvoiceDetail> invoiceDetail = getInvoiceDetail(invoiceNumber, 0); List<InvoiceDetail> invoiceDetail = getInvoiceDetail(invoiceNumber, 0);
PO po = getPOMaster(PONo, null, null, null).get(0); PO po = getPOMaster(PONo, null, null, null).get(0);
Integer customerId = po.getCustomerId(); String customerId = po.getCustomerId();
Customer customer = getCustomers(customerId).get(0); Customer customer = getCustomers(customerId).get(0);
Double previouslyBilledAmt = getPreviouslyBilledAmount(PONo); Double previouslyBilledAmt = getPreviouslyBilledAmount(PONo);
Double toBeBilledAmt = po.getContractAmt() - previouslyBilledAmt - invoice.getBillAmt(); Double toBeBilledAmt = po.getContractAmt() - previouslyBilledAmt - invoice.getBillAmt();
@ -507,17 +507,17 @@ public class SqlDAO extends DAO {
=============================== Customer Methods =============================================== =============================== Customer Methods ===============================================
*/ */
public List<Customer> getCustomers(int customerId) throws AstuteException { public List<Customer> getCustomers(String customerId) throws AstuteException {
try { try {
List<Customer> customers = new ArrayList<>(); List<Customer> customers = new ArrayList<>();
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
String sql = "SELECT customer_id, customer_name, bill_to_dept, add1, add2, city, state ,zip, zip_last_4, email, phone, fax FROM customer "; String sql = "SELECT customer_id, customer_name, bill_to_dept, add1, add2, city, state ,zip, zip_last_4, email, phone, fax FROM customer ";
if (customerId > 0) { if (customerId!=null && !customerId.isEmpty()) {
sql += " WHERE customer_id = " + customerId; sql += " WHERE customer_id = '" + customerId + "'";
} }
ResultSet rs = stmt.executeQuery(sql); ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) { while (rs.next()) {
int customerID = rs.getInt(1); String customerID = rs.getString(1);
String customerName = rs.getString(2); String customerName = rs.getString(2);
String billToDept = rs.getString(3); String billToDept = rs.getString(3);
String add1 = rs.getString(4); String add1 = rs.getString(4);
@ -539,75 +539,54 @@ public class SqlDAO extends DAO {
} }
} }
public int createCustomer(String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, int phone, int fax) throws AstuteException { public String createCustomer(String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, Long phone, Long fax) throws AstuteException {
try { try {
CallableStatement stmt = conn.prepareCall("{? = call create_customer_fun(?,?,?,?,?,?,?,?,?,?,?,?)}"); CallableStatement stmt = conn.prepareCall("{? = call create_customer_fun(?,?,?,?,?,?,?,?,?,?,?,?)}");
stmt.registerOutParameter(1, Types.INTEGER); stmt.registerOutParameter(1, Types.INTEGER);
stmt.setString(2, customerName); stmt.setString(2, customerId);
stmt.setString(3, billToDept); stmt.setString(3, customerName);
stmt.setString(4, add1); stmt.setString(4, billToDept);
stmt.setString(5, add2); stmt.setString(5, add1);
stmt.setString(6, city); stmt.setString(6, add2);
stmt.setString(7, state); stmt.setString(7, city);
stmt.setInt(8, zip); stmt.setString(8, state);
stmt.setInt(9, ziplast4); stmt.setInt(9, zip);
stmt.setString(10, email); stmt.setInt(10, ziplast4);
stmt.setInt(11, phone); stmt.setString(11, email);
stmt.setInt(12, fax); stmt.setLong(12, phone);
stmt.setLong(13, fax);
stmt.executeUpdate(); stmt.executeUpdate();
int customerId = stmt.getInt(1); String customerIdOut = stmt.getString(1);
return customerId; return customerIdOut;
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
throw new AstuteException(DB_ERROR,e.getMessage()); throw new AstuteException(DB_ERROR,e.getMessage());
} }
} }
public void updateCustomer( int customerId, String customerName, String billToDept, String add1, String public void updateCustomer( String customerId, String customerName, String billToDept, String add1, String
add2, String city, String state, int zip, int ziplast4, String email,int phone, int fax) throws add2, String city, String state, int zip, int ziplast4, String email,Long phone, Long fax) throws
AstuteException { AstuteException {
try { try {
String sql = "UPDATE CUSTOMER "; String sql = "UPDATE CUSTOMER ";
String updateClause = " SET "; String updateClause = " SET ";
String whereClause = ""; String whereClause = "";
if (customerId <= 0) { if (customerId==null || customerId.isEmpty()) {
throw new AstuteException(0, "CustomerId can't be null."); throw new AstuteException(0, "CustomerId can't be null.");
} else { } else {
whereClause = " WHERE customer_id =" + customerId; whereClause = " WHERE customer_id ='" + customerId + "'";
} }
// if (customerName != null && !customerName.isEmpty()) { updateClause = updateClause + " customer_name = '" + customerName + "',";
updateClause = updateClause + " customer_name = '" + customerName + "',"; updateClause = updateClause + " bill_to_dept = '" + billToDept + "',";
// } updateClause = updateClause + " add1 = '" + add1 + "',";
// if (billToDept != null && !billToDept.isEmpty()) { updateClause = updateClause + " add2 = '" + add2 + "',";
updateClause = updateClause + " bill_to_dept = '" + billToDept + "',"; updateClause = updateClause + " city = '" + city + "',";
// } updateClause = updateClause + " state = '" + state + "',";
// if (add1 != null && !add1.isEmpty()) { updateClause = updateClause + " zip = " + zip + ",";
updateClause = updateClause + " add1 = '" + add1 + "',"; updateClause = updateClause + " zip_last_4 = " + ziplast4 + ",";
// } updateClause = updateClause + " email = '" + email + "',";
// if (add2 != null && !add2.isEmpty()) { updateClause = updateClause + " phone = " + phone + ",";
updateClause = updateClause + " add2 = '" + add2 + "',"; updateClause = updateClause + " fax = " + fax + ",";
// }
// if (city != null || city.isEmpty()) {
updateClause = updateClause + " city = '" + city + "',";
// }
// if (state == null || state.isEmpty()) {
updateClause = updateClause + " state = '" + state + "',";
// }
// if (zip > 0) {
updateClause = updateClause + " zip = " + zip + ",";
// }
// if (ziplast4 > 0) {
updateClause = updateClause + " zip_last_4 = " + ziplast4 + ",";
// }
// if (email == null || email.isEmpty()) {
updateClause = updateClause + " email = '" + email + "',";
// }
// if (phone > 0) {
updateClause = updateClause + " phone = " + phone + ",";
// }
// if (fax > 0) {
updateClause = updateClause + " fax = " + fax + ",";
// }
if (!updateClause.equalsIgnoreCase(" SET ")) { if (!updateClause.equalsIgnoreCase(" SET ")) {
sql = sql + trimLastCharacter(updateClause, ",") + whereClause; sql = sql + trimLastCharacter(updateClause, ",") + whereClause;