public ActionResult RoomTypeEdit(int id, int projectid, FormCollection collection)
 {
     RoomType s = db.RoomTypes.Find(id);
     if (s == null)
     {
         s = new RoomType { DepartmentId = (int)projectid };
         ViewBag.Reload = true;
         db.RoomTypes.Add(s);
     }
     else if(!collection["Name"].Equals(s.Name)){
         ViewBag.Reload = true;
     }
     TryUpdateModel(s, "", new string[] { }, new string[] { "" }, collection);
     var query = (from o in db.RoomTypes where o.DepartmentId == s.DepartmentId && o.Name == s.Name && o.Id != s.Id select o).FirstOrDefault();
     if (query != null)
         ModelState.AddModelError("", "该产品类型已经存在");
     if (ModelState.IsValid)
     {
         db.SaveChanges();
         ViewBag.Success = true;
     }
     ViewBag.Project = db.Departments.Find(s.DepartmentId);
     return View(s);
 }
 public ActionResult RoomTypeEdit(int id, int projectid)
 {
     RoomType s = db.RoomTypes.Find(id);
     if (s == null)
     {
         s = new RoomType { DepartmentId = (int)projectid };
     }
     ViewBag.Reload = false;
     ViewBag.Project = db.Departments.Find(s.DepartmentId);
     return View(s);
 }