コード例 #1
0
        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);
        }
コード例 #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);
     }
 }
コード例 #3
0
        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;
        }
コード例 #4
0
        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;
        }
コード例 #5
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);
            }
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
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);
            }
        }
コード例 #8
0
 private void ReportButton_Click(object sender, EventArgs e)
 {
     DBActions dbActions = new DBActions();
     string report = dbActions.GetReport();
     MessageBox.Show(report, "Report message");
 }
コード例 #9
0
 private void MaxpeopleButton_Click(object sender, EventArgs e)
 {
     DBActions actions = new DBActions();
     MessageBox.Show(actions.MaxPop());
 }