Ejemplo n.º 1
0
 public ActionResult Update(tblDictionary model)
 {
     model.Delete           = false;
     _db.Entry(model).State = System.Data.Entity.EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("/Index/" + model.CategoryId));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 功能描述    :  根据主键取得[tblDictionary]表的记录
 /// 创建者      :  Auto Generator
 /// 创建日期    :  2009-04-29
 /// 修改者      :
 /// 修改日期    :
 /// 修改原因    :
 /// </summary>
 /// <param name="iPK">PK主键值</param>
 /// <returns>tblDictionary</returns>
 public tblDictionary ByPK(int iPK)
 {
     try
     {
         usp_tblDictionary_ByPK uspByPK = new usp_tblDictionary_ByPK();
         uspByPK.fldAutoID = iPK;
         DataTable tblData = uspByPK.ExecDataTable(1);
         if (tblData != null)
         {
             tblDictionary objData = new tblDictionary();
             objData.MetaDataTable = tblData;
             return(objData);
         }
         else
         {
             throw new Exception("取得单条记录失败,未找到对应的记录");
         }
     }
     catch (DBOpenException e)
     {
         throw new GetByPKException("打开数据库连接失败", "RuletblDictionary", "ByPK", iPK.ToString());
     }
     catch (DBQueryException e)
     {
         throw new GetByPKException("执行Sql语句失败", "RuletblDictionary", "ByPK", iPK.ToString());
     }
     catch (Exception e)
     {
         throw new GetByPKException(e.Message, "RuletblDictionary", "ByPK", iPK.ToString());
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 功能描述    :  添加[tblDictionary]表的记录
 /// 创建者      :  Auto Generator
 /// 创建日期    :  2009-04-29
 /// 修改者      :
 /// 修改日期    :
 /// 修改原因    :
 /// </summary>
 /// <param name="objInsert">需要添加的实体类</param>
 /// <returns>返回新增记录的PK主键的值</returns>
 public int Insert(tblDictionary objInsert)
 {
     try
     {
         usp_tblDictionary_Insert uspInsert = new usp_tblDictionary_Insert();
         uspInsert.ReceiveParameter(objInsert);
         uspInsert.ExecNoQuery(1);
         if (uspInsert.fldAutoID > 0)
         {
             return(uspInsert.fldAutoID);
         }
         else
         {
             throw new Exception("插入新记录失败");
         }
     }
     catch (DBOpenException e)
     {
         throw new InsertException("打开数据库连接失败", "RuletblDictionary", "Insert", objInsert.ToString());
     }
     catch (DBPKException e)
     {
         throw new InsertPKException("相同的记录已经存在,违反表的唯一键约束", "RuletblDictionary", "Insert", objInsert.ToString());
     }
     catch (DBQueryException e)
     {
         throw new InsertException("执行Sql语句失败", "RuletblDictionary", "Insert", objInsert.ToString());
     }
     catch (Exception e)
     {
         throw new InsertException(e.Message, "RuletblDictionary", "Insert", objInsert.ToString());
     }
 }
Ejemplo n.º 4
0
        public ActionResult Create(tblDictionary model)
        {
            model.Delete = false;
            _db.tblDictionary.Add(model);
            _db.SaveChanges();

            return(RedirectToAction("/Index/" + model.CategoryId));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 功能描述    :  更新[tblDictionary]表的记录
 /// 创建者      :  Auto Generator
 /// 创建日期    :  2009-04-29
 /// 修改者      :
 /// 修改日期    :
 /// 修改原因    :
 /// </summary>
 /// <param name="objUpdate_old">需要更新的实体类</param>
 /// <param name="objUpdate_new">更新后的实体类</param>
 /// <returns>true / false</returns>
 public bool Update(tblDictionary objUpdate_old, tblDictionary objUpdate_new)
 {
     try
     {
         usp_tblDictionary_Update uspUpdate = new usp_tblDictionary_Update();
         uspUpdate.ReceiveParameter_Old(objUpdate_old);
         uspUpdate.ReceiveParameter_New(objUpdate_new);
         int iResult = uspUpdate.ExecNoQuery(1);
         if (iResult > 0)
         {
             return(true);
         }
         else
         {
             throw new Exception("更新记录失败,未找到对应的记录");
         }
     }
     catch (DBOpenException e)
     {
         throw new UpdateException("打开数据库连接失败", "RuletblDictionary", "Update",
                                   "objUpdate_old:" + objUpdate_old.ToString() + ";objUpdate_new:" + objUpdate_new.ToString());
     }
     catch (DBPKException e)
     {
         throw new UpdatePKException("相同的记录已经存在,违反表的唯一键约束", "RuletblFW_Dept", "Update",
                                     "objUpdate_old:" + objUpdate_old.ToString() + ";objUpdate_new:" + objUpdate_new.ToString());
     }
     catch (DBQueryException e)
     {
         throw new UpdateException("执行Sql语句失败", "RuletblDictionary", "Update",
                                   "objUpdate_old:" + objUpdate_old.ToString() + ";objUpdate_new:" + objUpdate_new.ToString());
     }
     catch (Exception e)
     {
         throw new UpdateException(e.Message, "RuletblDictionary", "Update",
                                   "objUpdate_old:" + objUpdate_old.ToString() + ";objUpdate_new:" + objUpdate_new.ToString());
     }
 }