{
// final DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
final Calendar c = Calendar.getInstance();
long billId;
int month;
Bill bill1 = new Bill();
Sales sales= new Sales();
String dateInFormat;
month=c.get(Calendar.MONTH)+1;
if(month<10)
dateInFormat="0"+month+"/";
else
dateInFormat=month+"/";
if(c.get(Calendar.DAY_OF_MONTH)<10) // value of month starts fro
dateInFormat+="0"+c.get(Calendar.DAY_OF_MONTH)+"/";
else
dateInFormat+=c.get(Calendar.DAY_OF_MONTH)+"/";
dateInFormat+= c.get(Calendar.YEAR);
if(request.getSession().getAttribute("billId")!=null)
{
float amount=0;
billId=Long.parseLong(request.getSession().getAttribute("billId").toString());
System.out.println("control in " +billId);
List<Sales> salesList= salesDAO.selectByBillId(billId);
for(int i=0;i<salesList.size();i++)
{
sales = salesList.get(i);
amount+=sales.getTotal();
}
bill1=billDAO.selectBill(billId);
bill1.setAmount(amount);
billDAO.updateBill(bill1);
}
Bill bill= new Bill(0, dateInFormat);
billId= billDAO.createBill(bill);
request.getSession().setAttribute("billId", billId);
return new ModelAndView("redirect:listBill.htm");
}