/// <summary> /// Generuje klientów losowo dobierając wartości pól i dodaje ich do bazy. /// </summary> static void GenerateCustomers() { Random rnd = new Random(); string[] nameAndLastName; string[] postalCodeAndCity; int tpmGender = 0; Customer customer; for (int i = 0; i < numberOfCustomers; i++) { customer = new Customer(); tpmGender = rnd.Next(0, 9); customer.CustomerId = GenerateRandomPesel("Customer", tpmGender); nameAndLastName = GenerateNameAndLastName(tpmGender); customer.Name = nameAndLastName[0]; customer.LastName = nameAndLastName[1]; postalCodeAndCity = GeneratePostalCodeAndCity(); customer.PostalCode = postalCodeAndCity[0]; customer.City = postalCodeAndCity[1]; customer.Address = SampleDataSource.streets[rnd.Next(0, SampleDataSource.streets.Length - 1)] + ' ' + rnd.Next(1, 100).ToString(); customer.PhoneNumber = GeneratePhoneNumber(); customer.InsertIntoDB(); } }
private bool InsertCustomer() { Customer c = new Customer(); c.CustomerId = tbCustomerID.Text; c.Name = tbCustomerFirstName.Text; c.LastName = tbCustomerLastName.Text; c.PostalCode = tbCustomerPostalCode.Text; c.City = tbCustomerCity.Text; c.Address = tbCustomerAddress.Text; c.PhoneNumber = tbCustomerPhoneNumber.Text; if (Auxiliary.IsCurrentValueOK(Current_ControlToBool_Dict)) { c.InsertIntoDB(); modified = true; InsertedTo = Tables.Customers; return true; } else { MessageBox.Show(LangPL.InsertFormLang["Fill in all fields"]); return false; } }