コード例 #1
0
ファイル: OverTimesDetailsDAL.cs プロジェクト: hanyweal/HCM
 public int Delete(int OverTimeDetailID, int UserIdentity)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             OverTimesDetails OverTimeDetailObj = db.OverTimesDetails.SingleOrDefault(x => x.OverTimeDetailID.Equals(OverTimeDetailID));
             db.OverTimesDetails.Remove(OverTimeDetailObj);
             return(db.SaveChanges(UserIdentity));
         }
     }
     catch
     {
         throw;
     }
 }
コード例 #2
0
ファイル: OverTimesDetailsDAL.cs プロジェクト: hanyweal/HCM
 public int Insert(OverTimesDetails OverTimeDetail)
 {
     try
     {
         using (var db = new HCMEntities())
         {
             db.OverTimesDetails.Add(OverTimeDetail);
             db.SaveChanges();
             return(OverTimeDetail.OverTimeDetailID);
         }
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
             }
         }
         throw;
     }
 }