private bool RunVehicleExceptionReport(DateTime datStartDate) { bool blnFatalError = false; int intCounter; int intNumberOfRecords; int intVehicleID; int intRecordsReturned; DateTime datEndDate; string strFirstNamed = ""; string strLastName = ""; try { TheVehicleExceptionDataSet.vehicleexception.Rows.Clear(); datEndDate = TheDateSearchClass.AddingDays(datStartDate, 1); TheFindActiveVehicleMainDataSet = TheVehicleMainClass.FindActiveVehicleMain(); intNumberOfRecords = TheFindActiveVehicleMainDataSet.FindActiveVehicleMain.Rows.Count - 1; for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++) { intVehicleID = TheFindActiveVehicleMainDataSet.FindActiveVehicleMain[intCounter].VehicleID; TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet = TheInspectionClass.FindDailyVehicleInspectionByVehicleIDAndDateRange(intVehicleID, datStartDate, datEndDate); intRecordsReturned = TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet.FindDailyVehicleInspectionsByVehicleIDAndDateRange.Rows.Count; if (intRecordsReturned == 0) { TheFindVehicleInYardByVehicleIDAndDateRangeDataSet = TheVehicleInYardClass.FindVehiclesInYardByVehicleIDAndDateRange(intVehicleID, datStartDate, datEndDate); intRecordsReturned = TheFindVehicleInYardByVehicleIDAndDateRangeDataSet.FindVehiclesInYardByVehicleIDAndDateRange.Rows.Count; if (intRecordsReturned == 0) { TheFindVehicleInShopByVehicleIDDataSet = TheVehicleInShopClass.FindVehiclesInShopByVehicleID(intVehicleID); intRecordsReturned = TheFindVehicleInShopByVehicleIDDataSet.FindVehiclesInShopByVehicleID.Rows.Count; if (intRecordsReturned == 0) { TheFindcurrentAssignedVehicleMainByVehicleIDDataSet = TheVehicleAssignmentClass.FindCurrentAssignedVehicleMainByVehicleID(intVehicleID); intRecordsReturned = TheFindcurrentAssignedVehicleMainByVehicleIDDataSet.FindCurrentAssignedVehicleMainByVehicleID.Rows.Count; if (intRecordsReturned == 0) { strLastName = "NOT ASSIGNED"; strFirstNamed = "NOT ASSIGNED"; } else { strLastName = TheFindcurrentAssignedVehicleMainByVehicleIDDataSet.FindCurrentAssignedVehicleMainByVehicleID[0].LastName; strFirstNamed = TheFindcurrentAssignedVehicleMainByVehicleIDDataSet.FindCurrentAssignedVehicleMainByVehicleID[0].FirstName; } VehicleExceptionDataSet.vehicleexceptionRow NewVehicleRow = TheVehicleExceptionDataSet.vehicleexception.NewvehicleexceptionRow(); NewVehicleRow.AssignedOffice = TheFindActiveVehicleMainDataSet.FindActiveVehicleMain[intCounter].AssignedOffice; NewVehicleRow.FirstName = strFirstNamed; NewVehicleRow.LastName = strLastName; NewVehicleRow.VehicleID = intVehicleID; NewVehicleRow.VehicleNumber = TheFindActiveVehicleMainDataSet.FindActiveVehicleMain[intCounter].VehicleNumber; TheVehicleExceptionDataSet.vehicleexception.Rows.Add(NewVehicleRow); } } } } } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Automate Vehicle Reports // Run Vehicle Exception Report " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); blnFatalError = true; } return(blnFatalError); }
private void mitGenerateReport_Click(object sender, RoutedEventArgs e) { int intCounter; int intNumberOfRecords; int intVehicleID; int intRecordsReturned; DateTime datStartDate = DateTime.Now; DateTime datEndDate; string strFirstNamed = ""; string strLastName = ""; try { TheVehicleExceptionDataSet.vehicleexception.Rows.Clear(); datStartDate = TheDateSearchClass.RemoveTime(datStartDate); datEndDate = TheDateSearchClass.AddingDays(datStartDate, 1); TheFindActiveVehicleMainDataSet = TheVehicleMainClass.FindActiveVehicleMain(); intNumberOfRecords = TheFindActiveVehicleMainDataSet.FindActiveVehicleMain.Rows.Count - 1; for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++) { intVehicleID = TheFindActiveVehicleMainDataSet.FindActiveVehicleMain[intCounter].VehicleID; TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSete = TheInspectionClass.FindDailyVehicleInspectionByVehicleIDAndDateRange(intVehicleID, datStartDate, datEndDate); intRecordsReturned = TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSete.FindDailyVehicleInspectionsByVehicleIDAndDateRange.Rows.Count; if (intRecordsReturned == 0) { TheFindVehicleInYardByVehicleIDAndDateRangeDataSet = TheVehicleInYardClass.FindVehiclesInYardByVehicleIDAndDateRange(intVehicleID, datStartDate, datEndDate); intRecordsReturned = TheFindVehicleInYardByVehicleIDAndDateRangeDataSet.FindVehiclesInYardByVehicleIDAndDateRange.Rows.Count; if (intRecordsReturned == 0) { TheFindVehicleMainInShopByVehicleIDDataSet = TheVehicleInShopClass.FindVehicleMainInShopByVehicleID(intVehicleID); intRecordsReturned = TheFindVehicleMainInShopByVehicleIDDataSet.FindVehicleMainInShopByVehicleID.Rows.Count; if (intRecordsReturned == 0) { TheFindcurrentAssignedVehicleMainByVehicleIDDataSet = TheVehicleAssignmentClass.FindCurrentAssignedVehicleMainByVehicleID(intVehicleID); intRecordsReturned = TheFindcurrentAssignedVehicleMainByVehicleIDDataSet.FindCurrentAssignedVehicleMainByVehicleID.Rows.Count; if (intRecordsReturned == 0) { strLastName = "NOT ASSIGNED"; strFirstNamed = "NOT ASSIGNED"; } else { strLastName = TheFindcurrentAssignedVehicleMainByVehicleIDDataSet.FindCurrentAssignedVehicleMainByVehicleID[0].LastName; strFirstNamed = TheFindcurrentAssignedVehicleMainByVehicleIDDataSet.FindCurrentAssignedVehicleMainByVehicleID[0].FirstName; } VehicleExceptionDataSet.vehicleexceptionRow NewVehicleRow = TheVehicleExceptionDataSet.vehicleexception.NewvehicleexceptionRow(); NewVehicleRow.AssignedOffice = TheFindActiveVehicleMainDataSet.FindActiveVehicleMain[intCounter].AssignedOffice; NewVehicleRow.FirstName = strFirstNamed; NewVehicleRow.LastName = strLastName; NewVehicleRow.VehicleID = intVehicleID; NewVehicleRow.VehicleNumber = TheFindActiveVehicleMainDataSet.FindActiveVehicleMain[intCounter].VehicleNumber; TheVehicleExceptionDataSet.vehicleexception.Rows.Add(NewVehicleRow); } } } } dgrResults.ItemsSource = TheVehicleExceptionDataSet.vehicleexception; } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Vehicle Exception Report // Generate The Report Menu Item " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); } }