public static void SqlDelete(int id) { var curr = LemHeader.GetLogHeader(id); if (curr.MatchId != -1) { string sql = $"update LemHeader set deleted=1 where id={id}"; MobileCommon.ExecuteNonQuery(sql); DeleteHistory.SqlInsert(DeleteHistory.LemHeader, curr.MatchId); var labourList = LabourTimeEntry.GetLabourEntryList(id); labourList.ForEach(x => LabourTimeEntry.DeleteEntry(x.Id)); var equipList = EquipTimeEntry.GetEquipEntryList(id); equipList.ForEach(x => EquipTimeEntry.DeleteEntry(x.Id)); var attachList = Attachment.GetAttachList(Attachment.LemHeaderId, id); attachList.ForEach(x => Attachment.DeleteAttach(DeleteHistory.LemHeaderAttach, x.RepositoryId)); } else { SqlForceDelete(id); } }
public override void CommitReceive() { if (new EnumTableSyncStatus[] { EnumTableSyncStatus.Receiving, EnumTableSyncStatus.CompleteReceive }.Contains(SyncInfo.Status)) { DataTable table = MobileCommon.ExecuteDataAdapter($"select * from LemHeader where CompanyId={CompanyId} and SyncStatus='{EnumRecordSyncStatus.Updating}'"); List <LemHeader> oldList = table.Select().Select(r => new LemHeader(r)).ToList(); oldList.ForEach(r => LemHeader.SqlForceDelete(r.Id)); table = MobileCommon.ExecuteDataAdapter($"select * from LemHeader where CompanyId={CompanyId} and SyncStatus='{EnumRecordSyncStatus.Receiving}'"); List <LemHeader> newList = table.Select().Select(r => new LemHeader(r)).ToList(); foreach (var item in oldList) { int newHeaderId = newList.Single(x => x.MatchId == item.MatchId).Id; string sql = $"update LabourTimeEntry set LogHeaderId={newHeaderId} where SyncStatus<>'{EnumRecordSyncStatus.Receiving}' and CompanyId={CompanyId} and LogHeaderId={item.Id}"; MobileCommon.ExecuteNonQuery(sql); sql = $"update EquipTimeEntry set LogHeaderId={newHeaderId} where SyncStatus<>'{EnumRecordSyncStatus.Receiving}' and CompanyId={CompanyId} and LogHeaderId={item.Id}"; MobileCommon.ExecuteNonQuery(sql); sql = $"update LemAP set LogHeaderId={newHeaderId} where SyncStatus<>'{EnumRecordSyncStatus.Receiving}' and CompanyId={CompanyId} and LogHeaderId={item.Id}"; MobileCommon.ExecuteNonQuery(sql); sql = $"update CFS_FileLink set IdValue={newHeaderId} where SyncStatus<>'{EnumRecordSyncStatus.Receiving}' and CompanyId={CompanyId} and IdValue={item.Id}"; MobileCommon.ExecuteNonQuery(sql); } base.CommitReceive(); } }