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 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); } }
public string SendCity() { City city = new City(); DBActions dbActions = new DBActions(); string msg = ""; string table = "Cities"; int lastId = dbActions.LastId(table); city = dbActions.GetCity(lastId); msg = dbActions.AddCity(city); string delRes = dbActions.DeleteLocal(lastId, table); if (delRes != Resources.Success) { msg = string.Concat("Deletion from local DB failed: ", delRes); } DBActions.CheckCitiesEmptiness(); return msg; }
public string SendPerson() { Person person = new Person(); DBActions dbActions = new DBActions(); string msg = ""; string table = "People"; int lastId = dbActions.LastId(table); person = dbActions.GetPerson(lastId); msg = dbActions.PersonAdd(person); string delRes = dbActions.DeleteLocal(lastId, table); if (delRes != Resources.Success) { msg = string.Concat("Deletion from local DB failed: ", delRes); } DBActions.CheckPeopleEmptiness(); return msg; }
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); } }
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 ReportButton_Click(object sender, EventArgs e) { DBActions dbActions = new DBActions(); string report = dbActions.GetReport(); MessageBox.Show(report, "Report message"); }
private void MaxpeopleButton_Click(object sender, EventArgs e) { DBActions actions = new DBActions(); MessageBox.Show(actions.MaxPop()); }