protected override void AfterChange(DataColumn dc, DataRow row) { SST.SSTCaseMatterRow dr = (SST.SSTCaseMatterRow)row; switch (dc.ColumnName) { case "IssueId": //set legislation if (!dr.IsIssueIdNull()) { appDB.IssueRow ir = myA.AtMng.DB.Issue.FindByIssueId(dr.IssueId); if (!ir.IsLegProvisionIdNull()) { dr.LegislationId = ir.LegProvisionId; dr.EndEdit(); } } break; } }
protected override void BeforeUpdate(DataRow row) { SST.SSTCaseMatterRow dr = (SST.SSTCaseMatterRow)row; BeforeChange(mySSTCaseMatterDT.IssueIdColumn, dr); //TFS#56157 BY 2013-9-20 BeforeChange(mySSTCaseMatterDT.OutcomeIdColumn, dr); BeforeChange(mySSTCaseMatterDT.AcceptIssueColumn, dr); //add or update filexref for issue if (!dr.IsIssueIdNull()) { appDB.IssueRow ir = myA.AtMng.DB.Issue.FindByIssueId(dr.IssueId); if (dr.RowState == DataRowState.Added && !ir.IsFileIdNull()) { if (!XrefExists(ir.FileId)) { atriumDB.FileXRefRow fxr = (atriumDB.FileXRefRow)myA.FM.GetFileXRef().Add(myA.FM.CurrentFile); fxr.LinkType = 1; fxr.OtherFileId = ir.FileId; fxr.Rollup = false; fxr.FullFileNumber = myA.FM.EFile.Load(ir.FileId, false).FullFileNumber; } } else if (myA.IsFieldChanged(mySSTCaseMatterDT.IssueIdColumn, dr)) { int origIssueId = (int)dr[mySSTCaseMatterDT.IssueIdColumn, DataRowVersion.Original]; appDB.IssueRow origIr = myA.AtMng.DB.Issue.FindByIssueId(origIssueId); var fxrq = from f in myA.FM.DB.FileXRef where f.OtherFileId == origIr.FileId & f.LinkType == 1 select f; if (fxrq.Count() > 0) // if false, no issue found. { atriumDB.FileXRefRow fxr = fxrq.Single(); if (ir.IsFileIdNull()) { fxr.Delete(); } else { if (XrefExists(ir.FileId)) { fxr.Delete(); } else { //check List <int> files = new List <int>(); foreach (SST.SSTCaseMatterRow scmr in mySSTCaseMatterDT) { if (!scmr.IsIssueIdNull() && scmr.SSTCaseMatterId != dr.SSTCaseMatterId) { appDB.IssueRow ir1 = myA.AtMng.DB.Issue.FindByIssueId(scmr.IssueId); if (!ir1.IsFileIdNull()) { files.Add(ir1.FileId); } } } if (files.Contains(fxr.OtherFileId)) { //another issue uses that xref so add a new xref and don't change the current one atriumDB.FileXRefRow fxr1 = (atriumDB.FileXRefRow)myA.FM.GetFileXRef().Add(myA.FM.CurrentFile); fxr1.LinkType = 1; fxr1.OtherFileId = ir.FileId; fxr1.Rollup = false; fxr1.FullFileNumber = myA.FM.EFile.Load(ir.FileId, false).FullFileNumber; } else { fxr.OtherFileId = ir.FileId; } } } } else // no issue found, so no xref to update; add a new xref. { atriumDB.FileXRefRow fxr1 = (atriumDB.FileXRefRow)myA.FM.GetFileXRef().Add(myA.FM.CurrentFile); fxr1.LinkType = 1; fxr1.OtherFileId = ir.FileId; fxr1.Rollup = false; fxr1.FullFileNumber = myA.FM.EFile.Load(ir.FileId, false).FullFileNumber; } } } }