Exemplo n.º 1
0
 /*
  * Create By 付文欣
  * 根据专业号修改专业名称
  * 成功添加返回1,失败返回0,异常返回-1
  */
 public int changeNameById(int id,String newName)
 {
     try
     {
         MajorDBContext majorDBContext = new MajorDBContext();
         Major major = majorDBContext.majors.Where(m => m.id == id).ToList()[0];
         major.name = newName;
         return majorDBContext.SaveChanges();
     }
     catch (Exception e)
     {
         //throw e;
         //LogUtil.writeLogToFile(e);
         return -1;
     }
 }
Exemplo n.º 2
0
        /*
         * Create By 高晔
         * 创建和初始化本地数据库
         */
        public static void initLocalDB()
        {
            StudentDBContext studentDB = new StudentDBContext();

            studentDB.students.Find("");
            AdminDBContext adminDB = new AdminDBContext();

            adminDB.admins.Find("");
            DeanDBContext deanDB = new DeanDBContext();

            deanDB.deans.Find("");
            ProfessorDBContext professorDB = new ProfessorDBContext();

            professorDB.professors.Find("");
            SettingDBContext settingDBContext = new SettingDBContext();
            //settingDBContext.settings.Find("");
            MajorDBContext majorDBContext = new MajorDBContext();

            majorDBContext.majors.Find(0);
        }
Exemplo n.º 3
0
 /*
  * Create By 付文欣
  * 根据专业号删除专业
  * 成功删除返回1,失败返回0,异常返回-1
  */
 public int deleteMajorById(int id)
 {
     try
     {
         Major major = null;
         MajorDBContext majorDBContext = new MajorDBContext();
         if ((major = majorDBContext.majors.Find(id)) != null)
         {
             majorDBContext.majors.Remove(major);
             return majorDBContext.SaveChanges();
         }
         else
             return 0;
     }
     catch (Exception e)
     {
         //throw e;
         //LogUtil.writeLogToFile(e);
         return -1;
     }
 }
Exemplo n.º 4
0
 /*
  * Create By 付文欣
  * 添加一个专业
  * 成功添加返回1,失败返回0,异常返回-1
  */
 public int addMajor(string name)
 {
     try
     {
         MajorDBContext majorDBContext = new MajorDBContext();
         if(majorDBContext.majors.Where(m=> m.name == name).Count() > 0)
         {
             return 0;
         }
         Major major = new Major();
         major.name = name;
         majorDBContext.majors.Add(major);
         return majorDBContext.SaveChanges();
     }
     catch (Exception e)
     {
         //throw e;
         //LogUtil.writeLogToFile(e);
         return -1;
     }
 }
Exemplo n.º 5
0
 /*
  * Create By 付文欣
  * 根据专业号删除多个专业
  * 成功删除返回大于0的数,失败返回0,异常返回-1
  */
 public int deleteMajorsByIds(List<String> ids)
 {
     try
     {
         Major major;
         MajorDBContext majorDBContext = new MajorDBContext();
         foreach (var id in ids)
         {
             if ((major = majorDBContext.majors.Find(id)) != null)
             {
                 majorDBContext.majors.Remove(major);
             }
             else
                 return 0;
         }
         return majorDBContext.SaveChanges();
     }
     catch (Exception e)
     {
         //throw e;
         //LogUtil.writeLogToFile(e);
         return -1;
     }
 }
Exemplo n.º 6
0
 /*
  * Create by 付文欣
  * 通过专业号获取专业
  */
 public Major getMajorById(int id)
 {
     MajorDBContext majorDBContext = new MajorDBContext();
     Major major = majorDBContext.majors.Find(id);
     return major;
 }