/*public void InitializeData() * { * try * { * // Create a new adapter and give it a query to fetch sales order, contact, * // address, and product information for sales in the year 2002. Point connection * // information to the configuration setting "AdventureWorks". * string connectionString = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=BytejamDatabase;Integrated Security=True"; * SqlConnection connection = new SqlConnection( connectionString ); * * InitializeVoters( connection ); * InitializeBallots( connection ); * InitializeLicenses( connection ); * InitializeSocials( connection ); * } * catch ( SqlException ex ) * { * Console.WriteLine( "SQL exception occurred: " + ex.Message ); * } * } * private void InitializeVoters( SqlConnection connection ) * { * string commandText = "select * from Voters"; * SqlCommand command = new SqlCommand( commandText, connection ); * * SqlDataAdapter da = new SqlDataAdapter( command ); * da.SelectCommand = command; * * voters = new List<Voter>(); * * DataTable dt = new DataTable(); * * da.Fill( dt ); * * SortedDictionary<int, Voter> votersSorted = new SortedDictionary<int, Voter>(); * * foreach ( DataRow row in dt.Rows ) * { * if ( int.TryParse( row.Field<string>( "CID" ), out int rowIndex ) ) * if ( rowIndex > -1 ) * votersSorted.Add( rowIndex, new Voter( row, rowIndex ) ); * } * * foreach ( Voter voter in votersSorted.Values ) * voters.Add( voter ); * } * private void InitializeBallots( SqlConnection connection ) * { * string commandText = "select * from Ballots"; * SqlCommand command = new SqlCommand( commandText, connection ); * * SqlDataAdapter da = new SqlDataAdapter( command ); * da.SelectCommand = command; * * ballots = new List<Ballot>(); * * DataTable dt = new DataTable(); * * da.Fill( dt ); * * foreach ( DataRow row in dt.Rows ) * ballots.Add( new Ballot( row ) ); * } * private void InitializeLicenses( SqlConnection connection ) * { * string commandText = "select * from Licenses"; * SqlCommand command = new SqlCommand( commandText, connection ); * * SqlDataAdapter da = new SqlDataAdapter( command ); * da.SelectCommand = command; * * driversLicenses = new List<DriversLicense>(); * * DataTable dt = new DataTable(); * * da.Fill( dt ); * * //help i have know idea what this trash is * SortedDictionary<int, DriversLicense> driversLicensesSorted = new SortedDictionary<int, DriversLicense>(); * * foreach (DataRow row in dt.Rows) * { * if (int.TryParse(row.Field<string>("DID"), out int rowIndex)) * if (rowIndex > -1) * driversLicensesSorted.Add(rowIndex, new DriversLicense(row, rowIndex)); * } * * foreach (DriversLicense driversLicense in driversLicensesSorted.Values) * driversLicenses.Add(driversLicense); * *//*foreach (DataRow row in dt.Rows) * driversLicenses.Add(new DriversLicense(row));*//* * } * private void InitializeSocials( SqlConnection connection ) * { * string commandText = "select * from SocialSecurities"; * SqlCommand command = new SqlCommand( commandText, connection ); * * SqlDataAdapter da = new SqlDataAdapter( command ); * da.SelectCommand = command; * * socials = new List<Social>(); * * DataTable dt = new DataTable(); * * da.Fill( dt ); * * foreach ( DataRow row in dt.Rows ) * socials.Add( new Social( row ) ); * }*/ public bool ReFill() { int index = RandomizationModule.random.Next(22); Ballot ballet = (Ballot)ballots[index].Clone(); DriversLicense driversLicense = (DriversLicense)driversLicenses[index].Clone(); Social social = (Social)socials[index].Clone(); Voter voter = (Voter)voters[index].Clone(); bool isCorrect = true; if (isCorrect) { isCorrect = !ballet.Randomize(index); } if (isCorrect) { isCorrect = !social.Randomize(index); } if (isCorrect) { isCorrect = !driversLicense.Randomize(index); } if (isCorrect) { isCorrect = !voter.Randomize(index); } FillLabels(ballet, driversLicense, social, voter); return(isCorrect); }