コード例 #1
0
 public static SALEORDER[] GetAllSaleOrder()
 {
     SALEORDER[] orders = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         orders = ctx.SALEORDERs.ToArray<SALEORDER>();
     }
     return orders;
 }
コード例 #2
0
 public static COURSE ConvertToCourse(COURSE_CANCEL course)
 {
     COURSE cs = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         cs = ctx.COURSEs.Where(c => c.ID == course.ID).FirstOrDefault();
     }
     return cs;
 }
コード例 #3
0
 public static SALEORDER[] GetOrdersBySaler(int customer_id)
 {
     SALEORDER[] orders = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         orders = ctx.SALEORDERs.Where(o => o.SALER == customer_id).ToArray<SALEORDER>();
     }
     return orders;
 }
コード例 #4
0
 public static SALEORDER[] GetOrderByDateBetween(DateTime begin, DateTime end)
 {
     SALEORDER[] orders = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         orders = (from o in ctx.SALEORDERs
                   where o.TIME.CompareTo(begin) >= 0 && o.TIME.CompareTo(end) <= 0
                   select o).ToArray<SALEORDER>();
     }
     return orders;
 }
コード例 #5
0
 public static bool AddRecommendation(RECOMMENDATION reco)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             ctx.Set<RECOMMENDATION>().Add(reco);
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return true;
 }
コード例 #6
0
 public static bool AddCategory(CATEGORY category)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             ctx.Set<CATEGORY>().Add(category);
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return true;
 }
コード例 #7
0
 /// <summary>
 /// 创建新的ManagerType,注意ManagerType和Type在当前语义下表示意义相同,均表示Manager的类型
 /// </summary>
 /// <param name="type">需要创建的Type,需要在函数外部创建实例,并且为DESCRIPTION属性赋值</param>
 /// <returns>true表示成功创建,false表示失败</returns>
 public static bool AddManagerType(TYPE type)
 {
     int count = 0;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             ctx.TYPEs.Add(type);
             count = ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return count == 1;
 }
コード例 #8
0
 /// <summary>
 /// 创建新的Permission
 /// </summary>
 /// <param name="permission">需要创建的Manager,需要在函数外部创建实例,并且为NAME和TYPE属性赋值</param>
 /// <returns>true表示成功创建,false表示失败</returns>
 public static bool AddPermission(PERMISSION permission)
 {
     int count = 0;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             ctx.PERMISSIONs.Add(permission);
             count = ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return count == 1;
 }
コード例 #9
0
        public static bool AddCourseToRecommendation(COURSE course, RECOMMENDATION reco)
        {
            using (CloudEDUEntities ctx = new CloudEDUEntities())
            {
                try
                {
                    var rc = ctx.RECOMMENDATIONs.Include("COURSEs").Where(r => r.ID == reco.ID).FirstOrDefault();
                    var cs = ctx.COURSEs.Where(c => c.ID == course.ID).FirstOrDefault();
                    rc.COURSEs.Add(cs);
                    ctx.Entry(rc).State = System.Data.EntityState.Modified;
                    ctx.SaveChanges();
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e.ToString());
                    return false;
                }

            }
            return true;
        }
コード例 #10
0
 public static void test()
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         var s = from attends in ctx.ATTENDs
                 join courses in ctx.COURSE_AVAIL
                 on attends.COURSE_ID equals courses.ID
                 where attends.CUSTOMER_ID == 1
                 select courses;
         System.Diagnostics.Debug.WriteLine(s.Count());
     }
 }
コード例 #11
0
 /// <summary>
 /// 用于更改TYPE的一般信息,包括DESCRIPTION
 /// </summary>
 /// <param name="type">更改后的TYPE的实例</param>
 /// <returns>true表示成功创建,false表示失败</returns>
 public static bool UpdateManagerType(TYPE type)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             ctx.Entry(type).State = System.Data.EntityState.Modified;
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return true;
 }
コード例 #12
0
 public static bool RemovePermission(int permission_id)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             var permission = ctx.PERMISSIONs.Where(m => m.ID == permission_id).FirstOrDefault<PERMISSION>();
             ctx.Set<PERMISSION>().Remove(permission);
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return true;
 }
コード例 #13
0
 /// <summary>
 /// 回收授予某Manager的权限
 /// </summary>
 /// <param name="manager_id">被回收的Manager的ID</param>
 /// <param name="permission_id">被回收的Permission的ID</param>
 /// <returns>true表示成功创建,false表示失败</returns>
 public static bool RevokePermissionFromManager(int manager_id, int permission_id)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             var manager = ctx.MANAGERs.Include("PERMISSIONs").Where(mngr => mngr.ID == manager_id).FirstOrDefault<MANAGER>();
             var perm = ctx.PERMISSIONs.Where(p => p.ID == permission_id).FirstOrDefault<PERMISSION>();
             //System.Diagnostics.Debug.WriteLine(ctx.Entry(manager).State);
             //System.Diagnostics.Debug.WriteLine(ctx.Entry(perm).State);
             manager.PERMISSIONs.Remove(perm);
             ctx.Entry(manager).State = System.Data.EntityState.Modified;
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return true;
 }
コード例 #14
0
 public static MANAGER[] GetAllManagers()
 {
     MANAGER[] managers = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         managers = ctx.MANAGERs.ToArray<MANAGER>();
     }
     return managers;
 }
コード例 #15
0
 public static TYPE[] GetAllManagerTypes()
 {
     TYPE[] types = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         types = ctx.TYPEs.ToArray<TYPE>();
     }
     return types;
 }
