public AscmPalletDelivery Add(string palletSn, int batSumMainId, int deliveryOrderBatchId, int materialId, decimal quantity) { try { AscmPalletDelivery ascmPalletDelivery = new AscmPalletDelivery(); ascmPalletDelivery.organizationId = 0; ascmPalletDelivery.createUser = ""; ascmPalletDelivery.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmPalletDelivery.modifyUser = ""; ascmPalletDelivery.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); ascmPalletDelivery.palletSn = palletSn; ascmPalletDelivery.batSumMainId = batSumMainId; ascmPalletDelivery.deliveryOrderBatchId = deliveryOrderBatchId; ascmPalletDelivery.deliveryOrderId = 0; ascmPalletDelivery.materialId = materialId; ascmPalletDelivery.quantity = quantity; //ascmPalletDelivery.status = ""; ascmPalletDelivery.memo = ""; int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmPalletDelivery"); maxId++; ascmPalletDelivery.id = maxId; using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { YnDaoHelper.GetInstance().nHibernateHelper.Save(ascmPalletDelivery); tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 throw ex; } } return ascmPalletDelivery; } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("保存失败(Save AscmPalletDelivery)", ex); throw ex; } }
public void Update(AscmPalletDelivery ascmPalletDelivery, string sessionKey = null) { try { using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession(sessionKey).BeginTransaction()) { try { YnDaoHelper.GetInstance().nHibernateHelper.Update<AscmPalletDelivery>(ascmPalletDelivery, sessionKey); tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmPalletDelivery)", ex); throw ex; } } } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Save AscmPalletDelivery)", ex); throw ex; } }
public void Save(AscmPalletDelivery ascmPalletDelivery) { try { using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { YnDaoHelper.GetInstance().nHibernateHelper.Save(ascmPalletDelivery); tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 throw ex; } } } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("保存失败(Save AscmPalletDelivery)", ex); throw ex; } }
//public void Delete(int id) //{ // try // { // AscmPalletDelivery ascmPalletDelivery = Get(id); // Delete(ascmPalletDelivery); // } // catch (Exception ex) // { // throw ex; // } //} public void Delete(AscmPalletDelivery ascmPalletDelivery) { try { YnDaoHelper.GetInstance().nHibernateHelper.Delete<AscmPalletDelivery>(ascmPalletDelivery); } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmPalletDelivery)", ex); throw ex; } }