Current File : /home/obabain/ms_obaba_in/editProductDA.jsp
<%@ page language="java" import="javax.sql.*" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@page import="java.sql.*" %>
    <%@ include file="Connection.jsp" %>
    <%
    Statement st=con.createStatement();
    %>
<!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  method="get">
<%
try{

Statement stt=con.createStatement();
String id=request.getParameter("id");
String fid=request.getParameter("pfamily");
String psku=request.getParameter("phsn");
String pname=request.getParameter("pname");
String pdesc=request.getParameter("pdesc");
String pprice=request.getParameter("pprice");
String pqty=request.getParameter("qty");
String purchprice=request.getParameter("purchprice");
String provname=request.getParameter("provname");
String taxrate=request.getParameter("taxrate");
String unit=request.getParameter("unit");
String ptariff=request.getParameter("tariff");
String openingstock=request.getParameter("openingstock");

int i=stt.executeUpdate("update  ip_products set family_id="+fid+",product_sku='"+psku+"',product_name='"+pname+"',product_description='"+pdesc+"',product_price="+pprice+",product_qua="+pqty+",purchase_price="+purchprice+",provider_name='"+provname+"',tax_rate_id="+taxrate+",unit_id="+unit+",product_tariff="+ptariff+",opening_stock='"+openingstock+"' where product_id="+id+"");
//response.sendRedirect("editProduct.jsp?Id="+id+"");
ResultSet rs=stt.executeQuery("select * from ip_stock_register where product_id="+id+" and type='open'");
if(rs.next())
{
	int j=st.executeUpdate("update ip_stock_register set qty_pur="+openingstock+",product_name='"+pname+"',product_hsn='"+psku+"',total_qty="+openingstock+",product_grp="+fid+" where product_id="+id+" and type='open'");
}
else
{
	 st=con.createStatement();
	int op=st.executeUpdate("insert into ip_stock_register(product_id,product_name,qty_pur,product_hsn,last_updated_date,status,last_updated_by,total_qty,rej_qty,product_grp,type) values("+id+",'"+pname+"',"+openingstock+",'"+psku+"',NOW(),1,0,"+openingstock+",0,"+fid+",'open')");
}
response.sendRedirect("ViewProduct.jsp");
}
catch(Exception el){out.print(el);}

%>
</form>
</body>
</html>