private void Window_Loaded(object sender, RoutedEventArgs e) { //local variables int intInvoiceID; string strProblemUpdates = ""; int intCounter; int intNumberOfRecords; string strVendorName; string strVehicleNumber; try { TheFindVehicleMainProblemByProblemIDDataSet = TheVehicleProblemClass.FindVehicleMainProblemByProblemID(MainWindow.gintProblemID); txtProblemID.Text = Convert.ToString(TheFindVehicleMainProblemByProblemIDDataSet.FindVehicleMainProblemByProblemID[0].ProblemID); txtTransactionDate.Text = Convert.ToString(TheFindVehicleMainProblemByProblemIDDataSet.FindVehicleMainProblemByProblemID[0].TransactionDAte); txtProblem.Text = TheFindVehicleMainProblemByProblemIDDataSet.FindVehicleMainProblemByProblemID[0].Problem; txtProblemStatus.Text = TheFindVehicleMainProblemByProblemIDDataSet.FindVehicleMainProblemByProblemID[0].ProblemStatus; strVehicleNumber = TheFindVehicleMainProblemByProblemIDDataSet.FindVehicleMainProblemByProblemID[0].VehicleNumber; TheFindActiveVehicleByVehicleNumberDataSet = TheVehicleMainClass.FindActiveVehicleMainByVehicleNumber(strVehicleNumber); MainWindow.gintVehicleID = TheFindActiveVehicleByVehicleNumberDataSet.FindActiveVehicleMainByVehicleNumber[0].VehicleID; strVendorName = TheFindVehicleMainProblemByProblemIDDataSet.FindVehicleMainProblemByProblemID[0].VendorName; TheFindVendorByVendorNameDataSet = TheVendorsClass.FindVendorByVendorName(strVendorName); MainWindow.gintVendorID = TheFindVendorByVendorNameDataSet.FindVendorByVendorName[0].VendorID; if (TheFindVehicleMainProblemByProblemIDDataSet.FindVehicleMainProblemByProblemID[0].IsProblemResolutionNull() == false) { txtProblemResolution.Text = TheFindVehicleMainProblemByProblemIDDataSet.FindVehicleMainProblemByProblemID[0].ProblemResolution; } if (TheFindVehicleMainProblemByProblemIDDataSet.FindVehicleMainProblemByProblemID[0].IsInvoiceIDNull() == false) { intInvoiceID = TheFindVehicleMainProblemByProblemIDDataSet.FindVehicleMainProblemByProblemID[0].InvoiceID; if (intInvoiceID > 999) { TheFindVehicleInvoiceByInvoiceIDDataSet = TheVehicleProblemDocumentClass.FindVehicleInvoiceByInvoiceID(intInvoiceID); txtInvoiceAmount.Text = Convert.ToString(TheFindVehicleInvoiceByInvoiceIDDataSet.FindVehicleInvoiceByInvoiceID[0].InvoiceAmount); txtInvoicePath.Text = TheFindVehicleInvoiceByInvoiceIDDataSet.FindVehicleInvoiceByInvoiceID[0].InvoicePath; } } TheFindVehicleMainProblemUpdateByProblemIDDataSet = TheVehicleProblemClass.FindVehicleMainProblemUpdateByProblemID(MainWindow.gintProblemID); intNumberOfRecords = TheFindVehicleMainProblemUpdateByProblemIDDataSet.FindVehicleMainProblemUpdateByProblemID.Rows.Count; if (intNumberOfRecords > 0) { for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++) { strProblemUpdates += Convert.ToString(TheFindVehicleMainProblemUpdateByProblemIDDataSet.FindVehicleMainProblemUpdateByProblemID[intCounter].TransactionDate); strProblemUpdates += " "; strProblemUpdates += TheFindVehicleMainProblemUpdateByProblemIDDataSet.FindVehicleMainProblemUpdateByProblemID[intCounter].ProblemUpdate; strProblemUpdates += "\n\n"; } } txtCurrentUpdates.Text = strProblemUpdates; TheFindVenicleProblemDocumentationByProblemIDDataSet = TheVehicleProblemDocumentClass.FindVehicleProblemDocumentationByProblemID(MainWindow.gintProblemID); dgrProblemDocumentation.ItemsSource = TheFindVenicleProblemDocumentationByProblemIDDataSet.FindVehicleProblemDocumentationByProblemID; } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Edit Selected Vehicle Problem // Window Loaded " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); } }
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 strVendorName; string strContactName = ""; string strPhoneNumber = ""; int intRecordsReturned; try { TheVendorImportDataSet.vendorimport.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 = 1; intCounter <= intNumberOfRecords; intCounter++) { strVendorName = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2); strVendorName = strVendorName.ToUpper(); TheFindVendorByVendorNameDataSet = TheVendorsClass.FindVendorByVendorName(strVendorName); intRecordsReturned = TheFindVendorByVendorNameDataSet.FindVendorByVendorName.Rows.Count; if (intRecordsReturned == 0) { strContactName = (range.Cells[intCounter, 2] as Excel.Range).Value2.ToUpper(); strPhoneNumber = (range.Cells[intCounter, 3] as Excel.Range).Value2.ToUpper(); VendorImportDataSet.vendorimportRow NewVendorRow = TheVendorImportDataSet.vendorimport.NewvendorimportRow(); NewVendorRow.ContactName = strContactName; NewVendorRow.PhoneNumber = strPhoneNumber; NewVendorRow.VendorName = strVendorName; TheVendorImportDataSet.vendorimport.Rows.Add(NewVendorRow); } } PleaseWait.Close(); dgrResults.ItemsSource = TheVendorImportDataSet.vendorimport; mitProcess.IsEnabled = true; } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Import Vendors // Import Excel Menu Item " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); } }