public static int Insert(tblDeclarationLoan loan) { dbEcustomEntities _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true)); _db.Connection.Open(); loan.CreatedDate = CommonFactory.GetCurrentDate(); loan.ModifiedDate = CommonFactory.GetCurrentDate(); _db.AddTotblDeclarationLoans(loan); try { if (_db.Connection.State == ConnectionState.Closed) _db.Connection.Open(); return _db.SaveChanges(); } catch (Exception ex) { return -1; } finally { _db.Connection.Close(); } }