Beispiel #1
0
 private void btnModify_Click(object sender, EventArgs e)
 {
     try
     {
         if (gridFiles.Rows.Count > 0)
         {
             //Find the selected id
             int selectedId = int.Parse(gridFiles.SelectedRows[0].Cells[0].Value.ToString());
             //Find the selected row
             var selectedFile = list.First(x => x.Id == selectedId);
             //Modify the file
             frmFile frm = new frmFile();
             frm.selectedFileToUpdate = selectedFile;
             frm.PopulateControls(frm.selectedFileToUpdate);
             this.Hide();
             frm.BringToFront();
             frm.ShowDialog();
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show($"Sorry an error occured.\n {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void btnAddFile_Click(object sender, EventArgs e)
 {
     if (gridFiles.Rows.Count > 0)
     {
         //Find the selected id
         int selectedId = int.Parse(gridFiles.SelectedRows[0].Cells[0].Value.ToString());
         //Find the selected row
         var selectedFile = list.First(x => x.Id == selectedId);
         if (selectedFile.FileName != null)
         {
             //Modify the file
             frmMailUsers.FileName = selectedFile.FileName;
             this.Close();
         }
         else
         {
             MessageBox.Show("There is no pdf file available for the selected file.\nPlease modify file to include pdf", "Add File", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }