private void Window_Loaded(object sender, RoutedEventArgs e) { int intNumberOfRecords; int intCounter; string strAsseetCategory; int intSelectedIndex; try { gblnUploaded = false; TheFindSortedToolCategoryDataSet = TheToolCategoryClass.FindSortedToolCategory(); cboAssetCategory.Items.Add("Select Category"); intNumberOfRecords = TheFindSortedToolCategoryDataSet.FindSortedToolCategory.Rows.Count; for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++) { cboAssetCategory.Items.Add(TheFindSortedToolCategoryDataSet.FindSortedToolCategory[intCounter].ToolCategory); } cboAssetCategory.SelectedIndex = 0; TheFindWaspAssetByAssetIDDataSet = TheAssetClass.FindWaspAssetByAssetID(MainWindow.gintAssetID); txtAssetID.Text = Convert.ToString(MainWindow.gintAssetID); txtDescription.Text = TheFindWaspAssetByAssetIDDataSet.FindWaspAssetByAssetID[0].AssetDescription; txtBJCAssetID.Text = TheFindWaspAssetByAssetIDDataSet.FindWaspAssetByAssetID[0].BJCAssetID; strAsseetCategory = TheFindWaspAssetByAssetIDDataSet.FindWaspAssetByAssetID[0].AssetCategory; for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++) { if (strAsseetCategory == TheFindSortedToolCategoryDataSet.FindSortedToolCategory[intCounter].ToolCategory) { cboAssetCategory.SelectedIndex = intCounter + 1; } } txtSite.Text = TheFindWaspAssetByAssetIDDataSet.FindWaspAssetByAssetID[0].AssetSite; txtLocation.Text = TheFindWaspAssetByAssetIDDataSet.FindWaspAssetByAssetID[0].AssetLocation; txtWarehouseID.Text = Convert.ToString(TheFindWaspAssetByAssetIDDataSet.FindWaspAssetByAssetID[0].WarehouseID); txtDate.Text = Convert.ToString(TheFindWaspAssetByAssetIDDataSet.FindWaspAssetByAssetID[0].TransactionDate); txtSerialNo.Text = TheFindWaspAssetByAssetIDDataSet.FindWaspAssetByAssetID[0].SerialNumber; txtManufacturer.Text = TheFindWaspAssetByAssetIDDataSet.FindWaspAssetByAssetID[0].Manufacturer; txtModel.Text = TheFindWaspAssetByAssetIDDataSet.FindWaspAssetByAssetID[0].Model; TheEmployeeDateEntryClass.InsertIntoEmployeeDateEntry(MainWindow.TheVerifyLogonDataSet.VerifyLogon[0].EmployeeID, "New Blue Jay ERP // Edit Wasp Asset"); gblnUploaded = true; gblnNewCategory = false; } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Edit Wasp Asset // Window Loaded Method " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); } }
private void expImportExcel_Expanded(object sender, RoutedEventArgs e) { Excel.Application xlDropOrder; Excel.Workbook xlDropBook; Excel.Worksheet xlDropSheet; Excel.Range range; int intColumnRange = 0; int intCounter; int intNumberOfRecords; int intAssetID; string strAssetID; string strAssetDescription; string strAssetType; string strSite; string strLocation; string strSerialNumber; string strManufacturer; string strModel; int intRecordsReturned; bool blnItemFound; int intWarehouseID; PleaseWait PleaseWait = new PleaseWait(); PleaseWait.Show(); try { expImportExcel.IsExpanded = false; TheImportWASPITAssetsDataSet.importassets.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; } 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++) { blnItemFound = false; strAssetID = Convert.ToString((range.Cells[intCounter, 1] as Excel.Range).Value2).ToUpper(); intAssetID = Convert.ToInt32(strAssetID); strAssetDescription = Convert.ToString((range.Cells[intCounter, 2] as Excel.Range).Value2).ToUpper(); strAssetType = Convert.ToString((range.Cells[intCounter, 3] as Excel.Range).Value2).ToUpper(); strSite = Convert.ToString((range.Cells[intCounter, 5] as Excel.Range).Value2).ToUpper(); strLocation = Convert.ToString((range.Cells[intCounter, 6] as Excel.Range).Value2).ToUpper(); strSerialNumber = Convert.ToString((range.Cells[intCounter, 13] as Excel.Range).Value2).ToUpper(); strManufacturer = Convert.ToString((range.Cells[intCounter, 15] as Excel.Range).Value2).ToUpper(); strModel = Convert.ToString((range.Cells[intCounter, 16] as Excel.Range).Value2).ToUpper(); if (strSite == "GROVEPORT") { strSite = "CBUS-GROVEPORT"; } TheFindWarehouseByWarehouseNameDataSet = TheEmployeeClass.FindWarehouseByWarehouseName(strSite); intWarehouseID = TheFindWarehouseByWarehouseNameDataSet.FindWarehouseByWarehouseName[0].EmployeeID; TheFindWASPAssetByAssetIDDataSet = TheAssetClass.FindWaspAssetByAssetID(intAssetID); intRecordsReturned = TheFindWASPAssetByAssetIDDataSet.FindWaspAssetByAssetID.Rows.Count; if (intRecordsReturned > 0) { blnItemFound = true; } else if (intRecordsReturned < 1) { TheFindWaspAssetsBySerialNumberDataSet = TheAssetClass.FindWaspAssetsBySerialNumber(strSerialNumber); intRecordsReturned = TheFindWaspAssetsBySerialNumberDataSet.FindWaspAssetsBySerialNumber.Rows.Count; if (intRecordsReturned > 0) { blnItemFound = true; } } if (blnItemFound == false) { ImportWASPITAssetsDataSet.importassetsRow NewAssetRow = TheImportWASPITAssetsDataSet.importassets.NewimportassetsRow(); NewAssetRow.AssetDescription = strAssetDescription; NewAssetRow.AssetID = intAssetID; NewAssetRow.AssetType = strAssetType; NewAssetRow.Location = strLocation; NewAssetRow.Manufacturer = strManufacturer; NewAssetRow.Model = strModel; NewAssetRow.SerialNumber = strSerialNumber; NewAssetRow.Site = strSite; NewAssetRow.WarehouseID = intWarehouseID; TheImportWASPITAssetsDataSet.importassets.Rows.Add(NewAssetRow); } } dgrITAssets.ItemsSource = TheImportWASPITAssetsDataSet.importassets; } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Import Wasp IT Assets // Import Excel " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); } PleaseWait.Close(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { int intCounter; int intNumberOfRecords; int intSelectedIndex = 0; string strSite; string strLocation; try { cboSelectLocation.Items.Clear(); cboSelectLocation.Items.Add("Select Location"); cboSelectLocation.SelectedIndex = 0; cboSelectSite.Items.Clear(); cboSelectSite.Items.Add("Select Site"); TheFindWarehousesDataSet = TheEmployeeClass.FindWarehouses(); intNumberOfRecords = TheFindWarehousesDataSet.FindWarehouses.Rows.Count; for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++) { cboSelectSite.Items.Add(TheFindWarehousesDataSet.FindWarehouses[intCounter].FirstName); } cboSelectSite.SelectedIndex = 0; TheFindWaspAssetByAssetIDDataSet = TheAssetClass.FindWaspAssetByAssetID(MainWindow.gintAssetID); txtAssetID.Text = Convert.ToString(MainWindow.gintAssetID); strSite = TheFindWaspAssetByAssetIDDataSet.FindWaspAssetByAssetID[0].AssetSite; gstrSite = strSite; if (strSite == "GROVEPORT") { strSite = "CBUS-GROVEPORT"; } strLocation = TheFindWaspAssetByAssetIDDataSet.FindWaspAssetByAssetID[0].AssetLocation; intNumberOfRecords = TheFindWarehousesDataSet.FindWarehouses.Rows.Count; for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++) { if (strSite == TheFindWarehousesDataSet.FindWarehouses[intCounter].FirstName) { intSelectedIndex = intCounter + 1; } } cboSelectSite.SelectedIndex = intSelectedIndex; TheFindSortedAssetLocationsBySiteDataSet = TheAssetClass.FindSortedAssetLocationsBySite(gstrSite); intNumberOfRecords = TheFindSortedAssetLocationsBySiteDataSet.FindSortedWaspAssetLoctionsBySite.Rows.Count; intSelectedIndex = 0; if (intNumberOfRecords > 0) { for (intCounter = 0; intCounter < intNumberOfRecords; intCounter++) { if (strLocation == TheFindSortedAssetLocationsBySiteDataSet.FindSortedWaspAssetLoctionsBySite[intCounter].AssetLocation) { intSelectedIndex = intCounter + 1; } } } cboSelectLocation.SelectedIndex = intSelectedIndex; } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Blue Jay ERP // Change Wasp Location // Window Loaded Event " + Ex.Message); TheMessagesClass.ErrorMessage(Ex.ToString()); } }