/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.myprint.screenprint;
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
/**
*
* @author nitz
*/
public class LetterHeadDao {
public static boolean validate(String color, int papermaterial, int fontsize, String orientation, int quantity, String paperformat) throws ClassNotFoundException, SQLException, ParseException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
PreparedStatement stmt1 = null;
PreparedStatement stmt2 = null;
Statement s2 = null;
ResultSet rs = null;
// String dob = request.getParameter("DOB");
// SimpleDateFormat formater = new SimpleDateFormat("dd MMM yyyy HH:mm");
// DateFormat formatter = new SimpleDateFormat("dd-MMM", Locale.ENGLISH);
// DateFormat formatter = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy");
// Date date = (Date)formatter.parse(dt);
// java.util.Date today = new java.util.Date();
// Date date = new SimpleDateFormat("yyyy-MM-dd").parse(string);
// DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
// //get current date time with Date()
// Date date = new Date();
// //System.out.println(dateFormat.format(date)); don't print it, but save it!
// String yourDate = dateFormat.format(date);
//
//
//
// date = new SimpleDateFormat("yyyy-MM-dd").parse(yourDate);
// java.util.Date utilDate = new Date();
//// Convert it to java.sql.Date
// java.sql.Date date = new java.sql.Date(utilDate.getTime());
// java.sql.Date sqlDate = new java.sql.Date(currentDatetime.getTime());
String typ = "Letter Head";
try {
String connectionUrl = "jdbc:sqlserver://localhost:1433;databaseName=printersdb;user=sa;password=password@123";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
conn = DriverManager.getConnection(connectionUrl);
String query1 = "insert into orderdetails values(?)";
stmt1 = conn.prepareStatement(query1);
stmt1.setString(1, typ);
int j = stmt1.executeUpdate();
if (j > 0) {
status = true;
}
int maxID = 0;
s2 = conn.createStatement();
s2.execute("SELECT MAX(orderid) FROM orderdetails");
ResultSet rs2 = s2.getResultSet(); //
while (rs2.next()) {
maxID = rs2.getInt(1);
}
String query = "insert into letterheaddetails(orderno, papermaterial, fontsize, quantity, paperformat, color, orientation) values(?,?,?,?,?,?,?)";
stmt = conn.prepareStatement(query);
stmt.setInt(1, maxID);
stmt.setInt(2, papermaterial);
stmt.setInt(3, fontsize);
stmt.setInt(4, quantity);
stmt.setString(5, paperformat);
stmt.setString(6, color);
stmt.setString(7, orientation);
// stmt.setDate(8, new java.sql.Date(date.getTime()));
// setDate(1, today.getTime());
// .setDate(8,new java.sql.Date(today.getTime()));
int i = stmt.executeUpdate();
if (i > 0) {
status = true;
}
return status;
} catch (Exception e) {
System.out.println("Error Trace : " + e.getMessage());
}
return status;
}
}
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.myprint.screenprint;
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
/**
*
* @author nitz
*/
public class LetterHeadDao {
public static boolean validate(String color, int papermaterial, int fontsize, String orientation, int quantity, String paperformat) throws ClassNotFoundException, SQLException, ParseException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
PreparedStatement stmt1 = null;
PreparedStatement stmt2 = null;
Statement s2 = null;
ResultSet rs = null;
// String dob = request.getParameter("DOB");
// SimpleDateFormat formater = new SimpleDateFormat("dd MMM yyyy HH:mm");
// DateFormat formatter = new SimpleDateFormat("dd-MMM", Locale.ENGLISH);
// DateFormat formatter = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy");
// Date date = (Date)formatter.parse(dt);
// java.util.Date today = new java.util.Date();
// Date date = new SimpleDateFormat("yyyy-MM-dd").parse(string);
// DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
// //get current date time with Date()
// Date date = new Date();
// //System.out.println(dateFormat.format(date)); don't print it, but save it!
// String yourDate = dateFormat.format(date);
//
//
//
// date = new SimpleDateFormat("yyyy-MM-dd").parse(yourDate);
// java.util.Date utilDate = new Date();
//// Convert it to java.sql.Date
// java.sql.Date date = new java.sql.Date(utilDate.getTime());
// java.sql.Date sqlDate = new java.sql.Date(currentDatetime.getTime());
String typ = "Letter Head";
try {
String connectionUrl = "jdbc:sqlserver://localhost:1433;databaseName=printersdb;user=sa;password=password@123";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
conn = DriverManager.getConnection(connectionUrl);
String query1 = "insert into orderdetails values(?)";
stmt1 = conn.prepareStatement(query1);
stmt1.setString(1, typ);
int j = stmt1.executeUpdate();
if (j > 0) {
status = true;
}
int maxID = 0;
s2 = conn.createStatement();
s2.execute("SELECT MAX(orderid) FROM orderdetails");
ResultSet rs2 = s2.getResultSet(); //
while (rs2.next()) {
maxID = rs2.getInt(1);
}
String query = "insert into letterheaddetails(orderno, papermaterial, fontsize, quantity, paperformat, color, orientation) values(?,?,?,?,?,?,?)";
stmt = conn.prepareStatement(query);
stmt.setInt(1, maxID);
stmt.setInt(2, papermaterial);
stmt.setInt(3, fontsize);
stmt.setInt(4, quantity);
stmt.setString(5, paperformat);
stmt.setString(6, color);
stmt.setString(7, orientation);
// stmt.setDate(8, new java.sql.Date(date.getTime()));
// setDate(1, today.getTime());
// .setDate(8,new java.sql.Date(today.getTime()));
int i = stmt.executeUpdate();
if (i > 0) {
status = true;
}
return status;
} catch (Exception e) {
System.out.println("Error Trace : " + e.getMessage());
}
return status;
}
}
No comments:
Post a Comment