/// <summary> /// Generuje inkasentów losowo dobierając wartości pól i dodaje ich do bazy. /// </summary> static void GenerateCollectors() { Random rnd = new Random(); string[] nameAndLastName; string[] postalCodeAndCity; Collector collector; int tpmGender = 0; for (int i = 0; i < numberOfCollectors; i++) { collector = new Collector(); tpmGender = rnd.Next(0, 9); collector.CollectorId = GenerateRandomPesel("Collector", tpmGender); nameAndLastName = GenerateNameAndLastName(tpmGender); collector.Name = nameAndLastName[0]; collector.LastName = nameAndLastName[1]; postalCodeAndCity = GeneratePostalCodeAndCity(); collector.PostalCode = postalCodeAndCity[0]; collector.City = postalCodeAndCity[1]; collector.Address = SampleDataSource.streets[rnd.Next(0, SampleDataSource.streets.Length)] + ' ' + rnd.Next(1, 100).ToString(); collector.PhoneNumber = GeneratePhoneNumber(); collector.InsertIntoDB(); } }
private bool InsertCollector() { Collector c = new Collector(); c.CollectorId = tbCollectorID.Text; c.Name = tbCollectorFirstName.Text; c.LastName = tbCollectorLastName.Text; c.PostalCode = tbCollectorPostalCode.Text; c.City = tbCollectorCity.Text; c.Address = tbCollectorAddress.Text; c.PhoneNumber = tbCollectorPhoneNumber.Text; if (Auxiliary.IsCurrentValueOK(Current_ControlToBool_Dict)) { c.InsertIntoDB(); modified = true; InsertedTo = Tables.Collectors; return true; } else { MessageBox.Show(LangPL.InsertFormLang["Fill in all fields"]); return false; } }