本文整理汇总了C#中ResultSet.FindRow方法的典型用法代码示例。如果您正苦于以下问题:C# ResultSet.FindRow方法的具体用法?C# ResultSet.FindRow怎么用?C# ResultSet.FindRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResultSet
的用法示例。
在下文中一共展示了ResultSet.FindRow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTimetableDetails
// Used to get a dictionary of timetable details from the database
public Dictionary<string, TimetableDetails> GetTimetableDetails(DateTime date)
{
string query = string.Format("Date = '{0}'", string.Format("{0:MM-dd-yy}", date));
ResultSet timetableResults = new ResultSet(GetDataReader("[BusTripTable]", query)); // Search the database for all details relating to the specified date
CloseConnection();
Dictionary<string, TimetableDetails> details = new Dictionary<string, TimetableDetails>();
string[] timeSlots = { "8.30 - 10.15", "2.00 - 3.45 ", "10.45 - 1.45", "4.00 - 7.00 " };
for(int i = 0; i < timeSlots.Length; i++){ // Go through each possible timeslot and add the details about it to the details Dictionary
TimetableDetails timetableDetails = new TimetableDetails();
int row = timetableResults.FindRow<string>(2, timeSlots[i]); // Find the row which stores the data for this time slot
if (row == -1) // If there is no-one registered for this time slot use the small bus
{
timetableDetails.busUsed = "9 Person";
timetableDetails.seatsLeft = 24;
details.Add(timeSlots[i], timetableDetails);
continue;
}
if(timetableResults.GetData<int>(4, row) < 9) // If there are less than 9 people registered for this bus use the small bus
{
timetableDetails.busUsed = "9 Person";
}
else if (timetableResults.GetData<int>(4, row) < 17) // If there are >= 9 and < 17 people use the bigger bus
{
timetableDetails.busUsed = "17 Person";
}
else // If there are >= 17 people use both busses
{
timetableDetails.busUsed = "Both";
}
timetableDetails.seatsLeft = 24 - timetableResults.GetData<int>(4, row); // calculate the seats left now that we have found the number of seats
details.Add(timeSlots[i], timetableDetails); // Add these details to the dictionary
} // End of the loop through all of the time slots
return details;
}