public UserControlRegisterFingerPrints(LoginData data, Customer customer) { InitializeComponent(); this.data = data; this.customer = customer; rgxCommand = new Regex(patternCommand); rgxRetry = new Regex(patternRetry); rgxStored = new Regex(patternStored); rgxGetting = new Regex(patternGetting); dict.Add(1, "Right thumb"); dict.Add(2, "Right index finger"); dict.Add(3, "Right middle finger"); dict.Add(4, "Right ring finger"); dict.Add(5, "Right pinky"); dict.Add(6, "Left thumb"); dict.Add(7, "Left index finger"); dict.Add(8, "Left middle finger"); dict.Add(9, "Left ring finger"); dict.Add(10, "Left pinky"); fingerPrint = new BackgroundWorker(); fingerPrint.WorkerSupportsCancellation = true; fingerPrint.DoWork += new DoWorkEventHandler(fingerPrint_DoWork); fingerPrint.RunWorkerCompleted += new RunWorkerCompletedEventHandler(fingerPrint_RunWorkerCompleted); MySqlHelper helper = new MySqlHelper(); string connectionString = "datasource=localhost; port=3306; username="******"; password="******"db_atm", "t_customers") * 10; id = count + 1; foreach (string s in SerialPort.GetPortNames()) { ComboBoxPort.Items.Add(s); } }
private void fingerPrint_DoWork(object sender, DoWorkEventArgs e) { string pattern = @"#\d+"; Regex rgx; MatchCollection mc; Match match; string rec; serial.Open(); try { serial.WriteLine("2"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); serial.Close(); } this.Dispatcher.BeginInvoke((Action) delegate() { RichTextBoxSerial.AppendText("Place your finger for verification\n"); RichTextBoxSerial.ScrollToEnd(); }); this.Dispatcher.BeginInvoke((Action) delegate() { LabelStatus.Content = "Place finger now"; }); while (true) { try { serial.WriteLine("2"); rec = serial.ReadLine(); this.Dispatcher.BeginInvoke((Action) delegate() { RichTextBoxSerial.AppendText(rec); RichTextBoxSerial.ScrollToEnd(); }); if (rec.Length > 0) { pattern = @"#\d+"; rgx = new Regex(pattern); mc = rgx.Matches(rec); match = rgx.Match(rec); if (match.Success) { id = Convert.ToInt32(mc[0].ToString().Replace("#", "")); if (id != 0) { MySqlHelper helper = new MySqlHelper(); string connectionString = "datasource=localhost; port=3306; username="******"; password="******"db_atm", "t_customers", id); fingerVerified = helper.IDConfirmed(connectionString, "db_atm", "t_customers", acn, id); if (fingerVerified) { break; } } } pattern = @"not"; rgx = new Regex(pattern); mc = rgx.Matches(rec); match = rgx.Match(rec); if (match.Success) { failCount++; if (failCount < 3) { MessageBox.Show("Did not find a match.\nTry again when prompted to"); } } if (failCount == 3) { MessageBox.Show("ATM card temporarily disabled"); serial.Close(); break; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); serial.Close(); } } }
private void Transition() { if (fingerPrint.IsBusy) { fingerPrint.CancelAsync(); } try { MySqlHelper helper = new MySqlHelper(); string connectionString = "datasource=localhost; port=3306; username="******"; password="******"db_atm", "t_customers", customer); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } UserControl usc = new UserControlSaving(data, customer); var parent = (Grid)this.Parent; parent.Children.Add(usc); parent.Children.Remove(this); }