Hi,
we have 5 machines, for all machines we need to show total good parts for different timings on clicking on button. values are coming from PLC and storing it in DB for 15 mins.
here is my template, I binded this for named query for 30 mins.
Here is my main View,
I can use multistate button or single button for different timings. by clicking on button, value should change in all machine fields(TextField)
here is my SQL query for 60min, so I can change it for 30,80 and so on.
On clicking on 30 mins Button it should change for all machines.
DECLARE @currentdttm datetime
DECLARE @inputMin int
SET @inputMin = 60
SET @currentdttm = SWITCHOFFSET(SYSDATETIMEOFFSET(), '+05:30')
SELECT DateTime,TOTALGOODPARTS
FROM ROUGHER_PLC_DB
WHERE DateTime < @currentdttm
AND DateTime > dateadd(minute, -@inputMin, @currentdttm)
declare @MinHours TABLE(
S_NO int IDENTITY(1,1),
Date_Time datetime,
TOTALGOODPARTS_Min int,
hour_min int
)
declare @MaxHours TABLE(
S_NO int IDENTITY(1,1),
Date_Time datetime,
TOTALGOODPARTS_Max int,
hour_max int
)
BEGIN
BEGIN
INSERT INTO @MinHours
select TOP 1 DateTime,TOTALGOODPARTS,HOUR from ROUGHER_PLC_DB
where 1=1
AND DateTime < @currentdttm
AND DateTime > dateadd(minute, -@inputMin, @currentdttm)
order by DateTime asc
END
BEGIN
INSERT INTO @MaxHours
select TOP 1 DateTime,TOTALGOODPARTS,HOUR from ROUGHER_PLC_DB
where 1=1
AND DateTime < @currentdttm
AND DateTime > dateadd(minute, -@inputMin, @currentdttm)
order by DateTime desc
END
END
--Select * from @MinHours;
-- Select * from @MaxHours;
select MAX.Date_Time as MAX_TIME,MIN.Date_Time as MIN_TIME,MAX.TOTALGOODPARTS_Max - MIN.TOTALGOODPARTS_Min as GOOD_PARTS
from @MaxHours MAX
INNER JOIN @MinHours MIN
ON MAX.S_NO = MIN.S_NO
sorry, I am not getting.
Can you please guide how I can bind it and on Button.
you can find my screen in attachment. Template_View_values.zip (52.7 KB)