private void equipmentForm_Load(object sender, EventArgs e) { if (Scanning.InitReader()) { readerEventHandler = new EventHandler(myReader_OnRead); Scanning.MyEventHandler = readerEventHandler; populateTreeView(); populateMFRComboBox(); } }
private void myReader_OnRead(object sender, EventArgs e) { Symbol.Barcode.ReaderData TheReaderData = Scanning.MyReaderData; // If it is a successful read (as opposed to a failed one) if (TheReaderData.Result == Symbol.Results.SUCCESS) { if (TheReaderData.Type == Symbol.Barcode.DecoderTypes.PDF417) { util.CAC_PDF417 CAC_PDF417 = new util.CAC_PDF417(TheReaderData.Text); lastNameTextBox.Text = CAC_PDF417.LastName; firstNameTextBox.Text = CAC_PDF417.FirstName; middleInitialTextBox.Text = CAC_PDF417.MiddleInitial; ediTextBox.Text = CAC_PDF417.EDI; rankTextBox.Text = CAC_PDF417.Rank; branchComboBox.SelectedValue = CAC_PDF417.BranchCode; if (TheReaderData.MultiPart) { MessageBox.Show(TheReaderData.AuxData.Text); } } // Start the next read Scanning.StartRead(); } else { string sMsg = "Read Failed\n" + "Result = " + (TheReaderData.Result).ToString(); MessageBox.Show(sMsg, "ReadNotify"); if (TheReaderData.Result == Symbol.Results.E_SCN_READINCOMPATIBLE) { // If the failure is E_SCN_READINCOMPATIBLE, exit the application. MessageBox.Show("The application will now exit."); this.Close(); return; } } }
private void myReader_OnRead(object sender, EventArgs e) { Symbol.Barcode.ReaderData TheReaderData = Scanning.MyReaderData; // If it is a successful read (as opposed to a failed one) if (TheReaderData.Result == Symbol.Results.SUCCESS) { if (TheReaderData.Type == Symbol.Barcode.DecoderTypes.DATAMATRIX) { //Symbol.Barcode.DecoderTypes.DATAMATRIX util.Equip_DataMatrix scannedDataMatrix = new util.Equip_DataMatrix(TheReaderData.Text); serialNumberTextBox.Text = scannedDataMatrix.SerialNumber; mfrComboBox.SelectedValue = scannedDataMatrix.MFR; populateProductComboBox(mfrComboBox.SelectedValue.ToString()); productComboBox.SelectedValue = scannedDataMatrix.PartNumber; if (TheReaderData.MultiPart) { MessageBox.Show(TheReaderData.AuxData.Text); } } // Start the next read Scanning.StartRead(); } else { string sMsg = "Read Failed\n" + "Result = " + (TheReaderData.Result).ToString(); MessageBox.Show(sMsg, "ReadNotify"); if (TheReaderData.Result == Symbol.Results.E_SCN_READINCOMPATIBLE) { // If the failure is E_SCN_READINCOMPATIBLE, exit the application. MessageBox.Show("The application will now exit."); this.Close(); return; } } }
private void personnelForm_Load(object sender, EventArgs e) { SQLiteDataAdapter etDBDataAdapter = new SQLiteDataAdapter("SELECT Branch, BranchCode FROM Branch", etDBConnection); DataSet etDBDataSet = new DataSet("Personnel"); etDBConnection.Open(); etDBDataAdapter.Fill(etDBDataSet); etDBConnection.Close(); branchComboBox.DataSource = etDBDataSet.Tables[0]; branchComboBox.DisplayMember = "Branch"; branchComboBox.ValueMember = "BranchCode"; refreshPersonnelListbox(); if (Scanning.InitReader()) { readerEventHandler = new EventHandler(myReader_OnRead); Scanning.MyEventHandler = readerEventHandler; } }
private void insertEquipmentMenuItem_Click(object sender, EventArgs e) { if (insertEquipmentMenuItem.Text == "New") { Scanning.StartRead(); cancelActionEquipmentMenuItem.Enabled = true; insertEquipmentMenuItem.Text = "Insert"; } else { try { SQLiteCommand addEquipmentCommand = new SQLiteCommand(kumpotDBConnection); addEquipmentCommand.CommandText = "INSERT INTO EquipInventory (SerialNumber, PartNumber) VALUES ('" + serialNumberTextBox.Text.Trim() + "', '" + productComboBox.SelectedValue.ToString().Trim() + "')"; kumpotDBConnection.Open(); addEquipmentCommand.ExecuteScalar(); kumpotDBConnection.Close(); MessageBox.Show("Equipment Added"); insertEquipmentMenuItem.Text = "New"; cancelActionEquipmentMenuItem.Enabled = false; populateTreeView(); Scanning.StopRead(); } catch (SQLiteException ex) { MessageBox.Show(ex.Message); //switch (ex.ErrorCode) //{ // case SQLiteErrorCode.Constraint: // MessageBox.Show("Serial number is already added.", "Invalid Serial", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); // break; //} } finally { kumpotDBConnection.Close(); } } }
private void cancelMenuItem_Click(object sender, EventArgs e) { if (insertPersonnelMenuItem.Text == "Insert") { insertPersonnelMenuItem.Text = "New"; Scanning.StopRead(); togglePersonnelForm(false); clearPersonnelForm(); refreshPersonnelDetails(personnelListBox.SelectedValue.ToString()); editPersonnelMenuItem.Enabled = true; } else if (editPersonnelMenuItem.Text == "Update") { editPersonnelMenuItem.Text = "Edit"; togglePersonnelForm(false); clearPersonnelForm(); refreshPersonnelDetails(personnelListBox.SelectedValue.ToString()); insertPersonnelMenuItem.Enabled = true; ediTextBox.Enabled = true; } personnelListBox.Enabled = true; cancelMenuItem.Enabled = false; deletePersonnelMenuItem.Enabled = true; }
private void cancelActionEquipmentMenuItem_Click(object sender, EventArgs e) { insertEquipmentMenuItem.Text = "New"; cancelActionEquipmentMenuItem.Enabled = false; Scanning.StopRead(); }
private void equipmentForm_Closed(object sender, EventArgs e) { Scanning.TermReader(); }
private void insertPersonnelMenuItem_Click(object sender, EventArgs e) { if (insertPersonnelMenuItem.Text == "New") { togglePersonnelForm(true); personnelListBox.Enabled = false; insertPersonnelMenuItem.Text = "Insert"; deletePersonnelMenuItem.Enabled = false; cancelMenuItem.Enabled = true; editPersonnelMenuItem.Enabled = false; clearPersonnelForm(); Scanning.StartRead(); } else if (MessageBox.Show("Are you sure you want to commit this information to the database?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { if (lastNameTextBox.Text != "" && firstNameTextBox.Text != "" && ediTextBox.Text != "" && rankTextBox.Text != "") { try { SQLiteCommand addPersonnelCommand = new SQLiteCommand(etDBConnection); addPersonnelCommand.CommandText = "INSERT INTO Personnel (PersonnelEDI, FirstName, LastName, Rank, Branch, MiddleInitial) " + "VALUES ($EDI,$FirstName,$LastName,$Rank,$Branch,$MiddleInitial)"; addPersonnelCommand.Parameters.AddWithValue("$EDI", ediTextBox.Text.Trim()); addPersonnelCommand.Parameters.AddWithValue("$FirstName", firstNameTextBox.Text.Trim()); addPersonnelCommand.Parameters.AddWithValue("$LastName", lastNameTextBox.Text.Trim()); addPersonnelCommand.Parameters.AddWithValue("$Rank", rankTextBox.Text.Trim()); addPersonnelCommand.Parameters.AddWithValue("$Branch", branchComboBox.SelectedValue.ToString()); addPersonnelCommand.Parameters.AddWithValue("$MiddleInitial", middleInitialTextBox.Text.Trim()); //Open database and execute command etDBConnection.Open(); addPersonnelCommand.ExecuteNonQuery(); etDBConnection.Close(); MessageBox.Show("Personnel Added"); insertPersonnelMenuItem.Text = "New"; cancelMenuItem.Enabled = false; deletePersonnelMenuItem.Enabled = true; editPersonnelMenuItem.Enabled = true; personnelListBox.Enabled = true; togglePersonnelForm(false); clearPersonnelForm(); refreshPersonnelListbox(); Scanning.StopRead(); } catch (SQLiteException sqliteException) { MessageBox.Show(sqliteException.Message); //if (sqliteException.ErrorCode == SQLiteErrorCode.Constraint) //{ // MessageBox.Show("Entered EDI number is not unique and already added. User is possibly already added.", "Invalid EDI", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); //} } finally { etDBConnection.Close(); } } else { MessageBox.Show("Missing required information"); } } }
private void personnelForm_Closed(object sender, EventArgs e) { Scanning.TermReader(); }