Versioning ReportsCREATE TABLE engversion ( sono varchar (6) NOT NULL , bomversion int NOT NULL , aguid varchar (50) NULL , createdate smalldatetime NOT NULL CONSTRAINT DF_engversion_createdate DEFAULT (getdate()), CONSTRAINT PK_engversion PRIMARY KEY CLUSTERED ( sono, bomversion ))CREATE TABLE engboms ( sono varchar (6) NOT NULL , externalballoon int NOT NULL , process varchar (50) NULL , qty decimal(12, 3) NULL , partno varchar (255) NULL , partnodesc varchar (255) NULL , needdate smalldatetime NULL , aguid varchar (50) NOT NULL , CONSTRAINT PK_engboms PRIMARY KEY CLUSTERED ( sono, externalballoon, aguid ))CREATE PROC tool_Get_Bom_Versions_for_Diff(@leftversion int = 1, @rightversion int = 1, @sono varchar(6) = 'C9999')AS SET NOCOUNT ON-- DECLARE @leftversion int-- DECLARE @rightversion int-- DECLARE @sono varchar(6)-- SET @leftversion = 10-- SET @rightversion = 11-- SET @sono = 'C2729'SELECTexternalballoon,CASE WHEN laguid is null OR raguid is null THEN 1ELSE 0 ENDas deleteaddflag,CASE WHEN lprocess <> rprocess THEN 1ELSE 0ENDas processmodified,CASE WHEN lqty <> rqty THEN 1ELSE 0END as qtymodified,CASE WHEN lpartno <> rpartno THEN 1ELSE 0END as partnomodified,CASE WHEN lpartnodesc <> rpartnodesc THEN 1ELSE 0END as partnodescmodified,CASE WHEN lneeddate <> rneeddate THEN 1ELSE 0END as needdatemodified,lprocess, lqty, lpartno, lpartnodesc, CONVERT(char(10),lneeddate, 101) as lneeddate, laguid,rprocess, rqty, rpartno, rpartnodesc, convert(char(10),rneeddate, 101) as rneeddate, raguidFROM( SELECT Z.externalballoon, Y.process as lprocess, Y.qty as lqty, Y.partno as lpartno, Y.partnodesc as lpartnodesc, Y.needdate as lneeddate, Y.aguid as laguid, X.process as rprocess, X.qty as rqty, X.partno as rpartno, X.partnodesc as rpartnodesc, X.needdate as rneeddate, X.aguid as raguid FROM ( SELECT B.externalballoon from engversion A INNER JOIN engboms B ON A.aguid = B.aguid WHERE B.sono = @sono AND A.bomversion = @leftversion UNION SELECT B.externalballoon from engversion A INNER JOIN engboms B ON A.aguid = B.aguid WHERE B.sono = @sono AND A.bomversion = @rightversion ) Z LEFT JOIN ( SELECT B.externalballoon, B.process, B.qty, B.partno, B.partnodesc, B.needdate, B.aguid from engversion A INNER JOIN engboms B ON A.aguid = B.aguid WHERE B.sono = @sono AND A.bomversion = @leftversion ) Y ON Z.externalballoon = Y.externalballoon LEFT JOIN ( SELECT B.externalballoon, B.process, B.qty, B.partno, B.partnodesc, B.needdate, B.aguid from engversion A INNER JOIN engboms B ON A.aguid = B.aguid WHERE B.sono = @sono AND A.bomversion = @rightversion ) X ON Z.externalballoon = X.externalballoon)J
Get the union of all the keys in the two versionsthen use two types of flag columns1.) to designate a row in one set and one not in the other.(add/delete)2.) the specific edit that is causeing a difference.It's a pretty easy thing to accomplish, I feel very guilty about not being able to handle this in the presentation but I couldn't get it.All I do now in VS is use two lisview controls to act as pickers for the left and right version and use a third listview which conditionally sets the background color of each row (both versions on a single row) based on the conditional flag columns generated in the proc. *note data retrival via DataReaders, listview picker from array from Reader.listview reporting display generated from datatable from Reader.Made a simple legend out of labels.Red = Delete AddBlue = a changed in processGreen = a change in due dateetc.So I spent a week looking for a WinDiff control which I never found because I thought this was a presentation issue or should be a client side process.And ended up getting the whole thing done in a couple hours, as a total rookie, by expanding the result set to help with presentation.I even converted date cause I was so sick of looking stuff up. (System.Globalization.DateTimeFormatInfo I guess but I can never remember after a couple months.)Still the internal tier battle rages on, and my heart is restless."it's definitely useless and maybe harmful".