コード例 #16
0
 /// <summary>
 /// 用于更改Manager的Type
 /// </summary>
 /// <param name="manager">需要更改的Manager的实例</param>
 /// <param name="type">需要改为的Type的ID</param>
 /// <returns>true表示成功创建,false表示失败</returns>
 public static bool ChangeManagerManagerType(MANAGER manager, int type)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             manager.MNGR_TYPE = type;
             ctx.Entry(manager).State = System.Data.EntityState.Modified;
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return true;
     //throw new Exception("Not Support Yet");
 }
コード例 #17
0
 private static bool AddLessonsToCourse(LESSON[] lessons, COURSE course)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             var cs = ctx.COURSEs.Include("LESSONs").Where(c => c.ID == course.ID).FirstOrDefault();
             foreach (LESSON ls in lessons)
                 cs.LESSONs.Add(ls);
             ctx.Entry(cs).State = System.Data.EntityState.Modified;
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return true;
 }
コード例 #18
0
 public static PERMISSION GetPermissionByPermissionName(string name)
 {
     PERMISSION perm = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         perm = ctx.PERMISSIONs.Where(p => p.NAME == name).FirstOrDefault();
     }
     return perm;
 }
コード例 #19
0
 /// <summary>
 /// 用于更改Permission的一般信息,包括NAME和TYPE
 /// </summary>
 /// <param name="permission">更改后的Permission的实例</param>
 /// <returns>true表示成功创建,false表示失败</returns>
 public static bool UpdatePermission(PERMISSION permission)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             ctx.Entry(permission).State = System.Data.EntityState.Modified;
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return true;
 }
コード例 #20
0
 public static MANAGER[] GetManagersByPermissions(PERMISSION[] perms)
 {
     MANAGER[] managers = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         IQueryable<MANAGER> mgr = ctx.MANAGERs.Include("PERMISSIONs");
         foreach (PERMISSION p in perms)
         {
             mgr = mgr.Where(m => m.PERMISSIONs.Select(pe => pe.ID).Contains(p.ID));
         }
         managers = mgr.ToArray();
     }
     return managers;
 }
コード例 #21
0
 public static MANAGER[] GetManagersByPermission(PERMISSION permission)
 {
     MANAGER[] managers = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         PERMISSION perm = ctx.PERMISSIONs.Include("MANAGERs").Where(p => p.ID == permission.ID).FirstOrDefault();
         managers = perm.MANAGERs.ToArray();
         //managers = (from mngr in ctx.MANAGERs
         //            where mngr.PERMISSIONs.Contains<PERMISSION>(permission)
         //            select mngr).ToArray<MANAGER>();
     }
     return managers;
 }
コード例 #22
0
 public static MANAGER[] GetManagersByManagerType(int manager_type)
 {
     MANAGER[] managers = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         managers = ctx.MANAGERs.Where(c => c.MNGR_TYPE == manager_type).ToArray();
     }
     return managers;
 }
コード例 #23
0
 public static MANAGER GetManagerByName(string name)
 {
     MANAGER manager = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         var returnValue = from mngr in ctx.MANAGERs
                           where mngr.NAME == name
                           select mngr;
         manager = returnValue.FirstOrDefault<MANAGER>();
     }
     //       System.Diagnostics.Debug.WriteLine(manager);
     return manager;
 }
コード例 #24
0
 public static PERMISSION[] GetAllPermissions()
 {
     PERMISSION[] permissions = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         permissions = ctx.PERMISSIONs.ToArray<PERMISSION>();
     }
     return permissions;
 }
コード例 #25
0
 public static TYPE GetTypeByID(int type_id)
 {
     TYPE type = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         type = ctx.TYPEs.Where(t => t.ID == type_id).FirstOrDefault();
     }
     return type;
 }
コード例 #26
0
 public static bool RemoveManager(int manager_id)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             var manager = ctx.MANAGERs.Where(m => m.ID == manager_id).FirstOrDefault<MANAGER>();
             ctx.Set<MANAGER>().Remove(manager);
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return true;
 }
コード例 #27
0
 private static bool AddResourcesToLesson(RESOURCE[] res, LESSON lesson)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         var ls = ctx.LESSONs.Include("RESOURCEs").Where(l => l.ID == lesson.ID).FirstOrDefault();
         foreach (RESOURCE rs in res)
             ls.RESOURCEs.Add(rs);
         ctx.Entry(ls).State = System.Data.EntityState.Modified;
         ctx.SaveChanges();
     }
     return true;
 }
コード例 #28
0
 /// <summary>
 /// 移除TYPE。如果有Manager与该TYPE相关联,则该Manager的MNGR_TYPE将会为NULL
 /// </summary>
 /// <param name="type_id">被删除的TYPE的id</param>
 /// <returns>true表示成功创建,false表示失败</returns>
 public static bool RemoveManagerType(int type_id)
 {
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         try
         {
             var type = ctx.TYPEs.Where(m => m.ID == type_id).FirstOrDefault<TYPE>();
             ctx.Set<TYPE>().Remove(type);
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e.ToString());
             return false;
         }
     }
     return true;
     //throw new Exception("Not Support Yet");
 }
コード例 #29
0
 public static PERMISSION[] GetPermissionsByManager(MANAGER manager)
 {
     PERMISSION[] permissions = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         MANAGER mngr = ctx.MANAGERs.Include("PERMISSIONs").Where(m => m.ID == manager.ID).FirstOrDefault();
         permissions = mngr.PERMISSIONs.ToArray();
         //permissions = ctx.PERMISSIONs.Include("MANAGERs")
         //    .Where(p => p.MANAGERs.Contains(manager))
         //    .ToArray<PERMISSION>();
     }
     return permissions;
 }
コード例 #30
0
 public static OPR_LOG[] GetAllDBLogs()
 {
     OPR_LOG[] logs = null;
     using (CloudEDUEntities ctx = new CloudEDUEntities())
     {
         logs = ctx.OPR_LOG.ToArray();
     }
     return logs;
 }