private void AddCityButtonClick(object sender, EventArgs e) { City addedCity = new City(); InputSanitizer inputSanitizer = new InputSanitizer(); addedCity.Name = inputSanitizer.Names(CityTextBox.Text); addedCity.Region = inputSanitizer.Names(RegionTextBox.Text); addedCity.Country = inputSanitizer.Names(CountryTextBox.Text); addedCity.Attrib = AttributeCheckbox.Checked; DBActions dbAct = new DBActions(); string msg = dbAct.AddCity(addedCity); MessageBox.Show(msg); }
private void EditButton_Click(object sender, EventArgs e) { City editedCity = new City(); DBActions dbActions = new DBActions(); InputSanitizer inputSanitizer = new InputSanitizer(); try { editedCity.Id = Convert.ToInt32(inputSanitizer.DigitsOnly(IDTextBox.Text)); editedCity.Name = inputSanitizer.Names(NameTextBox.Text); editedCity.Region = inputSanitizer.Names(RegionTextBox.Text); editedCity.Country = inputSanitizer.Names(CountryTextBox.Text); editedCity.Attrib = attribCheckBox.Checked; string msg = dbActions.EditCity(editedCity); MessageBox.Show(msg); } catch(Exception ex) { MessageBox.Show(Resources.IdIncorrect + ex.Message); } }
private void AddPeopleButton_Click(object sender, EventArgs e) { InputSanitizer inputSanitizer = new InputSanitizer(); Person addedPerson = new Person(); addedPerson.FIO = inputSanitizer.Names(FIOTextBox.Text); try { addedPerson.CityId = Convert.ToInt32(inputSanitizer.DigitsOnly(CityIDTextBox.Text)); DBActions dbActions = new DBActions(); string res = dbActions.PersonAdd(addedPerson); MessageBox.Show(res, "Client message"); } catch (Exception ex) { MessageBox.Show(Resources.IdIncorrect + ex.Message); } }
private void ChangePersonButton_Click(object sender, EventArgs e) { Person changedPerson = new Person(); DBActions dbActions = new DBActions(); InputSanitizer inputSanitizer = new InputSanitizer(); try { changedPerson.Id = Convert.ToInt32(inputSanitizer.DigitsOnly(IDTexbBox.Text)); changedPerson.CityId = Convert.ToInt32(inputSanitizer.DigitsOnly(CityIDTextBox.Text)); changedPerson.FIO = inputSanitizer.Names(FIOTextBox.Text); string msg = dbActions.PersonEdit(changedPerson); MessageBox.Show(msg, "Client message"); } catch(Exception ex) { MessageBox.Show(Resources.IdIncorrect + ex.Message); } }
public void Should_ReturnCleanName_WhenDirtyStringSanitized() { InputSanitizer inputSanitizer = new InputSanitizer(); string res = inputSanitizer.Names(@"Add&&*is-Ab^^:;eb#a 2"); Assert.AreEqual(res,"Addis-Abeba 2"); }