Thanks mubles0
-- ============================================= -- Author: Rob Reid -- Create date: 04-JAN-2011 -- Description: Ensure prices are valid in terms of betfairs price ranges /* -- examples SELECT dbo.udf_BETFAIR_CHECK_PRICE(11.82) 11.50 SELECT dbo.udf_BETFAIR_CHECK_PRICE(115.81) 110.00 SELECT dbo.udf_BETFAIR_CHECK_PRICE(2.47) 2.46 SELECT dbo.udf_BETFAIR_CHECK_PRICE(1.49) 1.49 */ -- ============================================= ALTER FUNCTION [dbo].[udf_BETFAIR_CHECK_PRICE] ( @Price decimal(10,2) ) RETURNS decimal(10,2) AS BEGIN DECLARE @Remainder decimal(10,2) -- check whether our price is within each betfair range and check for any remainder -- usinga MOD function. If there is no remainder the price is already valid and if -- there is a remainder we can deduct it from our price to create a valid value SELECT @Remainder = CASE WHEN @Price BETWEEN 100 AND 1000 THEN @Price % 10 WHEN @Price BETWEEN 50 AND 99 THEN @Price % 5 WHEN @Price BETWEEN 30 AND 49 THEN @Price % 2 WHEN @Price BETWEEN 20 AND 29 THEN @Price % 1 WHEN @Price BETWEEN 10 AND 19.99 THEN @Price % 0.5 WHEN @Price BETWEEN 6 AND 9.99 THEN @Price % 0.2 WHEN @Price BETWEEN 4 AND 5.99 THEN @Price % 0.1 WHEN @Price BETWEEN 3 AND 3.99 THEN @Price % 0.05 WHEN @Price BETWEEN 2 AND 2.99 THEN @Price % 0.02 ELSE 0 END -- if there is any remainder we deduct it from our price to create a valid price IF @Remainder > 0 SELECT @Price = @Price - @Remainder RETURN @Price END
Private Sub DGView_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DGView.CellFormatting
Dim d As Date
If e.ColumnIndex = RaceTimeColNo Then 'Race time column is being updated
d = e.Value
e.Value = d.ToString("H:mm") 'Convert DateTime value to 24-hour time value
End If
End Sub
Comment