Exemplo n.º 1
0
        public FindDailyVehicleInspectionsByEmployeeIDAndDateRangeDataSet FindDailyVehicleInspectionByEmployeeIDAndDateRange(int intEmployeeID, DateTime datStartDate, DateTime datEndDate)
        {
            try
            {
                aFindDailyVehicleInspectionsByEmployeeIDAndDateRangeDataSet      = new FindDailyVehicleInspectionsByEmployeeIDAndDateRangeDataSet();
                aFindDailyVehicleInspectionsByEmployeeIDAndDateRangeTableAdapter = new FindDailyVehicleInspectionsByEmployeeIDAndDateRangeDataSetTableAdapters.FindDailyVehicleInspectionsByEmployeeIDAndDateRangeTableAdapter();
                aFindDailyVehicleInspectionsByEmployeeIDAndDateRangeTableAdapter.Fill(aFindDailyVehicleInspectionsByEmployeeIDAndDateRangeDataSet.FindDailyVehicleInspectionsByEmployeeIDAndDateRange, intEmployeeID, datStartDate, datEndDate);
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Inspection Class // Find Daily Vehicle Inspectioon By Employee ID and Date Range " + Ex.Message);
            }

            return(aFindDailyVehicleInspectionsByEmployeeIDAndDateRangeDataSet);
        }
        private void mitGenerateReport_Click(object sender, RoutedEventArgs e)
        {
            //setting local variables
            bool   blnThereIsAProblem = false;
            bool   blnFatalError      = false;
            string strValueForValidation;
            string strErrorMessage = "";
            int    intCounter;
            int    intNumberOfRecords;
            int    intInspectionID;
            int    intRecordsReturned;
            string strVehicleNumber;

            PleaseWait PleaseWait = new PleaseWait();

            PleaseWait.Show();

            try
            {
                TheDailyVehicleInspectionReportDataSet.dailyinspection.Rows.Clear();

                strValueForValidation = txtStartDate.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDateData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "Start Date is not a Date\n";
                }
                else
                {
                    gdatStartDate = Convert.ToDateTime(strValueForValidation);
                }
                strValueForValidation = txtEndDate.Text;
                blnThereIsAProblem    = TheDataValidationClass.VerifyDateData(strValueForValidation);
                if (blnThereIsAProblem == true)
                {
                    blnFatalError    = true;
                    strErrorMessage += "End Date is not a Date\n";
                }
                else
                {
                    gdatEndDate = Convert.ToDateTime(strValueForValidation);
                    gdatEndDate = TheDataSearchClass.RemoveTime(gdatEndDate);
                    gdatEndDate = TheDataSearchClass.AddingDays(gdatEndDate, 1);
                }
                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage(strErrorMessage);
                    PleaseWait.Close();
                    return;
                }
                else
                {
                    blnFatalError = TheDataValidationClass.verifyDateRange(gdatStartDate, gdatEndDate);

                    if (blnFatalError == true)
                    {
                        TheMessagesClass.ErrorMessage("Start Date is After the End Date");
                        PleaseWait.Close();
                        return;
                    }
                }

                if (gstrReportType == "DATE RANGE")
                {
                    TheFindDailyVehicleInspectionByDateRangeDataSet = TheInspectionClass.FindDailyVehicleInspectionByDateRange(gdatStartDate, gdatEndDate);

                    intNumberOfRecords = TheFindDailyVehicleInspectionByDateRangeDataSet.FindDailyVehicleInspectionByDateRange.Rows.Count - 1;

                    if (intNumberOfRecords > -1)
                    {
                        for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                        {
                            DailyVehicleInspectionReportDataSet.dailyinspectionRow NewInspectionRow = TheDailyVehicleInspectionReportDataSet.dailyinspection.NewdailyinspectionRow();

                            intInspectionID = TheFindDailyVehicleInspectionByDateRangeDataSet.FindDailyVehicleInspectionByDateRange[intCounter].TransactionID;

                            TheFindVehicleInspectionProblemByInsepctionIDDataSet = TheInspectionClass.FindVehicleInspectionProblemsbyInspectionID(intInspectionID);

                            intRecordsReturned = TheFindVehicleInspectionProblemByInsepctionIDDataSet.FindVehicleInspectionProblemsByInspectionID.Rows.Count;

                            if (intRecordsReturned == 0)
                            {
                                NewInspectionRow.InspectionNotes = "NO NOTES REPORTED";
                            }
                            else
                            {
                                NewInspectionRow.InspectionNotes = TheFindVehicleInspectionProblemByInsepctionIDDataSet.FindVehicleInspectionProblemsByInspectionID[0].InspectionNotes;
                            }

                            NewInspectionRow.FirstName        = TheFindDailyVehicleInspectionByDateRangeDataSet.FindDailyVehicleInspectionByDateRange[intCounter].FirstName;
                            NewInspectionRow.InspectionDate   = TheFindDailyVehicleInspectionByDateRangeDataSet.FindDailyVehicleInspectionByDateRange[intCounter].InspectionDate;
                            NewInspectionRow.InspectionID     = intInspectionID;
                            NewInspectionRow.InspectionStatus = TheFindDailyVehicleInspectionByDateRangeDataSet.FindDailyVehicleInspectionByDateRange[intCounter].InspectionStatus;
                            NewInspectionRow.LastName         = TheFindDailyVehicleInspectionByDateRangeDataSet.FindDailyVehicleInspectionByDateRange[intCounter].LastName;
                            NewInspectionRow.OdometerReading  = TheFindDailyVehicleInspectionByDateRangeDataSet.FindDailyVehicleInspectionByDateRange[intCounter].OdometerReading;
                            NewInspectionRow.VehicleID        = TheFindDailyVehicleInspectionByDateRangeDataSet.FindDailyVehicleInspectionByDateRange[intCounter].VehicleID;
                            NewInspectionRow.VehicleNumber    = TheFindDailyVehicleInspectionByDateRangeDataSet.FindDailyVehicleInspectionByDateRange[intCounter].VehicleNumber;
                            NewInspectionRow.HomeOffice       = TheFindDailyVehicleInspectionByDateRangeDataSet.FindDailyVehicleInspectionByDateRange[intCounter].AssignedOffice;

                            TheDailyVehicleInspectionReportDataSet.dailyinspection.Rows.Add(NewInspectionRow);
                        }
                    }
                }
                else if (gstrReportType == "EMPLOYEE")
                {
                    TheFindDailyVehicleInspectionByEmployeeIDAndDateRangeDataSet = TheInspectionClass.FindDailyVehicleInspectionByEmployeeIDAndDateRange(gintEmployeeID, gdatStartDate, gdatEndDate);

                    intNumberOfRecords = TheFindDailyVehicleInspectionByEmployeeIDAndDateRangeDataSet.FindDailyVehicleInspectionsByEmployeeIDAndDateRange.Rows.Count - 1;

                    if (intNumberOfRecords > -1)
                    {
                        for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                        {
                            DailyVehicleInspectionReportDataSet.dailyinspectionRow NewInspectionRow = TheDailyVehicleInspectionReportDataSet.dailyinspection.NewdailyinspectionRow();

                            intInspectionID = TheFindDailyVehicleInspectionByEmployeeIDAndDateRangeDataSet.FindDailyVehicleInspectionsByEmployeeIDAndDateRange[intCounter].TransactionID;

                            TheFindVehicleInspectionProblemByInsepctionIDDataSet = TheInspectionClass.FindVehicleInspectionProblemsbyInspectionID(intInspectionID);

                            intRecordsReturned = TheFindVehicleInspectionProblemByInsepctionIDDataSet.FindVehicleInspectionProblemsByInspectionID.Rows.Count;

                            if (intRecordsReturned == 0)
                            {
                                NewInspectionRow.InspectionNotes = "NO NOTES REPORTED";
                            }
                            else
                            {
                                NewInspectionRow.InspectionNotes = TheFindVehicleInspectionProblemByInsepctionIDDataSet.FindVehicleInspectionProblemsByInspectionID[0].InspectionNotes;
                            }

                            NewInspectionRow.FirstName        = TheFindDailyVehicleInspectionByEmployeeIDAndDateRangeDataSet.FindDailyVehicleInspectionsByEmployeeIDAndDateRange[intCounter].FirstName;
                            NewInspectionRow.InspectionDate   = TheFindDailyVehicleInspectionByEmployeeIDAndDateRangeDataSet.FindDailyVehicleInspectionsByEmployeeIDAndDateRange[intCounter].InspectionDate;
                            NewInspectionRow.InspectionID     = intInspectionID;
                            NewInspectionRow.InspectionStatus = TheFindDailyVehicleInspectionByEmployeeIDAndDateRangeDataSet.FindDailyVehicleInspectionsByEmployeeIDAndDateRange[intCounter].InspectionStatus;
                            NewInspectionRow.LastName         = TheFindDailyVehicleInspectionByEmployeeIDAndDateRangeDataSet.FindDailyVehicleInspectionsByEmployeeIDAndDateRange[intCounter].LastName;
                            NewInspectionRow.OdometerReading  = TheFindDailyVehicleInspectionByEmployeeIDAndDateRangeDataSet.FindDailyVehicleInspectionsByEmployeeIDAndDateRange[intCounter].OdometerReading;
                            NewInspectionRow.VehicleID        = TheFindDailyVehicleInspectionByEmployeeIDAndDateRangeDataSet.FindDailyVehicleInspectionsByEmployeeIDAndDateRange[intCounter].VehicleID;
                            NewInspectionRow.VehicleNumber    = TheFindDailyVehicleInspectionByEmployeeIDAndDateRangeDataSet.FindDailyVehicleInspectionsByEmployeeIDAndDateRange[intCounter].VehicleNumber;
                            NewInspectionRow.HomeOffice       = TheFindDailyVehicleInspectionByEmployeeIDAndDateRangeDataSet.FindDailyVehicleInspectionsByEmployeeIDAndDateRange[intCounter].AssignedOffice;

                            TheDailyVehicleInspectionReportDataSet.dailyinspection.Rows.Add(NewInspectionRow);
                        }
                    }
                }
                else if (gstrReportType == "VEHICLE NUMBER")
                {
                    strVehicleNumber = txtSearchInfo.Text;
                    if (strVehicleNumber == "")
                    {
                        TheMessagesClass.ErrorMessage("Vehicle Number Not Entered");
                        PleaseWait.Close();
                        return;
                    }

                    TheFindActiveVehicleMainByVehicleNumberDataSet = TheVehicleMainClass.FindActiveVehicleMainByVehicleNumber(strVehicleNumber);

                    intRecordsReturned = TheFindActiveVehicleMainByVehicleNumberDataSet.FindActiveVehicleMainByVehicleNumber.Rows.Count;

                    if (intRecordsReturned == 0)
                    {
                        TheMessagesClass.ErrorMessage("Vehicle Numbered Does Not Exist");
                        PleaseWait.Close();
                        return;
                    }
                    else
                    {
                        gintVehicleID = TheFindActiveVehicleMainByVehicleNumberDataSet.FindActiveVehicleMainByVehicleNumber[0].VehicleID;
                    }

                    TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet = TheInspectionClass.FindDailyVehicleInspectionByVehicleIDAndDateRange(gintVehicleID, gdatStartDate, gdatEndDate);

                    intNumberOfRecords = TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet.FindDailyVehicleInspectionsByVehicleIDAndDateRange.Rows.Count - 1;

                    if (intNumberOfRecords > -1)
                    {
                        for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                        {
                            DailyVehicleInspectionReportDataSet.dailyinspectionRow NewInspectionRow = TheDailyVehicleInspectionReportDataSet.dailyinspection.NewdailyinspectionRow();

                            intInspectionID = TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet.FindDailyVehicleInspectionsByVehicleIDAndDateRange[intCounter].TransactionID;

                            TheFindVehicleInspectionProblemByInsepctionIDDataSet = TheInspectionClass.FindVehicleInspectionProblemsbyInspectionID(intInspectionID);

                            intRecordsReturned = TheFindVehicleInspectionProblemByInsepctionIDDataSet.FindVehicleInspectionProblemsByInspectionID.Rows.Count;

                            if (intRecordsReturned == 0)
                            {
                                NewInspectionRow.InspectionNotes = "NO NOTES REPORTED";
                            }
                            else
                            {
                                NewInspectionRow.InspectionNotes = TheFindVehicleInspectionProblemByInsepctionIDDataSet.FindVehicleInspectionProblemsByInspectionID[0].InspectionNotes;
                            }

                            NewInspectionRow.FirstName        = TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet.FindDailyVehicleInspectionsByVehicleIDAndDateRange[intCounter].FirstName;
                            NewInspectionRow.InspectionDate   = TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet.FindDailyVehicleInspectionsByVehicleIDAndDateRange[intCounter].InspectionDate;
                            NewInspectionRow.InspectionID     = intInspectionID;
                            NewInspectionRow.InspectionStatus = TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet.FindDailyVehicleInspectionsByVehicleIDAndDateRange[intCounter].InspectionStatus;
                            NewInspectionRow.LastName         = TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet.FindDailyVehicleInspectionsByVehicleIDAndDateRange[intCounter].LastName;
                            NewInspectionRow.OdometerReading  = TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet.FindDailyVehicleInspectionsByVehicleIDAndDateRange[intCounter].OdometerReading;
                            NewInspectionRow.VehicleID        = TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet.FindDailyVehicleInspectionsByVehicleIDAndDateRange[intCounter].VehicleID;
                            NewInspectionRow.VehicleNumber    = TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet.FindDailyVehicleInspectionsByVehicleIDAndDateRange[intCounter].VehicleNumber;
                            NewInspectionRow.HomeOffice       = TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet.FindDailyVehicleInspectionsByVehicleIDAndDateRange[intCounter].AssignedOffice;

                            TheDailyVehicleInspectionReportDataSet.dailyinspection.Rows.Add(NewInspectionRow);
                        }
                    }
                }

                dgrResults.ItemsSource = TheDailyVehicleInspectionReportDataSet.dailyinspection;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Daily Vehicle Inspection Report // Generate Report Menu Item " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }

            PleaseWait.Close();
        }