Friday, 19 December 2014

lord

<%--
    Document   : LetterHead
    Created on : 22-Nov-2014, 17:24:43
    Author     : nitz
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="">
        <meta name="author" content="">
        <link rel="icon" href="../../favicon.ico">

        <title>Welcome to Jay Siyaram Printers</title>

        <!-- Bootstrap core CSS -->
        <link href="Bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
        <link href="Bootstrap/css/awesome-bootstrap-checkbox.css" rel="stylesheet" type="text/css"/>


        <!-- Custom styles for this template -->
        <link href="Bootstrap/css/starter-template.css" rel="stylesheet" type="text/css"/>

        <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
        <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
        <script src="../../assets/js/ie-emulation-modes-warning.js"></script>

        <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>

    <body>
        <p class="text-center">
            <h4 align="center">
        <%
            if ((session.getAttribute("name") == null) || (session.getAttribute("name") == "")) {
                RequestDispatcher rd = request.getRequestDispatcher("login.jsp");
                rd.forward(request, response);
        %>
        You are not logged in<br/>
        <a href="login.jsp">Please Login</a>
        <%} else {
        %>
        Welcome, <%=session.getAttribute("name")%>
        <a href='Loggedout.jsp'>Log out.</a>
        <%
            }
        %></h4></p>

        <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="index.jsp">Jay Siyaram Printers</a>
                </div>
                <div id="navbar" class="collapse navbar-collapse">
                    <ul class="nav navbar-nav">

                        <li class="active"><a href="index.jsp">Home</a></li>
                        <li><a href="#about">About</a></li>
                        <li><a href="ContactUs.jsp">Contact</a></li>
                    </ul>
                </div><!--/.nav-collapse -->
            </div>       
        </nav>
        <div class="container">
            <hr class="featurette-divider">

            <form  name="f1" action="LetterHeadServlet" method="post" class="form-horizontal well span6" onsubmit="return validate()">
                <h1> LetterHead Printing Details:</h1>
                <hr class="featurette-divider">
                <div class="form-group">
                    <label class="col-sm-2 control-label">Color</label>
                    <div class="col-sm-3">
                        <select class="form-control" id="sel1" name="drdColor">
                            <option>Single Color</option>
                            <option>Two Color</option>
                            <option>Multi Color</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">Paper Material</label>
                    <div class="col-sm-3">
                        <div class="radio">
                            <input type="radio" name="radioMaterial" id="radio1" value="70" checked>
                            <label for="radio1">
                                70
                            </label> g/m<sup>2</sup>
                        </div>
                        <div class="radio">
                            <input type="radio" name="radioMaterial" id="radio2" value="85">
                            <label for="radio2">
                                85
                            </label> g/m<sup>2</sup>
                        </div>
                        <div class="radio">
                            <input type="radio" name="radioMaterial" id="radio3" value="100">
                            <label for="radio3">
                                100
                            </label> g/m<sup>2</sup>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">Font size</label>
                    <div class="col-sm-5">
                        <input type="text" name="txtFontSize" class="form-control" class="span3" /><span id="sizeloc" ></span>
                    </div>
                </div>
                <div class="form-group"><br>
                    <label class="col-sm-2 control-label">Orientation </label>
                    <div class="col-sm-3">
                        <div class="radio">
                            <input type="radio" name="radioOrient" id="radio4" value="Horizontal" checked>
                            <label for="radio4">
                                Horizontal
                            </label>
                        </div>
                        <div class="radio">
                            <input type="radio" name="radioOrient" id="radio5" value="Vertical">
                            <label for="radio5">
                                Vertical
                            </label>
                        </div>                       
                    </div>
                </div>
                <div class="form-group"><br>
                    <label class="col-sm-2 control-label">Quantity</label>
                    <div class="col-sm-5">
                        <input type="text" name="txtQuantity" class="form-control" class="span3" /><span id="qtyloc" ></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">Paper Format </label>
                    <div class="col-sm-3">
                        <div class="radio">
                            <input type="radio" name="radioPformat" id="radio6" value="A4" checked>
                            <label for="radio6">
                                A4 Format
                            </label>
                        </div>
                        <div class="radio">
                            <input type="radio" name="radioPformat" id="radio7" value="Legal">
                            <label for="radio7">
                                Legal Format
                            </label>
                        </div>                       
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <input type="submit" name="btnSubmit" value="Submit" class="btn btn-success"/>
                    </div>
                </div>
            </form>


            <hr class="featurette-divider">
            <!-- FOOTER -->
            <footer>
                <p class="pull-right"><a href="#">Back to top</a></p>
                <p>&copy; 2014 4everHappy, Inc. &middot; <a href="#">Privacy</a> &middot; <a href="#">Terms</a></p>
            </footer>
        </div>
        <!-- /.container -->


        <!-- Bootstrap core JavaScript
        ================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->

       

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <script src="Bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
        <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
        <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
    </body>
</html>

mobile services

/*
 * 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.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.JSONObject;

/**
 *
 * @author nitz
 */
public class LetterHeadServlet extends HttpServlet {

    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {

            response.setContentType("application/json");

            JSONObject js = new JSONObject();
           
            String color = request.getParameter("drdColor");
            int material = Integer.parseInt(request.getParameter("radioMaterial"));
            int fontSize = Integer.parseInt(request.getParameter("txtFontSize"));
            String orientation = request.getParameter("radioOrient");
            int quantity = Integer.parseInt(request.getParameter("txtQuantity"));
            String paperFormat = request.getParameter("radioPformat");

            if (LetterHeadDao.validate(color, material, fontSize, orientation, quantity, paperFormat)) {

                RequestDispatcher rd = request.getRequestDispatcher("NewPrint.jsp");
                rd.forward(request, response);
            } else {

                js.put("msg", "Error");
            }

            out.print(js);
            out.close();

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}

letterhead

/*
 * 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;

    }

}

mobile phone gadgets

http://www.thaicreate.com/java/java-jsp-example-update-database.html