public void Delete(AscmWhTeam AscmWhTeam) { try { YnDaoHelper.GetInstance().nHibernateHelper.Delete<AscmWhTeam>(AscmWhTeam); } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmWhTeam)", ex); throw ex; } }
public void Update(AscmWhTeam AscmWhTeam) { using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { YnDaoHelper.GetInstance().nHibernateHelper.Update<AscmWhTeam>(AscmWhTeam); tx.Commit(); //正确执行提交 } catch (Exception ex) { tx.Rollback(); //回滚 YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmWhTeam)", ex); throw ex; } } }
public void Save(AscmWhTeam AscmWhTeam) { try { int count = YnDaoHelper.GetInstance().nHibernateHelper.GetCount("select count(*) from AscmWhTeam where id=" + AscmWhTeam.id); if (count == 0) { using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { int id = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId(" select max(id) from AscmWhTeam ") + 1; AscmWhTeam.id = id; YnDaoHelper.GetInstance().nHibernateHelper.Save(AscmWhTeam); tx.Commit(); //正确执行提交 } catch (Exception ex) { tx.Rollback(); //回滚 throw ex; } } } else { throw new Exception("已经存在组别!"); } } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("保存失败(Save AscmWhTeam)", ex); throw ex; } }