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