As to the question #1:
Think of it! You can NOT get: {
id
,
name
,
surname
and
salary
of the personnel} from one textbox. You need at least 4 textboxes.
You need to create a
class[
^] with all those properties (members). Note, that salary have to be a numeric value and it can not be an integer! As a textbox stores text, you have to convert that text into numeric value...
Then a
collection (list)[
^] of your class.
Inside button's click method you have to:
- create an instance of your class,
- set all members (based on values stored in the textboxes),
- add that instance of your class on the list,
- bind that list to
DataGridView.DataSource[
^]
As to the question #2:
You need to loop through the list (of your custom class) and sum up salaries.
That'a all!
For further details, please see:
Bind data to DataGridView Control - Windows Forms .NET Framework | Microsoft Docs[
^]