public virtual bool ArchiveLendSlip(LendSlip paras) { using (SqlConnection conn = new SqlConnection(Common.SQLHelper.Asset_strConn)) { conn.Open(); SqlTransaction sqlTransaction = conn.BeginTransaction(); try { LendSlip lendSlip = LendSlip.GetBy(paras.ID); Asset asset = Asset.GetBy(lendSlip.AssetID); if (asset == null) { throw new Exception("资产不存在"); } if (!asset.Status.Contains("领用")) { throw new Exception("资产未被领用"); } asset.RemoveStatus("领用"); asset.RefreshPosition(); paras.CopyTo(lendSlip, false); lendSlip.ReturnDate = DateTime.Now; asset.sqlTransaction = lendSlip.sqlTransaction = sqlTransaction; asset.Update(); lendSlip.Update(); sqlTransaction.Commit(); return(true); } catch { sqlTransaction.Rollback(); throw; } } }
public virtual IEnumerable <LendSlip> GetLendSlipsOf(string AssetID) { return(LendSlip.GetBy(AssetID)); }