Current File : //home/obabain/autoclutchess_obaba_in/ReceiptVoucherDA.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 particular=null;
Double paid_amt=0.00;
double amt=0.00;
String ttotal=null;
String cashchq=null;
String newid=null;
String supplid=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 payno=request.getParameter("payno");
String pdate=request.getParameter("paydate");
String narr=request.getParameter("narr");
String total=request.getParameter("gtotal");
String acc=request.getParameter("account");
String parti=request.getParameter("country");
String chqno=request.getParameter("chqno");
String chqdate=request.getParameter("chqdate");
String chrg=request.getParameter("chrg");
String bank=request.getParameter("bank");
String total2=request.getParameter("total2");
//Double chr=(-1)*Double.parseDouble(chrg);
if(chqno.equals(""))
{
cashchq="cash";
}
else
{
cashchq="chq";
}
String[] a=null;
String[] b=null;
String[] c=null;
String[] g=null;
String[] co=null;
String[] billtyp=null;
//a=request.getParameterValues("particular[]");
b=request.getParameterValues("city[]");
c=request.getParameterValues("billamt[]");
billtyp=request.getParameterValues("typ[]");
co=request.getParameterValues("comm[]");
//g=request.getParameterValues("amt[]");
if(payno.contentEquals(""))
{
response.sendRedirect("Receiptvoucher.jsp");
}
else if(payno!= null || payno.length() > 0 || payno!="")
{
int i=st.executeUpdate("insert into account_voucher_main(voucher_no,account,voucher_date,particular,credit_amt,voucher_type,narration,crdr_type,createdby,cash_cheque,branch_id) values('"+payno+"','"+acc+"','"+pdate+"','"+parti+"',"+total2+",'receipt','"+narr+"','Dr',"+loginid+",'"+cashchq+"',"+loginid+")");
rs=st.executeQuery("select max(voucher_id)nid from account_voucher_main where branch_id="+loginid+"");
while(rs.next())
{
newid=rs.getString("nid");
}
if(chqno.length()> 0)
{
int l=st.executeUpdate("insert into cheque_voucher(chq_no,chq_date,created_date,voucher_no,voucher_type,branch_id) values('"+chqno+"','"+chqdate+"',NOW(),'"+newid+"','Rec',"+loginid+")");
}
for(int j=1;j<=co.length-1;j++)
{
if(billtyp[j].equals("B"))
{
if(b[j].equals("-1"))
{
System.out.print(b[j]);
int k=st.executeUpdate("insert into account_voucher_sub(voucher_id,particular,voucher_date,bill_no,debit_amt,crdr_type,voucher_type,type) values("+newid+",'"+parti+"','"+pdate+"',0,"+total+",'Cr','receipt','WB')");
}
else
{
int k=st.executeUpdate("insert into account_voucher_sub(voucher_id,particular,voucher_date,bill_no,debit_amt,crdr_type,voucher_type,type) values("+newid+",'"+parti+"','"+pdate+"','"+b[j]+"',"+c[j]+",'Cr','receipt','"+billtyp[j]+"')");
}
}
else
{
int k=st.executeUpdate("insert into account_voucher_sub(voucher_id,particular,voucher_date,bill_no,debit_amt,crdr_type,voucher_type,type) values("+newid+",'"+acc+"','"+pdate+"','"+b[j]+"',"+c[j]+",'Cr','receipt','"+billtyp[j]+"')");
}
if(billtyp[j].equals("B"))
{
ResultSet rr=st.executeQuery("select * from account_ledger where l_id="+parti+"");
while(rr.next())
{
particular=rr.getString("type");
supplid=rr.getString("ref_id");
}
if(particular.equals("3"))
{
ResultSet ra=st.executeQuery("select * from ip_sales_invoice where sinvoice_id="+b[j]+" and supplier_id="+supplid+"");
while(ra.next())
{
paid_amt=Double.parseDouble(ra.getString("received_amt"));
}
amt=paid_amt+Double.parseDouble(c[j]);
System.out.print(amt);
int u=st.executeUpdate("update ip_sales_invoice set received_amt="+amt+" where sinvoice_id="+b[j]+" and supplier_id="+supplid+"");
}
else if(particular.equals("1"))
{
ResultSet ra=st.executeQuery("select * from journalentry where journal_id="+b[j]+"");
while(ra.next())
{
paid_amt=Double.parseDouble(ra.getString("paid_amt"));
}
amt=paid_amt+Double.parseDouble(c[j]);
int u=st.executeUpdate("update journalentry set paid_amt="+amt+" where journal_id="+b[j]+"");
}
}
}
response.sendRedirect("ViewReceiptVoucher.jsp");
}
}
catch(Exception el){out.print(el);}
%>
</form>
</body>
</html>