예제 #1
0
        public FindActiveVehicleMainSortedDataSet FindActiveVehicleMainSorted()
        {
            try
            {
                aFindActiveVehicleMainSortedDataSet      = new FindActiveVehicleMainSortedDataSet();
                aFindActiveVehicleMainSortedTableAdapter = new FindActiveVehicleMainSortedDataSetTableAdapters.FindActiveVehicleMainSortedTableAdapter();
                aFindActiveVehicleMainSortedTableAdapter.Fill(aFindActiveVehicleMainSortedDataSet.FindActiveVehicleMainSorted);
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Video Main Class // Find Active Vehicle Main Sorted " + Ex.Message);
            }

            return(aFindActiveVehicleMainSortedDataSet);
        }
        private void expCreateReport_Expanded(object sender, RoutedEventArgs e)
        {
            //setting local variables
            DateTime datStartDate;
            DateTime datEndDate;
            DateTime datTransactionDate;
            DateTime datLimitingDate;
            int      intCounter;
            int      intNumberOfRecords;
            int      intRecordReturned;
            int      intVehicleID;

            PleaseWait PleaseWait = new PleaseWait();

            PleaseWait.Show();

            try
            {
                TheVehicleUsageDataSet.vehicleusage.Rows.Clear();
                expCreateReport.IsExpanded = false;

                TheFindActiveVehicleMainSortedDataSet = TheVehicleMainClass.FindActiveVehicleMainSorted();

                intNumberOfRecords = TheFindActiveVehicleMainSortedDataSet.FindActiveVehicleMainSorted.Rows.Count - 1;

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    VehicleUsageDataSet.vehicleusageRow NewVehicleRow = TheVehicleUsageDataSet.vehicleusage.NewvehicleusageRow();

                    NewVehicleRow.VehicleID      = TheFindActiveVehicleMainSortedDataSet.FindActiveVehicleMainSorted[intCounter].VehicleID;
                    NewVehicleRow.VehicleNumber  = TheFindActiveVehicleMainSortedDataSet.FindActiveVehicleMainSorted[intCounter].VehicleNumber;
                    NewVehicleRow.AssignedOffice = TheFindActiveVehicleMainSortedDataSet.FindActiveVehicleMainSorted[intCounter].AssignedOffice;
                    NewVehicleRow.TimesInYard    = 0;
                    NewVehicleRow.TimesUnknown   = 0;
                    NewVehicleRow.TimesDriven    = 0;

                    TheVehicleUsageDataSet.vehicleusage.Rows.Add(NewVehicleRow);
                }

                datEndDate   = DateTime.Now;
                datEndDate   = TheDateSearchClass.RemoveTime(datEndDate);
                datStartDate = TheDateSearchClass.SubtractingDays(datEndDate, 120);

                datTransactionDate = datStartDate;
                datLimitingDate    = TheDateSearchClass.AddingDays(datTransactionDate, 1);
                intNumberOfRecords = TheVehicleUsageDataSet.vehicleusage.Rows.Count - 1;

                while (datLimitingDate <= datEndDate)
                {
                    if (datTransactionDate.DayOfWeek != DayOfWeek.Saturday)
                    {
                        if (datTransactionDate.DayOfWeek != DayOfWeek.Sunday)
                        {
                            for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                            {
                                intVehicleID = TheVehicleUsageDataSet.vehicleusage[intCounter].VehicleID;

                                TheFindGEOFenceByVehicleIDDataSet = TheGEOFenceClass.FindGEOFenceByVehicleID(intVehicleID, datTransactionDate, datLimitingDate);

                                intRecordReturned = TheFindGEOFenceByVehicleIDDataSet.FindGEOFenceByVehicleID.Rows.Count;

                                if (intRecordReturned > 0)
                                {
                                    TheVehicleUsageDataSet.vehicleusage[intCounter].TimesDriven++;
                                }
                                else
                                {
                                    TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet = TheInspectionsClass.FindDailyVehicleInspectionByVehicleIDAndDateRange(intVehicleID, datTransactionDate, datLimitingDate);

                                    intRecordReturned = TheFindDailyVehicleInspectionByVehicleIDAndDateRangeDataSet.FindDailyVehicleInspectionsByVehicleIDAndDateRange.Rows.Count;

                                    if (intRecordReturned > 0)
                                    {
                                        TheVehicleUsageDataSet.vehicleusage[intCounter].TimesDriven++;
                                    }
                                    else
                                    {
                                        TheFindVehicleInYardByVehicleIDAndDateRangeDataSet = TheVehicleInYardClass.FindVehiclesInYardByVehicleIDAndDateRange(intVehicleID, datTransactionDate, datLimitingDate);

                                        intRecordReturned = TheFindVehicleInYardByVehicleIDAndDateRangeDataSet.FindVehiclesInYardByVehicleIDAndDateRange.Rows.Count;

                                        if (intRecordReturned > 0)
                                        {
                                            TheVehicleUsageDataSet.vehicleusage[intCounter].TimesInYard++;
                                        }
                                        else
                                        {
                                            TheVehicleUsageDataSet.vehicleusage[intCounter].TimesUnknown++;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    datTransactionDate = TheDateSearchClass.AddingDays(datTransactionDate, 1);
                    datLimitingDate    = TheDateSearchClass.AddingDays(datLimitingDate, 1);
                }

                dgrResults.ItemsSource = TheVehicleUsageDataSet.vehicleusage;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Vehicle Usage Report // Create Report Expander " + Ex.Message);

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

            PleaseWait.Close();
        }
예제 #3
0
        private void mitImportExcel_Click(object sender, RoutedEventArgs e)
        {
            bool blnIsNotInteger = false;

            Excel.Application xlDropOrder;
            Excel.Workbook    xlDropBook;
            Excel.Worksheet   xlDropSheet;
            Excel.Range       range;

            string strInformation = "";
            int    intColumnRange = 0;
            int    intCounter;
            int    intNumberOfRecords;
            string strVehicleNumber;
            int    intVehicleID;
            int    intSecondCounter;
            int    intSecondNumberOfRecords;

            try
            {
                TheDOTAuditDataSet.dotaudit.Rows.Clear();

                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.FileName = "Document"; // Default file name
                // dlg.DefaultExt = ".csv"; // Default file extension
                //dlg.Filter = "Excel (.csv)|*.csv"; // Filter files by extension

                // Show open file dialog box
                Nullable <bool> result = dlg.ShowDialog();

                // Process open file dialog box results
                if (result == true)
                {
                    // Open document
                    string filename = dlg.FileName;
                }

                PleaseWait PleaseWait = new PleaseWait();
                PleaseWait.Show();

                xlDropOrder = new Excel.Application();
                xlDropBook  = xlDropOrder.Workbooks.Open(dlg.FileName, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                xlDropSheet = (Excel.Worksheet)xlDropOrder.Worksheets.get_Item(1);

                range = xlDropSheet.UsedRange;
                intNumberOfRecords = range.Rows.Count - 1;
                intColumnRange     = range.Columns.Count;

                for (intCounter = 2; intCounter <= intNumberOfRecords; intCounter++)
                {
                    strInformation = Convert.ToString((range.Cells[intCounter, 2] as Excel.Range).Value2);

                    strInformation  = strInformation.Substring(4, 4);
                    blnIsNotInteger = TheDataValidationClass.VerifyIntegerData(strInformation);
                    if (blnIsNotInteger == false)
                    {
                        DOTAuditDataSet.dotauditRow NewVehicleRow = TheDOTAuditDataSet.dotaudit.NewdotauditRow();

                        strVehicleNumber = strInformation;
                        TheFindActiveVehicleBVehicleNumberDataSet = TheVehicleMainClass.FindActiveVehicleMainByVehicleNumber(strVehicleNumber);
                        intVehicleID                = TheFindActiveVehicleBVehicleNumberDataSet.FindActiveVehicleMainByVehicleNumber[0].VehicleID;
                        NewVehicleRow.VehicleID     = intVehicleID;
                        NewVehicleRow.VehicleNumber = strVehicleNumber;
                        NewVehicleRow.VIN           = TheFindActiveVehicleBVehicleNumberDataSet.FindActiveVehicleMainByVehicleNumber[0].VINNumber;

                        TheDOTAuditDataSet.dotaudit.Rows.Add(NewVehicleRow);
                    }
                }

                ThefindActiveVehicleMainSortedDataSet = TheVehicleMainClass.FindActiveVehicleMainSorted();

                intNumberOfRecords = ThefindActiveVehicleMainSortedDataSet.FindActiveVehicleMainSorted.Rows.Count - 1;

                intSecondNumberOfRecords = TheDOTAuditDataSet.dotaudit.Rows.Count - 1;

                for (intCounter = 0; intCounter <= intNumberOfRecords; intCounter++)
                {
                    intVehicleID = ThefindActiveVehicleMainSortedDataSet.FindActiveVehicleMainSorted[intCounter].VehicleID;

                    for (intSecondCounter = 0; intSecondCounter <= intSecondNumberOfRecords; intSecondCounter++)
                    {
                        if (intVehicleID == TheDOTAuditDataSet.dotaudit[intSecondCounter].VehicleID)
                        {
                            DOTAuditDataSet.dotauditRow NewVehicleRow = TheSortedDOTAuditDataSete.dotaudit.NewdotauditRow();

                            NewVehicleRow.VehicleNumber = TheDOTAuditDataSet.dotaudit[intSecondCounter].VehicleNumber;
                            NewVehicleRow.VehicleID     = intVehicleID;
                            NewVehicleRow.VIN           = TheDOTAuditDataSet.dotaudit[intSecondCounter].VIN;

                            TheSortedDOTAuditDataSete.dotaudit.Rows.Add(NewVehicleRow);
                        }
                    }
                }

                PleaseWait.Close();
                dgrResults.ItemsSource = TheSortedDOTAuditDataSete.dotaudit;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // DOT Audit Report // Import Excel Menu Item " + Ex.Message);

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