Laptimes and sectors are now fixed

This commit is contained in:
2023-05-24 15:01:41 +02:00
parent f356d90c35
commit e8028528e0
2 changed files with 13 additions and 12 deletions

View File

@@ -47,6 +47,7 @@ namespace Test_Merge
List<(int LapTime, int Lap)> lapsInfos = Storage.GetDriverLaptimes(driverName, 5);
int id = 0;
foreach ((int LapTime, int Lap) lapData in lapsInfos)
{
Button newButton = new Button();
@@ -55,6 +56,8 @@ namespace Test_Merge
newButton.Text = Reader.ConvertMsToTime(lapData.LapTime);
newButton.Size = labelDimensions;
newButton.Click += form1.btnLapTime_Click;
newButton.Location = new Point(0, id * newButton.Height);
id++;
}
}
}
@@ -152,16 +155,13 @@ namespace Test_Merge
{
List<int> sectors = Storage.GetSectorsFromLapTime(driverName, Lap);
string message = "Lap time infos" + Environment.NewLine;
if (sectors.Count() == 3)
{
message += LapTime + Environment.NewLine;
if (sectors.Count > 0)
message += "Sector 1 : " + Reader.ConvertMsToTime(sectors[0]) + Environment.NewLine;
if (sectors.Count > 1)
message += "Sector 2 : " + Reader.ConvertMsToTime(sectors[1]) + Environment.NewLine;
if (sectors.Count > 2)
message += "Sector 3 : " + Reader.ConvertMsToTime(sectors[2]) + Environment.NewLine;
}
if (sectors.Count > 0)
message += "Sector 1 : " + Reader.ConvertMsToTime(sectors[0]) + Environment.NewLine;
if (sectors.Count > 1)
message += "Sector 2 : " + Reader.ConvertMsToTime(sectors[1]) + Environment.NewLine;
if (sectors.Count > 2)
message += "Sector 3 : " + Reader.ConvertMsToTime(sectors[2]) + Environment.NewLine;
MessageBox.Show(message);
}
public void DisplayLiveRanking(Panel pnl, Form1 form1)

View File

@@ -120,7 +120,7 @@ namespace Test_Merge
public List<int> GetSectorsFromLapTime(string driverName,int lap)
{
int driverId = GetDriverID(driverName);
string selectQuery = "SELECT Sector1,Sector2,Sector3 FROM Stats WHERE DriverID = @driverID AND Lap = @Lap";
string selectQuery = "SELECT Sector1,Sector2,Sector3 FROM Stats WHERE DriverID = @driverID AND Lap = @lap";
List<int> result = new List<int>();
using (var command = new SQLiteCommand(selectQuery, Connection))
{
@@ -131,8 +131,9 @@ namespace Test_Merge
SQLiteDataReader reader = command.ExecuteReader();
while (reader.Read())
{
int sectorTime = reader.GetInt32(0);
result.Add(sectorTime);
result.Add(reader.GetInt32(0));
result.Add(reader.GetInt32(1));
result.Add(reader.GetInt32(2));
}
}
catch