Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Version User display

Author  Topic 

Sitka
Aged Yak Warrior

571 Posts

Posted - 2005-12-12 : 12:43:35
See in wikipedia

http://en.wikipedia.org/w/index.php?title=Microsoft_SQL_Server&diff=30790673&oldid=30789604

how from the history tab you can compare versions in a similar way to VSS. Has anyone ever found such a control for Windows forms?


"it's definitely useless and maybe harmful".

Sitka
Aged Yak Warrior

571 Posts

Posted - 2005-12-15 : 16:46:26
Versioning Reports



CREATE 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'



SELECT
externalballoon,
CASE WHEN laguid is null OR raguid is null THEN 1
ELSE 0
END
as deleteaddflag,
CASE WHEN lprocess <> rprocess THEN 1
ELSE 0
END
as processmodified,
CASE WHEN lqty <> rqty THEN 1
ELSE 0
END as qtymodified,
CASE WHEN lpartno <> rpartno THEN 1
ELSE 0
END as partnomodified,
CASE WHEN lpartnodesc <> rpartnodesc THEN 1
ELSE 0
END as partnodescmodified,
CASE WHEN lneeddate <> rneeddate THEN 1
ELSE 0
END 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, raguid
FROM
(
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 versions
then use two types of flag columns
1.) 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 Add
Blue = a changed in process
Green = a change in due date
etc.

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".
Go to Top of Page
   

- Advertisement -