public virtual ActionResult Create(Depart tocreate)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var dep = new Depart();
             UpdateModel(dep);
             db.AddToDeparts(dep);
             db.SaveChanges();
             return RedirectToAction("Index");
         }
         catch
         {
             return View(tocreate);
         }
     }
     ModelState.AddModelError("", "不能创建,请检查是否输入完整");
     return View(tocreate);
 }
Example #2
0
 /// <summary>
 /// Create a new Depart object.
 /// </summary>
 /// <param name="departID">Initial value of the DepartID property.</param>
 public static Depart CreateDepart(global::System.Int32 departID)
 {
     Depart depart = new Depart();
     depart.DepartID = departID;
     return depart;
 }
Example #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Departs EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDeparts(Depart depart)
 {
     base.AddObject("Departs", depart);
 }