Example #1
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();
     }
 }
Example #2
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();
     }
 }
Example #3
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 activation of form.It reloads the datagrid view datasource.
 /// </summary>
 /// <param name="sender">Sender object</param>
 /// <param name="e">Event argument</param>
 private void addGPS_Activated(object sender, EventArgs e)
 {
     Models.Category[] allCategories = CategoryDelegate.GetAllCategories().ToArray();
     category_comboBox.DataSource    = allCategories;
     category_comboBox.ValueMember   = Constants.CATEGORY_ID;
     category_comboBox.DisplayMember = Constants.CATEGORY_NAME;
 }
Example #5
0
        /// <summary>
        /// Event handler for the activation of the form.
        /// </summary>
        /// <param name="sender">Sender Object</param>
        /// <param name="e">Event argument</param>
        private void locateCategory_Activated(object sender, EventArgs e)
        {
            List <Models.Category> allCategories = CategoryDelegate.GetAllCategories().ToList();

            Models.Category category = new Models.Category();
            category.categoryId   = 0;
            category.categoryName = Constants.ALL;
            allCategories.Insert(0, category);
            category_comboBox.BindingContext = new BindingContext();
            category_comboBox.DataSource     = allCategories;
            category_comboBox.ValueMember    = Constants.CATEGORY_ID;
            category_comboBox.DisplayMember  = Constants.CATEGORY_NAME;
            loadGoogleMapForAllCategory();
        }
Example #6
0
 /// <summary>
 /// Collects categroy details and saves as a datatable.
 /// </summary>
 /// <returns>Returns category data as datatable</returns>
 private DataTable GetRESTData()
 {
     categoryDetail = new DataTable();
     try
     {
         this.allCategoryDetails = CategoryDelegate.GetAllCategories();
         categoryDetail.Columns.Add("Category Name", typeof(string));
         categoryDetail.Columns.Add("Category Color", typeof(string));
         categoryDetail.Columns.Add("Category Description", typeof(string));
         foreach (Models.Category category in allCategoryDetails)
         {
             categoryDetail.Rows.Add(category.categoryName, category.colorIndication, category.categoryDesc);
         }
         return(categoryDetail);
     }
     catch (Exception ex)
     {
         log.Error(string.Format("Error in get Reposiory details from server {0}", ex.Message));
         return(categoryDetail);
     }
 }