Current File : /home/obabain/public_html/abc/MaterialrequisitionDA.jsp |
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ include file="Connection.jsp" %>
<%!String lpo=null;
int inid=0;
String date=null;
%>
<%!String sid=null;int lastid=0; %>
<%
String loginid=(String)session.getAttribute("logid");
String name=(String)session.getAttribute("uname");
String firstname=(String)session.getAttribute("firstname");
Statement st1=con.createStatement();
ResultSet rs=st1.executeQuery("select * from material1 where reqno=(select max(reqno) from material1)");
while(rs.next())
{
lpo=rs.getString("reqno");
}
rs=st1.executeQuery("select NOW() as date");
while(rs.next())
{
date=rs.getString("date");
}
%>
<!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>
<%
try
{
String pono=request.getParameter("po_no");
String podate=request.getParameter("po_date");
String[] a=null;String[] b=null;String[] c=null;String[] d=null;String[] f=null;String[] fr=null;
b=request.getParameterValues("material[]");
System.out.println("b is:"+b);
c=request.getParameterValues("issueqty[]");
d=request.getParameterValues("issuedate[]");
f=request.getParameterValues("returnqtyqty[]");
fr=request.getParameterValues("tot[]");
/* Statement stm=con.createStatement(); */
if((pono.length()!=0||pono!="") &&(podate.length()!=0||podate!=""))
{
ResultSet rr=st1.executeQuery("SELECT id FROM material1 where reqno='"+pono+"' ");
Statement stm=con.createStatement();
int l1=stm.executeUpdate("insert into material1(reqno,date) values('"+pono+"','"+podate+"')");
for(int j=0;j<b.length;j++){
Statement st=con.createStatement();
rs=st.executeQuery("select max(id)id from material1");
while(rs.next())
{
lastid=rs.getInt("id");
System.out.println("id ishjhkjj"+lastid);
}
int l=st.executeUpdate("insert into material_table(reqno,date,item_name,pname,price,familyid,returnqty, retvalue) values('"+lastid+"','"+podate+"','"+b[j]+"',(select product_name from ip_products where product_id='"+b[j]+"'),'"+c[j]+"','"+d[j]+"','"+f[j]+"','"+fr[j]+"')");
int j1=st.executeUpdate("insert into ip_stock_register(product_id,product_name,qty_pur,closing_qty,product_hsn,last_updated_date,status,total_qty_nos,total_qty_wt,rej_qty_nos,rej_qty_wt,product_grp,type,branch_id,invno,return_qty,price,value) values('"+b[j]+"',(select product_name from ip_products where product_id='"+b[j]+"'),'"+f[j]+"',0,'0','"+podate+"',1,0,'0',0,'0',(select family_id from ip_products where product_id='"+b[j]+"'),'R','"+loginid+"',(select max(id) from material_table),'"+f[j]+"','"+c[j]+"','"+fr[j]+"')");
}
int pononew=Integer.parseInt(pono)+1;
int x=st1.executeUpdate("update materialincreament set sl_no='"+pononew+"',date=NOW() where type='PO'");
response.sendRedirect("MaterialReqview.jsp");
}
}
catch(Exception el){
out.println(el);
}
%>
</body>
</html>