Esempio n. 1
0
 public ActionResult Create(ItemConfig itemConfig)
 {
     ItemConfigService itemConfigService = ItemConfigService.GetInstance();
     if (string.IsNullOrEmpty(itemConfig.name))
     {
         ModelState.AddModelError("Name", "相关设置名称不能为空!");
     }
     //if (itemConfig.value==null)
     //{
     //    ModelState.AddModelError("Value", "相关设置值不能为空!");
     //}
     if (itemConfigService.Exists(itemConfig.name))//如果存在不能添加
     {
         ModelState.AddModelError("Exist", "相关设置名称已存在");
     }
     if (ModelState.IsValid)
     {
         int flag = itemConfigService.AddItemConfig(itemConfig);
         if (flag > 0)
         {
             return RedirectToAction("Index");
         }
         else
         {
             ModelState.AddModelError("Fails", "相关配置创建失败!");
             return View();
         }
     }
     else
     {
         return View();
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 功能:添加一条相关设置记录
 /// 作者:鄢睿
 /// 创建时间:2011年2月16日 16:18
 /// </summary>
 /// <param name="itemConfig">相关设置</param>
 /// <returns>flag小于等于0失败,大于0成功</returns>
 public int AddItemConfig(ItemConfig itemConfig)
 {
     int res =  _itemConfigDao.AddItemConfig(itemConfig);
        if (res > 0 && itemConfig.name.Equals(ItemConfig.CO2))
        {
     //更新用户的静态量
        ItemConfig.reductionRate = itemConfig.value;
        }
        return res;
 }
Esempio n. 3
0
 public ActionResult Tree(ItemConfig itemConfig)
 {
     itemConfigService.Update(itemConfig);
     ItemConfig.treeConvert = itemConfig.value;
     return View();
 }
Esempio n. 4
0
        public ActionResult reg_collector(string days, string count)
        {
            int tid = 0;
            int.TryParse(count, out tid);
            ItemConfig config = new ItemConfig();
            config.id = ItemConfig.maxCollectorCountId;
            config.type = 1;
            config.value = tid;
            itemConfigService.UpdateValue(config);//更新数量

            config.id = ItemConfig.maxexpiredDaysId;//更新天数
            int.TryParse(days, out tid);
            config.value = tid;
            itemConfigService.UpdateValue(config);//更新天数
            TempData["return"] = "修改成功";
            return Redirect("/itemconfig/reg_collector");
        }
Esempio n. 5
0
 public ActionResult Edit(ItemConfig itemConfig)
 {
     itemConfigService.Update(itemConfig);
     return View();
 }
Esempio n. 6
0
 public int UpdateValue(ItemConfig config)
 {
     return _itemConfigDao.UpdateValue(config);
 }