public void Update(AscmRfid ascmRfid) { int count = YnDaoHelper.GetInstance().nHibernateHelper.GetCount("select count(*) from AscmRfid where id='" + ascmRfid.id + "'"); if (count > 0) { using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { YnDaoHelper.GetInstance().nHibernateHelper.Update <AscmRfid>(ascmRfid); tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmRfid)", ex); throw ex; } } } else { throw new Exception("标签SN不存在,无法更新\"" + ascmRfid.id + "\"!"); } }
public void Update(AscmRfid ascmRfid) { //int count = YnDaoHelper.GetInstance().nHibernateHelper.GetCount("select count(*) from AscmRfid where id<>" + ascmRfid.id + " and docNumber='" + ascmRfid.docNumber + "'"); //if (count == 0) //{ // using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) // { // try // { // YnDaoHelper.GetInstance().nHibernateHelper.Update<AscmRfid>(ascmRfid); // tx.Commit();//正确执行提交 // } // catch (Exception ex) // { // tx.Rollback();//回滚 // YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmRfid)", ex); // throw ex; // } // } //} //else //{ // throw new Exception("已经存在员工编号\"" + ascmRfid.name + "\"!"); //} }
public void Save(AscmRfid ascmRfid) { try { int count = YnDaoHelper.GetInstance().nHibernateHelper.GetCount("select count(*) from AscmRfid where id='" + ascmRfid.id + "'"); if (count == 0) { int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(organizationId) from AscmRfid"); using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { maxId++; ascmRfid.organizationId = maxId; YnDaoHelper.GetInstance().nHibernateHelper.Save(ascmRfid); tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 throw ex; } } } else { YnBaseClass2.Helper.LogHelper.GetLog().Error("已存在(Save AscmRfid)" + ascmRfid.id.ToString()); } } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("保存失败(Save AscmRfid)", ex); throw ex; } }
public void Save(AscmRfid ascmRfid) { try { //int count = YnDaoHelper.GetInstance().nHibernateHelper.GetCount("select count(*) from AscmRfid where docNumber='" + ascmRfid.docNumber + "'"); //if (count == 0) //{ // int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmRfid"); // using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) // { // try // { // maxId++; // ascmRfid.id = maxId; // YnDaoHelper.GetInstance().nHibernateHelper.Save(ascmRfid); // tx.Commit();//正确执行提交 // } // catch (Exception ex) // { // tx.Rollback();//回滚 // throw ex; // } // } //} //else //{ // throw new Exception("已经存在员工编号\"" + ascmRfid.name + "\"!"); //} } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("保存失败(Save AscmRfid)", ex); throw ex; } }
public void Save(bool _new, AscmEmployeeCar ascmEmployeeCar, AscmRfid ascmRfid_Old, AscmRfid ascmRfid_New_Update, AscmRfid ascmRfid_New_Save) { try { DateTime dtServerTime = MideaAscm.Dal.YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentDate("AscmEmployeeCar"); ascmEmployeeCar.modifyTime = dtServerTime.ToString("yyyy-MM-dd HH:mm:ss"); if (ascmRfid_Old != null) { ascmRfid_Old.modifyTime = dtServerTime.ToString("yyyy-MM-dd HH:mm:ss"); } if (ascmRfid_New_Update != null) { ascmRfid_New_Update.modifyTime = dtServerTime.ToString("yyyy-MM-dd HH:mm:ss"); } if (ascmRfid_New_Save != null) { ascmRfid_New_Save.modifyTime = dtServerTime.ToString("yyyy-MM-dd HH:mm:ss"); } using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { if (_new) { ascmEmployeeCar.createTime = dtServerTime.ToString("yyyy-MM-dd HH:mm:ss"); YnDaoHelper.GetInstance().nHibernateHelper.Save(ascmEmployeeCar); } else { YnDaoHelper.GetInstance().nHibernateHelper.Update(ascmEmployeeCar); } if (ascmRfid_Old != null) { YnDaoHelper.GetInstance().nHibernateHelper.Update(ascmRfid_Old); } if (ascmRfid_New_Update != null) { YnDaoHelper.GetInstance().nHibernateHelper.Update(ascmRfid_New_Update); } if (ascmRfid_New_Save != null) { ascmRfid_New_Save.createTime = dtServerTime.ToString("yyyy-MM-dd HH:mm:ss"); YnDaoHelper.GetInstance().nHibernateHelper.Save(ascmRfid_New_Save); } tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 throw ex; } } } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("保存失败(Save AscmEmployeeCar)", ex); throw ex; } }
public void Delete(AscmRfid ascmRfid) { try { YnDaoHelper.GetInstance().nHibernateHelper.Delete <AscmRfid>(ascmRfid); } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmRfid)", ex); throw ex; } }
public void Delete(string id) { try { AscmRfid ascmRfid = Get(id); Delete(ascmRfid); } catch (Exception ex) { throw ex; } }
public AscmRfid Get(string id, string sessionKey) { AscmRfid ascmRfid = null; try { ascmRfid = YnDaoHelper.GetInstance().nHibernateHelper.Get <AscmRfid>(id, sessionKey); } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Get AscmRfid)", ex); throw ex; } return(ascmRfid); }
/// <summary> /// 2013/07/17 /// </summary> /// <param name="epc"></param> /// <returns></returns> public AscmRfid GetByEpc(string epcId) { AscmRfid ascmRfid = null; try { NHibernate.ISession session = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession(); NHibernate.IQuery query = session.CreateQuery("from AscmRfid where epcId='" + epcId + "' "); ascmRfid = query.UniqueResult <AscmRfid>(); } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Get AscmRfid)", ex); throw ex; } return(ascmRfid); }
public AscmRfid Get(string id) { AscmRfid ascmRfid = null; try { ascmRfid = YnDaoHelper.GetInstance().nHibernateHelper.Get <AscmRfid>(id); } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Get AscmRfid)", ex); throw ex; } if (ascmRfid == null) { return(ascmRfid); } else if (!string.IsNullOrEmpty(ascmRfid.bindType)) { ascmRfid.bindType = ascmRfid.bindType.ToUpper(); } return(ascmRfid); }