protected override int OnUpdate() { if (ID <= 0) { return(-1); } var rs = base.OnUpdate(); var myatt = MyAttachment.FindByID(ID); if (myatt == null) { myatt = new MyAttachment(); myatt.CopyFrom(this); myatt.ID = ID; rs += myatt.Insert(); } else { myatt.CopyFrom(this); myatt.ID = ID; rs += myatt.Update(); } return(rs); }
/// <summary>已重载。在事务保护范围内处理业务,位于Valid之后</summary> /// <returns></returns> protected override Int32 OnInsert() { var rs = base.OnInsert(); var myatt = new MyAttachment(); myatt.CopyFrom(this); myatt.ID = ID; rs += myatt.Insert(); return(rs); }
protected override int OnDelete() { string mapPath = Utils.GetMapPath(BaseConfigs.GetForumPath + "upload/"); var name = (FileName + "").Trim(); if (!String.IsNullOrEmpty(name) && File.Exists(mapPath + name)) { File.Delete(mapPath + name); } var myatt = MyAttachment.FindByKey(ID); if (myatt != null) { myatt.Delete(); } return(base.OnDelete()); }