/// <summary> /// Prints the votercards in the database /// </summary> private void PrintVoterCards() { _view.StatusTextBox.Text = ""; try { var printer = new VoterCardPrinter(); DAOFactory.CurrentUserDAO.PrintVoterCards(printer); ShowSuccess("All voter cards printed successfully"); } catch (Exception ex) { ShowError(ex.Message + ". Some voter cards may not have been printed."); } }
/// <summary> /// Update all persons in the dataset with this update /// </summary> /// <param name="voterCardPrinter"></param> public void PrintVoterCards(VoterCardPrinter voterCardPrinter) { Contract.Requires(this.ActionPermitted(SystemAction.PrintVoterCards)); this.TestPermission(SystemAction.PrintVoterCards, "You don't have permission to print votercards."); _dao.PrintVoterCards(voterCardPrinter); }
public void TestPrintVoterCards() { var vp = new VoterCardPrinter(); _dao.PrintVoterCards(vp); }
public void PrintVoterCards(VoterCardPrinter printer) { var connection = new MySqlConnection(this._connectionString); connection.Open(); const string Query = "SELECT id FROM voter_card WHERE valid=1;"; var validVotercards = new MySqlCommand(Query, connection); MySqlDataReader rdr = null; try { rdr = validVotercards.ExecuteReader(); while (rdr.Read()) { var id = rdr.GetInt32("id"); var v = LoadVoterCard(id); printer.Print(v); } } catch (Exception) { throw; } finally { if (rdr != null) rdr.Close(); connection.Close(); } }