예제 #1
0
        public FindDailyVehicleInspectionByDateRangeDataSet FindDailyVehicleInspectionByDateRange(DateTime datStartDate, DateTime datEndDate)
        {
            try
            {
                aFindDailyVehicleInspectionByDateRangeDataSet      = new FindDailyVehicleInspectionByDateRangeDataSet();
                aFindDailyVehicleInspectionByDateRangeTableAdapter = new FindDailyVehicleInspectionByDateRangeDataSetTableAdapters.FindDailyVehicleInspectionByDateRangeTableAdapter();
                aFindDailyVehicleInspectionByDateRangeTableAdapter.Fill(aFindDailyVehicleInspectionByDateRangeDataSet.FindDailyVehicleInspectionByDateRange, datStartDate, datEndDate);
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Inspections Class // Find Daily Vehicle Inspection by Date Range " + Ex.Message);
            }

            return(aFindDailyVehicleInspectionByDateRangeDataSet);
        }
        private bool RunDailyVehicleInspectionReport(DateTime datStartDate)
        {
            //setting local varaibles
            DateTime datLimitDate;
            int      intCounter;
            int      intNumberOfRecords;
            int      intRecordsReturned;
            int      intInspectionID;
            bool     blnFatalError = false;

            try
            {
                TheDailyVehicleInspectionReportDataSet.dailyinspection.Rows.Clear();
                datLimitDate = TheDataSearchClass.AddingDays(datStartDate, 1);

                TheFindDailyVehicleInspectionByDateRangeDataSet = TheInspectionClass.FindDailyVehicleInspectionByDateRange(datStartDate, datLimitDate);

                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;

                        TheDailyVehicleInspectionReportDataSet.dailyinspection.Rows.Add(NewInspectionRow);
                    }
                }
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Automated Vehicle Reports // Run Daily Vehicle Inspection Report " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());

                blnFatalError = true;
            }

            return(blnFatalError);
        }
        private void TodaysInspections()
        {
            //setting local varaibles
            DateTime datTodaysDate = DateTime.Now;
            DateTime datLimitDate;
            int      intCounter;
            int      intNumberOfRecords;
            int      intRecordsReturned;
            int      intInspectionID;

            try
            {
                TheDailyVehicleInspectionReportDataSet.dailyinspection.Rows.Clear();
                rdoDateRange.IsChecked = true;
                datTodaysDate          = TheDataSearchClass.RemoveTime(datTodaysDate);
                datLimitDate           = TheDataSearchClass.AddingDays(datTodaysDate, 1);

                TheFindDailyVehicleInspectionByDateRangeDataSet = TheInspectionClass.FindDailyVehicleInspectionByDateRange(datTodaysDate, datLimitDate);

                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);
                    }
                }

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

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
        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();
        }