Exemplo n.º 1
0
 /*
  * Create By 付文欣
  * 添加一个设置
  * 成功添加返回1,失败返回0,异常返回-1
  */
 public int addSetting(Setting setting)
 {
     try
     {
         SettingDBContext settingDBContext = new SettingDBContext();
         settingDBContext.settings.Add(setting);
         return(settingDBContext.SaveChanges());
     }
     catch (Exception e)
     {
         //throw e;
         //LogUtil.writeLogToFile(e);
         return(-1);
     }
 }
Exemplo n.º 2
0
 /*
  * Create By 付文欣
  * 根据年份号删除设置
  * 成功删除返回1,失败返回0,异常返回-1
  */
 public int deleteSettingById(string id)
 {
     try
     {
         Setting          setting;
         SettingDBContext settingDBContext = new SettingDBContext();
         if ((setting = settingDBContext.settings.Find(id)) != null)
         {
             settingDBContext.settings.Remove(setting);
             return(settingDBContext.SaveChanges());
         }
         else
         {
             return(0);
         }
     }
     catch (Exception e)
     {
         //throw e;
         //LogUtil.writeLogToFile(e);
         return(-1);
     }
 }
Exemplo n.º 3
0
 /*
  * Create By 付文欣
  * 根据年份号修改模式
  * 成功添加返回1,失败返回0,异常返回-1
  */
 public int changeModeById(String id, int mode)
 {
     try
     {
         SettingDBContext settingDBContext = new SettingDBContext();
         Setting          setting          = settingDBContext.settings.Where(m => m.yearId == id).ToList()[0];
         if (setting != null)
         {
             setting.mode = mode;
             return(settingDBContext.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 updateSetting(Setting newSetting)
 {
     try
     {
         SettingDBContext settingDBContext = new SettingDBContext();
         Setting          setting          = settingDBContext.settings.Where(m => m.yearId == newSetting.yearId).ToList()[0];
         if (setting != null)
         {
             settingDBContext.settings.Remove(setting);
             settingDBContext.settings.Add(newSetting);
             return(settingDBContext.SaveChanges());
         }
         else
         {
             return(0);
         }
     }
     catch (Exception e)
     {
         //throw e;
         //LogUtil.writeLogToFile(e);
         return(-1);
     }
 }