예제 #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();
     }
 }
예제 #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();
     }
 }