/// <summary>
 /// Event handler for the generate button click.
 /// It generates charts based on total number of animals per category.
 /// </summary>
 /// <param name="sender">Sender Object</param>
 /// <param name="e">Event argument</param>
 private void generate_button_Click(object sender, EventArgs e)
 {
     reportChart.Series[Constants.COUNT].Points.Clear();
     reportChart.Titles.Clear();
     if (toDate > DateTime.Now)
     {
         PopUp popUP = new PopUp(Constants.TO_DATE_VALIDATION_MESSAGE);
         popUP.ShowDialog();
     }
     else if (fromDate > toDate && fromDate > DateTime.Now)
     {
         PopUp popUP = new PopUp(Constants.FROM_DATE_VALIDATION_MESSAGE);
         popUP.ShowDialog();
     }
     else
     {
         string startDate = fromDate.ToString(Constants.DATE_PICKER_FOMAT);
         string endDate   = toDate.ToString(Constants.DATE_PICKER_FOMAT);
         List <Models.AnimalCategoryCount> animals = AnimalDelegate.GetAnimalsCountPerCategory(startDate, endDate);
         int i = 0;
         foreach (Models.AnimalCategoryCount animal in animals)
         {
             reportChart.Series[Constants.COUNT].Points.AddXY(animal.categoryName, animal.totalAnimals);
             Color color = ColorTranslator.FromHtml(animal.colorIndication);
             reportChart.Series[Constants.COUNT].Points[i].Color = color;
             i++;
         }
         reportChart.Titles.Add(Constants.COUNT_OF_ALL_THE_ANIMALS_PER_CATEGORY);
     }
 }
Exemple #2
0
 /// <summary>
 /// Event handler for add button click of adding new animal .
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void add_button_Click(object sender, EventArgs e)
 {
     try
     {
         Add_GPS      animalGPSAllocation = new Add_GPS();
         DialogResult dialogresult        = animalGPSAllocation.ShowDialog();
         if (dialogresult == DialogResult.OK)
         {
             string animalName  = animalGPSAllocation.animalName;
             int    categoryId  = animalGPSAllocation.categoryId;
             string gpsDeviceId = animalGPSAllocation.GPSDeviceId;
             this.animalDetails.Rows.Add(animalName, gpsDeviceId);
             this.gps_dataGridView.Refresh();
             Models.Animal animalDetails = GetAnimalDetails(animalName, categoryId, gpsDeviceId);
             AnimalDelegate.AddNewAnimal(animalDetails);
             dataGrid();
             animalGPSAllocation.Dispose();
             PopUp popUpBox = new PopUp(Constants.SUCCESSFULL_GPS_ALLOCATION_MESSAGE);
             popUpBox.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         log.Error(string.Format("Error in allocating the animal with GPS Device {0}", ex.Message));
         dataGrid();
         PopUp popUp = new PopUp(Constants.ERROR_GPS_ALLOCATION_MESSAGE);
         popUp.ShowDialog();
     }
 }
Exemple #3
0
 /// <summary>
 /// Event handler for add button click.
 /// It accept data and send it to server.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void add_button_Click(object sender, EventArgs e)
 {
     try
     {
         AddCategory  category     = new AddCategory();
         DialogResult dialogresult = category.ShowDialog();
         if (dialogresult == DialogResult.OK)
         {
             string categoryName  = category.categoryName;
             string categoryColor = category.colorHexValue;
             string categoryDesc  = category.description;
             this.categoryDetail.Rows.Add(categoryName, categoryColor);
             this.category_dataGridView.Refresh();
             Models.Category categoryDetails = GetCategory(categoryName, categoryColor, categoryDesc);
             CategoryDelegate.AddNewCategory(categoryDetails);
             dataGrid();
             category.Dispose();
             PopUp popUpBox = new PopUp(Constants.SUCCESSFUL_ADD_CATEGORY_MESSAGE);
             popUpBox.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         log.Error(string.Format("Error in send new category data to server {0}", ex.Message));
         dataGrid();
         PopUp popUp = new PopUp(Constants.ERROR_CREATING_CATEGORY_MESSAGE);
         popUp.ShowDialog();
     }
 }
Exemple #4
0
 /// <summary>
 /// Event handler for edit button click.
 /// </summary>
 /// <param name="sender">Sender Object</param>
 /// <param name="e">Event argument</param>
 private void editCategory_button_Click(object sender, EventArgs e)
 {
     try
     {
         selectedRow = this.category_dataGridView.CurrentRow.Index;
         Models.Category categoryToEdit = allCategoryDetails[selectedRow];
         AddCategory     category       = new AddCategory();
         category.colorHexValue = categoryToEdit.colorIndication;
         category.categoryName  = categoryToEdit.categoryName;
         category.description   = categoryToEdit.categoryDesc;
         DialogResult dialogresult = category.ShowDialog();
         if (dialogresult == DialogResult.OK)
         {
             string categoryName  = category.categoryName;
             string categoryColor = category.colorHexValue;
             string categoryDesc  = category.description;
             this.categoryDetail.Rows.Add(categoryName, categoryColor, categoryDesc);
             this.category_dataGridView.Refresh();
             Models.Category categoryDetails = GetUpdatedCategory(categoryName, categoryColor, categoryDesc, categoryToEdit.categoryId);
             CategoryDelegate.UpdateCategory(categoryDetails);
             dataGrid();
             category.Dispose();
             PopUp popUpBox = new PopUp(Constants.SUCCESSFUL_UPDATED_CATEGORY_MESSAGE);
             popUpBox.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         log.Error(string.Format("Error in updating category data to server {0}", ex.Message));
         dataGrid();
         PopUp popUp = new PopUp(Constants.ERROR_UPDATING_CATEGORY_MESSAGE);
         popUp.ShowDialog();
     }
 }
Exemple #5
0
 /// <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
     {
         foreach (DataGridViewRow row in this.category_dataGridView.SelectedRows)
         {
             int             categoryIndex       = row.Index;
             Models.Category categoryToBeDeleted = allCategoryDetails[categoryIndex];
             Models.Category deletedItem         = CategoryDelegate.DeleteCategory(categoryToBeDeleted.categoryId);
             if (deletedItem != null)
             {
                 this.category_dataGridView.Rows.RemoveAt(categoryIndex);
                 this.category_dataGridView.Refresh();
                 dataGrid();
             }
             PopUp popUpBox = new PopUp(Constants.SUCCESSFUL_DELETE_CATEGORY_MESSAGE);
             popUpBox.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         PopUp popUpBox = new PopUp(Constants.ERROR_DELETING_CATEGORY_MESSAGE);
         popUpBox.ShowDialog();
         log.Error(string.Format("Error in delete category from server {0}", ex.Message));
     }
 }
 /// <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();
     }
 }
Exemple #8
0
 /// <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();
     }
 }