コード例 #1
0
 public static bool AddText(Infor tx)
 {
     using (var _context = new DBMindMapEntities())
     {
         try
         {
             _context.Infors.AddOrUpdate(tx);
             _context.SaveChanges();
             return(true);
         }
         catch (DbEntityValidationException e)
         {
             StringBuilder sb = new StringBuilder();
             foreach (var eve in e.EntityValidationErrors)
             {
                 sb.AppendLine(string.Format("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)
                 {
                     sb.AppendLine(string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                 ve.PropertyName,
                                                 ve.ErrorMessage));
                 }
             }
             throw new DbEntityValidationException(sb.ToString(), e);
         }
     }
 }
コード例 #2
0
 public static List <Shape> getListShape()
 {
     using (var _context = new DBMindMapEntities())
     {
         var sh = (from t in _context.Shapes
                   select t).ToList();
         return(sh);
     }
 }
コード例 #3
0
 public static List <ProjectShape> getListProject()
 {
     using (var _context = new DBMindMapEntities())
     {
         var pr = (from t in _context.ProjectShapes
                   select t).ToList();
         return(pr);
     }
 }
コード例 #4
0
 public static List <Shape> CheckShape(int id)
 {
     using (var _context = new DBMindMapEntities())
     {
         var sh = (from t in _context.Shapes
                   where t.ID == id
                   select t).ToList();
         return(sh);
     }
 }
コード例 #5
0
 public static Infor getInfor(int id)
 {
     using (var _context = new DBMindMapEntities())
     {
         var x = (from i in _context.Infors
                  where i.ID == id
                  select i).SingleOrDefault();
         return(x);
     }
 }
コード例 #6
0
 public static ProjectShape getProject(int id)
 {
     using (var _context = new DBMindMapEntities())
     {
         var pr = (from t in _context.ProjectShapes
                   where t.IDPro == id
                   select t).SingleOrDefault();
         return(pr);
     }
 }
コード例 #7
0
 public static bool AddShape(Shape sp)
 {
     using (var _context = new DBMindMapEntities())
     {
         try
         {
             _context.Shapes.AddOrUpdate(sp);
             _context.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             MessageBox.Show(e.Message);
             return(false);
         }
     }
 }
コード例 #8
0
 public static bool AddProject(ProjectShape project)
 {
     using (var _context = new DBMindMapEntities())
     {
         try
         {
             //MessageBox.Show("Successful!!");
             _context.ProjectShapes.AddOrUpdate(project);
             _context.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             MessageBox.Show(e.Message);
             return(false);
         }
     }
 }
コード例 #9
0
        public static bool DeleteProject(int id)
        {
            using (var _context = new DBMindMapEntities())
            {
                try
                {
                    var lstidShape = (from t in _context.Shapes
                                      where t.IDPro == id
                                      select t.ID).ToList();

                    foreach (var x in lstidShape)
                    {
                        var infor = (from z in _context.Infors
                                     where z.ID == x
                                     select z).SingleOrDefault();
                        if (infor != null)
                        {
                            _context.Infors.Remove(infor);
                        }
                    }

                    foreach (var x in lstidShape)
                    {
                        var sh = (from s in _context.Shapes
                                  where s.ID == x
                                  select s).SingleOrDefault();
                        _context.Shapes.Remove(sh);
                    }

                    var pr = (from q in _context.ProjectShapes
                              where q.IDPro == id
                              select q).SingleOrDefault();
                    _context.ProjectShapes.Remove(pr);
                    _context.SaveChanges();
                    return(false);
                } catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    return(false);
                }
            }
        }