private void ChooseAddress_Load(object sender, EventArgs e) { uxCBAisle.SelectedIndex = 0; uxCBShelf.SelectedIndex = 0; uxCBSubshelf.SelectedIndex = 0; try { dsPhysicalInventory = new DataSetPhysicalInventory(); cache.AddObject(CacheAddress.PhysicalInventoryData, dsPhysicalInventory); taWarehouseInventory = new WarehouseInventoryTableAdapter(); taWarehouseLocations = new WarehouseLocationsTableAdapter(); taPhysicalProgress = new PhysicalProgressTableAdapter(); taPhysicalProgressSummary = new PhysicalProgressSummaryTableAdapter(); taEmployee = new EmployeeTableAdapter(); cache.AddObject(CacheAddress.WarehouseInventoryTableAdapter, taWarehouseInventory); cache.AddObject(CacheAddress.WarehouseLocationsTableAdapter, taWarehouseLocations); cache.AddObject(CacheAddress.PhysicalProgressTableAdapter, taPhysicalProgress); cache.AddObject(CacheAddress.PhysicalProgressSummaryTableAdapter, taPhysicalProgressSummary); cache.AddObject(CacheAddress.EmployeeTableAdapter, taEmployee); cache.AddObject(CacheAddress.BeginPhysicalAisle, BeginPhysicalAisle); cache.AddObject(CacheAddress.BeginPhysicalShelf, BeginPhysicalShelf); cache.AddObject(CacheAddress.BeginPhysicalSubshelf, BeginPhysicalSubshelf); taWarehouseLocations.Fill(dsPhysicalInventory.WarehouseLocations); } catch (SqlException ex) { foreach (SqlError SQLErr in ex.Errors) { MessageBox.Show(SQLErr.Message); } } }
private void MyRFGunRFScan(object sender, RFScanEventArgs e) { string scanData = e.Text; try { // Look for a serial with no identifier. int serial; try { serial = Int32.Parse(scanData); if (TryProcessSerial(serial) == -1) { throw new Exception(string.Format("No identifier, but scan data {0} not recognized.", scanData)); } RefreshProgress(); return; } catch (FormatException) { // Ignore exception and continue trying to find a serial. } catch (Exception ex) { throw new Exception(string.Format("{0} No identifier, but scan data {1} not recognized.", ex.Message, scanData)); } // Look first for serial scan. if (scanData.Substring(0, 1) == "S" || scanData.Substring(0, 1) == " ") { // Scan object to location. serial = Int32.Parse(scanData.Substring(1)); if (TryProcessSerial(serial) == -1) { throw new Exception(string.Format("\"S\" identifier found, but scan data {0} not recognized", scanData)); } RefreshProgress(); return; } if (scanData.Substring(1, 1) == "S" || scanData.Substring(0, 1) == "1T") { // Scan object to location. serial = Int32.Parse(scanData.Substring(2)); if (TryProcessSerial(serial) == -1) { throw new Exception( string.Format("\"#S\" or 1T identifier found, but scan data {0} not recognized", scanData)); } RefreshProgress(); return; } // Handle a location label scan. using (var wlTA = new WarehouseLocationsTableAdapter()) { var wlDT = wlTA.GetDataByLocation(scanData); switch (wlDT.Rows.Count) { case 1: RackSelection.Text = wlDT[0].Rack; ShelfSelection.Text = wlDT[0].Shelf; PositionSelection.Text = wlDT[0].Position; RefreshProgress(); return; } throw new Exception("Expecting label or serial scan."); } } catch (SqlException ex) { foreach (SqlError sqlErr in ex.Errors) { MessageBox.Show(sqlErr.Message); } } catch (ArgumentNullException ex) { uxLabelMessage.Text = ex.Message + "Scan not recognized."; } catch (OverflowException ex) { uxLabelMessage.Text = ex.Message + "Scan not recognized. " + scanData; } catch (FormatException ex) { uxLabelMessage.Text = ex.Message + "Scan not recognized. " + scanData; } catch (Exception ex) { uxLabelMessage.Text = ex.Message + scanData; } }