/// <summary> /// Event handler for submit button click.It accepts input fields and store in client. /// </summary> /// <param name="sender">Sender object</param> /// <param name="e">Event argument</param> private void submit_button_Click(object sender, EventArgs e) { if (!(name_textBox.Text == "" | colorHexCode == null)) { categoryName = this.name_textBox.Text; colorHexValue = Constants.HASH_CONSTANT + this.colorHexCode; description = this.description_richTextBox.Text; this.Dispose(); } else { PopUp popUP = new PopUp(Constants.MANDATORY_FIELD_ERROR_MESSAGE); popUP.ShowDialog(); } }
/// <summary> /// Event handler for add animal click. /// </summary> /// <param name="sender">Sender object</param> /// <param name="e">Event argument</param> private void add_button_Click(object sender, EventArgs e) { try { if (!(animalName_text.Text == "" | gpsDeviceId_Text.Text == "")) { Models.Category selectedCategory = (Models.Category) this.category_comboBox.Items[category_comboBox.SelectedIndex]; this.categoryId = selectedCategory.categoryId; this.animalName = this.animalName_text.Text; this.GPSDeviceId = this.gpsDeviceId_Text.Text; } } catch (Exception ex) { log.Error(String.Format("Error in adding new animal {0}", ex.Message)); PopUp popUpBox = new PopUp("Error in creating a new animal"); popUpBox.ShowDialog(); } }
/// <summary> /// Event handler for delete button click. /// </summary> /// <param name="sender">Sender Object</param> /// <param name="e">Event argument</param> private void delete_button_Click(object sender, EventArgs e) { try { selectedRow = this.gps_dataGridView.CurrentRow.Index; Models.Animal animalToBeDeleted = allAnimalsLocated[selectedRow]; Models.Animal deletedItem = AnimalDelegate.DeleteAnimal(animalToBeDeleted.animalId); if (deletedItem != null) { this.gps_dataGridView.Rows.RemoveAt(selectedRow); this.gps_dataGridView.Refresh(); dataGrid(); } PopUp popUpBox = new PopUp(Constants.SUCCESSFUL_ANIMAL_DELETING_MESSAGE); popUpBox.ShowDialog(); } catch (Exception ex) { PopUp popUpBox = new PopUp(Constants.ERROR_ANIMAL_DELETING_MESSAGE); popUpBox.ShowDialog(); log.Error(string.Format("Error in delete animal from server {0}", ex.Message)); this.SuspendLayout(); } }