Пример #1
0
        private void mitSave_Click(object sender, RoutedEventArgs e)
        {
            //setting local variables
            string strDOTStatus;
            bool   blnFatalError;
            int    intRecordsReturned;

            try
            {
                strDOTStatus = txtDOTStatus.Text;
                if (strDOTStatus == "")
                {
                    TheMessagesClass.ErrorMessage("The DOT Status Was Not Entered");
                    return;
                }

                TheFindDOTStatusByStatusDataSet = TheVehicleInfoClass.FindDOTStatusByStatus(strDOTStatus);

                intRecordsReturned = TheFindDOTStatusByStatusDataSet.FindDOTStatusByStatus.Rows.Count;

                if (intRecordsReturned > 0)
                {
                    TheMessagesClass.InformationMessage("DOT Status Already Exists");
                    return;
                }

                blnFatalError = TheVehicleInfoClass.InsertDOTStatus(strDOTStatus);

                if (blnFatalError == true)
                {
                    TheMessagesClass.ErrorMessage("There Was a problem, Contact ID");
                    return;
                }

                txtDOTStatus.Text = "";
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Add DOT Status // Save Menu " + Ex.Message);

                TheMessagesClass.ErrorMessage(Ex.ToString());
            }
        }
Пример #2
0
        private void mitImportExcel_Click(object sender, RoutedEventArgs e)
        {
            Excel.Application xlDropOrder;
            Excel.Workbook    xlDropBook;
            Excel.Worksheet   xlDropSheet;
            Excel.Range       range;

            int    intColumnRange = 0;
            int    intCounter;
            int    intNumberOfRecords;
            string strVehicleNumber;
            int    intRecordsReturned;
            string strAssignedOffice;
            string strIMEI;
            int    intGPSStatusID;
            int    intDOTStatusID;
            string strDOTStatus;
            string strGPSStatus;

            try
            {
                TheImportVehiclesDataSet.importvehicles.Rows.Clear();

                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.FileName   = "Document";             // Default file name
                dlg.DefaultExt = ".xlsx";                // Default file extension
                dlg.Filter     = "Excel (.xlsx)|*.xlsx"; // 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;
                intColumnRange     = range.Columns.Count;

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

                    TheFindActiveVehicleMainShortVehicleNumberDataSet = TheVehicleMainClass.FindActiveVehicleMainShortVehicleNumber(strVehicleNumber);

                    intRecordsReturned = TheFindActiveVehicleMainShortVehicleNumberDataSet.FindActiveVehicleMainShortVehicleNumber.Rows.Count;

                    if (intRecordsReturned == 0)
                    {
                        strAssignedOffice = Convert.ToString((range.Cells[intCounter, 8] as Excel.Range).Value2).ToUpper();
                        strDOTStatus      = Convert.ToString((range.Cells[intCounter, 13] as Excel.Range).Value2).ToUpper();
                        strIMEI           = Convert.ToString((range.Cells[intCounter, 11] as Excel.Range).Value2).ToUpper();

                        MainWindow.gintEmployeeID = FindEmployeeID(strAssignedOffice);

                        if (MainWindow.gintEmployeeID < 1)
                        {
                            TheMessagesClass.ErrorMessage("Problems Find Assigned Office, Check the Spelling");

                            return;
                        }

                        TheFindDOTStatusByStatusDataSet = TheVehicleInfoClass.FindDOTStatusByStatus(strDOTStatus);

                        intRecordsReturned = TheFindDOTStatusByStatusDataSet.FindDOTStatusByStatus.Rows.Count;

                        if (intRecordsReturned < 1)
                        {
                            TheMessagesClass.ErrorMessage("DOT Status Was Not Found, Check Spelling");

                            return;
                        }

                        intDOTStatusID = TheFindDOTStatusByStatusDataSet.FindDOTStatusByStatus[0].DOTStatusID;

                        if (strIMEI.Length > 12)
                        {
                            strGPSStatus = "IN USE";
                        }
                        else
                        {
                            strGPSStatus = "NOT IN USE";
                        }

                        TheFindGPSStatusByStatusDataSet = TheVehicleInfoClass.FindGPSStatusByStatus(strGPSStatus);

                        intGPSStatusID = TheFindGPSStatusByStatusDataSet.FindGPSStatusByStatus[0].GPSStatusID;

                        ImportVehiclesDataSet.importvehiclesRow NewVehicleRow = TheImportVehiclesDataSet.importvehicles.NewimportvehiclesRow();

                        NewVehicleRow.AssignedOffice      = strAssignedOffice;
                        NewVehicleRow.EmployeeID          = MainWindow.gintEmployeeID;
                        NewVehicleRow.CDLRequired         = Convert.ToString((range.Cells[intCounter, 9] as Excel.Range).Value2).ToUpper();
                        NewVehicleRow.DOTStatus           = strDOTStatus;
                        NewVehicleRow.IMEI                = strIMEI;
                        NewVehicleRow.MedicalCardRequired = Convert.ToString((range.Cells[intCounter, 10] as Excel.Range).Value2).ToUpper();
                        NewVehicleRow.OdometerReading     = Convert.ToInt32(Convert.ToString((range.Cells[intCounter, 6] as Excel.Range).Value2));
                        NewVehicleRow.TamperTag           = Convert.ToString((range.Cells[intCounter, 12] as Excel.Range).Value2).ToUpper();
                        NewVehicleRow.VehicleMake         = Convert.ToString((range.Cells[intCounter, 3] as Excel.Range).Value2).ToUpper();
                        NewVehicleRow.VehicleModel        = Convert.ToString((range.Cells[intCounter, 4] as Excel.Range).Value2).ToUpper();
                        NewVehicleRow.VehicleNumber       = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2).ToUpper();
                        NewVehicleRow.VINNumber           = Convert.ToString((range.Cells[intCounter, 7] as Excel.Range).Value2).ToUpper();
                        NewVehicleRow.Year                = Convert.ToInt32(Convert.ToString((range.Cells[intCounter, 2] as Excel.Range).Value2));
                        NewVehicleRow.DOTStatusID         = intDOTStatusID;
                        NewVehicleRow.GPSStatusID         = intGPSStatusID;
                        NewVehicleRow.LicensePlate        = Convert.ToString((range.Cells[intCounter, 5] as Excel.Range).Value2).ToUpper();

                        TheImportVehiclesDataSet.importvehicles.Rows.Add(NewVehicleRow);
                    }
                }

                PleaseWait.Close();
                dgrResults.ItemsSource = TheImportVehiclesDataSet.importvehicles;
                mitProcess.IsEnabled   = true;
            }
            catch (Exception Ex)
            {
                TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Import Vehicles // Import Excel Menu Item " + Ex.Message);

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