/// <summary> /// 修改 /// </summary> /// <param name="p_BE">要修改的实体</param> /// <param name="sqlTrans">事务类</param> public void RUpdate(BaseEntity p_BE, int p_ID, int p_Seq, IDBTransAccess sqlTrans) { try { if (p_Seq == 0) { throw new BaseException("挂板数据有问题,请联系管理员"); } string sql = "DELETE Data_ItemGB WHERE MainID=" + SysString.ToDBString(p_ID); sql += " AND Seq=" + SysString.ToDBString(p_Seq); sqlTrans.ExecuteNonQuery(sql); ItemGBRule rule = new ItemGBRule(); ItemGB entity = (ItemGB)p_BE; entity.MainID = p_ID; entity.Seq = p_Seq; rule.RAdd(entity, sqlTrans); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RAdd(BaseEntity p_BE, int p_ID, IDBTransAccess sqlTrans) { try { ItemGBRule rule = new ItemGBRule(); ItemGB entity = (ItemGB)p_BE; string sql = "SELECT GBCode FROM Data_ItemGB WHERE GBCode=" + SysString.ToDBString(entity.GBCode); DataTable dt = sqlTrans.Fill(sql); if (dt.Rows.Count > 0) { throw new BaseException("挂板条码已存在,请重新输入"); } sql = "SELECT Max(Seq) Seq FROM Data_ItemGB WHERE MainID=" + SysString.ToDBString(p_ID); dt = sqlTrans.Fill(sql); int seq = 1; if (dt.Rows.Count > 0) { seq = SysConvert.ToInt32(dt.Rows[0][0]); } entity.MainID = p_ID; entity.Seq = seq + 1; rule.RAdd(entity, sqlTrans); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }