Exemple #1
0
        public void BindPastPerformance(BrisPastPerformance pp, double diffInSeconds)
        {
            InitializeGrid(_gridRawTimes);
            AddRowToGrid(_gridRawTimes, "Leader", pp.LeadersFirstCall, pp.LeadersSecondCall, pp.LeadersThirdCall, pp.LeadersFinalCall);
            AddRowToGrid(_gridRawTimes, "This", pp.GetFraction(FractionCall.Level.First).FormatedTime, pp.GetFraction(FractionCall.Level.Second).FormatedTime, pp.GetFraction(FractionCall.Level.Stretch).FormatedTime, pp.GetFraction(FractionCall.Level.Final).FormatedTime);

            double d1 = (-1)*(diffInSeconds * pp.FirstFractionInYards) / pp.DistanceInYards;
            double d2 = (-1) * (diffInSeconds * pp.SecondFractionInYards) / pp.DistanceInYards;
            double d3 = (-1) * (diffInSeconds * pp.ThirdFractionInYards) / pp.DistanceInYards;
            double d4 = (-1)*diffInSeconds;

            InitializeGrid(_gridAdjustedTimes);
            AddRowToGrid(_gridAdjustedTimes, "Leader", pp.AdjustedLeadersFirstCall(d1), pp.AdjustedLeadersSecondCall(d2), pp.AdjustedLeadersThirdCall(d3), pp.AdjustedLeadersFinalCall(d4));

            double thisAdjHorseCall1 = pp.GetFraction(FractionCall.Level.First).Time + d1;
            double thisAdjHorseCall2 = pp.GetFraction(FractionCall.Level.Second).Time + d2;
            double thisAdjHorseCall3 = pp.GetFraction(FractionCall.Level.Stretch).Time + d3;
            double thisAdjHorseFinal = pp.GetFraction(FractionCall.Level.Final).Time + d4;

            string t1 = Utilities.ConvertTimeToMMSSFifth(thisAdjHorseCall1.ToString());
            string t2 = Utilities.ConvertTimeToMMSSFifth(thisAdjHorseCall2.ToString());
            string t3 = Utilities.ConvertTimeToMMSSFifth(thisAdjHorseCall3.ToString());
            string t4 = Utilities.ConvertTimeToMMSSFifth(thisAdjHorseFinal.ToString());

            AddRowToGrid(_gridAdjustedTimes, "This", t1, t2, t3, t4);
        }
Exemple #2
0
        public RaceChart(BrisPastPerformance pp)
        {
            string trackCode = pp.TrackCode;
            string date = string.Format("{0}{1:00}{2:00}",pp.Date.Year,pp.Date.Month,pp.Date.Day);
            int raceNumber = Convert.ToInt32(pp.RaceNumber);

            LoadFromDb(trackCode,date,raceNumber);
        }
        private ShowFractionsForTheDayForm(DateTime date, string trackCode, string horseName, int raceNumber, BrisPastPerformance pp)
        {
            _pp = pp;
            _date = date;
            _trackCode = trackCode;
            _horseName = horseName;
            _raceNumber = raceNumber;

            InitializeComponent();
        }
Exemple #4
0
 private RaceInfo(BrisPastPerformance pp)
 {
     TrackCode = pp.TrackCode;
     Date = string.Format("{0:0000}{1:00}{2:00}", pp.Date.Year, pp.Date.Month, pp.Date.Day);
     RaceNumber = Convert.ToInt32(pp.RaceNumber);
     GoldenFigure = (int)pp.GoldenFigureForTheWinner;
     GoldenPaceFigure = (int) pp.GoldenPaceFigureForTheRace;
     Surface = pp.Surface;
     Distance = pp.DistanceInYards;
     TrackCondition = pp.TrackCondition;
 }
Exemple #5
0
 public CynthiaParsForm(string trackCode, int distance, BrisPastPerformance pp)
 {
     _trackCode = trackCode;
     _distance = distance;
     _pp = pp;
     _avgDailyVariant = GetAverageDailyVariantFromDb();
     _dailyVariant = _pp.TrackVariant;
     _adjustedWinersTime = _pp.WinnersFinalTime - DiffInSeconds;
     _adjustedThisHorseTime = _pp.ThisHorseFinalTime - DiffInSeconds;
     InitializeComponent();
 }
Exemple #6
0
 public static int AvgVariant(BrisPastPerformance pp)
 {
     SqlDataAdapter dataAdapter = new SqlDataAdapter(SQLLoadAvgVariant(pp), Hogar.DbTools.DbUtilities.SqlConnection);
     DataSet dataSet = new DataSet();
     dataAdapter.Fill(dataSet);
     int var = 0;
     foreach (DataRow dr in dataSet.Tables[0].Rows)
     {
         var = (int)dr["AVERAGE_VARIANT"];
     }
     return var;
 }
 public static void DisplayModal(BrisPastPerformance pp)
 {
     DateTime date = pp.Date;
     string trackCode = pp.TrackCode;
     string horseName = pp.Parent.Name;
     int raceNumber = Convert.ToInt32(pp.RaceNumber);
     if (!DateOfRace.RaceExistsInDb(trackCode, date, raceNumber))
     {
         string caption = string.Format("{0}, {1}", trackCode, Utilities.GetFullDateString(Utilities.GetDateInYYYYMMDD(date)));
         MessageBox.Show("Sorry, race does not exist in the data base!", caption);
     }
     else
     {
         var form = new ShowFractionsForTheDayForm(date, trackCode, horseName, raceNumber, pp);
         form.ShowDialog();
     }
 }
        void CalculateAdjustedProjections(CynthiaPar cp0, CynthiaPar cp1, BrisPastPerformance pp)
        {
            double firstCallProjectionDiff = FirstCallAdjustment(cp0, cp1);
            double secondCallProjectionDiff = SecondCallAdjustment(cp0, cp1);
            double finalCallProjectionDiff = FinalCallAdjustment(cp0, cp1);

            BrisPastPerformance.FractionCallsToUseForCynthia f = pp.FractionsToUseForCynthia;

            double firstCallProjection = firstCallProjectionDiff + f.FirstCall;
            double secondCallProjection = secondCallProjectionDiff + f.SecondCall;
            double finalCallProjection = finalCallProjectionDiff + f.FinalCall;
            double variantDiff = (pp.AvgVariant-pp.TrackVariant) / 10.0;

            _txtboxFirstCallProjectionAdjustedByVariant.Text = Utilities.ConvertTimeToMMSSFifth(firstCallProjection + (variantDiff * 1.0 / 4.0));
            _txtboxSecondCallProjectionAdjustedByVariant.Text = Utilities.ConvertTimeToMMSSFifth(secondCallProjection + (variantDiff * 2.0 / 3.0));
            _txtboxFinalCallProjectionAdjustedByVariant.Text = Utilities.ConvertTimeToMMSSFifth(finalCallProjection + (variantDiff * 4.0 / 4.0));
        }
        private void CalculateProjections(CynthiaPar cp0, CynthiaPar cp1, BrisPastPerformance pp)
        {
            double firstCallProjectionDiff = FirstCallAdjustment(cp0, cp1);
            double secondCallProjectionDiff = SecondCallAdjustment(cp0, cp1);
            double finalCallProjectionDiff = FinalCallAdjustment(cp0, cp1);

             BrisPastPerformance.FractionCallsToUseForCynthia f = pp.FractionsToUseForCynthia;

            double firstCallProjection = firstCallProjectionDiff + f.FirstCall;
            double secondCallProjection = secondCallProjectionDiff + f.SecondCall;
            double finalCallProjection = finalCallProjectionDiff + f.FinalCall;

            _txtboxFirstCallProjection.Text = Utilities.ConvertTimeToMMSSFifth(firstCallProjection);

            _txtboxSecondCallProjection.Text = Utilities.ConvertTimeToMMSSFifth(secondCallProjection);

            _txtboxFinalCallProjection.Text = Utilities.ConvertTimeToMMSSFifth(finalCallProjection);
        }
 private static void ShowRaceChart(BrisPastPerformance pp)
 {
     string trackCode = pp.TrackCode;
     string raceNumber = pp.RaceNumber;
     int year = pp.Date.Year;
     int month = pp.Date.Month;
     int day = pp.Date.Day;
     DailyCard dc = DailyCard.Load(trackCode, year, month, day);
     if (null != dc && dc.ExistsInDb)
     {
         var f = new RaceChartForm(dc.GetRaceFromRaceNumber(Convert.ToInt32(raceNumber)).RaceID);
         f.ShowDialog();
     }
     else
     {
         var f = new FirstSecondAndThridInfoForm(pp);
         f.ShowDialog();
     }
 }
        public void Bind(BrisPastPerformance pp)
        {
            string trackCode = RaceTracks.GetNameFromTrackCode(pp.TrackCode);

            string raceInfo = string.Format("Race# {0} {1} {2}", pp.RaceNumber, trackCode, pp.DateAsString);

            _labelRaceInfo.Text = raceInfo;
            _hyperlinkFont = new Font(_grid.DefaultCellStyle.Font, FontStyle.Underline);

            _pp = pp;
            RaceChart rc = new RaceChart(pp);
            _grid.Columns.Clear();
            _grid.Columns.Add("PROGRAM_NUMBER", "PROGRAM_NUMBER");
            _grid.Columns.Add("ODDS", "ODDS");
            _grid.Columns.Add("HORSE_NAME", "HORSE_NAME");

            Race r = _pp.Parent.CorrespondingHorse.Parent;
            foreach (RaceChartLine rcl in rc.Results)
            {
                int row = _grid.Rows.Add();
                _grid[2, row].Value = rcl.HorseName;
                SetCellStyleToHyperlink(2, row);
                Color backColor = Color.White;
                if (r.ContainsHorse(rcl.HorseName))
                {
                    backColor = Color.LightPink;
                    string horseNumber = r.GetProgramNumberFromHorse(rcl.HorseName);
                    if (horseNumber.Length > 0)
                    {
                        Horse h = r.GetHorseByProgramNumber(horseNumber);
                        _grid[0, row].Value = horseNumber;
                        _grid[1, row].Value = string.Format("{0:0.00}",h.RealTimeOdds);
                    }
                }
                _grid.Rows[row].DefaultCellStyle.BackColor = backColor;
                _grid.Rows[row].DefaultCellStyle.SelectionBackColor = backColor;

                _grid.Rows[row].DefaultCellStyle.ForeColor = Color.Black;
                _grid.Rows[row].DefaultCellStyle.SelectionForeColor = Color.Black;
            }
        }
Exemple #12
0
        internal Sartin(BrisPastPerformance pp)
        {
            _firstFraction = pp.SpeedDuringFirstFraction * Utilities.FEET_IN_A_YEARD;
            _secondFraction = pp.SpeedDuringSecondFraction * Utilities.FEET_IN_A_YEARD;
            _finalFraction = pp.SpeedDuringFinalFraction * Utilities.FEET_IN_A_YEARD;
            _earlyPace = pp.SpeedFromStartToSecondCall * Utilities.FEET_IN_A_YEARD;

            int distance = pp.DistanceInYards;

            if (distance <= 0)
            {
                _distanceType = DistanceType.Invalid;
            }
            else if (distance <= Utilities.YARDS_IN_A_FURLONG * 7)
            {
                _distanceType = DistanceType.Sprint;
            }
            else
            {
                _distanceType = DistanceType.Route;
            }
        }
        bool ShowCynthiaParsToGrid(DataGridView g, CynthiaPar cp, BrisPastPerformance pp)
        {
            bool cynthiaParWasChanged = false;

            g.Columns.Clear();
            g.Columns.Add("Track", "Track");
            g.Columns.Add("Class", "Class");
            g.Columns.Add("Dist", "Dist");
            g.Columns.Add("Surf", "Surf");
            g.Columns.Add("About", "About");
            g.Columns.Add("AvVar", "AvVar");
            g.Columns.Add("1stCall", "1stCall");
            g.Columns.Add("2ndCall", "2ndCall");
            g.Columns.Add("Final", "Final");

            if (cp.IsValid)
            {

                int i = g.Rows.Add();

                g[0, i].Value = cp.TrackCode;
                g[1, i].Value = cp.CynthiaClassification;
                g[2, i].Value = cp.Distance;
                g[3, i].Value = cp.Surface;
                g[4, i].Value = cp.AboutFlag;
                g[6, i].Value = Utilities.ConvertTimeToMMSSFifth(cp.FirstCall);
                g[7, i].Value = Utilities.ConvertTimeToMMSSFifth(cp.MidCall);
                g[8, i].Value = Utilities.ConvertTimeToMMSSFifth(cp.FinalCall);

            }
            else
            {
                string msg = string.Format("Sorry Cynthia par not found for \n {0} \n You want to add it manually? ", cp.ToString());

                if (MessageBox.Show(msg, "Not found", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    try
                    {
                        AddCynthiaParManuallyForm f = new AddCynthiaParManuallyForm(cp);
                       f.ShowDialog();
                       if (null != pp)
                       {
                           pp.Parent.ReloadCynthiaParForTheRace();

                       }
                       else
                       {
                           return ShowCynthiaParsToGrid(_gridTodaysRacePars, _horse.Parent.CynthiaParsForTheRace, null);

                       }

                       cynthiaParWasChanged = true;

                    }
                    catch(Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }

            return cynthiaParWasChanged;
        }
        private void AddPastPerformancesToGrid(BrisPastPerformance pp, int rowIndex, ref int daysBefore)
        {
            SetRowColors(pp);

            _grid.Rows[rowIndex].DefaultCellStyle.Font = GetFontToUse(pp);

            DataGridViewCellCollection cells = _grid.Rows[rowIndex].Cells;
            cells[_daysAgoColumnIndex].Value = pp.DaysSinceThatRace;
            cells[_daysOffColumnIndex].Value = pp.DaysSinceLastRace;
            cells[_trackConditionColumnIndex].Value = pp.TrackCondition;
            cells[_trackCodeColumnIndex].Value = pp.TrackCode.ToUpper();
            cells[_classificationColumnIndex].Value = pp.RaceClassification;
            cells[_distanceColumnIndex].Value = Utilities.ConvertYardsToMilesOrFurlongsAbreviation(pp.DistanceInYards);
            cells[_firstFractionColumnIndex].Value = pp.FirstFractionPosition;
            cells[_secondFractionColumnIndex].Value = pp.SecondFractionPosition;
            cells[_finalPositionColumnIndex].Value = pp.FinalPosition;
            cells[_brisSpeedFigureIndex].Value = pp.BrisSpeedRating;
            //cells[_goldenPaceFigureForThisHorseIndex].Value = pp.GoldenPaceFigureForThisHorse;
            //cells[_goldenPaceFigureIndex].Value = pp.GoldenPaceFigureForTheRace;
            //cells[_goldenFigureForWinnerOfTheRaceColumnIndex].Value = pp.GoldenFigureForTheWinner;
            //cells[_goldenFigureForThisHorseColumnIndex].Value = pp.GoldenFigureForThisHorse;

            PaintBrisSpeedFigureCell(cells[_brisSpeedFigureIndex]);
            //PaintGoldenPaceFigureCell(cells[_goldenPaceFigureForThisHorseIndex]);
            //PaintGoldenPaceFigureCell(cells[_goldenPaceFigureIndex]);
            //PaintGoldenFigureCell(cells[_goldenFigureForWinnerOfTheRaceColumnIndex]);
            //PaintGoldenFigureCell(cells[_goldenFigureForThisHorseColumnIndex]);

            daysBefore += pp.DaysSinceLastRace;

            Color backColor = pp.IsATurfRace ? Color.LightGreen : Color.White;
            Color foreColor = Color.Black;

            if (!pp.CynthiaParForTheRace.IsValid)
            {
                backColor = Color.LightGray;
                foreColor = Color.Black;
            }

            cells[_trackConditionColumnIndex].Style.BackColor = backColor;
            cells[_trackConditionColumnIndex].Style.SelectionBackColor = backColor;

            cells[_trackConditionColumnIndex].Style.ForeColor = foreColor;
            cells[_trackConditionColumnIndex].Style.SelectionBackColor = foreColor;

            cells[0].Style.BackColor = Color.White;
            cells[0].Style.SelectionBackColor = Color.White;
            cells[0].Style.ForeColor = Color.White;
            cells[0].Style.SelectionForeColor = Color.White;

            _grid.Rows[rowIndex].Tag = pp;

            UpdateSelectedAsRunningLineCell(rowIndex);
        }
Exemple #15
0
        private RaceInfo GetRaceInfo(BrisPastPerformance pp)
        {
            var newRaceInfo = RaceInfo.Make(pp);
            newRaceInfo.AddPastPerformance(pp);

            var existingRaceInfo = _races.Find(ri => ri.ToString() == newRaceInfo.ToString());

            if (null != existingRaceInfo)
            {
                existingRaceInfo.AddPastPerformance(pp);
                return existingRaceInfo;
            }

            else
            {
                _races.Add(newRaceInfo);
                return newRaceInfo;
            }
        }
Exemple #16
0
        private List<BrisPastPerformance> MakePastPerformances()
        {
            _pp = new List<BrisPastPerformance>();
            _pp.Clear();
            for (int i = 0; i < FieldIndex.MAX_PAST_PERFORMANCES; ++i)
            {
                if(null != _parsableText)
                {
                    var p = new BrisPastPerformance(_parsableText, i, this);

                    if (p.IsValid)
                    {
                        _pp.Add(p);
                    }
                }
                else
                {
                    var p = new BrisPastPerformance(_tokenizer, i, this);

                    if (p.IsValid)
                    {
                        _pp.Add(p);
                    }
                }

            }

            return _pp;
        }
 private Font GetFontToUse(BrisPastPerformance pp)
 {
     Font f = pp.IsARoute ? _boldFont : _normalFont;
     if (pp.DaysSinceLastRace >= Utilities.LAYOFF_DAYS)
     {
         f = new Font(f, FontStyle.Underline);
     }
     return f;
 }
 private void SetRowColors(BrisPastPerformance pp)
 {
     if (pp.DaysSinceLastRace == 0)
     {
         _background = Color.White;
     }
     else if (pp.DaysSinceLastRace >= Utilities.LAYOFF_DAYS)
     {
         _background = _background == Color.White ? Color.LightGray : Color.White;
     }
 }
Exemple #19
0
 public void AddPastPerformance(BrisPastPerformance pp)
 {
     _pastPerformance.Add(pp);
 }
 public FirstSecondAndThridInfoForm(BrisPastPerformance pp)
 {
     _pp = pp;
     InitializeComponent();
 }
Exemple #21
0
 public static RaceInfo Make(BrisPastPerformance pp)
 {
     return new RaceInfo(pp);
 }
Exemple #22
0
        internal static StarterInfo CreateFromBrisPastPerformance(BrisPastPerformance pp)
        {
            if (null == pp || pp.GoldenFigureForThisHorse == -999)
                return null;

            var si = new StarterInfo { Previous = null, Next = null };

            si.HorseName = pp.Parent.CorrespondingHorse.Name;
            si.RaceId = -9999;
            si.TrackCode = pp.Parent.CorrespondingHorse.Parent.Parent.TrackCode;
            si.RacingDate = Utilities.GetDateInYYYYMMDD(pp.Date);
            si.FinishPosition = Convert.ToInt32(pp.FinalPosition);
            si.Odds = pp.OddsAsDouble;
            si.GoldenFigure = (int)pp.GoldenFigureForThisHorse;

            if (si.GoldenFigure < 0)
            {
                si.GoldenFigure = 1;
            }

            si.WinnersGoldenFigure = (int)pp.GoldenFigureForTheWinner;

            si.TrackCondition = pp.TrackCondition;
            si.Distance = pp.DistanceInYards;

            int scp;
            int.TryParse(pp.SecondCallPosition, out scp);
            si.SecondCallPosition = scp;

            return si;
        }
Exemple #23
0
        private static string SQLLoadAvgVariant(BrisPastPerformance pp)
        {
            BrisPastPerformance.SurfaceType st = pp.SurfaceAndDistanceType;

                string surface = "";
                switch (st)
                {
                    case BrisPastPerformance.SurfaceType.Dirt:
                        surface = "D";
                        break;
                    case BrisPastPerformance.SurfaceType.Turf:
                        surface = "T";
                        break;
                    case BrisPastPerformance.SurfaceType.InnerTurf:
                        surface = "I";
                        break;
                    case BrisPastPerformance.SurfaceType.InnerDirt:
                        surface = "N";
                        break;
                    default:
                        surface = "X";
                        break;

                }

                string aboutFlag = "";

                if (pp.AboutDistanceFlag)
                {
                    aboutFlag = "A";
                }
                else
                {
                    aboutFlag = "";
                }

                string sprintOrRoute = pp.DistanceInYards >= Utilities.YARDS_IN_A_FURLONG * 8 ? "R" : "S";

                string trackCondition = pp.TrackCondition.Trim();

                if (trackCondition.ToUpper() == "SY")
                {
                    trackCondition = "sly";
                }
                else if (trackCondition.ToUpper() == "FT")
                {
                    trackCondition = "fst";
                }
                else if (trackCondition.ToUpper() == "TF")
                {
                    trackCondition = "gd";
                }

                string sql = string.Format(@"SELECT TRACK_CONDITION, AVERAGE_VARIANT
                                             FROM CYNTHIA_AVERAGE_VARIANTS
                                            WHERE
                                                TRACK_CODE = '{0}'
                                            AND SURFACE = '{1}'
                                            AND SPRINT_OR_ROUTE = '{2}'
                                            AND ABOUT_FLAG = '{3}'
                                            AND TRACK_CONDITION = '{4}'",
                                    CynthiasAbrForTrackCode(pp.TrackCode),
                                     surface,
                                     sprintOrRoute,
                                     aboutFlag,
                                     trackCondition);

                return sql;
        }