private void llLogout_Click(object sender, EventArgs e) { try { UserID = string.Empty; UserName = string.Empty; CustName = string.Empty; LocationName = string.Empty; ItemActivity = string.Empty; if (MyReader != null) { MyReader.Dispose(); } if (conn != null && conn.State == ConnectionState.Open) { conn.Close(); conn.Dispose(); } this.Close(); } catch (Exception ex) { Helper.LogError(ex, "llLogout_Click"); } }
public void TermBarcode() { if (_myBarcode2 != null) { try { StopScan(); _myBarcode2.Dispose(); _myBarcode2 = null; } catch (OperationFailureException ex) { // MessageBox.Show(Resources.GetString("TermBarcode") + "\n" +Resources.GetString("OperationFailure") + "\n" + ex.Message +"\n" +Resources.GetString("Result") + " = " + (Results)((uint)ex.Result)); } catch (InvalidRequestException ex) { // MessageBox.Show(Resources.GetString("TermBarcode") + "\n" +Resources.GetString("InvalidRequest") + "\n" +ex.Message); } catch (InvalidIndexerException ex) { // MessageBox.Show(Resources.GetString("TermBarcode") + "\n" +Resources.GetString("InvalidIndexer") + "\n" +ex.Message); } ; } }
private void MyReader_OnScan(ScanDataCollection sd) { try { if (this.InvokeRequired) { this.BeginInvoke(new Barcode2.OnScanHandler(MyReader_OnScan), new object[] { sd }); } else { foreach (ScanData data in sd) { if (data.Result == Results.SUCCESS) { this.LocationName = data.Text; MyReader.OnScan -= eventHandler; if (MyReader != null) { MyReader.Dispose(); } Activity fActivity = new Activity(this.mainForm); fActivity.UserName = UserName; fActivity.UserID = UserID; fActivity.CustName = CustName; fActivity.LocationName = LocationName; fActivity.ItemActivity = ItemActivity; fActivity.Show(); this.Close(); } else if (data.Result == Results.CANCELED) { MyReader.ScanBufferStart(); } } } } catch (Exception ex) { MessageBox.Show("Location_Scan: " + ex.Message); } }
/// <summary> /// form clkose /// </summary> private void frmxPackage_Closing(object sender, CancelEventArgs e) { try { Barkod.EnableScanner = false; Barkod.Dispose(); } catch (Exception) { } }
public static void wakeScanner(Button scanButton, TextBox textBox, bool scannerMode) { scanButton.Enabled = false; Symbol.Generic.Device MyDevice = Symbol.Barcode.Device.AvailableDevices[0]; Barcode2 MyBarcode = new Barcode2(MyDevice.ToString()); MyBarcode.Enable(); MyBarcode.Config.Reader.ReaderSpecific.LaserSpecific.AimDuration = 500; if (scannerMode) { MyBarcode.Config.TriggerMode = TRIGGERMODES.HARD; } else { MyBarcode.Config.TriggerMode = TRIGGERMODES.SOFT_ONCE; } ScanData MyData = MyBarcode.ScanWait(8000); // 5 seconds timeout if (MyData.Result == Symbol.Barcode2.Results.E_SCN_READTIMEOUT) // Barcode was not scanned within 8 secs { scanButton.Text = "No Scan Found"; textBox.Text = "No Scan Found"; MyBarcode.Dispose(); //enable add product button scanButton.Enabled = true; } if (MyData.Result == Symbol.Barcode2.Results.SUCCESS) // Barcode was scanned successfully { scanButton.Text = MyData.ToString(); textBox.Text = MyData.ToString(); MyBarcode.Dispose(); //enable add product button scanButton.Enabled = true; } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { if (scanner != null) { if (scanner.IsScanPending) { scanner.ScanCancel(); } scanner.Dispose(); scanner = null; } }
/// <summary> /// Stop reading and disable/close the Barcode2 object. /// </summary> public void TermBarcode() { // If we have a reader if (myBarcode2 != null) { try { // stop all the notifications. StopScan(); // Free it up. myBarcode2.Dispose(); // Make the reference null. myBarcode2 = null; } catch (OperationFailureException ex) { MessageBox.Show(Resources.GetString("TermBarcode") + "\n" + Resources.GetString("OperationFailure") + "\n" + ex.Message + "\n" + Resources.GetString("Result") + " = " + (Results)((uint)ex.Result) ); } catch (InvalidRequestException ex) { MessageBox.Show(Resources.GetString("TermBarcode") + "\n" + Resources.GetString("InvalidRequest") + "\n" + ex.Message); } catch (InvalidIndexerException ex) { MessageBox.Show(Resources.GetString("TermBarcode") + "\n" + Resources.GetString("InvalidIndexer") + "\n" + ex.Message); }; } }