public void CreateAccount(string username, string password, string cPassword, string firstname, string lastname, RegistrationDataProvider registrationData) { registrationData.ResetData(); // Jei buvo paliktas bent vienas tuscias laukas, programa meta errora if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(cPassword) || string.IsNullOrEmpty(firstname) || string.IsNullOrEmpty(lastname)) { registrationData.emptyFields = true; } // Jei passwordai nevienodi programa meta errora else if (password != cPassword) { registrationData.passwordsDontMatch = true; } // Jei visi laukai irasyti ir slaptazodziai sutampa, tuomet programa i DB iraso naujo vartuotojo duomenis else { //Nusiskaitomos reikšmės iš textboxų user.UserName = username.Trim(); user.Password = password.Trim(); if (!CheckPassword(password.Trim())) { registrationData.passwordIsNotCorrect = true; return; } else { user.FirstName = firstname.Trim(); user.LastName = lastname.Trim(); //Pridedamas useris į DB SQLConnection.AddNewItem(user); } } }
public Registration(string username, string password, string cPassword, string firstname, string lastname, RegistrationDataProvider registrationData) { user = new User(); CreateEvent = new EventHandler(CreateAccount); CreateEvent.Invoke(username, password, cPassword, firstname, lastname, registrationData); }