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);
            }
        }
Ejemplo n.º 2
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     InputSanitizer inputSanitizer = new InputSanitizer();
     try
     {
         int id = Convert.ToInt32(inputSanitizer.DigitsOnly(IDTextBox.Text));
         DBActions dbActions = new DBActions();
         string msg = dbActions.DeleteCity(id);
         MessageBox.Show(msg);
     }
     catch(Exception ex)
     {
         MessageBox.Show(Resources.IdIncorrect + ex.Message);
     }
 }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
 public void Should_Return143_WhenDirtyStringSanitized()
 {
     InputSanitizer inputSanitizer = new InputSanitizer();
     string res = inputSanitizer.DigitsOnly(@"%1##Udhsgd4&*??/-/3");
     Assert.AreEqual(res,"143");
 }