Current File : /home/obabain/anms_obaba_in/addmorder.jsp
<%@page import="java.sql.Statement"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ include file="Connection.jsp" %><%!int i; String s=null;%>
    <%
String count=null;String id=null;String sys_id=null;

Statement st=con.createStatement();
ResultSet rs = null;
rs = st.executeQuery("select tb.*,(select concat(Prefix,MO_Id))codes from system_generated_id tb");
while(rs.next()){
count=rs.getString("codes");
id=rs.getString("MO_Id");
i=Integer.parseInt(id)+1;
 s=String.valueOf(i);
 if(s.length()==1)
 {
	 sys_id="00"+s;
 }
 else{
	 sys_id="0"+s;
 }
 
	 System.out.println(count);
}

//st.executeUpdate("INSERT INTO manufacture_order(mocus_id)VALUES('"+count+"');");

 
%>
<%!
ResultSet rb1=null;
%>
<%-- <a href="ProductionOrder.jsp?mo_Id=<%=rs.getI("mo_Id")%>"></a> --%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<% 

    	  //String  count=request.getParameter("address");
      /* String sh_date=request.getParameter("sh_date");
      String product=request.getParameter("product");
      System.out.print(product);
      String bom=request.getParameter("bom");
      String proqty=request.getParameter("pro_qty");
      String res=request.getParameter("resperson");
      String raw=request.getParameter("loc");
      String raw1=request.getParameter("loc1");
      String p_id=request.getParameter("p_id");
     
      String machinname=request.getParameter("machinname");
      String machin_capacity=request.getParameter("machin_capacity");
      String type=request.getParameter("type");
      String labourcost=request.getParameter("labourcost");
      String machinecost=request.getParameter("machinecost");
      String othercharges=request.getParameter("othercharges");
      
 
      session.setAttribute("sh_date",sh_date); 
 session.setAttribute("product",product); 
 session.setAttribute("bom",bom); 
 session.setAttribute("pro_qty",proqty); 
 session.setAttribute("res",res); 
 session.setAttribute("raw",raw); 
 session.setAttribute("raw1",raw1); 
 session.setAttribute("p_id",p_id); 
 session.setAttribute("machinname",machinname); 
 session.setAttribute("machin_capacity",machin_capacity); 
 session.setAttribute("type",type); 
  */
  
 /* response.sendRedirect("ViewProduce.jsp");  */
  %> 
  <% 
  String s=request.getParameter("s");
  String sh_date=request.getParameter("sh_date");
  String product=request.getParameter("product");

  String bom=request.getParameter("bom");
  String proqty=request.getParameter("pro_qty");
  String res=request.getParameter("resperson");
  String raw=request.getParameter("loc");
  String raw1=request.getParameter("loc1");
  String p_id=request.getParameter("p_id");
 
  String machinname=request.getParameter("machinname");
  String machin_capacity=request.getParameter("machin_capacity");
  String type=request.getParameter("type");
  String labourcost=request.getParameter("labourcost");
  String machinecost=request.getParameter("machinecost");
  String processcost=request.getParameter("processcost");
  String othercharges=request.getParameter("othercharges");
  String ex_date=request.getParameter("ex_date");
  String s_time=request.getParameter("s_time");
  String e_time=request.getParameter("e_time");
  
  rb1=st.executeQuery("select tb.*,((select sum(qty_pur) from ip_stock_register where product_id=tb.fg_id)-(tb.quantity*"+proqty+"))q from bom_rawmaterial tb where d1_id="+p_id+" and ((select sum(qty_pur) from ip_stock_register where product_id=tb.fg_id)-(tb.quantity*"+proqty+"))<=0");
  if(rb1.next())
  {
	  
	  response.sendRedirect("insufficient_list.jsp");
	  
  }
  else
  {
	 
	  Statement st1=con.createStatement();
	  int i=st1.executeUpdate("insert into manufacture_order(mocus_id,Scheduledate,Product,BillofMaterial,ProductQty,ResponsiblePerson,RawMaterialLocation,Location,p_id,machinname,machinecapacity,type,labourcost,machinecost,processcost,othercharge,ex_date,s_time,e_time)values('"+count+"','"+sh_date+"','"+product+"','"+bom+"','"+proqty+"','"+res+"','"+raw+"','"+raw1+"','"+p_id+"','"+machinname+"','"+machin_capacity+"','"+type+"','"+labourcost+"','"+machinecost+"','"+processcost+"','"+othercharges+"','"+ex_date+"','"+s_time+"','"+e_time+"')");
	  st1.executeUpdate("update system_generated_id set MO_Id='"+sys_id+"'"); 
	  
	  Statement st2=con.createStatement();
	  int j=st2.executeUpdate("insert into ip_stock_register(product_id,product_name,qty_pur,last_updated_date,status,last_updated_by,total_qty,rej_qty,product_grp,type) values("+p_id+",'"+product+"',"+proqty+",'"+sh_date+"',0,0,"+proqty+",0,1,'P')");
  Statement st3=con.createStatement();
  ResultSet rs1=st3.executeQuery("select tb.*,(tb.quantity*"+proqty+")rqty from bom_rawmaterial tb where d1_id="+p_id+"");
  while(rs1.next())
  {
	  String rqty=rs1.getString("rqty");
	  String pid=rs1.getString("rqty");
	  String rproduct=rs1.getString("product");
	  double q=(-1)*Double.parseDouble(rs1.getString("rqty"));
	  Statement stt=con.createStatement();
	  int l=stt.executeUpdate("insert into ip_stock_register (product_id,product_name,qty_pur,last_updated_date,status,last_updated_by,total_qty,rej_qty,product_grp,type) values("+pid+",'"+rproduct+"',"+q+",'"+sh_date+"',0,0,"+rqty+",0,2,'S')");
  }
  response.sendRedirect("ProductionOrder.jsp");
  }
  
 /* String s=null;
	ResultSet rb1=st.executeQuery("select tb.hsn,tb.product,tb.fg_id from bom_rawmaterial tb where d1_id="+p_id+" and ((select product_qua from ip_products where product_id=tb.fg_id)+(select sum(qty_pur) from ip_stock_register where product_id=tb.fg_id))<(quantity*"+proqty+")");
	
	if(rb1.next()){
		  s="Insufficient Stock";
		 
	}
		else
		{
			 s="Stock is Available"; */
			/*  if(proqty.length()!=0)
		      {
		    	 
		 st=con.createStatement();
		st.executeUpdate("insert into manufacture_order(mocus_id,Scheduledate,Product,BillofMaterial,ProductQty,ResponsiblePerson,RawMaterialLocation,Location,p_id,machinname,machinecapacity,type,labourcost,machinecost,othercharge)values('"+count+"','"+sh_date+"','"+product+"','"+bom+"','"+proqty+"','"+res+"','"+raw+"','"+raw1+"','"+p_id+"','"+machinname+"','"+machin_capacity+"','"+type+"','"+labourcost+"','"+machinecost+"','"+othercharges+"')");
		      /* RequestDispatcher dd = request.getRequestDispatcher("ViewM_orderForm.jsp");
		      dd.forward(request, response);  
		      st.executeUpdate("update system_generated_id set MO_Id='"+sys_id+"'"); 
		  response.sendRedirect("M_orderForm.jsp"); 
		      } */
	      
			 
	
		
	
	
	
    
     %> 
     
  
     
     
     
     
     
      
      <!-- }catch(Exception el){out.println(el);}
      %>  -->
   	 <script type="text/javascript">
function abc() {
	
	var n1=document.getElementById("stock").value;
	var n2=document.getElementById("btnblue");
	var n3=document.getElementById("showit");
alert(n1);
/* 	if (n3.style.display === "none") {
		n3.style.display = "block";
    } else {
    	n3.style.display = "none";
    }
	 */
	if(n1=='Insufficient Stock')
		{
		 n2.style.backgroundColor = "#d43f3a";
			n2.style.borderColor="#d43f3a";
			 n3.style.backgroundColor ="#2e6da4";
			n3.style.borderColor="#2e6da4"; 
			 n2.disabled = true;
		
	      
		}
	else
		{
		n2.style.backgroundColor = "#2e6da4";
		n2.style.borderColor="#2e6da4";
		n3.style.backgroundColor ="#d43f3a";
		n3.style.borderColor="#d43f3a";
		n3.disabled=true;
		}
	
		 
}
</script>  
    
<script type="text/javascript">
$(function(){
    $("#loader").css("display","none");
    
    $("#showit").click(function(e){
      $("#loader").css("display","inline-block");
    })
})

</script>
</body>
</html>