public void SaveInvoice() { StringBuilder sbQry = new StringBuilder(); clsDB oDB = new clsDB(); try { oDB.Connect(); oDB.BeginTran(); foreach (Item ItemObj in this.ItemObject) { sbQry.AppendLine("Insert Into Invoice(TinNo,PanNo,BillNo,InvoiceDate,InvoiceDateTime,Address,PoNo"); sbQry.AppendLine(",ItemDesc,Qty,Rate,Amount,Vat,GrandTotalWords) Values('" + TinNo + "','" + PanNo + "'"); sbQry.AppendLine(",'" + BillNo + "','" + DateTime.Now.ToString("dd-MMM-yyyy") + "',Getdate(),'" + Address + "'"); sbQry.AppendLine(",'" + PoNo + "','" + ItemObj.ItemDesc + "'," + ItemObj.ItemQty + "," + ItemObj.Rate + "," + ItemObj.Amount + ",'" + Vat + "','" + GrandTotalInWords + "')"); oDB.ExecuteNonQuery(sbQry.ToString()); sbQry.Length = 0; } oDB.CommitTran(); } catch (Exception ex) { oDB.RollBackTran(); throw ex; } finally { sbQry = null; oDB.DisConnect(); oDB = null; } }