Current File : //home/obabain/public_html/abc/BndSaleTransactionDA.jsp |
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@include file="Connection.jsp" %>
<%
Statement st=con.createStatement();
ResultSet rs = null;
String loginid=(String)session.getAttribute("logid");
String name=(String)session.getAttribute("uname");
String firstname=(String)session.getAttribute("firstname");
%>
<%!String sid=null; %>
<!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>
<form>
<%
try{
String tnumber=request.getParameter("num");
String frombranch=request.getParameter("frombranch");
String tobranch=request.getParameter("tobranch");
String[] f=null;
String[] a=null;
String[] b=null;
String[] c=null;
String[] g=null;
a=request.getParameterValues("product[]");
b=request.getParameterValues("amt[]");
c=request.getParameterValues("amt2[]");
f=request.getParameterValues("unit[]");
int i=st.executeUpdate("insert into ip_sales_transaction(tnumber,frombranch,tobranch,createddate,loginid) values('"+tnumber+"','"+frombranch+"','"+tobranch+"',NOW(),'"+loginid+"')");
for(int j=1;j<= a.length-1 ;j++){
double dedqty=(-1)*Double.parseDouble(b[j]);
Statement stmt=con.createStatement();
rs=stmt.executeQuery("select max(st_id)sid from ip_sales_transaction where loginid="+loginid+"");
while(rs.next())
{
sid=rs.getString("sid");
}
int n=st.executeUpdate("insert into ip_salestransfer_items(st_id,product_id,qty,price,unit,transfer_date) values("+sid+","+a[j]+","+b[j]+","+c[j]+","+f[j]+",NOW())");
Statement st1=con.createStatement();
int k=st1.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,branch_id) values("+a[j]+",(select product_name from ip_products where product_id="+a[j]+"),"+dedqty+",NOW(),0,'"+loginid+"',"+b[j]+",0,(select family_id from ip_products where product_id="+a[j]+"),'S','"+frombranch+"')");
/* Statement st2=con.createStatement();
int l=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,branch_id) values("+a[j]+",(select product_name from ip_products where product_id="+a[j]+"),"+b[j]+",NOW(),0,'"+loginid+"',"+b[j]+",0,(select family_id from ip_products where product_id="+a[j]+"),'P',"+tobranch+")");
*/
}
response.sendRedirect("BndSalesTransaction.jsp");
}
catch(Exception el){out.print(el);}
%>
</form>
</body>
</html>